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,248 lines 115 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.7. * 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 CommandSchema = z.lazy(() => z .object({ id: JsUintSchema, }) .and(CommandDataSchema) .and(ExtensibleSchema)); export const CommandDataSchema = z.lazy(() => z.union([ BrowserCommandSchema, BrowsingContextCommandSchema, EmulationCommandSchema, InputCommandSchema, NetworkCommandSchema, ScriptCommandSchema, SessionCommandSchema, StorageCommandSchema, WebExtensionCommandSchema, ])); export const EmptyParamsSchema = z.lazy(() => ExtensibleSchema); export const MessageSchema = z.lazy(() => z.union([CommandResponseSchema, ErrorResponseSchema, EventSchema])); export const CommandResponseSchema = z.lazy(() => z .object({ type: z.literal('success'), id: JsUintSchema, result: ResultDataSchema, }) .and(ExtensibleSchema)); 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 ResultDataSchema = z.lazy(() => z.union([ BrowserResultSchema, BrowsingContextResultSchema, EmulationResultSchema, InputResultSchema, NetworkResultSchema, ScriptResultSchema, SessionResultSchema, StorageResultSchema, WebExtensionResultSchema, ])); export const EmptyResultSchema = z.lazy(() => ExtensibleSchema); export const EventSchema = z.lazy(() => z .object({ type: z.literal('event'), }) .and(EventDataSchema) .and(ExtensibleSchema)); export const EventDataSchema = z.lazy(() => z.union([ BrowsingContextEventSchema, InputEventSchema, LogEventSchema, NetworkEventSchema, ScriptEventSchema, ])); 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 network collector', 'no such element', 'no such frame', 'no such handle', 'no such history entry', 'no such intercept', 'no such network data', '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', 'unavailable network data', '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 const SessionResultSchema = z.lazy(() => z.union([ Session.EndResultSchema, Session.NewResultSchema, Session.StatusResultSchema, Session.SubscribeResultSchema, Session.UnsubscribeResultSchema, ])); export var Session; (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.ProxyConfigurationSchema = z.lazy(() => z.union([ Session.AutodetectProxyConfigurationSchema, Session.DirectProxyConfigurationSchema, Session.ManualProxyConfigurationSchema, Session.PacProxyConfigurationSchema, Session.SystemProxyConfigurationSchema, ])); })(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'), 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(), file: 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.SubscribeParametersSchema = 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), })); })(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.EndResultSchema = z.lazy(() => EmptyResultSchema); })(Session || (Session = {})); (function (Session) { Session.SubscribeSchema = z.lazy(() => z.object({ method: z.literal('session.subscribe'), params: Session.SubscribeParametersSchema, })); })(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 = {})); (function (Session) { Session.UnsubscribeResultSchema = z.lazy(() => EmptyResultSchema); })(Session || (Session = {})); export const BrowserCommandSchema = z.lazy(() => z.union([ Browser.CloseSchema, Browser.CreateUserContextSchema, Browser.GetClientWindowsSchema, Browser.GetUserContextsSchema, Browser.RemoveUserContextSchema, Browser.SetClientWindowStateSchema, Browser.SetDownloadBehaviorSchema, ])); export const BrowserResultSchema = z.lazy(() => z.union([ Browser.CloseResultSchema, Browser.CreateUserContextResultSchema, Browser.GetClientWindowsResultSchema, Browser.GetUserContextsResultSchema, Browser.RemoveUserContextResultSchema, Browser.SetClientWindowStateResultSchema, Browser.SetDownloadBehaviorResultSchema, ])); 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.CloseResultSchema = z.lazy(() => EmptyResultSchema); })(Browser || (Browser = {})); (function (Browser) { Browser.CreateUserContextSchema = z.lazy(() => z.object({ method: z.literal('browser.createUserContext'), params: Browser.CreateUserContextParametersSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.CreateUserContextParametersSchema = z.lazy(() => z.object({ acceptInsecureCerts: z.boolean().optional(), proxy: Session.ProxyConfigurationSchema.optional(), unhandledPromptBehavior: Session.UserPromptHandlerSchema.optional(), })); })(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.RemoveUserContextResultSchema = z.lazy(() => EmptyResultSchema); })(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 = {})); (function (Browser) { Browser.SetClientWindowStateResultSchema = z.lazy(() => Browser.ClientWindowInfoSchema); })(Browser || (Browser = {})); (function (Browser) { Browser.SetDownloadBehaviorSchema = z.lazy(() => z.object({ method: z.literal('browser.setDownloadBehavior'), params: Browser.SetDownloadBehaviorParametersSchema, })); })(Browser || (Browser = {})); (function (Browser) { Browser.SetDownloadBehaviorParametersSchema = z.lazy(() => z.object({ downloadBehavior: z.union([Browser.DownloadBehaviorSchema, z.null()]), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Browser || (Browser = {})); (function (Browser) { Browser.DownloadBehaviorSchema = z.lazy(() => z.union([ Browser.DownloadBehaviorAllowedSchema, Browser.DownloadBehaviorDeniedSchema, ])); })(Browser || (Browser = {})); (function (Browser) { Browser.DownloadBehaviorAllowedSchema = z.lazy(() => z.object({ type: z.literal('allowed'), destinationFolder: z.string(), })); })(Browser || (Browser = {})); (function (Browser) { Browser.DownloadBehaviorDeniedSchema = z.lazy(() => z.object({ type: z.literal('denied'), })); })(Browser || (Browser = {})); (function (Browser) { Browser.SetDownloadBehaviorResultSchema = z.lazy(() => EmptyResultSchema); })(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.SetBypassCspSchema, BrowsingContext.SetViewportSchema, BrowsingContext.TraverseHistorySchema, ])); export const BrowsingContextResultSchema = z.lazy(() => z.union([ BrowsingContext.ActivateResultSchema, BrowsingContext.CaptureScreenshotResultSchema, BrowsingContext.CloseResultSchema, BrowsingContext.CreateResultSchema, BrowsingContext.GetTreeResultSchema, BrowsingContext.HandleUserPromptResultSchema, BrowsingContext.LocateNodesResultSchema, BrowsingContext.NavigateResultSchema, BrowsingContext.PrintResultSchema, BrowsingContext.ReloadResultSchema, BrowsingContext.SetBypassCspResultSchema, BrowsingContext.SetViewportResultSchema, BrowsingContext.TraverseHistoryResultSchema, ])); export const BrowsingContextEventSchema = z.lazy(() => z.union([ BrowsingContext.ContextCreatedSchema, BrowsingContext.ContextDestroyedSchema, BrowsingContext.DomContentLoadedSchema, BrowsingContext.DownloadEndSchema, BrowsingContext.DownloadWillBeginSchema, BrowsingContext.FragmentNavigatedSchema, BrowsingContext.HistoryUpdatedSchema, BrowsingContext.LoadSchema, BrowsingContext.NavigationAbortedSchema, BrowsingContext.NavigationCommittedSchema, BrowsingContext.NavigationFailedSchema, BrowsingContext.NavigationStartedSchema, BrowsingContext.UserPromptClosedSchema, BrowsingContext.UserPromptOpenedSchema, ])); 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.BaseNavigationInfoSchema = z.lazy(() => z.object({ context: BrowsingContext.BrowsingContextSchema, navigation: z.union([BrowsingContext.NavigationSchema, z.null()]), timestamp: JsUintSchema, url: z.string(), userContext: Browser.UserContextSchema.optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.NavigationInfoSchema = z.lazy(() => BrowsingContext.BaseNavigationInfoSchema); })(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.ActivateResultSchema = z.lazy(() => EmptyResultSchema); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.CaptureScreenshotSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.captureScreenshot'), params: BrowsingContext.CaptureScreenshotParametersSchema, })); })(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.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.CloseResultSchema = z.lazy(() => EmptyResultSchema); })(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, userContext: Browser.UserContextSchema.optional(), })); })(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.HandleUserPromptResultSchema = z.lazy(() => EmptyResultSchema); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.LocateNodesSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.locateNodes'), params: BrowsingContext.LocateNodesParametersSchema, })); })(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.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.ReloadResultSchema = z.lazy(() => BrowsingContext.NavigateResultSchema); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetBypassCspSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.setBypassCSP'), params: BrowsingContext.SetBypassCspParametersSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetBypassCspParametersSchema = z.lazy(() => z.object({ bypass: z.union([z.literal(true), z.null()]), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetBypassCspResultSchema = z.lazy(() => EmptyResultSchema); })(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.optional(), viewport: z.union([BrowsingContext.ViewportSchema, z.null()]).optional(), devicePixelRatio: z.union([z.number().gt(0), z.null()]).optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.ViewportSchema = z.lazy(() => z.object({ width: JsUintSchema, height: JsUintSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.SetViewportResultSchema = z.lazy(() => EmptyResultSchema); })(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(() => EmptyResultSchema); })(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, timestamp: JsUintSchema, url: z.string(), userContext: Browser.UserContextSchema.optional(), })); })(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.DownloadWillBeginParamsSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadWillBeginParamsSchema = z.lazy(() => z .object({ suggestedFilename: z.string(), }) .and(BrowsingContext.BaseNavigationInfoSchema)); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadEndSchema = z.lazy(() => z.object({ method: z.literal('browsingContext.downloadEnd'), params: BrowsingContext.DownloadEndParamsSchema, })); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadEndParamsSchema = z.lazy(() => z.union([ BrowsingContext.DownloadCanceledParamsSchema, BrowsingContext.DownloadCompleteParamsSchema, ])); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadCanceledParamsSchema = z.lazy(() => z .object({ status: z.literal('canceled'), }) .and(BrowsingContext.BaseNavigationInfoSchema)); })(BrowsingContext || (BrowsingContext = {})); (function (BrowsingContext) { BrowsingContext.DownloadCompleteParamsSchema = z.lazy(() => z .object({ status: z.literal('complete'), filepath: z.union([z.string(), z.null()]), }) .and(BrowsingContext.BaseNavigationInfoSchema)); })(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, userContext: Browser.UserContextSchema.optional(), 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, userContext: Browser.UserContextSchema.optional(), defaultValue: z.string().optional(), })); })(BrowsingContext || (BrowsingContext = {})); export const EmulationCommandSchema = z.lazy(() => z.union([ Emulation.SetForcedColorsModeThemeOverrideSchema, Emulation.SetGeolocationOverrideSchema, Emulation.SetLocaleOverrideSchema, Emulation.SetNetworkConditionsSchema, Emulation.SetScreenOrientationOverrideSchema, Emulation.SetScreenSettingsOverrideSchema, Emulation.SetScriptingEnabledSchema, Emulation.SetScrollbarTypeOverrideSchema, Emulation.SetTimezoneOverrideSchema, Emulation.SetTouchOverrideSchema, Emulation.SetUserAgentOverrideSchema, ])); export const EmulationResultSchema = z.lazy(() => z.union([ Emulation.SetForcedColorsModeThemeOverrideResultSchema, Emulation.SetGeolocationOverrideResultSchema, Emulation.SetLocaleOverrideResultSchema, Emulation.SetScreenOrientationOverrideResultSchema, Emulation.SetScriptingEnabledResultSchema, Emulation.SetScrollbarTypeOverrideResultSchema, Emulation.SetTimezoneOverrideResultSchema, Emulation.SetTouchOverrideResultSchema, Emulation.SetUserAgentOverrideResultSchema, ])); export var Emulation; (function (Emulation) { Emulation.SetForcedColorsModeThemeOverrideSchema = z.lazy(() => z.object({ method: z.literal('emulation.setForcedColorsModeThemeOverride'), params: Emulation.SetForcedColorsModeThemeOverrideParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetForcedColorsModeThemeOverrideParametersSchema = z.lazy(() => z.object({ theme: z.union([Emulation.ForcedColorsModeThemeSchema, z.null()]), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.ForcedColorsModeThemeSchema = z.lazy(() => z.enum(['light', 'dark'])); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetForcedColorsModeThemeOverrideResultSchema = z.lazy(() => EmptyResultSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetGeolocationOverrideSchema = z.lazy(() => z.object({ method: z.literal('emulation.setGeolocationOverride'), params: Emulation.SetGeolocationOverrideParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetGeolocationOverrideParametersSchema = z.lazy(() => z .union([ z.object({ coordinates: z.union([ Emulation.GeolocationCoordinatesSchema, z.null(), ]), }), z.object({ error: Emulation.GeolocationPositionErrorSchema, }), ]) .and(z.object({ contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), }))); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.GeolocationCoordinatesSchema = z.lazy(() => z.object({ latitude: z.number().gte(-90).lte(90), longitude: z.number().gte(-180).lte(180), accuracy: z.number().gte(0).default(1).optional(), altitude: z.union([z.number(), z.null().default(null)]).optional(), altitudeAccuracy: z .union([z.number().gte(0), z.null().default(null)]) .optional(), heading: z .union([z.number().gt(0).lt(360), z.null().default(null)]) .optional(), speed: z.union([z.number().gte(0), z.null().default(null)]).optional(), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.GeolocationPositionErrorSchema = z.lazy(() => z.object({ type: z.literal('positionUnavailable'), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetGeolocationOverrideResultSchema = z.lazy(() => EmptyResultSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetLocaleOverrideSchema = z.lazy(() => z.object({ method: z.literal('emulation.setLocaleOverride'), params: Emulation.SetLocaleOverrideParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetLocaleOverrideParametersSchema = z.lazy(() => z.object({ locale: z.union([z.string(), z.null()]), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetLocaleOverrideResultSchema = z.lazy(() => EmptyResultSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetNetworkConditionsSchema = z.lazy(() => z.object({ method: z.literal('emulation.setNetworkConditions'), params: Emulation.SetNetworkConditionsParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetNetworkConditionsParametersSchema = z.lazy(() => z.object({ networkConditions: z.union([Emulation.NetworkConditionsSchema, z.null()]), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.NetworkConditionsSchema = z.lazy(() => Emulation.NetworkConditionsOfflineSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.NetworkConditionsOfflineSchema = z.lazy(() => z.object({ type: z.literal('offline'), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetNetworkConditionsResultSchema = z.lazy(() => EmptyResultSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetScreenSettingsOverrideSchema = z.lazy(() => z.object({ method: z.literal('emulation.setScreenSettingsOverride'), params: Emulation.SetScreenSettingsOverrideParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.ScreenAreaSchema = z.lazy(() => z.object({ width: JsUintSchema, height: JsUintSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetScreenSettingsOverrideParametersSchema = z.lazy(() => z.object({ screenArea: z.union([Emulation.ScreenAreaSchema, z.null()]), contexts: z .array(BrowsingContext.BrowsingContextSchema) .min(1) .optional(), userContexts: z.array(Browser.UserContextSchema).min(1).optional(), })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetScreenSettingsOverrideResultSchema = z.lazy(() => EmptyResultSchema); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetScreenOrientationOverrideSchema = z.lazy(() => z.object({ method: z.literal('emulation.setScreenOrientationOverride'), params: Emulation.SetScreenOrientationOverrideParametersSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.ScreenOrientationNaturalSchema = z.lazy(() => z.enum(['portrait', 'landscape'])); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.ScreenOrientationTypeSchema = z.lazy(() => z.enum([ 'portrait-primary', 'portrait-secondary', 'landscape-primary', 'landscape-secondary', ])); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.ScreenOrientationSchema = z.lazy(() => z.object({ natural: Emulation.ScreenOrientationNaturalSchema, type: Emulation.ScreenOrientationTypeSchema, })); })(Emulation || (Emulation = {})); (function (Emulation) { Emulation.SetScreenOrientationOverr