cddl2java 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +12 -8
  3. package/.release-it.ts +0 -10
  4. package/src/cli.ts +0 -42
  5. package/src/constants.ts +0 -25
  6. package/src/index.ts +0 -731
  7. package/src/templates.ts +0 -258
  8. package/src/utils.ts +0 -23
  9. package/tests/__fixtures__/AccessibilityValue.java +0 -71
  10. package/tests/__fixtures__/Browser/BrowserModule.java +0 -34
  11. package/tests/__fixtures__/Browser/ClientWindowInfo.java +0 -122
  12. package/tests/__fixtures__/Browser/ClientWindowNamedState.java +0 -50
  13. package/tests/__fixtures__/Browser/ClientWindowRectState.java +0 -98
  14. package/tests/__fixtures__/Browser/CreateUserContextResult.java +0 -16
  15. package/tests/__fixtures__/Browser/GetClientWindowsResult.java +0 -50
  16. package/tests/__fixtures__/Browser/GetUserContextsResult.java +0 -50
  17. package/tests/__fixtures__/Browser/RemoveUserContextParameters.java +0 -50
  18. package/tests/__fixtures__/Browser/SetClientWindowStateParameters.java +0 -50
  19. package/tests/__fixtures__/Browser/UserContextInfo.java +0 -50
  20. package/tests/__fixtures__/BrowsingContext/AccessibilityLocator.java +0 -62
  21. package/tests/__fixtures__/BrowsingContext/ActivateParameters.java +0 -50
  22. package/tests/__fixtures__/BrowsingContext/BaseNavigationInfo.java +0 -86
  23. package/tests/__fixtures__/BrowsingContext/BoxClipRectangle.java +0 -98
  24. package/tests/__fixtures__/BrowsingContext/BrowsingContextModule.java +0 -34
  25. package/tests/__fixtures__/BrowsingContext/CaptureScreenshotParameters.java +0 -86
  26. package/tests/__fixtures__/BrowsingContext/CaptureScreenshotResult.java +0 -50
  27. package/tests/__fixtures__/BrowsingContext/ClipRectangle.java +0 -17
  28. package/tests/__fixtures__/BrowsingContext/CloseParameters.java +0 -62
  29. package/tests/__fixtures__/BrowsingContext/ContextLocator.java +0 -62
  30. package/tests/__fixtures__/BrowsingContext/CreateParameters.java +0 -86
  31. package/tests/__fixtures__/BrowsingContext/CreateResult.java +0 -50
  32. package/tests/__fixtures__/BrowsingContext/CreateType.java +0 -35
  33. package/tests/__fixtures__/BrowsingContext/CssLocator.java +0 -62
  34. package/tests/__fixtures__/BrowsingContext/DownloadWillBeginParams.java +0 -50
  35. package/tests/__fixtures__/BrowsingContext/ElementClipRectangle.java +0 -62
  36. package/tests/__fixtures__/BrowsingContext/GetTreeParameters.java +0 -62
  37. package/tests/__fixtures__/BrowsingContext/GetTreeResult.java +0 -50
  38. package/tests/__fixtures__/BrowsingContext/HandleUserPromptParameters.java +0 -74
  39. package/tests/__fixtures__/BrowsingContext/HistoryUpdatedParameters.java +0 -62
  40. package/tests/__fixtures__/BrowsingContext/ImageFormat.java +0 -62
  41. package/tests/__fixtures__/BrowsingContext/Info.java +0 -122
  42. package/tests/__fixtures__/BrowsingContext/InnerTextLocator.java +0 -98
  43. package/tests/__fixtures__/BrowsingContext/LocateNodesParameters.java +0 -98
  44. package/tests/__fixtures__/BrowsingContext/LocateNodesResult.java +0 -50
  45. package/tests/__fixtures__/BrowsingContext/Locator.java +0 -20
  46. package/tests/__fixtures__/BrowsingContext/NavigateParameters.java +0 -74
  47. package/tests/__fixtures__/BrowsingContext/NavigateResult.java +0 -62
  48. package/tests/__fixtures__/BrowsingContext/PrintMarginParameters.java +0 -86
  49. package/tests/__fixtures__/BrowsingContext/PrintPageParameters.java +0 -62
  50. package/tests/__fixtures__/BrowsingContext/PrintParameters.java +0 -134
  51. package/tests/__fixtures__/BrowsingContext/PrintResult.java +0 -50
  52. package/tests/__fixtures__/BrowsingContext/ReadinessState.java +0 -36
  53. package/tests/__fixtures__/BrowsingContext/ReloadParameters.java +0 -74
  54. package/tests/__fixtures__/BrowsingContext/SetViewportParameters.java +0 -86
  55. package/tests/__fixtures__/BrowsingContext/TraverseHistoryParameters.java +0 -62
  56. package/tests/__fixtures__/BrowsingContext/TraverseHistoryResult.java +0 -28
  57. package/tests/__fixtures__/BrowsingContext/UserPromptClosedParameters.java +0 -86
  58. package/tests/__fixtures__/BrowsingContext/UserPromptOpenedParameters.java +0 -98
  59. package/tests/__fixtures__/BrowsingContext/UserPromptType.java +0 -37
  60. package/tests/__fixtures__/BrowsingContext/Viewport.java +0 -62
  61. package/tests/__fixtures__/BrowsingContext/XPathLocator.java +0 -62
  62. package/tests/__fixtures__/ContextValue.java +0 -55
  63. package/tests/__fixtures__/EmptyResult.java +0 -21
  64. package/tests/__fixtures__/Emulation/EmulationModule.java +0 -34
  65. package/tests/__fixtures__/Emulation/GeolocationCoordinates.java +0 -122
  66. package/tests/__fixtures__/Emulation/SetGeolocationOverrideParameters.java +0 -74
  67. package/tests/__fixtures__/Input/ElementOrigin.java +0 -62
  68. package/tests/__fixtures__/Input/FileDialogInfo.java +0 -74
  69. package/tests/__fixtures__/Input/InputModule.java +0 -34
  70. package/tests/__fixtures__/Input/KeyDownAction.java +0 -62
  71. package/tests/__fixtures__/Input/KeySourceAction.java +0 -18
  72. package/tests/__fixtures__/Input/KeySourceActions.java +0 -74
  73. package/tests/__fixtures__/Input/KeyUpAction.java +0 -62
  74. package/tests/__fixtures__/Input/NoneSourceAction.java +0 -16
  75. package/tests/__fixtures__/Input/NoneSourceActions.java +0 -74
  76. package/tests/__fixtures__/Input/Origin.java +0 -36
  77. package/tests/__fixtures__/Input/PauseAction.java +0 -62
  78. package/tests/__fixtures__/Input/PerformActionsParameters.java +0 -62
  79. package/tests/__fixtures__/Input/PointerCommonProperties.java +0 -122
  80. package/tests/__fixtures__/Input/PointerDownAction.java +0 -62
  81. package/tests/__fixtures__/Input/PointerMoveAction.java +0 -98
  82. package/tests/__fixtures__/Input/PointerParameters.java +0 -50
  83. package/tests/__fixtures__/Input/PointerSourceAction.java +0 -19
  84. package/tests/__fixtures__/Input/PointerSourceActions.java +0 -86
  85. package/tests/__fixtures__/Input/PointerType.java +0 -36
  86. package/tests/__fixtures__/Input/PointerUpAction.java +0 -62
  87. package/tests/__fixtures__/Input/ReleaseActionsParameters.java +0 -50
  88. package/tests/__fixtures__/Input/SetFilesParameters.java +0 -74
  89. package/tests/__fixtures__/Input/SourceActions.java +0 -19
  90. package/tests/__fixtures__/Input/WheelScrollAction.java +0 -122
  91. package/tests/__fixtures__/Input/WheelSourceAction.java +0 -17
  92. package/tests/__fixtures__/Input/WheelSourceActions.java +0 -74
  93. package/tests/__fixtures__/Log/BaseLogEntry.java +0 -98
  94. package/tests/__fixtures__/Log/ConsoleLogEntry.java +0 -74
  95. package/tests/__fixtures__/Log/Entry.java +0 -18
  96. package/tests/__fixtures__/Log/GenericLogEntry.java +0 -50
  97. package/tests/__fixtures__/Log/JavascriptLogEntry.java +0 -50
  98. package/tests/__fixtures__/Log/Level.java +0 -37
  99. package/tests/__fixtures__/Log/LogModule.java +0 -34
  100. package/tests/__fixtures__/Network/AddInterceptParameters.java +0 -74
  101. package/tests/__fixtures__/Network/AddInterceptResult.java +0 -50
  102. package/tests/__fixtures__/Network/AuthChallenge.java +0 -62
  103. package/tests/__fixtures__/Network/AuthCredentials.java +0 -74
  104. package/tests/__fixtures__/Network/AuthRequiredParameters.java +0 -50
  105. package/tests/__fixtures__/Network/Base64Value.java +0 -62
  106. package/tests/__fixtures__/Network/BaseParameters.java +0 -122
  107. package/tests/__fixtures__/Network/BeforeRequestSentParameters.java +0 -50
  108. package/tests/__fixtures__/Network/BytesValue.java +0 -17
  109. package/tests/__fixtures__/Network/ContinueRequestParameters.java +0 -110
  110. package/tests/__fixtures__/Network/ContinueResponseParameters.java +0 -110
  111. package/tests/__fixtures__/Network/ContinueWithAuthCredentials.java +0 -62
  112. package/tests/__fixtures__/Network/ContinueWithAuthNoCredentials.java +0 -50
  113. package/tests/__fixtures__/Network/ContinueWithAuthParameters.java +0 -50
  114. package/tests/__fixtures__/Network/Cookie.java +0 -146
  115. package/tests/__fixtures__/Network/CookieHeader.java +0 -62
  116. package/tests/__fixtures__/Network/FailRequestParameters.java +0 -50
  117. package/tests/__fixtures__/Network/FetchErrorParameters.java +0 -50
  118. package/tests/__fixtures__/Network/FetchTimingInfo.java +0 -194
  119. package/tests/__fixtures__/Network/Header.java +0 -62
  120. package/tests/__fixtures__/Network/Initiator.java +0 -98
  121. package/tests/__fixtures__/Network/InterceptPhase.java +0 -36
  122. package/tests/__fixtures__/Network/NetworkModule.java +0 -34
  123. package/tests/__fixtures__/Network/ProvideResponseParameters.java +0 -110
  124. package/tests/__fixtures__/Network/RemoveInterceptParameters.java +0 -50
  125. package/tests/__fixtures__/Network/RequestData.java +0 -158
  126. package/tests/__fixtures__/Network/ResponseCompletedParameters.java +0 -50
  127. package/tests/__fixtures__/Network/ResponseContent.java +0 -50
  128. package/tests/__fixtures__/Network/ResponseData.java +0 -182
  129. package/tests/__fixtures__/Network/ResponseStartedParameters.java +0 -50
  130. package/tests/__fixtures__/Network/SameSite.java +0 -36
  131. package/tests/__fixtures__/Network/SetCacheBehaviorParameters.java +0 -62
  132. package/tests/__fixtures__/Network/SetCookieHeader.java +0 -146
  133. package/tests/__fixtures__/Network/StringValue.java +0 -62
  134. package/tests/__fixtures__/Network/UrlPattern.java +0 -17
  135. package/tests/__fixtures__/Network/UrlPatternPattern.java +0 -110
  136. package/tests/__fixtures__/Network/UrlPatternString.java +0 -62
  137. package/tests/__fixtures__/Script/AddPreloadScriptParameters.java +0 -98
  138. package/tests/__fixtures__/Script/AddPreloadScriptResult.java +0 -50
  139. package/tests/__fixtures__/Script/ArrayBufferRemoteValue.java +0 -74
  140. package/tests/__fixtures__/Script/ArrayLocalValue.java +0 -62
  141. package/tests/__fixtures__/Script/ArrayRemoteValue.java +0 -86
  142. package/tests/__fixtures__/Script/AudioWorkletRealmInfo.java +0 -50
  143. package/tests/__fixtures__/Script/BaseRealmInfo.java +0 -62
  144. package/tests/__fixtures__/Script/BigIntValue.java +0 -62
  145. package/tests/__fixtures__/Script/BooleanValue.java +0 -62
  146. package/tests/__fixtures__/Script/CallFunctionParameters.java +0 -134
  147. package/tests/__fixtures__/Script/ChannelProperties.java +0 -74
  148. package/tests/__fixtures__/Script/ChannelValue.java +0 -62
  149. package/tests/__fixtures__/Script/ContextTarget.java +0 -62
  150. package/tests/__fixtures__/Script/DateLocalValue.java +0 -62
  151. package/tests/__fixtures__/Script/DedicatedWorkerRealmInfo.java +0 -62
  152. package/tests/__fixtures__/Script/DisownParameters.java +0 -62
  153. package/tests/__fixtures__/Script/ErrorRemoteValue.java +0 -74
  154. package/tests/__fixtures__/Script/EvaluateParameters.java +0 -110
  155. package/tests/__fixtures__/Script/EvaluateResult.java +0 -17
  156. package/tests/__fixtures__/Script/EvaluateResultException.java +0 -74
  157. package/tests/__fixtures__/Script/EvaluateResultSuccess.java +0 -74
  158. package/tests/__fixtures__/Script/ExceptionDetails.java +0 -98
  159. package/tests/__fixtures__/Script/FunctionRemoteValue.java +0 -74
  160. package/tests/__fixtures__/Script/GeneratorRemoteValue.java +0 -74
  161. package/tests/__fixtures__/Script/GetRealmsParameters.java +0 -62
  162. package/tests/__fixtures__/Script/GetRealmsResult.java +0 -50
  163. package/tests/__fixtures__/Script/HTMLCollectionRemoteValue.java +0 -86
  164. package/tests/__fixtures__/Script/LocalValue.java +0 -24
  165. package/tests/__fixtures__/Script/MapLocalValue.java +0 -62
  166. package/tests/__fixtures__/Script/MapRemoteValue.java +0 -86
  167. package/tests/__fixtures__/Script/MessageParameters.java +0 -74
  168. package/tests/__fixtures__/Script/NodeListRemoteValue.java +0 -86
  169. package/tests/__fixtures__/Script/NodeProperties.java +0 -146
  170. package/tests/__fixtures__/Script/NodeRemoteValue.java +0 -98
  171. package/tests/__fixtures__/Script/NullValue.java +0 -50
  172. package/tests/__fixtures__/Script/NumberValue.java +0 -62
  173. package/tests/__fixtures__/Script/ObjectLocalValue.java +0 -62
  174. package/tests/__fixtures__/Script/ObjectRemoteValue.java +0 -86
  175. package/tests/__fixtures__/Script/PaintWorkletRealmInfo.java +0 -50
  176. package/tests/__fixtures__/Script/PrimitiveProtocolValue.java +0 -21
  177. package/tests/__fixtures__/Script/PromiseRemoteValue.java +0 -74
  178. package/tests/__fixtures__/Script/ProxyRemoteValue.java +0 -74
  179. package/tests/__fixtures__/Script/RealmDestroyedParameters.java +0 -50
  180. package/tests/__fixtures__/Script/RealmInfo.java +0 -23
  181. package/tests/__fixtures__/Script/RealmTarget.java +0 -50
  182. package/tests/__fixtures__/Script/RealmType.java +0 -41
  183. package/tests/__fixtures__/Script/RegExpLocalValue.java +0 -62
  184. package/tests/__fixtures__/Script/RegExpValue.java +0 -62
  185. package/tests/__fixtures__/Script/RemoteObjectReference.java +0 -62
  186. package/tests/__fixtures__/Script/RemoteReference.java +0 -17
  187. package/tests/__fixtures__/Script/RemoteValue.java +0 -36
  188. package/tests/__fixtures__/Script/RemovePreloadScriptParameters.java +0 -50
  189. package/tests/__fixtures__/Script/ResultOwnership.java +0 -35
  190. package/tests/__fixtures__/Script/ScriptModule.java +0 -34
  191. package/tests/__fixtures__/Script/SerializationOptions.java +0 -74
  192. package/tests/__fixtures__/Script/ServiceWorkerRealmInfo.java +0 -50
  193. package/tests/__fixtures__/Script/SetLocalValue.java +0 -62
  194. package/tests/__fixtures__/Script/SetRemoteValue.java +0 -86
  195. package/tests/__fixtures__/Script/SharedReference.java +0 -62
  196. package/tests/__fixtures__/Script/SharedWorkerRealmInfo.java +0 -50
  197. package/tests/__fixtures__/Script/Source.java +0 -62
  198. package/tests/__fixtures__/Script/SpecialNumber.java +0 -37
  199. package/tests/__fixtures__/Script/StackFrame.java +0 -86
  200. package/tests/__fixtures__/Script/StackTrace.java +0 -50
  201. package/tests/__fixtures__/Script/StringValue.java +0 -62
  202. package/tests/__fixtures__/Script/SymbolRemoteValue.java +0 -74
  203. package/tests/__fixtures__/Script/Target.java +0 -17
  204. package/tests/__fixtures__/Script/TypedArrayRemoteValue.java +0 -74
  205. package/tests/__fixtures__/Script/UndefinedValue.java +0 -50
  206. package/tests/__fixtures__/Script/WeakMapRemoteValue.java +0 -74
  207. package/tests/__fixtures__/Script/WeakSetRemoteValue.java +0 -74
  208. package/tests/__fixtures__/Script/WindowProxyProperties.java +0 -50
  209. package/tests/__fixtures__/Script/WindowProxyRemoteValue.java +0 -86
  210. package/tests/__fixtures__/Script/WindowRealmInfo.java +0 -74
  211. package/tests/__fixtures__/Script/WorkerRealmInfo.java +0 -50
  212. package/tests/__fixtures__/Script/WorkletRealmInfo.java +0 -50
  213. package/tests/__fixtures__/Session/Capabilities.java +0 -55
  214. package/tests/__fixtures__/Session/CapabilitiesRequest.java +0 -62
  215. package/tests/__fixtures__/Session/CapabilityRequest.java +0 -110
  216. package/tests/__fixtures__/Session/NewParameters.java +0 -50
  217. package/tests/__fixtures__/Session/NewResult.java +0 -62
  218. package/tests/__fixtures__/Session/ProxyConfiguration.java +0 -20
  219. package/tests/__fixtures__/Session/SessionModule.java +0 -34
  220. package/tests/__fixtures__/Session/StatusResult.java +0 -62
  221. package/tests/__fixtures__/Session/SubscribeResult.java +0 -50
  222. package/tests/__fixtures__/Session/SubscriptionRequest.java +0 -74
  223. package/tests/__fixtures__/Session/UnsubscribeByAttributesRequest.java +0 -62
  224. package/tests/__fixtures__/Session/UnsubscribeByIDRequest.java +0 -50
  225. package/tests/__fixtures__/Session/UnsubscribeParameters.java +0 -17
  226. package/tests/__fixtures__/Session/UserPromptHandler.java +0 -110
  227. package/tests/__fixtures__/Session/UserPromptHandlerType.java +0 -36
  228. package/tests/__fixtures__/Storage/BrowsingContextPartitionDescriptor.java +0 -62
  229. package/tests/__fixtures__/Storage/CookieFilter.java +0 -146
  230. package/tests/__fixtures__/Storage/DeleteCookiesParameters.java +0 -62
  231. package/tests/__fixtures__/Storage/DeleteCookiesResult.java +0 -50
  232. package/tests/__fixtures__/Storage/GetCookiesParameters.java +0 -62
  233. package/tests/__fixtures__/Storage/GetCookiesResult.java +0 -62
  234. package/tests/__fixtures__/Storage/PartialCookie.java +0 -134
  235. package/tests/__fixtures__/Storage/PartitionDescriptor.java +0 -17
  236. package/tests/__fixtures__/Storage/PartitionKey.java +0 -62
  237. package/tests/__fixtures__/Storage/SetCookieParameters.java +0 -62
  238. package/tests/__fixtures__/Storage/SetCookieResult.java +0 -50
  239. package/tests/__fixtures__/Storage/StorageKeyPartitionDescriptor.java +0 -74
  240. package/tests/__fixtures__/Storage/StorageModule.java +0 -34
  241. package/tests/__fixtures__/WebExtension/ExtensionArchivePath.java +0 -62
  242. package/tests/__fixtures__/WebExtension/ExtensionBase64Encoded.java +0 -62
  243. package/tests/__fixtures__/WebExtension/ExtensionData.java +0 -18
  244. package/tests/__fixtures__/WebExtension/ExtensionPath.java +0 -62
  245. package/tests/__fixtures__/WebExtension/InstallParameters.java +0 -50
  246. package/tests/__fixtures__/WebExtension/InstallResult.java +0 -50
  247. package/tests/__fixtures__/WebExtension/UninstallParameters.java +0 -50
  248. package/tests/__fixtures__/WebExtension/WebExtensionModule.java +0 -34
  249. package/tests/__output__/AccessibilityValue.java +0 -71
  250. package/tests/__output__/Browser/BrowserModule.java +0 -34
  251. package/tests/__output__/Browser/ClientWindowInfo.java +0 -122
  252. package/tests/__output__/Browser/ClientWindowNamedState.java +0 -50
  253. package/tests/__output__/Browser/ClientWindowRectState.java +0 -98
  254. package/tests/__output__/Browser/CreateUserContextResult.java +0 -16
  255. package/tests/__output__/Browser/GetClientWindowsResult.java +0 -50
  256. package/tests/__output__/Browser/GetUserContextsResult.java +0 -50
  257. package/tests/__output__/Browser/RemoveUserContextParameters.java +0 -50
  258. package/tests/__output__/Browser/SetClientWindowStateParameters.java +0 -50
  259. package/tests/__output__/Browser/UserContextInfo.java +0 -50
  260. package/tests/__output__/BrowsingContext/AccessibilityLocator.java +0 -62
  261. package/tests/__output__/BrowsingContext/ActivateParameters.java +0 -50
  262. package/tests/__output__/BrowsingContext/BaseNavigationInfo.java +0 -86
  263. package/tests/__output__/BrowsingContext/BoxClipRectangle.java +0 -98
  264. package/tests/__output__/BrowsingContext/BrowsingContextModule.java +0 -34
  265. package/tests/__output__/BrowsingContext/CaptureScreenshotParameters.java +0 -86
  266. package/tests/__output__/BrowsingContext/CaptureScreenshotResult.java +0 -50
  267. package/tests/__output__/BrowsingContext/ClipRectangle.java +0 -17
  268. package/tests/__output__/BrowsingContext/CloseParameters.java +0 -62
  269. package/tests/__output__/BrowsingContext/ContextLocator.java +0 -62
  270. package/tests/__output__/BrowsingContext/CreateParameters.java +0 -86
  271. package/tests/__output__/BrowsingContext/CreateResult.java +0 -50
  272. package/tests/__output__/BrowsingContext/CreateType.java +0 -35
  273. package/tests/__output__/BrowsingContext/CssLocator.java +0 -62
  274. package/tests/__output__/BrowsingContext/DownloadWillBeginParams.java +0 -50
  275. package/tests/__output__/BrowsingContext/ElementClipRectangle.java +0 -62
  276. package/tests/__output__/BrowsingContext/GetTreeParameters.java +0 -62
  277. package/tests/__output__/BrowsingContext/GetTreeResult.java +0 -50
  278. package/tests/__output__/BrowsingContext/HandleUserPromptParameters.java +0 -74
  279. package/tests/__output__/BrowsingContext/HistoryUpdatedParameters.java +0 -62
  280. package/tests/__output__/BrowsingContext/ImageFormat.java +0 -62
  281. package/tests/__output__/BrowsingContext/Info.java +0 -122
  282. package/tests/__output__/BrowsingContext/InnerTextLocator.java +0 -98
  283. package/tests/__output__/BrowsingContext/LocateNodesParameters.java +0 -98
  284. package/tests/__output__/BrowsingContext/LocateNodesResult.java +0 -50
  285. package/tests/__output__/BrowsingContext/Locator.java +0 -20
  286. package/tests/__output__/BrowsingContext/NavigateParameters.java +0 -74
  287. package/tests/__output__/BrowsingContext/NavigateResult.java +0 -62
  288. package/tests/__output__/BrowsingContext/PrintMarginParameters.java +0 -86
  289. package/tests/__output__/BrowsingContext/PrintPageParameters.java +0 -62
  290. package/tests/__output__/BrowsingContext/PrintParameters.java +0 -134
  291. package/tests/__output__/BrowsingContext/PrintResult.java +0 -50
  292. package/tests/__output__/BrowsingContext/ReadinessState.java +0 -36
  293. package/tests/__output__/BrowsingContext/ReloadParameters.java +0 -74
  294. package/tests/__output__/BrowsingContext/SetViewportParameters.java +0 -86
  295. package/tests/__output__/BrowsingContext/TraverseHistoryParameters.java +0 -62
  296. package/tests/__output__/BrowsingContext/TraverseHistoryResult.java +0 -28
  297. package/tests/__output__/BrowsingContext/UserPromptClosedParameters.java +0 -86
  298. package/tests/__output__/BrowsingContext/UserPromptOpenedParameters.java +0 -98
  299. package/tests/__output__/BrowsingContext/UserPromptType.java +0 -37
  300. package/tests/__output__/BrowsingContext/Viewport.java +0 -62
  301. package/tests/__output__/BrowsingContext/XPathLocator.java +0 -62
  302. package/tests/__output__/ContextValue.java +0 -55
  303. package/tests/__output__/EmptyResult.java +0 -21
  304. package/tests/__output__/Emulation/EmulationModule.java +0 -34
  305. package/tests/__output__/Emulation/GeolocationCoordinates.java +0 -122
  306. package/tests/__output__/Emulation/SetGeolocationOverrideParameters.java +0 -74
  307. package/tests/__output__/Input/ElementOrigin.java +0 -62
  308. package/tests/__output__/Input/FileDialogInfo.java +0 -74
  309. package/tests/__output__/Input/InputModule.java +0 -34
  310. package/tests/__output__/Input/KeyDownAction.java +0 -62
  311. package/tests/__output__/Input/KeySourceAction.java +0 -18
  312. package/tests/__output__/Input/KeySourceActions.java +0 -74
  313. package/tests/__output__/Input/KeyUpAction.java +0 -62
  314. package/tests/__output__/Input/NoneSourceAction.java +0 -16
  315. package/tests/__output__/Input/NoneSourceActions.java +0 -74
  316. package/tests/__output__/Input/Origin.java +0 -36
  317. package/tests/__output__/Input/PauseAction.java +0 -62
  318. package/tests/__output__/Input/PerformActionsParameters.java +0 -62
  319. package/tests/__output__/Input/PointerCommonProperties.java +0 -122
  320. package/tests/__output__/Input/PointerDownAction.java +0 -62
  321. package/tests/__output__/Input/PointerMoveAction.java +0 -98
  322. package/tests/__output__/Input/PointerParameters.java +0 -50
  323. package/tests/__output__/Input/PointerSourceAction.java +0 -19
  324. package/tests/__output__/Input/PointerSourceActions.java +0 -86
  325. package/tests/__output__/Input/PointerType.java +0 -36
  326. package/tests/__output__/Input/PointerUpAction.java +0 -62
  327. package/tests/__output__/Input/ReleaseActionsParameters.java +0 -50
  328. package/tests/__output__/Input/SetFilesParameters.java +0 -74
  329. package/tests/__output__/Input/SourceActions.java +0 -19
  330. package/tests/__output__/Input/WheelScrollAction.java +0 -122
  331. package/tests/__output__/Input/WheelSourceAction.java +0 -17
  332. package/tests/__output__/Input/WheelSourceActions.java +0 -74
  333. package/tests/__output__/Log/BaseLogEntry.java +0 -98
  334. package/tests/__output__/Log/ConsoleLogEntry.java +0 -74
  335. package/tests/__output__/Log/Entry.java +0 -18
  336. package/tests/__output__/Log/GenericLogEntry.java +0 -50
  337. package/tests/__output__/Log/JavascriptLogEntry.java +0 -50
  338. package/tests/__output__/Log/Level.java +0 -37
  339. package/tests/__output__/Log/LogModule.java +0 -34
  340. package/tests/__output__/Network/AddInterceptParameters.java +0 -74
  341. package/tests/__output__/Network/AddInterceptResult.java +0 -50
  342. package/tests/__output__/Network/AuthChallenge.java +0 -62
  343. package/tests/__output__/Network/AuthCredentials.java +0 -74
  344. package/tests/__output__/Network/AuthRequiredParameters.java +0 -50
  345. package/tests/__output__/Network/Base64Value.java +0 -62
  346. package/tests/__output__/Network/BaseParameters.java +0 -122
  347. package/tests/__output__/Network/BeforeRequestSentParameters.java +0 -50
  348. package/tests/__output__/Network/BytesValue.java +0 -17
  349. package/tests/__output__/Network/ContinueRequestParameters.java +0 -110
  350. package/tests/__output__/Network/ContinueResponseParameters.java +0 -110
  351. package/tests/__output__/Network/ContinueWithAuthCredentials.java +0 -62
  352. package/tests/__output__/Network/ContinueWithAuthNoCredentials.java +0 -50
  353. package/tests/__output__/Network/ContinueWithAuthParameters.java +0 -50
  354. package/tests/__output__/Network/Cookie.java +0 -146
  355. package/tests/__output__/Network/CookieHeader.java +0 -62
  356. package/tests/__output__/Network/FailRequestParameters.java +0 -50
  357. package/tests/__output__/Network/FetchErrorParameters.java +0 -50
  358. package/tests/__output__/Network/FetchTimingInfo.java +0 -194
  359. package/tests/__output__/Network/Header.java +0 -62
  360. package/tests/__output__/Network/Initiator.java +0 -98
  361. package/tests/__output__/Network/InterceptPhase.java +0 -36
  362. package/tests/__output__/Network/NetworkModule.java +0 -34
  363. package/tests/__output__/Network/ProvideResponseParameters.java +0 -110
  364. package/tests/__output__/Network/RemoveInterceptParameters.java +0 -50
  365. package/tests/__output__/Network/RequestData.java +0 -158
  366. package/tests/__output__/Network/ResponseCompletedParameters.java +0 -50
  367. package/tests/__output__/Network/ResponseContent.java +0 -50
  368. package/tests/__output__/Network/ResponseData.java +0 -182
  369. package/tests/__output__/Network/ResponseStartedParameters.java +0 -50
  370. package/tests/__output__/Network/SameSite.java +0 -36
  371. package/tests/__output__/Network/SetCacheBehaviorParameters.java +0 -62
  372. package/tests/__output__/Network/SetCookieHeader.java +0 -146
  373. package/tests/__output__/Network/StringValue.java +0 -62
  374. package/tests/__output__/Network/UrlPattern.java +0 -17
  375. package/tests/__output__/Network/UrlPatternPattern.java +0 -110
  376. package/tests/__output__/Network/UrlPatternString.java +0 -62
  377. package/tests/__output__/Script/AddPreloadScriptParameters.java +0 -98
  378. package/tests/__output__/Script/AddPreloadScriptResult.java +0 -50
  379. package/tests/__output__/Script/ArrayBufferRemoteValue.java +0 -74
  380. package/tests/__output__/Script/ArrayLocalValue.java +0 -62
  381. package/tests/__output__/Script/ArrayRemoteValue.java +0 -86
  382. package/tests/__output__/Script/AudioWorkletRealmInfo.java +0 -50
  383. package/tests/__output__/Script/BaseRealmInfo.java +0 -62
  384. package/tests/__output__/Script/BigIntValue.java +0 -62
  385. package/tests/__output__/Script/BooleanValue.java +0 -62
  386. package/tests/__output__/Script/CallFunctionParameters.java +0 -134
  387. package/tests/__output__/Script/ChannelProperties.java +0 -74
  388. package/tests/__output__/Script/ChannelValue.java +0 -62
  389. package/tests/__output__/Script/ContextTarget.java +0 -62
  390. package/tests/__output__/Script/DateLocalValue.java +0 -62
  391. package/tests/__output__/Script/DedicatedWorkerRealmInfo.java +0 -62
  392. package/tests/__output__/Script/DisownParameters.java +0 -62
  393. package/tests/__output__/Script/ErrorRemoteValue.java +0 -74
  394. package/tests/__output__/Script/EvaluateParameters.java +0 -110
  395. package/tests/__output__/Script/EvaluateResult.java +0 -17
  396. package/tests/__output__/Script/EvaluateResultException.java +0 -74
  397. package/tests/__output__/Script/EvaluateResultSuccess.java +0 -74
  398. package/tests/__output__/Script/ExceptionDetails.java +0 -98
  399. package/tests/__output__/Script/FunctionRemoteValue.java +0 -74
  400. package/tests/__output__/Script/GeneratorRemoteValue.java +0 -74
  401. package/tests/__output__/Script/GetRealmsParameters.java +0 -62
  402. package/tests/__output__/Script/GetRealmsResult.java +0 -50
  403. package/tests/__output__/Script/HTMLCollectionRemoteValue.java +0 -86
  404. package/tests/__output__/Script/LocalValue.java +0 -24
  405. package/tests/__output__/Script/MapLocalValue.java +0 -62
  406. package/tests/__output__/Script/MapRemoteValue.java +0 -86
  407. package/tests/__output__/Script/MessageParameters.java +0 -74
  408. package/tests/__output__/Script/NodeListRemoteValue.java +0 -86
  409. package/tests/__output__/Script/NodeProperties.java +0 -146
  410. package/tests/__output__/Script/NodeRemoteValue.java +0 -98
  411. package/tests/__output__/Script/NullValue.java +0 -50
  412. package/tests/__output__/Script/NumberValue.java +0 -62
  413. package/tests/__output__/Script/ObjectLocalValue.java +0 -62
  414. package/tests/__output__/Script/ObjectRemoteValue.java +0 -86
  415. package/tests/__output__/Script/PaintWorkletRealmInfo.java +0 -50
  416. package/tests/__output__/Script/PrimitiveProtocolValue.java +0 -21
  417. package/tests/__output__/Script/PromiseRemoteValue.java +0 -74
  418. package/tests/__output__/Script/ProxyRemoteValue.java +0 -74
  419. package/tests/__output__/Script/RealmDestroyedParameters.java +0 -50
  420. package/tests/__output__/Script/RealmInfo.java +0 -23
  421. package/tests/__output__/Script/RealmTarget.java +0 -50
  422. package/tests/__output__/Script/RealmType.java +0 -41
  423. package/tests/__output__/Script/RegExpLocalValue.java +0 -62
  424. package/tests/__output__/Script/RegExpValue.java +0 -62
  425. package/tests/__output__/Script/RemoteObjectReference.java +0 -62
  426. package/tests/__output__/Script/RemoteReference.java +0 -17
  427. package/tests/__output__/Script/RemoteValue.java +0 -36
  428. package/tests/__output__/Script/RemovePreloadScriptParameters.java +0 -50
  429. package/tests/__output__/Script/ResultOwnership.java +0 -35
  430. package/tests/__output__/Script/ScriptModule.java +0 -34
  431. package/tests/__output__/Script/SerializationOptions.java +0 -74
  432. package/tests/__output__/Script/ServiceWorkerRealmInfo.java +0 -50
  433. package/tests/__output__/Script/SetLocalValue.java +0 -62
  434. package/tests/__output__/Script/SetRemoteValue.java +0 -86
  435. package/tests/__output__/Script/SharedReference.java +0 -62
  436. package/tests/__output__/Script/SharedWorkerRealmInfo.java +0 -50
  437. package/tests/__output__/Script/Source.java +0 -62
  438. package/tests/__output__/Script/SpecialNumber.java +0 -37
  439. package/tests/__output__/Script/StackFrame.java +0 -86
  440. package/tests/__output__/Script/StackTrace.java +0 -50
  441. package/tests/__output__/Script/StringValue.java +0 -62
  442. package/tests/__output__/Script/SymbolRemoteValue.java +0 -74
  443. package/tests/__output__/Script/Target.java +0 -17
  444. package/tests/__output__/Script/TypedArrayRemoteValue.java +0 -74
  445. package/tests/__output__/Script/UndefinedValue.java +0 -50
  446. package/tests/__output__/Script/WeakMapRemoteValue.java +0 -74
  447. package/tests/__output__/Script/WeakSetRemoteValue.java +0 -74
  448. package/tests/__output__/Script/WindowProxyProperties.java +0 -50
  449. package/tests/__output__/Script/WindowProxyRemoteValue.java +0 -86
  450. package/tests/__output__/Script/WindowRealmInfo.java +0 -74
  451. package/tests/__output__/Script/WorkerRealmInfo.java +0 -50
  452. package/tests/__output__/Script/WorkletRealmInfo.java +0 -50
  453. package/tests/__output__/Session/Capabilities.java +0 -55
  454. package/tests/__output__/Session/CapabilitiesRequest.java +0 -62
  455. package/tests/__output__/Session/CapabilityRequest.java +0 -110
  456. package/tests/__output__/Session/NewParameters.java +0 -50
  457. package/tests/__output__/Session/NewResult.java +0 -62
  458. package/tests/__output__/Session/ProxyConfiguration.java +0 -20
  459. package/tests/__output__/Session/SessionModule.java +0 -34
  460. package/tests/__output__/Session/StatusResult.java +0 -62
  461. package/tests/__output__/Session/SubscribeResult.java +0 -50
  462. package/tests/__output__/Session/SubscriptionRequest.java +0 -74
  463. package/tests/__output__/Session/UnsubscribeByAttributesRequest.java +0 -62
  464. package/tests/__output__/Session/UnsubscribeByIDRequest.java +0 -50
  465. package/tests/__output__/Session/UnsubscribeParameters.java +0 -17
  466. package/tests/__output__/Session/UserPromptHandler.java +0 -110
  467. package/tests/__output__/Session/UserPromptHandlerType.java +0 -36
  468. package/tests/__output__/Storage/BrowsingContextPartitionDescriptor.java +0 -62
  469. package/tests/__output__/Storage/CookieFilter.java +0 -146
  470. package/tests/__output__/Storage/DeleteCookiesParameters.java +0 -62
  471. package/tests/__output__/Storage/DeleteCookiesResult.java +0 -50
  472. package/tests/__output__/Storage/GetCookiesParameters.java +0 -62
  473. package/tests/__output__/Storage/GetCookiesResult.java +0 -62
  474. package/tests/__output__/Storage/PartialCookie.java +0 -134
  475. package/tests/__output__/Storage/PartitionDescriptor.java +0 -17
  476. package/tests/__output__/Storage/PartitionKey.java +0 -62
  477. package/tests/__output__/Storage/SetCookieParameters.java +0 -62
  478. package/tests/__output__/Storage/SetCookieResult.java +0 -50
  479. package/tests/__output__/Storage/StorageKeyPartitionDescriptor.java +0 -74
  480. package/tests/__output__/Storage/StorageModule.java +0 -34
  481. package/tests/__output__/WebExtension/ExtensionArchivePath.java +0 -62
  482. package/tests/__output__/WebExtension/ExtensionBase64Encoded.java +0 -62
  483. package/tests/__output__/WebExtension/ExtensionData.java +0 -18
  484. package/tests/__output__/WebExtension/ExtensionPath.java +0 -62
  485. package/tests/__output__/WebExtension/InstallParameters.java +0 -50
  486. package/tests/__output__/WebExtension/InstallResult.java +0 -50
  487. package/tests/__output__/WebExtension/UninstallParameters.java +0 -50
  488. package/tests/__output__/WebExtension/WebExtensionModule.java +0 -34
  489. package/tests/bidi.cddl +0 -2511
  490. package/tests/mod.test.ts +0 -65
  491. package/tsconfig.json +0 -11
package/src/index.ts DELETED
@@ -1,731 +0,0 @@
1
- import fs from 'node:fs/promises'
2
- import path from 'node:path'
3
- import util from 'node:util'
4
-
5
- import camelcase from 'camelcase'
6
- import { Array as CDDLArray, parse as parseCDDL, type PropertyReference, type Property, type Group, type Variable, type Assignment, type PropertyType } from 'cddl'
7
-
8
- import { pascalCase, writeFile } from './utils.js'
9
- import { CDDL_PARSE_ERROR_MESSAGE } from './constants.js'
10
- import {
11
- emptyResultTemplate,
12
- contextValueTemplate,
13
- accessibilityValueTemplate,
14
- getEnumTemplate,
15
- capabilitiesTemplate,
16
- newResultTemplate,
17
- } from './templates.js'
18
-
19
- type Scope = string
20
- type FileName = string
21
- type MapKey = [Scope, FileName]
22
-
23
- function parseCDDLFile (filePath: string) {
24
- let ast
25
-
26
- try {
27
- ast = parseCDDL(filePath)
28
- } catch (err) {
29
- /* c8 ignore next */ console.log(util.format(CDDL_PARSE_ERROR_MESSAGE, `Failed to parse ${filePath}: ${(err as Error).stack}`))
30
- /* c8 ignore next */ process.exit(0)
31
- }
32
-
33
- /**
34
- * CDDL ast transformation
35
- * Unfortunately the CDDL can not be always correctly transformed into TypeScript
36
- * Therefor we need to make some adjustments here:
37
- *
38
- * - remove CommandData and Extensible from Command group
39
- */
40
- const commandGroup = ast.findIndex((a: Assignment) => a.Name === 'Command')
41
- if (commandGroup !== -1) {
42
- (ast[commandGroup] as Group).Properties = [(ast[commandGroup] as Group).Properties[0]]
43
- }
44
-
45
- /**
46
- * have groups with method property extend from Command group
47
- */
48
- const commandGroups = ast.filter((a: Assignment) => (
49
- a.Type === 'group' &&
50
- a.Properties &&
51
- a.Properties[0] &&
52
- (a.Properties[0] as Property).Name === 'method'
53
- )) as Group[]
54
-
55
- for (const g of commandGroups) {
56
- g.Properties.push({
57
- HasCut: false,
58
- Occurrence: { n: 1, m: 1 },
59
- Name: '',
60
- Type: [{ Type: 'group', Value: 'Command', Unwrapped: false }],
61
- Comments: []
62
- })
63
- }
64
-
65
- return ast
66
- }
67
-
68
- const stringTypes = [
69
- 'script.InternalId',
70
- 'browser.ClientWindow',
71
- 'browser.UserContext',
72
- 'browsingContext.BrowsingContext',
73
- 'browsingContext.Navigation',
74
- 'network.Request',
75
- 'script.Channel',
76
- 'script.Handle',
77
- 'script.InternalId',
78
- 'script.PreloadScript',
79
- 'script.Realm',
80
- 'script.SharedId',
81
- 'browser.ClientWindow',
82
- 'browser.UserContext',
83
- 'browsingContext.BrowsingContext',
84
- 'browsingContext.Navigation',
85
- 'network.Request',
86
- 'script.Channel',
87
- 'script.Handle',
88
- 'script.InternalId',
89
- 'script.PreloadScript',
90
- 'script.Realm',
91
- 'script.SharedId'
92
- ]
93
-
94
- async function createModules (assignments: Assignment[]) {
95
- const javaFiles = new Map<MapKey, string>()
96
- for (const assignment of assignments) {
97
- /**
98
- * only create methods for groups that have a method property and therefor are commands that
99
- * receive a certain result
100
- */
101
- if (assignment.Type !== 'group' || assignment.Properties.length === 0 || (assignment.Properties[0] as Property).Name !== 'method') {
102
- continue
103
- }
104
-
105
- const responseType = assignments.find((a) => camelcase(a.Name) === `${camelcase(assignment.Name)}Result`)
106
- const methodId = (((assignment.Properties[0] as Property).Type as PropertyReference[])[0]).Value as string
107
- const paramName = (((assignment.Properties[1] as Property).Type as PropertyReference[])[0]).Value as string
108
-
109
- // Extract scope and command from assignment name
110
- const [scope, command] = assignment.Name.split('.')
111
- const moduleScope = (scope[0].toUpperCase() + scope.slice(1)) as string
112
-
113
- // Handle parameter class name - safely extract from paramName
114
- let paramClass: string
115
- const paramParts = paramName.split('.')
116
- if (paramParts.length > 1) {
117
- // Parameter has a scope prefix (e.g., 'session.Capabilities')
118
- paramClass = paramParts[1][0].toUpperCase() + paramParts[1].slice(1)
119
- } else {
120
- // Parameter doesn't have a scope prefix
121
- paramClass = paramName[0].toUpperCase() + paramName.slice(1)
122
- }
123
-
124
- // Properly format parameter type
125
- const paramType = `${paramClass}`
126
-
127
- // Handle return type - should be in same package
128
- const resultTypeJava = responseType
129
- ? resultName(responseType.Name)
130
- : 'EmptyResult'
131
-
132
- // Adjust result type to proper package reference if it's EmptyResult
133
- const resultTypeJavaEmbed = responseType
134
- ? resultTypeJava
135
- : 'org.openqa.selenium.bidirectional.EmptyResult'
136
-
137
- const specUrl = `https://w3c.github.io/webdriver-bidi/#command-${methodId.replace('.', '-')}`
138
- const description = `WebDriver Bidi command to send command method "${methodId}" with parameters.`
139
- const c = [
140
- '*',
141
- ` * ${description}`,
142
- ` * @url ${specUrl}`,
143
- ` * @param parameters \`${paramType}\` {@link ${specUrl} | command parameter}`,
144
- ` * @return Command object with result type for ${methodId}`,
145
- ' *'
146
- ]
147
-
148
- const mapKey: MapKey = [moduleScope, `${moduleScope}Module`]
149
- if (!javaFiles.has(mapKey)) {
150
- javaFiles.set(mapKey, `package org.openqa.selenium.bidirectional.${scope.toLowerCase()};
151
-
152
- import java.util.Map;
153
- import java.util.HashMap;
154
- import org.openqa.selenium.bidi.Command;
155
- import org.openqa.selenium.bidirectional.EmptyResult;
156
-
157
- /**
158
- * Auto generated class for running WebDriver BiDi ${scope.toLowerCase()} commands in Java
159
- */
160
- public class ${moduleScope}Module {
161
- `)
162
- }
163
-
164
- let code = javaFiles.get(mapKey) as string
165
-
166
- code += `
167
- /*${c.join('\n ')}/
168
- public Command<${resultTypeJavaEmbed}> ${command} (${paramType} parameters) {
169
- return new Command<>(
170
- "${methodId}",
171
- parameters.asMap(),
172
- ${resultTypeJavaEmbed}.class
173
- );
174
- }
175
- }`
176
- javaFiles.set(mapKey, code)
177
- }
178
-
179
- return javaFiles
180
- }
181
-
182
- // Helper function to get correct class name for result types
183
- function resultName(name: string): string {
184
- const [_scope, resultName] = name.split('.');
185
- return resultName[0].toUpperCase() + resultName.slice(1);
186
- }
187
-
188
- async function createPropertyClasses (assignments: Assignment[]) {
189
- const javaPropFiles = new Map<MapKey, string>()
190
- const allGroupEnums = assignments
191
- .filter((a) => (
192
- a.Type === 'variable' &&
193
- Array.isArray(a.PropertyType) &&
194
- a.PropertyType.every((p: PropertyType) => (p as PropertyReference).Type === 'group'))
195
- )
196
- .map((a) => {
197
- const prop = ((a as Variable).PropertyType as PropertyReference[])
198
- return {
199
- name: (a as Variable).Name,
200
- enums: prop.map((p) => p.Value as string)
201
- }
202
- })
203
-
204
- for (const assignment of assignments) {
205
- /**
206
- * only create methods for groups that have a method property and therefor are commands that
207
- * receive a certain result
208
- */
209
- if (!(assignment.Type !== 'group' || assignment.Properties.length === 0 || (assignment.Properties[0] as Property).Name !== 'method')) {
210
- continue
211
- }
212
-
213
- /**
214
- * some commands have no scope, e.g. "Command"
215
- */
216
- if (!assignment.Name.includes('.')) {
217
- continue
218
- }
219
-
220
- const scopeCamelCase = assignment.Name.split('.')[0][0].toUpperCase() + assignment.Name.split('.')[0].slice(1)
221
- if ('Properties' in assignment) {
222
- const prop = assignment.Name.split('.')[1]
223
- const propClassName = prop[0].toUpperCase() + prop.slice(1)
224
- const mapKey: MapKey = [scopeCamelCase, propClassName]
225
-
226
- const props = new Map<string, { type: string, isLiteral: boolean }>()
227
- for (const property of assignment.Properties) {
228
- if (Array.isArray(property) || !property.Name) {
229
- continue
230
- }
231
-
232
- let { type, isLiteral } = parseType(property.Type)
233
-
234
- // Override specific unknown types with known implementations
235
- let finalType = type;
236
-
237
- // Check for array of types
238
- // {
239
- // "HasCut": true,
240
- // "Occurrence": {
241
- // "n": 0,
242
- // "m": null
243
- // },
244
- // "Name": "cookies",
245
- // "Type": [
246
- // {
247
- // "Type": "array",
248
- // "Name": "",
249
- // "Values": [
250
- // {
251
- // "HasCut": false,
252
- // "Occurrence": {
253
- // "n": 0,
254
- // "m": null
255
- // },
256
- // "Name": "",
257
- // "Type": [
258
- // {
259
- // "Type": "group",
260
- // "Value": "network.SetCookieHeader",
261
- // "Unwrapped": false
262
- // }
263
- // ],
264
- // "Comments": []
265
- // }
266
- // ],
267
- // "Comments": []
268
- // }
269
- // ],
270
- // "Comments": []
271
- // }
272
- if (
273
- Array.isArray(property.Type) &&
274
- property.Type.length > 0 &&
275
- property.Type[0] &&
276
- (property.Type[0] as CDDLArray).Type === 'array'
277
- ) {
278
- const prop = property.Type[0] as CDDLArray
279
- if (prop.Values && prop.Values.length > 0 && prop.Values[0] && Array.isArray((prop.Values[0] as Property).Type)) {
280
- const propType = (prop.Values[0] as Property).Type as PropertyReference[]
281
- if (typeof propType[0].Value === 'string') {
282
- finalType = `List<${parseType(propType[0]).type}>`
283
- }
284
- }
285
- }
286
-
287
- /**
288
- * special cases for which we don't have proper type handling yet
289
- */
290
- if (type === 'Unknown') {
291
- // Apply special case overrides for common property names
292
- if (property.Name === 'capabilities') {
293
- finalType = 'Capabilities';
294
- } else if (property.Name === 'value' &&
295
- (assignment.Name.includes('Accessibility') || assignment.Name.includes('Element'))) {
296
- finalType = 'AccessibilityValue';
297
- } else if (property.Name === 'value' && assignment.Name.includes('Context')) {
298
- finalType = 'ContextValue';
299
- } else if (property.Name === 'attributes') {
300
- finalType = 'Map<String, String>';
301
- } else {
302
- /* c8 ignore next */ throw new Error(`Unknown property: ${property.Name}`)
303
- }
304
- }
305
-
306
- props.set(parsePropertyName(property.Name), { type: finalType, isLiteral })
307
- }
308
-
309
- if (props.size > 0) {
310
- let code = ''
311
- if (!javaPropFiles.has(mapKey)) {
312
- const implementsExtension = allGroupEnums.find(({ name, enums }) => name && enums.includes(`${scopeCamelCase.toLowerCase()}.${propClassName}`))
313
- code += `package org.openqa.selenium.bidirectional.${scopeCamelCase.toLowerCase()};
314
-
315
- import java.util.Map;
316
- import java.util.HashMap;
317
- import java.util.List;
318
- import java.util.ArrayList;
319
- import org.openqa.selenium.bidirectional.*;
320
-
321
- /**
322
- * Auto-generated class for WebDriver BiDi protocol
323
- * Represents parameters for ${assignment.Name} command
324
- */
325
- public class ${propClassName}${implementsExtension ? ` implements ${implementsExtension.name.includes('.') ? implementsExtension.name.split('.')[1] : implementsExtension.name}` : ''} {
326
- `
327
- }
328
-
329
- const assignableProps = Array.from(props.entries()).filter(([_, { isLiteral }]: [string, { type: string, isLiteral: boolean }]) => !isLiteral)
330
- const literalProps = Array.from(props.entries()).filter(([_, { isLiteral }]: [string, { type: string, isLiteral: boolean }]) => isLiteral)
331
-
332
- // Add constructor
333
- const assignablePropsCode = assignableProps.length > 0
334
- ? `
335
- ` + assignableProps.map(([prop]: [string, { type: string, isLiteral: boolean }]) => `this.${prop} = ${prop};`).join(`
336
- `)
337
- : ''
338
- const literalPropsCode = literalProps.length > 0
339
- ? `
340
- ` + literalProps.map(([prop, { type }]: [string, { type: string, isLiteral: boolean }]) => `this.${prop} = "${type}";`).join(`
341
- `)
342
- : ''
343
- code += `
344
- /**
345
- * Creates a new ${propClassName} instance
346
- */
347
- public ${propClassName}(${assignableProps.map(([prop, { type }]: [string, { type: string, isLiteral: boolean }]) => `${type} ${prop}`).join(', ')}) {${
348
- assignablePropsCode + literalPropsCode}
349
- }
350
- `
351
- // Add properties and getters
352
- for (const [prop, { type, isLiteral }] of props.entries()) {
353
- const propName = parsePropertyName(prop)
354
- const propNameCamelCase = propName[0].toUpperCase() + propName.slice(1)
355
- // Use String type for literals
356
- const javaType = isLiteral ? 'String' : type
357
- code += `
358
- private final ${javaType} ${prop};
359
-
360
- /**
361
- * Gets the ${prop} property
362
- * @return ${javaType} value
363
- */
364
- public ${javaType} get${propNameCamelCase}() {
365
- return this.${prop};
366
- }
367
- `
368
- }
369
-
370
- // Add asMap method for command parameters
371
- code += `
372
- /**
373
- * Converts this object to a map for use with BiDi protocol
374
- * @return Map representation of this object
375
- */
376
- public Map<String, Object> asMap() {
377
- Map<String, Object> toReturn = new HashMap<>();
378
- ${Array.from(props.entries()).map(([prop]: [string, { type: string, isLiteral: boolean }]) =>
379
- `toReturn.put("${parsePropertyName(prop)}", this.${prop});`
380
- ).join(`
381
- `)}
382
- return toReturn;
383
- }
384
-
385
- }`
386
- javaPropFiles.set(mapKey, code)
387
- }
388
- } else if (assignment.Type === 'variable') {
389
- const propType = assignment.PropertyType as PropertyType[]
390
-
391
- /**
392
- * handle group enums like
393
- * {
394
- * Type: 'variable',
395
- * Name: 'input.WheelSourceAction',
396
- * IsChoiceAddition: false,
397
- * PropertyType: [
398
- * { Type: 'group', Value: 'input.PauseAction', Unwrapped: false },
399
- * { Type: 'group', Value: 'input.WheelScrollAction', Unwrapped: false }
400
- * ],
401
- * Comments: []
402
- * }
403
- */
404
- if (propType.every((p) => (p as PropertyReference).Type === 'group')) {
405
- const enumClasses = propType.map((p) => (p as PropertyReference).Value as string)
406
- const [module, prop] = assignment.Name.split('.')
407
- let code = (
408
- '/**\n' +
409
- ` * Auto-generated class for WebDriver BiDi protocol\n` +
410
- ` * Represents enum for ${assignment.Name} which can be either of these classes:\n` +
411
- ` * - ${enumClasses.join('\n * - ')}\n` +
412
- ` */\n` +
413
- `public class ${prop} {\n\n}`
414
- )
415
- javaPropFiles.set([pascalCase(module), prop], code)
416
- } else
417
- /**
418
- * handle literal enums like
419
- * {
420
- * Type: 'variable',
421
- * Name: 'input.PointerType',
422
- * IsChoiceAddition: false,
423
- * PropertyType: [
424
- * { Type: 'literal', Value: 'mouse', Unwrapped: false },
425
- * { Type: 'literal', Value: 'pen', Unwrapped: false },
426
- * { Type: 'literal', Value: 'touch', Unwrapped: false }
427
- * ],
428
- * Comments: []
429
- * }
430
- */
431
- if (propType.every((p) => (p as PropertyReference).Type === 'literal' || (p as PropertyReference).Type === 'group')) {
432
- const [module, prop] = assignment.Name.split('.')
433
- const enumValues = propType.map((p) => {
434
- if ((p as PropertyReference).Type === 'group') {
435
- const [mod, prop] = ((p as PropertyReference).Value as string).split('.')
436
- return `${mod.slice(0, 1).toUpperCase() + mod.slice(1)}.${prop}`
437
- }
438
- return (p as PropertyReference).Value
439
- }) as string[]
440
- const code = getEnumTemplate(prop, enumValues)
441
- javaPropFiles.set([pascalCase(module), prop], code)
442
- }
443
- }
444
- }
445
-
446
- return javaPropFiles
447
- }
448
-
449
- function parsePropertyName (name: string): string {
450
- /**
451
- * avoid having assignments with reserved words
452
- */
453
- if (name === 'this') {
454
- return 'self'
455
- }
456
- if (name === 'self') {
457
- return 'this'
458
- }
459
- return name
460
- }
461
-
462
- function parseType (specType: any): { type: string, isLiteral: boolean } {
463
- let type = 'Unknown'
464
- let isLiteral = false
465
-
466
- // Handle complex single object with Type field (not in an array)
467
- if (!Array.isArray(specType) && typeof specType === 'object' && 'Type' in specType) {
468
- specType = [specType]
469
- }
470
-
471
- // Handle single value types
472
- if (specType.length === 1) {
473
- // Handle primitive types
474
- if (specType[0] === 'bool') {
475
- return { type: 'Boolean', isLiteral: false };
476
- } else if (specType[0] === 'float') {
477
- return { type: 'Float', isLiteral: false };
478
- } else if ((specType[0] === 'string' || specType[0] === 'text')) {
479
- return { type: 'String', isLiteral: false };
480
- } else if (specType[0] === 'null' || specType[0] === 'any') {
481
- return { type: 'Object', isLiteral: false }; // null/any represented as Object in Java
482
- } else if (typeof specType[0] === 'object') {
483
- // Handle various object types
484
- if ('Type' in specType[0]) {
485
- const objType = specType[0].Type
486
-
487
- if (objType === 'group') {
488
- if ('Value' in specType[0] && typeof specType[0].Value === 'string') {
489
- // Special types
490
- const value = specType[0].Value;
491
-
492
- // Numeric types
493
- if (value === 'js-int') {
494
- return { type: 'Integer', isLiteral: false };
495
- } else if (value === 'js-uint') {
496
- return { type: 'Long', isLiteral: false };
497
- }
498
-
499
- // Special case known types
500
- const knownTypes: Record<string, string> = {
501
- 'session.Capabilities': 'Session.Capabilities',
502
- 'Capabilities': 'Capabilities',
503
- 'session.Subscription': 'String',
504
- 'browsingContext.BrowsingContext': 'String',
505
- 'browser.UserContext': 'String',
506
- 'browser.ClientWindow': 'String'
507
- };
508
-
509
- if (value in knownTypes) {
510
- return { type: knownTypes[value], isLiteral: false };
511
- }
512
-
513
- if (stringTypes.includes(value)) {
514
- return { type: 'String', isLiteral: false };
515
- }
516
-
517
- // Reference to another type - keep proper casing
518
- const parts = value.split('.');
519
- if (parts.length > 1) {
520
- // Handle scoped types (e.g., 'session.Subscription')
521
- const scope = parts[0][0].toUpperCase() + parts[0].slice(1);
522
- const typeName = parts[1][0].toUpperCase() + parts[1].slice(1);
523
- return { type: `${scope}.${typeName}`, isLiteral: false };
524
- }
525
- /* c8 ignore next */throw new Error(`Unknown type: ${value}`)
526
- }
527
- } else if (objType === 'float') {
528
- return { type: 'Float', isLiteral: false };
529
- } else if (objType === 'range') {
530
- // For range types, determine integer vs float
531
- if (specType[0].Value && typeof specType[0].Value === 'object' &&
532
- specType[0].Value.Min && specType[0].Value.Min.Value !== undefined) {
533
- const minVal = specType[0].Value.Min.Value;
534
- return { type: Number.isInteger(minVal) ? 'Integer' : 'Float', isLiteral: false };
535
- }
536
- /* c8 ignore next */ throw new Error(`Unknown type: ${JSON.stringify(specType[0].Value)}`)
537
- } else if (objType === 'literal' && 'Value' in specType[0] && specType[0].Value !== undefined) {
538
- return { type: specType[0].Value, isLiteral: true };
539
- } else if (Array.isArray(specType[0].Values)) {
540
- const propType = specType[0].Values[0] as Property
541
- if (propType.Type && Array.isArray(propType.Type) && propType.Type.length === 1) {
542
- const subType = parseType(propType.Type[0])
543
- return { type: `List<${subType.type}>`, isLiteral: false }
544
- }
545
-
546
- return { type: 'List<String>', isLiteral: false }
547
- }
548
- }
549
-
550
- // Handle type with operator (default values)
551
- if ('Operator' in specType[0] && specType[0].Operator) {
552
- // Handle boolean with default
553
- if (specType[0].Type === 'bool') {
554
- return { type: 'Boolean', isLiteral: false };
555
- }
556
-
557
- // Handle complex types with operators
558
- if (typeof specType[0].Type === 'object' && 'Type' in specType[0].Type) {
559
- if (specType[0].Type.Type === 'range') {
560
- return { type: 'Float', isLiteral: false };
561
- } else if (specType[0].Type.Type === 'group' && 'Value' in specType[0].Type) {
562
- if (specType[0].Type.Value === 'js-uint') {
563
- return { type: 'Long', isLiteral: false };
564
- }
565
-
566
- // For other group references
567
- const parts = specType[0].Type.Value.split('.');
568
- if (parts.length > 1) {
569
- const scope = parts[0][0].toUpperCase() + parts[0].slice(1);
570
- const typeName = parts[1][0].toUpperCase() + parts[1].slice(1);
571
- return { type: `${scope}.${typeName}`, isLiteral: false };
572
- }
573
- }
574
- }
575
- /* c8 ignore next */ throw new Error(`Unknown operator: ${JSON.stringify(specType[0].Operator)}`)
576
- }
577
- }
578
- } else {
579
- // Multiple types represent a union - use Object for unions
580
- return { type: 'Object', isLiteral: false };
581
- }
582
-
583
- return { type, isLiteral }
584
- }
585
-
586
- async function createJavaFiles (javaFiles: Map<MapKey, string>, outputDir: string) {
587
- for (const [[moduleScope, moduleName], code] of javaFiles.entries()) {
588
- const rootDir = path.join(outputDir, moduleScope)
589
-
590
- await fs.mkdir(rootDir, { recursive: true })
591
- await writeFile(path.resolve(rootDir, `${moduleName}.java`), code)
592
- }
593
- }
594
-
595
- async function createResultClasses (assignments: Assignment[]) {
596
- const javaResultFiles = new Map<MapKey, string>()
597
- for (const assignment of assignments) {
598
- /**
599
- * only create result classes for result types
600
- */
601
- if (!assignment.Name.includes('Result')) {
602
- continue
603
- }
604
-
605
- /**
606
- * skip empty result
607
- */
608
- if (assignment.Name === 'EmptyResult') {
609
- continue
610
- }
611
-
612
- /**
613
- * some results have no scope, skip them
614
- */
615
- if (!assignment.Name.includes('.')) {
616
- continue
617
- }
618
-
619
- const [scope, resultName] = assignment.Name.split('.')
620
- const scopeCamelCase = scope[0].toUpperCase() + scope.slice(1)
621
- const resultClassName = resultName[0].toUpperCase() + resultName.slice(1)
622
- const mapKey: MapKey = [scopeCamelCase, resultClassName]
623
-
624
- // Special case for session.NewResult - skip and handle separately
625
- if (assignment.Name === 'session.NewResult') {
626
- javaResultFiles.set(mapKey, newResultTemplate);
627
- continue;
628
- }
629
-
630
- const props = new Map<string, { type: string, isLiteral: boolean }>()
631
-
632
- if ('Properties' in assignment && assignment.Properties) {
633
- for (const property of assignment.Properties as Property[]) {
634
- const { type, isLiteral } = parseType(property.Type)
635
- props.set(parsePropertyName(property.Name), { type, isLiteral })
636
- }
637
- }
638
-
639
- let code = `package org.openqa.selenium.bidirectional.${scopeCamelCase.toLowerCase()};
640
-
641
- import java.util.Map;
642
- import java.util.HashMap;
643
- import java.util.List;
644
- import java.util.ArrayList;
645
- import org.openqa.selenium.bidirectional.EmptyResult;
646
-
647
- /**
648
- * Auto-generated class for WebDriver BiDi protocol
649
- * Represents response for ${assignment.Name} command
650
- */
651
- public class ${resultClassName} {
652
- `
653
-
654
- if (props.size > 0) {
655
- // Add constructor
656
- code += `
657
- /**
658
- * Creates a new ${resultClassName} instance
659
- */
660
- public ${resultClassName}(${Array.from(props.entries()).map(([prop, { type }]: [string, { type: string, isLiteral: boolean }]) =>
661
- `${type} ${prop}`).join(', ')}) {
662
- ${Array.from(props.entries()).map(([prop]: [string, { type: string, isLiteral: boolean }]) =>
663
- `this.${prop} = ${prop};`).join(`
664
- `)}
665
- }
666
-
667
- `
668
- // Add properties and getters
669
- for (const [prop, { type }] of props.entries()) {
670
- const propNameCamelCase = prop[0].toUpperCase() + prop.slice(1)
671
- code += `
672
- private final ${type} ${prop};
673
-
674
- /**
675
- * Gets the ${prop} property
676
- * @return ${type} value
677
- */
678
- public ${type} get${propNameCamelCase}() {
679
- return this.${prop};
680
- }
681
- `
682
- }
683
-
684
- } else {
685
- // Empty constructor for classes without properties
686
- code += `
687
- /**
688
- * Creates a new ${resultClassName} instance
689
- */
690
- public ${resultClassName}() {
691
- // No properties to initialize
692
- }
693
- `
694
- }
695
-
696
- javaResultFiles.set(mapKey, code)
697
- }
698
-
699
- return javaResultFiles
700
- }
701
-
702
- async function createEmptyResultClass(outputDir: string) {
703
- await fs.mkdir(path.join(outputDir), { recursive: true });
704
- await writeFile(path.resolve(outputDir, 'EmptyResult.java'), emptyResultTemplate);
705
- }
706
-
707
- async function createHelperClasses( outputDir: string) {
708
- // Create directories and write files
709
- await writeFile(path.resolve(outputDir, 'ContextValue.java'), contextValueTemplate);
710
- await writeFile(path.resolve(outputDir, 'AccessibilityValue.java'), accessibilityValueTemplate);
711
- await fs.mkdir(path.join(outputDir, 'Session'), { recursive: true });
712
- await writeFile(path.resolve(outputDir, 'Session/Capabilities.java'), capabilitiesTemplate);
713
- }
714
-
715
- export async function transform (cddlFilePath: string, outputDir: string) {
716
- const ast = parseCDDLFile(cddlFilePath)
717
- const [moduleCode, propertyCode, resultCode] = await Promise.all([
718
- createModules(ast),
719
- createPropertyClasses(ast),
720
- createResultClasses(ast)
721
- ])
722
-
723
- await fs.mkdir(outputDir, { recursive: true })
724
- await Promise.all([
725
- createJavaFiles(moduleCode, outputDir),
726
- createJavaFiles(propertyCode, outputDir),
727
- createJavaFiles(resultCode, outputDir),
728
- createEmptyResultClass(outputDir),
729
- createHelperClasses(outputDir)
730
- ])
731
- }