MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / generateClass

Function generateClass

javascript/selenium-webdriver/generate_bidi.mjs:1191–1229  ·  view source on GitHub ↗
({
  className,
  parentClassName = 'Domain',
  summary = [],
  commands,
  events,
  runtimeByTsName,
  enumConstants,
})

Source from the content-addressed store, hash-verified

1189}
1190
1191function generateClass({
1192 className,
1193 parentClassName = 'Domain',
1194 summary = [],
1195 commands,
1196 events,
1197 runtimeByTsName,
1198 enumConstants,
1199}) {
1200 const lines = []
1201
1202 const doc = INTERNAL_API_DOC.split('\n')
1203 if (summary.length) doc.splice(1, 0, ...summary.map((line) => ` * ${line}`), ' *')
1204 lines.push(doc.join('\n'))
1205 lines.push(`export class ${className} extends ${parentClassName} {`)
1206
1207 for (const evt of events) {
1208 lines.push('')
1209 lines.push(generateEventDescriptor(evt, runtimeByTsName))
1210 }
1211
1212 for (const { propertyName, values } of enumConstants) {
1213 lines.push('')
1214 lines.push(` static readonly ${propertyName} = ${generateEnumConstantLiteral(values)}`)
1215 }
1216
1217 lines.push('')
1218 lines.push(` static async create(driver: unknown): Promise<${className}> {`)
1219 lines.push(` return new ${className}(await Domain.connect(driver), DOMAIN_TOKEN)`)
1220 lines.push(` }`)
1221
1222 for (const cmd of commands) {
1223 lines.push('')
1224 lines.push(generateCommandMethod(cmd, runtimeByTsName))
1225 }
1226
1227 lines.push(`}`)
1228 return lines.join('\n')
1229}
1230
1231// A static EventDescriptor<T> constant — no subscribe/dispatch method. Callers
1232// reach events via the inherited addCallback(descriptor, handler), never a

Callers 1

generateDomainFileFunction · 0.85

Calls 6

generateEventDescriptorFunction · 0.85
generateCommandMethodFunction · 0.85
splitMethod · 0.80
pushMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected