UNPKG

chromium-bidi

Version:

An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.

1,298 lines 88.5 kB
/** * 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. */ /** * THIS FILE IS AUTOGENERATED by cddlconv 0.1.5. * Run `node tools/generate-bidi-types.mjs` to regenerate. * @see https://github.com/w3c/webdriver-bidi/blob/master/index.bs */ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck Some types may be circular. import z from 'zod'; export const EventSchema = z.lazy(() => z .object({ type: z.literal('event'), }) .and(EventDataSchema) .and(ExtensibleSchema)); export const CommandSchema = z.lazy(() => z .object({ id: JsUintSchema, }) .and(CommandDataSchema) .and(ExtensibleSchema)); export const CommandResponseSchema = z.lazy(() => z .object({ type: z.literal('success'), id: JsUintSchema, result: ResultDataSchema, }) .and(ExtensibleSchema)); export const EventDataSchema = z.lazy(() => z.union([ BrowsingContextEventSchema, LogEventSchema, NetworkEventSchema, ScriptEventSchema, ])); export const CommandDataSchema = z.lazy(() => z.union([ BrowserCommandSchema, BrowsingContextCommandSchema, InputCommandSchema, NetworkCommandSchema, ScriptCommandSchema, SessionCommandSchema, StorageCommandSchema, WebExtensionCommandSchema, ])); export const ResultDataSchema = z.lazy(() => z.union([ BrowsingContextResultSchema, EmptyResultSchema, NetworkResultSchema, ScriptResultSchema, SessionResultSchema, StorageResultSchema, WebExtensionResultSchema, ])); export const EmptyParamsSchema = z.lazy(() => ExtensibleSchema); export const MessageSchema = z.lazy(() => z.union([CommandResponseSchema, ErrorResponseSchema, EventSchema])); export const ErrorResponseSchema = z.lazy(() => z .object({ type: z.literal('error'), id: z.union([JsUintSchema, z.null()]), error: ErrorCodeSchema, message: z.string(), stacktrace: z.string().optional(), }) .and(ExtensibleSchema)); export const EmptyResultSchema = z.lazy(() => ExtensibleSchema); export const ExtensibleSchema = z.lazy(() => z.record(z.string(), z.any())); export const JsIntSchema = z .number() .int() .gte(-9007199254740991) .lte(9007199254740991); export const JsUintSchema = z .number() .int() .nonnegative() .gte(0) .lte(9007199254740991); export const ErrorCodeSchema = z.lazy(() => z.enum([ 'invalid argument', 'invalid selector', 'invalid session id', 'invalid web extension', 'move target out of bounds', 'no such alert', 'no such element', 'no such frame', 'no such handle', 'no such history entry', 'no such intercept', 'no such node', 'no such request', 'no such script', 'no such storage partition', 'no such user context', 'no such web extension', 'session not created', 'unable to capture screen', 'unable to close browser', 'unable to set cookie', 'unable to set file input', 'underspecified storage partition', 'unknown command', 'unknown error', 'unsupported operation', ])); export const SessionCommandSchema = z.lazy(() => z.union([ Session.EndSchema, Session.NewSchema, Session.StatusSchema, Session.SubscribeSchema, Session.UnsubscribeSchema, ])); export var Session; (function (Session) { Session.ProxyConfigurationSchema = z.lazy(() => z.union([ Session.AutodetectProxyConfigurationSchema, Session.DirectProxyConfigurationSchema, Session.ManualProxyConfigurationSchema, Session.PacProxyConfigurationSchema, Session.SystemProxyConfigurationSchema, z.object({}), ])); })(Session || (Session = {})); export const SessionResultSchema = z.lazy(() => z.union([ Session.NewResultSchema, Session.StatusResultSchema, Session.SubscribeResultSchema, ])); (function (Session) { Session.CapabilitiesRequestSchema = z.lazy(() => z.object({ alwaysMatch: Session.CapabilityRequestSchema.optional(), firstMatch: z.array(Session.CapabilityRequestSchema).optional(), })); })(Session || (Session = {})); (function (Session) { Session.CapabilityRequestSchema = z.lazy(() => z .object({ acceptInsecureCerts: z.boolean().optional(), browserName: z.string().optional(), browserVersion: z.string().optional(), platformName: z.string().optional(), proxy: Session.ProxyConfigurationSchema.optional(), unhandledPromptBehavior: Session.UserPromptHandlerSchema.optional(), }) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.AutodetectProxyConfigurationSchema = z.lazy(() => z .object({ proxyType: z.literal('autodetect'), }) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.DirectProxyConfigurationSchema = z.lazy(() => z .object({ proxyType: z.literal('direct'), }) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.ManualProxyConfigurationSchema = z.lazy(() => z .object({ proxyType: z.literal('manual'), ftpProxy: z.string().optional(), httpProxy: z.string().optional(), sslProxy: z.string().optional(), }) .and(Session.SocksProxyConfigurationSchema.or(z.object({}))) .and(z.object({ noProxy: z.array(z.string()).optional(), })) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.SocksProxyConfigurationSchema = z.lazy(() => z.object({ socksProxy: z.string(), socksVersion: z.number().int().nonnegative().gte(0).lte(255), })); })(Session || (Session = {})); (function (Session) { Session.PacProxyConfigurationSchema = z.lazy(() => z .object({ proxyType: z.literal('pac'), proxyAutoconfigUrl: z.string(), }) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.SystemProxyConfigurationSchema = z.lazy(() => z .object({ proxyType: z.literal('system'), }) .and(ExtensibleSchema)); })(Session || (Session = {})); (function (Session) { Session.UserPromptHandlerSchema = z.lazy(() => z.object({ alert: Session.UserPromptHandlerTypeSchema.optional(), beforeUnload: Session.UserPromptHandlerTypeSchema.optional(), confirm: Session.UserPromptHandlerTypeSchema.optional(), default: Session.UserPromptHandlerTypeSchema.optional(), prompt: Session.UserPromptHandlerTypeSchema.optional(), })); })(Session || (Session = {})); (function (Session) { Session.UserPromptHandlerTypeSchema = z.lazy(() => z.enum(['accept', 'dismiss', 'ignore'])); })(Session || (Session = {})); (function (Session) { Session.SubscriptionSchema = z.lazy(() => z.string()); })(Session || (Session = {})); (function (Session) { Session.SubscriptionRequestSchema = z.lazy(() => z.object({ events: z.array(z.string()).min(1), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Session || (Session = {})); (function (Session) { Session.UnsubscribeByIdRequestSchema = z.lazy(() => z.object({ subscriptions: z.array(Session.SubscriptionSchema).min(1), })); })(Session || (Session = {})); (function (Session) { Session.UnsubscribeByAttributesRequestSchema = z.lazy(() => z.object({ events: z.array(z.string()).min(1), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), })); })(Session || (Session = {})); (function (Session) { Session.StatusSchema = z.lazy(() => z.object({ method: z.literal('session.status'), params: EmptyParamsSchema, })); })(Session || (Session = {})); (function (Session) { Session.StatusResultSchema = z.lazy(() => z.object({ ready: z.boolean(), message: z.string(), })); })(Session || (Session = {})); (function (Session) { Session.NewSchema = z.lazy(() => z.object({ method: z.literal('session.new'), params: Session.NewParametersSchema, })); })(Session || (Session = {})); (function (Session) { Session.NewParametersSchema = z.lazy(() => z.object({ capabilities: Session.CapabilitiesRequestSchema, })); })(Session || (Session = {})); (function (Session) { Session.NewResultSchema = z.lazy(() => z.object({ sessionId: z.string(), capabilities: z .object({ acceptInsecureCerts: z.boolean(), browserName: z.string(), browserVersion: z.string(), platformName: z.string(), setWindowRect: z.boolean(), userAgent: z.string(), proxy: Session.ProxyConfigurationSchema.optional(), unhandledPromptBehavior: Session.UserPromptHandlerSchema.optional(), webSocketUrl: z.string().optional(), }) .and(ExtensibleSchema), })); })(Session || (Session = {})); (function (Session) { Session.EndSchema = z.lazy(() => z.object({ method: z.literal('session.end'), params: EmptyParamsSchema, })); })(Session || (Session = {})); (function (Session) { Session.SubscribeSchema = z.lazy(() => z.object({ method: z.literal('session.subscribe'), params: Session.SubscriptionRequestSchema, })); })(Session || (Session = {})); (function (Session) { Session.SubscribeResultSchema = z.lazy(() => z.object({ subscription: Session.SubscriptionSchema, })); })(Session || (Session = {})); (function (Session) { Session.UnsubscribeSchema = z.lazy(() => z.object({ method: z.literal('session.unsubscribe'), params: Session.UnsubscribeParametersSchema, })); })(Session || (Session = {})); (function (Session) { Session.UnsubscribeParametersSchema = z.lazy(() => z.union([ Session.UnsubscribeByAttributesRequestSchema, Session.UnsubscribeByIdRequestSchema, ])); })(Session || (Session = {})); export const BrowserCommandSchema = z.lazy(() => z.union([ Browser.CloseSchema, Browser.CreateUserContextSchema, Browser.GetClientWindowsSchema, Browser.GetUserContextsSchema, Browser.RemoveUserContextSchema, Browser.SetClientWindowStateSchema, z.object({}), ])); export const BrowserResultSchema = z.lazy(() => z.union([ Browser.CreateUserContextResultSchema, Browser.GetUserContextsResultSchema, ])); export var Browser; (function (Browser) { Browser.ClientWindowSchema = z.lazy(() => z.string()); })(Browser || (Browser = {})); (function (Browser) { Browser.ClientWindowInfoSchema = z.lazy(() => z.object({ active: z.boolean(), clientWindow: Browser.ClientWindowSchema, height: JsUintSchema, state: z.enum(['fullscreen', 'maximized', 'minimized', 'normal']), width: JsUintSchema, x: JsIntSchema, y: JsIntSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.UserContextSchema = z.lazy(() => z.string()); })(Browser || (Browser = {})); (function (Browser) { Browser.UserContextInfoSchema = z.lazy(() => z.object({ userContext: Browser.UserContextSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.CloseSchema = z.lazy(() => z.object({ method: z.literal('browser.close'), params: EmptyParamsSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.CreateUserContextSchema = z.lazy(() => z.object({ method: z.literal('browser.createUserContext'), params: EmptyParamsSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.CreateUserContextResultSchema = z.lazy(() => Browser.UserContextInfoSchema); })(Browser || (Browser = {})); (function (Browser) { Browser.GetClientWindowsSchema = z.lazy(() => z.object({ method: z.literal('browser.getClientWindows'), params: EmptyParamsSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.GetClientWindowsResultSchema = z.lazy(() => z.object({ clientWindows: z.array(Browser.ClientWindowInfoSchema), })); })(Browser || (Browser = {})); (function (Browser) { Browser.GetUserContextsSchema = z.lazy(() => z.object({ method: z.literal('browser.getUserContexts'), params: EmptyParamsSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.GetUserContextsResultSchema = z.lazy(() => z.object({ userContexts: z.array(Browser.UserContextInfoSchema).min(1), })); })(Browser || (Browser = {})); (function (Browser) { Browser.RemoveUserContextSchema = z.lazy(() => z.object({ method: z.literal('browser.removeUserContext'), params: Browser.RemoveUserContextParametersSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.RemoveUserContextParametersSchema = z.lazy(() => z.object({ userContext: Browser.UserContextSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.SetClientWindowStateSchema = z.lazy(() => z.object({ method: z.literal('browser.setClientWindowState'), params: Browser.SetClientWindowStateParametersSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.SetClientWindowStateParametersSchema = z.lazy(() => z .object({ clientWindow: Browser.ClientWindowSchema, }) .and(z.union([ Browser.ClientWindowNamedStateSchema, Browser.ClientWindowRectStateSchema, ]))); })(Browser || (Browser = {})); (function (Browser) { Browser.ClientWindowNamedStateSchema = z.lazy(() => z.object({ state: z.enum(['fullscreen', 'maximized', 'minimized']), })); })(Browser || (Browser = {})); (function (Browser) { Browser.ClientWindowRectStateSchema = z.lazy(() => z.object({ state: z.literal('normal'), width: JsUintSchema.optional(), height: JsUintSchema.optional(), x: JsIntSchema.optional(), y: JsIntSchema.optional(), })); })(Browser || (Browser = {})); export const BrowsingContextCommandSchema = z.lazy(() => z.union([ BrowsingContext.ActivateSchema, BrowsingContext.CaptureScreenshotSchema, BrowsingContext.CloseSchema, BrowsingContext.CreateSchema, BrowsingContext.GetTreeSchema, BrowsingContext.HandleUserPromptSchema, BrowsingContext.LocateNodesSchema, BrowsingContext.NavigateSchema, BrowsingContext.PrintSchema, BrowsingContext.ReloadSchema, BrowsingContext.SetViewportSchema, BrowsingContext.TraverseHistorySchema, ])); export const BrowsingContextEventSchema = z.lazy(() => z.union([ BrowsingContext.ContextCreatedSchema, BrowsingContext.ContextDestroyedSchema, BrowsingContext.DomContentLoadedSchema, BrowsingContext.DownloadWillBeginSchema, BrowsingContext.FragmentNavigatedSchema, BrowsingContext.HistoryUpdatedSchema, BrowsingContext.LoadSchema, BrowsingContext.NavigationAbortedSchema, BrowsingContext.NavigationCommittedSchema, BrowsingContext.NavigationFailedSchema, BrowsingContext.NavigationStartedSchema, BrowsingContext.UserPromptClosedSchema, BrowsingContext.UserPromptOpenedSchema, ])); export const BrowsingContextResultSchema = z.lazy(() => z.union([ BrowsingContext.CaptureScreenshotResultSchema, BrowsingContext.CreateResultSchema, BrowsingContext.GetTreeResultSchema, BrowsingContext.LocateNodesResultSchema, BrowsingContext.NavigateResultSchema, BrowsingContext.PrintResultSchema, BrowsingContext.TraverseHistoryResultSchema, ])); export var BrowsingContext; (function (BrowsingContext) { BrowsingContext.BrowsingContextSchema = z.lazy(() => z.string()); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.InfoListSchema = z.lazy(() => z.array(BrowsingContext.InfoSchema)); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.InfoSchema = z.lazy(() => z.object({ children: z.union([BrowsingContext.InfoListSchema, z.null()]), clientWindow: Browser.ClientWindowSchema, context: BrowsingContext.BrowsingContextSchema, originalOpener: z.union([ BrowsingContext.BrowsingContextSchema, z.null(), ]), url: z.string(), userContext: Browser.UserContextSchema, parent: z .union([BrowsingContext.BrowsingContextSchema, z.null()]) .optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LocatorSchema = z.lazy(() => z.union([ BrowsingContext.AccessibilityLocatorSchema, BrowsingContext.CssLocatorSchema, BrowsingContext.ContextLocatorSchema, BrowsingContext.InnerTextLocatorSchema, BrowsingContext.XPathLocatorSchema, ])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.AccessibilityLocatorSchema = z.lazy(() => z.object({ type: z.literal('accessibility'), value: z.object({ name: z.string().optional(), role: z.string().optional(), }), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CssLocatorSchema = z.lazy(() => z.object({ type: z.literal('css'), value: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ContextLocatorSchema = z.lazy(() => z.object({ type: z.literal('context'), value: z.object({ context: BrowsingContext.BrowsingContextSchema, }), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.InnerTextLocatorSchema = z.lazy(() => z.object({ type: z.literal('innerText'), value: z.string(), ignoreCase: z.boolean().optional(), matchType: z.enum(['full', 'partial']).optional(), maxDepth: JsUintSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.XPathLocatorSchema = z.lazy(() => z.object({ type: z.literal('xpath'), value: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationSchema = z.lazy(() => z.string()); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationInfoSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, navigation: z.union([BrowsingContext.NavigationSchema, z.null()]), timestamp: JsUintSchema, url: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ReadinessStateSchema = z.lazy(() => z.enum(['none', 'interactive', 'complete'])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.UserPromptTypeSchema = z.lazy(() => z.enum(['alert', 'beforeunload', 'confirm', 'prompt'])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ActivateSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.activate'), params: BrowsingContext.ActivateParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ActivateParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CaptureScreenshotParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, origin: z.enum(['viewport', 'document']).default('viewport').optional(), format: BrowsingContext.ImageFormatSchema.optional(), clip: BrowsingContext.ClipRectangleSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CaptureScreenshotSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.captureScreenshot'), params: BrowsingContext.CaptureScreenshotParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ImageFormatSchema = z.lazy(() => z.object({ type: z.string(), quality: z.number().gte(0).lte(1).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ClipRectangleSchema = z.lazy(() => z.union([ BrowsingContext.BoxClipRectangleSchema, BrowsingContext.ElementClipRectangleSchema, ])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ElementClipRectangleSchema = z.lazy(() => z.object({ type: z.literal('element'), element: Script.SharedReferenceSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.BoxClipRectangleSchema = z.lazy(() => z.object({ type: z.literal('box'), x: z.number(), y: z.number(), width: z.number(), height: z.number(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CaptureScreenshotResultSchema = z.lazy(() => z.object({ data: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CloseSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.close'), params: BrowsingContext.CloseParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CloseParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, promptUnload: z.boolean().default(false).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CreateSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.create'), params: BrowsingContext.CreateParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CreateTypeSchema = z.lazy(() => z.enum(['tab', 'window'])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CreateParametersSchema = z.lazy(() => z.object({ type: BrowsingContext.CreateTypeSchema, referenceContext: BrowsingContext.BrowsingContextSchema.optional(), background: z.boolean().default(false).optional(), userContext: Browser.UserContextSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CreateResultSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.GetTreeSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.getTree'), params: BrowsingContext.GetTreeParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.GetTreeParametersSchema = z.lazy(() => z.object({ maxDepth: JsUintSchema.optional(), root: BrowsingContext.BrowsingContextSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.GetTreeResultSchema = z.lazy(() => z.object({ contexts: BrowsingContext.InfoListSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.HandleUserPromptSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.handleUserPrompt'), params: BrowsingContext.HandleUserPromptParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.HandleUserPromptParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, accept: z.boolean().optional(), userText: z.string().optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LocateNodesParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, locator: BrowsingContext.LocatorSchema, maxNodeCount: JsUintSchema.gte(1).optional(), serializationOptions: Script.SerializationOptionsSchema.optional(), startNodes: z.array(Script.SharedReferenceSchema).min(1).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LocateNodesSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.locateNodes'), params: BrowsingContext.LocateNodesParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LocateNodesResultSchema = z.lazy(() => z.object({ nodes: z.array(Script.NodeRemoteValueSchema), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigateSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.navigate'), params: BrowsingContext.NavigateParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigateParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, url: z.string(), wait: BrowsingContext.ReadinessStateSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigateResultSchema = z.lazy(() => z.object({ navigation: z.union([BrowsingContext.NavigationSchema, z.null()]), url: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.PrintSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.print'), params: BrowsingContext.PrintParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.PrintParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, background: z.boolean().default(false).optional(), margin: BrowsingContext.PrintMarginParametersSchema.optional(), orientation: z .enum(['portrait', 'landscape']) .default('portrait') .optional(), page: BrowsingContext.PrintPageParametersSchema.optional(), pageRanges: z.array(z.union([JsUintSchema, z.string()])).optional(), scale: z.number().gte(0.1).lte(2).default(1).optional(), shrinkToFit: z.boolean().default(true).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.PrintMarginParametersSchema = z.lazy(() => z.object({ bottom: z.number().gte(0).default(1).optional(), left: z.number().gte(0).default(1).optional(), right: z.number().gte(0).default(1).optional(), top: z.number().gte(0).default(1).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.PrintPageParametersSchema = z.lazy(() => z.object({ height: z.number().gte(0.0352).default(27.94).optional(), width: z.number().gte(0.0352).default(21.59).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.PrintResultSchema = z.lazy(() => z.object({ data: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ReloadSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.reload'), params: BrowsingContext.ReloadParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ReloadParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, ignoreCache: z.boolean().optional(), wait: BrowsingContext.ReadinessStateSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetViewportSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.setViewport'), params: BrowsingContext.SetViewportParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetViewportParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, viewport: z.union([BrowsingContext.ViewportSchema, z.null()]).optional(), devicePixelRatio: z.union([z.number().gt(0), z.null()]).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ViewportSchema = z.lazy(() => z.object({ width: JsUintSchema, height: JsUintSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.TraverseHistorySchema = z.lazy(() => z.object({ method: z.literal('browsingContext.traverseHistory'), params: BrowsingContext.TraverseHistoryParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.TraverseHistoryParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, delta: JsIntSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.TraverseHistoryResultSchema = z.lazy(() => z.object({})); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ContextCreatedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.contextCreated'), params: BrowsingContext.InfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ContextDestroyedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.contextDestroyed'), params: BrowsingContext.InfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationStartedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.navigationStarted'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.FragmentNavigatedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.fragmentNavigated'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.HistoryUpdatedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.historyUpdated'), params: BrowsingContext.HistoryUpdatedParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.HistoryUpdatedParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, url: z.string(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DomContentLoadedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.domContentLoaded'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LoadSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.load'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadWillBeginSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.downloadWillBegin'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationAbortedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.navigationAborted'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationCommittedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.navigationCommitted'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationFailedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.navigationFailed'), params: BrowsingContext.NavigationInfoSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.UserPromptClosedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.userPromptClosed'), params: BrowsingContext.UserPromptClosedParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.UserPromptClosedParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, accepted: z.boolean(), type: BrowsingContext.UserPromptTypeSchema, userText: z.string().optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.UserPromptOpenedSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.userPromptOpened'), params: BrowsingContext.UserPromptOpenedParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.UserPromptOpenedParametersSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, handler: Session.UserPromptHandlerTypeSchema, message: z.string(), type: BrowsingContext.UserPromptTypeSchema, defaultValue: z.string().optional(), })); })(BrowsingContext || (BrowsingContext = {})); export const NetworkCommandSchema = z.lazy(() => z.union([ Network.AddInterceptSchema, Network.ContinueRequestSchema, Network.ContinueResponseSchema, Network.ContinueWithAuthSchema, Network.FailRequestSchema, Network.ProvideResponseSchema, Network.RemoveInterceptSchema, Network.SetCacheBehaviorSchema, ])); export const NetworkEventSchema = z.lazy(() => z.union([ Network.AuthRequiredSchema, Network.BeforeRequestSentSchema, Network.FetchErrorSchema, Network.ResponseCompletedSchema, Network.ResponseStartedSchema, ])); export const NetworkResultSchema = z.lazy(() => Network.AddInterceptResultSchema); export var Network; (function (Network) { Network.AuthChallengeSchema = z.lazy(() => z.object({ scheme: z.string(), realm: z.string(), })); })(Network || (Network = {})); (function (Network) { Network.AuthCredentialsSchema = z.lazy(() => z.object({ type: z.literal('password'), username: z.string(), password: z.string(), })); })(Network || (Network = {})); (function (Network) { Network.BaseParametersSchema = z.lazy(() => z.object({ context: z.union([BrowsingContext.BrowsingContextSchema, z.null()]), isBlocked: z.boolean(), navigation: z.union([BrowsingContext.NavigationSchema, z.null()]), redirectCount: JsUintSchema, request: Network.RequestDataSchema, timestamp: JsUintSchema, intercepts: z.array(Network.InterceptSchema).min(1).optional(), })); })(Network || (Network = {})); (function (Network) { Network.BytesValueSchema = z.lazy(() => z.union([Network.StringValueSchema, Network.Base64ValueSchema])); })(Network || (Network = {})); (function (Network) { Network.StringValueSchema = z.lazy(() => z.object({ type: z.literal('string'), value: z.string(), })); })(Network || (Network = {})); (function (Network) { Network.Base64ValueSchema = z.lazy(() => z.object({ type: z.literal('base64'), value: z.string(), })); })(Network || (Network = {})); (function (Network) { Network.SameSiteSchema = z.lazy(() => z.enum(['strict', 'lax', 'none'])); })(Network || (Network = {})); (function (Network) { Network.CookieSchema = z.lazy(() => z .object({ name: z.string(), value: Network.BytesValueSchema, domain: z.string(), path: z.string(), size: JsUintSchema, httpOnly: z.boolean(), secure: z.boolean(), sameSite: Network.SameSiteSchema, expiry: JsUintSchema.optional(), }) .and(ExtensibleSchema)); })(Network || (Network = {})); (function (Network) { Network.CookieHeaderSchema = z.lazy(() => z.object({ name: z.string(), value: Network.BytesValueSchema, })); })(Network || (Network = {})); (function (Network) { Network.FetchTimingInfoSchema = z.lazy(() => z.object({ timeOrigin: z.number(), requestTime: z.number(), redirectStart: z.number(), redirectEnd: z.number(), fetchStart: z.number(), dnsStart: z.number(), dnsEnd: z.number(), connectStart: z.number(), connectEnd: z.number(), tlsStart: z.number(), requestStart: z.number(), responseStart: z.number(), responseEnd: z.number(), })); })(Network || (Network = {})); (function (Network) { Network.HeaderSchema = z.lazy(() => z.object({ name: z.string(), value: Network.BytesValueSchema, })); })(Network || (Network = {})); (function (Network) { Network.InitiatorSchema = z.lazy(() => z.object({ columnNumber: JsUintSchema.optional(), lineNumber: JsUintSchema.optional(), request: Network.RequestSchema.optional(), stackTrace: Script.StackTraceSchema.optional(), type: z.enum(['parser', 'script', 'preflight', 'other']).optional(), })); })(Network || (Network = {})); (function (Network) { Network.InterceptSchema = z.lazy(() => z.string()); })(Network || (Network = {})); (function (Network) { Network.RequestSchema = z.lazy(() => z.string()); })(Network || (Network = {})); (function (Network) { Network.RequestDataSchema = z.lazy(() => z.object({ request: Network.RequestSchema, url: z.string(), method: z.string(), headers: z.array(Network.HeaderSchema), cookies: z.array(Network.CookieSchema), headersSize: JsUintSchema, bodySize: z.union([JsUintSchema, z.null()]), destination: z.string(), initiatorType: z.union([z.string(), z.null()]), timings: Network.FetchTimingInfoSchema, })); })(Network || (Network = {})); (function (Network) { Network.ResponseContentSchema = z.lazy(() => z.object({ size: JsUintSchema, })); })(Network || (Network = {})); (function (Network) { Network.ResponseDataSchema = z.lazy(() => z.object({ url: z.string(), protocol: z.string(), status: JsUintSchema, statusText: z.string(), fromCache: z.boolean(), headers: z.array(Network.HeaderSchema), mimeType: z.string(), bytesReceived: JsUintSchema, headersSize: z.union([JsUintSchema, z.null()]), bodySize: z.union([JsUintSchema, z.null()]), content: Network.ResponseContentSchema, authChallenges: z.array(Network.AuthChallengeSchema).optional(), })); })(Network || (Network = {})); (function (Network) { Network.SetCookieHeaderSchema = z.lazy(() => z.object({ name: z.string(), value: Network.BytesValueSchema, domain: z.string().optional(), httpOnly: z.boolean().optional(), expiry: z.string().optional(), maxAge: JsIntSchema.optional(), path: z.string().optional(), sameSite: Network.SameSiteSchema.optional(), secure: z.boolean().optional(), })); })(Network || (Network = {})); (function (Network) { Network.UrlPatternSchema = z.lazy(() => z.union([Network.UrlPatternPatternSchema, Network.UrlPatternStringSchema])); })(Network || (Network = {})); (function (Network) { Network.UrlPatternPatternSchema = z.lazy(() => z.object({ type: z.literal('pattern'), protocol: z.string().optional(), hostname: z.string().optional(), port: z.string().optional(), pathname: z.string().optional(), search: z.string().optional(), })); })(Network || (Network = {})); (function (Network) { Network.UrlPatternStringSchema = z.lazy(() => z.object({ type: z.literal('string'), pattern: z.string(), })); })(Network || (Network = {})); (function (Network) { Network.AddInterceptParametersSchema = z.lazy(() => z.object({ phases: z.array(Network.InterceptPhaseSchema).min(1), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), urlPatterns: z.array(Network.UrlPatternSchema).optional(), })); })(Network || (Network = {})); (function (Network) { Network.AddInterceptSchema = z.lazy(() => z.object({ method: z.literal('network.addIntercept'), params: Network.AddInterceptParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.InterceptPhaseSchema = z.lazy(() => z.enum(['beforeRequestSent', 'responseStarted', 'authRequired'])); })(Network || (Network = {})); (function (Network) { Network.AddInterceptResultSchema = z.lazy(() => z.object({ intercept: Network.InterceptSchema, })); })(Network || (Network = {})); (function (Network) { Network.ContinueRequestSchema = z.lazy(() => z.object({ method: z.literal('network.continueRequest'), params: Network.ContinueRequestParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ContinueRequestParametersSchema = z.lazy(() => z.object({ request: Network.RequestSchema, body: Network.BytesValueSchema.optional(), cookies: z.array(Network.CookieHeaderSchema).optional(), headers: z.array(Network.HeaderSchema).optional(), method: z.string().optional(), url: z.string().optional(), })); })(Network || (Network = {})); (function (Network) { Network.ContinueResponseSchema = z.lazy(() => z.object({ method: z.literal('network.continueResponse'), params: Network.ContinueResponseParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ContinueResponseParametersSchema = z.lazy(() => z.object({ request: Network.RequestSchema, cookies: z.array(Network.SetCookieHeaderSchema).optional(), credentials: Network.AuthCredentialsSchema.optional(), headers: z.array(Network.HeaderSchema).optional(), reasonPhrase: z.string().optional(), statusCode: JsUintSchema.optional(), })); })(Network || (Network = {})); (function (Network) { Network.ContinueWithAuthSchema = z.lazy(() => z.object({ method: z.literal('network.continueWithAuth'), params: Network.ContinueWithAuthParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ContinueWithAuthParametersSchema = z.lazy(() => z .object({ request: Network.RequestSchema, }) .and(z.union([ Network.ContinueWithAuthCredentialsSchema, Network.ContinueWithAuthNoCredentialsSchema, ]))); })(Network || (Network = {})); (function (Network) { Network.ContinueWithAuthCredentialsSchema = z.lazy(() => z.object({ action: z.literal('provideCredentials'), credentials: Network.AuthCredentialsSchema, })); })(Network || (Network = {})); (function (Network) { Network.ContinueWithAuthNoCredentialsSchema = z.lazy(() => z.object({ action: z.enum(['default', 'cancel']), })); })(Network || (Network = {})); (function (Network) { Network.FailRequestSchema = z.lazy(() => z.object({ method: z.literal('network.failRequest'), params: Network.FailRequestParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.FailRequestParametersSchema = z.lazy(() => z.object({ request: Network.RequestSchema, })); })(Network || (Network = {})); (function (Network) { Network.ProvideResponseSchema = z.lazy(() => z.object({ method: z.literal('network.provideResponse'), params: Network.ProvideResponseParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ProvideResponseParametersSchema = z.lazy(() => z.object({ request: Network.RequestSchema, body: Network.BytesValueSchema.optional(), cookies: z.array(Network.SetCookieHeaderSchema).optional(), headers: z.array(Network.HeaderSchema).optional(), reasonPhrase: z.string().optional(), statusCode: JsUintSchema.optional(), })); })(Network || (Network = {})); (function (Network) { Network.RemoveInterceptSchema = z.lazy(() => z.object({ method: z.literal('network.removeIntercept'), params: Network.RemoveInterceptParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.RemoveInterceptParametersSchema = z.lazy(() => z.object({ intercept: Network.InterceptSchema, })); })(Network || (Network = {})); (function (Network) { Network.SetCacheBehaviorSchema = z.lazy(() => z.object({ method: z.literal('network.setCacheBehavior'), params: Network.SetCacheBehaviorParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.SetCacheBehaviorParametersSchema = z.lazy(() => z.object({ cacheBehavior: z.enum(['default', 'bypass']), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), })); })(Network || (Network = {})); export const ScriptEventSchema = z.lazy(() => z.union([ Script.MessageSchema, Script.RealmCreatedSchema, Script.RealmDestroyedSchema, ])); (function (Network) { Network.AuthRequiredParametersSchema = z.lazy(() => Network.BaseParametersSchema.and(z.object({ response: Network.ResponseDataSchema, }))); })(Network || (Network = {})); (function (Network) { Network.BeforeRequestSentParametersSchema = z.lazy(() => Network.BaseParametersSchema.and(z.object({ initiator: Network.InitiatorSchema.optional(), }))); })(Network || (Network = {})); (function (Network) { Network.FetchErrorParametersSchema = z.lazy(() => Network.BaseParametersSchema.and(z.object({ errorText: z.string(), }))); })(Network || (Network = {})); (function (Network) { Network.ResponseCompletedParametersSchema = z.lazy(() => Network.BaseParametersSchema.and(z.object({ response: Network.ResponseDataSchema, }))); })(Network || (Network = {})); (function (Network) { Network.ResponseStartedParametersSchema = z.lazy(() => Network.BaseParametersSchema.and(z.object({ response: Network.ResponseDataSchema, }))); })(Network || (Network = {})); export const ScriptCommandSchema = z.lazy(() => z.union([ Script.AddPreloadScriptSchema, Script.CallFunctionSchema, Script.DisownSchema, Script.EvaluateSchema, Script.GetRealmsSchema, Script.RemovePreloadScriptSchema, ])); export const ScriptResultSchema = z.lazy(() => z.union([ Script.AddPreloadScriptResultSchema, Script.EvaluateResultSchema, Script.GetRealmsResultSchema, ])); (function (Network) { Network.AuthRequiredSchema = z.lazy(() => z.object({ method: z.literal('network.authRequired'), params: Network.AuthRequiredParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.BeforeRequestSentSchema = z.lazy(() => z.object({ method: z.literal('network.beforeRequestSent'), params: Network.BeforeRequestSentParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.FetchErrorSchema = z.lazy(() => z.object({ method: z.literal('network.fetchError'), params: Network.FetchErrorParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ResponseCompletedSchema = z.lazy(() => z.object({ method: z.literal('network.responseCompleted'), params: Network.ResponseCompletedParametersSchema, })); })(Network || (Network = {})); (function (Network) { Network.ResponseStartedSchema =