dom.nim 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## Declaration of the Document Object Model for the `JavaScript backend
  10. ## <backends.html#backends-the-javascript-target>`_.
  11. import std/private/since
  12. when not defined(js):
  13. {.error: "This module only works on the JavaScript platform".}
  14. const
  15. DomApiVersion* = 3 ## the version of DOM API we try to follow. No guarantees though.
  16. type
  17. EventTarget* = ref EventTargetObj
  18. EventTargetObj {.importc.} = object of RootObj
  19. onabort*: proc (event: Event) {.closure.}
  20. onblur*: proc (event: Event) {.closure.}
  21. onchange*: proc (event: Event) {.closure.}
  22. onclick*: proc (event: Event) {.closure.}
  23. ondblclick*: proc (event: Event) {.closure.}
  24. onerror*: proc (event: Event) {.closure.}
  25. onfocus*: proc (event: Event) {.closure.}
  26. onkeydown*: proc (event: Event) {.closure.}
  27. onkeypress*: proc (event: Event) {.closure.}
  28. onkeyup*: proc (event: Event) {.closure.}
  29. onload*: proc (event: Event) {.closure.}
  30. onmousedown*: proc (event: Event) {.closure.}
  31. onmousemove*: proc (event: Event) {.closure.}
  32. onmouseout*: proc (event: Event) {.closure.}
  33. onmouseover*: proc (event: Event) {.closure.}
  34. onmouseup*: proc (event: Event) {.closure.}
  35. onreset*: proc (event: Event) {.closure.}
  36. onselect*: proc (event: Event) {.closure.}
  37. onstorage*: proc (event: Event) {.closure.}
  38. onsubmit*: proc (event: Event) {.closure.}
  39. onunload*: proc (event: Event) {.closure.}
  40. onloadstart*: proc (event: Event) {.closure.}
  41. onprogress*: proc (event: Event) {.closure.}
  42. onloadend*: proc (event: Event) {.closure.}
  43. DomEvent* {.pure.} = enum
  44. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/Events>`_
  45. Abort = "abort",
  46. BeforeInput = "beforeinput",
  47. Blur = "blur",
  48. Click = "click",
  49. CompositionEnd = "compositionend",
  50. CompositionStart = "compositionstart",
  51. CompositionUpdate = "compositionupdate",
  52. DblClick = "dblclick",
  53. Error = "error",
  54. Focus = "focus",
  55. FocusIn = "focusin",
  56. FocusOut = "focusout",
  57. Input = "input",
  58. KeyDown = "keydown",
  59. KeyPress = "keypress",
  60. KeyUp = "keyup",
  61. Load = "load",
  62. MouseDown = "mousedown",
  63. MouseEnter = "mouseenter",
  64. MouseLeave = "mouseleave",
  65. MouseMove = "mousemove",
  66. MouseOut = "mouseout",
  67. MouseOver = "mouseover",
  68. MouseUp = "mouseup",
  69. Resize = "resize",
  70. Scroll = "scroll",
  71. Select = "select",
  72. Storage = "storage",
  73. Unload = "unload",
  74. Wheel = "wheel"
  75. PerformanceMemory* {.importc.} = ref object
  76. jsHeapSizeLimit*: float
  77. totalJSHeapSize*: float
  78. usedJSHeapSize*: float
  79. PerformanceTiming* {.importc.} = ref object
  80. connectStart*: float
  81. domComplete*: float
  82. domContentLoadedEventEnd*: float
  83. domContentLoadedEventStart*: float
  84. domInteractive*: float
  85. domLoading*: float
  86. domainLookupEnd*: float
  87. domainLookupStart*: float
  88. fetchStart*: float
  89. loadEventEnd*: float
  90. loadEventStart*: float
  91. navigationStart*: float
  92. redirectEnd*: float
  93. redirectStart*: float
  94. requestStart*: float
  95. responseEnd*: float
  96. responseStart*: float
  97. secureConnectionStart*: float
  98. unloadEventEnd*: float
  99. unloadEventStart*: float
  100. Performance* {.importc.} = ref object
  101. memory*: PerformanceMemory
  102. timing*: PerformanceTiming
  103. Range* {.importc.} = ref object
  104. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Range>`_
  105. collapsed*: bool
  106. commonAncestorContainer*: Node
  107. endContainer*: Node
  108. endOffset*: int
  109. startContainer*: Node
  110. startOffset*: int
  111. Selection* {.importc.} = ref object
  112. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Selection>`_
  113. anchorNode*: Node
  114. anchorOffset*: int
  115. focusNode*: Node
  116. focusOffset*: int
  117. isCollapsed*: bool
  118. rangeCount*: int
  119. `type`*: cstring
  120. Storage* {.importc.} = ref object
  121. Window* = ref WindowObj
  122. WindowObj {.importc.} = object of EventTargetObj
  123. document*: Document
  124. event*: Event
  125. history*: History
  126. location*: Location
  127. closed*: bool
  128. defaultStatus*: cstring
  129. devicePixelRatio*: float
  130. innerHeight*, innerWidth*: int
  131. locationbar*: ref LocationBar
  132. menubar*: ref MenuBar
  133. name*: cstring
  134. outerHeight*, outerWidth*: int
  135. pageXOffset*, pageYOffset*: int
  136. scrollX*: float
  137. scrollY*: float
  138. personalbar*: ref PersonalBar
  139. scrollbars*: ref ScrollBars
  140. statusbar*: ref StatusBar
  141. status*: cstring
  142. toolbar*: ref ToolBar
  143. frames*: seq[Frame]
  144. screen*: Screen
  145. performance*: Performance
  146. onpopstate*: proc (event: Event)
  147. localStorage*: Storage
  148. sessionStorage*: Storage
  149. parent*: Window
  150. Frame* = ref FrameObj
  151. FrameObj {.importc.} = object of WindowObj
  152. ClassList* = ref ClassListObj
  153. ClassListObj {.importc.} = object of RootObj
  154. NodeType* = enum
  155. ElementNode = 1,
  156. AttributeNode,
  157. TextNode,
  158. CDATANode,
  159. EntityRefNode,
  160. EntityNode,
  161. ProcessingInstructionNode,
  162. CommentNode,
  163. DocumentNode,
  164. DocumentTypeNode,
  165. DocumentFragmentNode,
  166. NotationNode
  167. Node* = ref NodeObj
  168. NodeObj {.importc.} = object of EventTargetObj
  169. attributes*: seq[Node]
  170. childNodes*: seq[Node]
  171. children*: seq[Node]
  172. data*: cstring
  173. firstChild*: Node
  174. lastChild*: Node
  175. nextSibling*: Node
  176. nodeName*: cstring
  177. nodeType*: NodeType
  178. nodeValue*: cstring
  179. parentNode*: Node
  180. content*: Node
  181. previousSibling*: Node
  182. ownerDocument*: Document
  183. innerHTML*: cstring
  184. outerHTML*: cstring
  185. innerText*: cstring
  186. textContent*: cstring
  187. style*: Style
  188. baseURI*: cstring
  189. parentElement*: Element
  190. isConnected*: bool
  191. Document* = ref DocumentObj
  192. DocumentObj {.importc.} = object of NodeObj
  193. activeElement*: Element
  194. documentElement*: Element
  195. alinkColor*: cstring
  196. bgColor*: cstring
  197. body*: Element
  198. charset*: cstring
  199. cookie*: cstring
  200. defaultCharset*: cstring
  201. fgColor*: cstring
  202. head*: Element
  203. lastModified*: cstring
  204. linkColor*: cstring
  205. referrer*: cstring
  206. title*: cstring
  207. URL*: cstring
  208. vlinkColor*: cstring
  209. anchors*: seq[AnchorElement]
  210. forms*: seq[FormElement]
  211. images*: seq[ImageElement]
  212. applets*: seq[Element]
  213. embeds*: seq[EmbedElement]
  214. links*: seq[LinkElement]
  215. fonts*: FontFaceSet
  216. Element* = ref ElementObj
  217. ElementObj {.importc.} = object of NodeObj
  218. className*: cstring
  219. classList*: ClassList
  220. checked*: bool
  221. defaultChecked*: bool
  222. defaultValue*: cstring
  223. disabled*: bool
  224. form*: FormElement
  225. name*: cstring
  226. readOnly*: bool
  227. options*: seq[OptionElement]
  228. selectedOptions*: seq[OptionElement]
  229. clientWidth*, clientHeight*: int
  230. contentEditable*: cstring
  231. isContentEditable*: bool
  232. dir*: cstring
  233. offsetHeight*: int
  234. offsetWidth*: int
  235. offsetLeft*: int
  236. offsetTop*: int
  237. ValidityState* = ref ValidityStateObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ValidityState>`_
  238. ValidityStateObj {.importc.} = object
  239. badInput*: bool
  240. customError*: bool
  241. patternMismatch*: bool
  242. rangeOverflow*: bool
  243. rangeUnderflow*: bool
  244. stepMismatch*: bool
  245. tooLong*: bool
  246. tooShort*: bool
  247. typeMismatch*: bool
  248. valid*: bool
  249. valueMissing*: bool
  250. Blob* = ref BlobObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Blob>`_
  251. BlobObj {.importc.} = object of RootObj
  252. size*: int
  253. `type`*: cstring
  254. File* = ref FileObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/File>`_
  255. FileObj {.importc.} = object of Blob
  256. lastModified*: int
  257. name*: cstring
  258. TextAreaElement* = ref TextAreaElementObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement>`_
  259. TextAreaElementObj {.importc.} = object of Element
  260. value*: cstring
  261. selectionStart*, selectionEnd*: int
  262. selectionDirection*: cstring
  263. rows*, cols*: int
  264. InputElement* = ref InputElementObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement>`_
  265. InputElementObj {.importc.} = object of Element
  266. # Properties related to the parent form
  267. formAction*: cstring
  268. formEncType*: cstring
  269. formMethod*: cstring
  270. formNoValidate*: bool
  271. formTarget*: cstring
  272. # Properties that apply to any type of input element that is not hidden
  273. `type`*: cstring
  274. autofocus*: bool
  275. required*: bool
  276. value*: cstring
  277. validity*: ValidityState
  278. validationMessage*: cstring
  279. willValidate*: bool
  280. # Properties that apply only to elements of type "checkbox" or "radio"
  281. indeterminate*: bool
  282. # Properties that apply only to elements of type "image"
  283. alt*: cstring
  284. height*: cstring
  285. src*: cstring
  286. width*: cstring
  287. # Properties that apply only to elements of type "file"
  288. accept*: cstring
  289. files*: seq[Blob]
  290. # Properties that apply only to text/number-containing or elements
  291. autocomplete*: cstring
  292. maxLength*: int
  293. size*: int
  294. pattern*: cstring
  295. placeholder*: cstring
  296. min*: cstring
  297. max*: cstring
  298. selectionStart*: int
  299. selectionEnd*: int
  300. selectionDirection*: cstring
  301. # Properties not yet categorized
  302. dirName*: cstring
  303. accessKey*: cstring
  304. list*: Element
  305. multiple*: bool
  306. labels*: seq[Element]
  307. step*: cstring
  308. valueAsDate*: cstring
  309. valueAsNumber*: float
  310. LinkElement* = ref LinkObj
  311. LinkObj {.importc.} = object of ElementObj
  312. target*: cstring
  313. text*: cstring
  314. x*: int
  315. y*: int
  316. EmbedElement* = ref EmbedObj
  317. EmbedObj {.importc.} = object of ElementObj
  318. height*: int
  319. hspace*: int
  320. src*: cstring
  321. width*: int
  322. `type`*: cstring
  323. vspace*: int
  324. AnchorElement* = ref AnchorObj
  325. AnchorObj {.importc.} = object of ElementObj
  326. text*: cstring
  327. x*, y*: int
  328. OptionElement* = ref OptionObj
  329. OptionObj {.importc.} = object of ElementObj
  330. defaultSelected*: bool
  331. selected*: bool
  332. selectedIndex*: int
  333. text*: cstring
  334. value*: cstring
  335. FormElement* = ref FormObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement>`_
  336. FormObj {.importc.} = object of ElementObj
  337. acceptCharset*: cstring
  338. action*: cstring
  339. autocomplete*: cstring
  340. elements*: seq[Element]
  341. encoding*: cstring
  342. enctype*: cstring
  343. length*: int
  344. `method`*: cstring
  345. noValidate*: bool
  346. target*: cstring
  347. ImageElement* = ref ImageObj
  348. ImageObj {.importc.} = object of ElementObj
  349. border*: int
  350. complete*: bool
  351. height*: int
  352. hspace*: int
  353. lowsrc*: cstring
  354. src*: cstring
  355. vspace*: int
  356. width*: int
  357. Style* = ref StyleObj
  358. StyleObj {.importc.} = object of RootObj
  359. alignContent*: cstring
  360. alignItems*: cstring
  361. alignSelf*: cstring
  362. all*: cstring
  363. animation*: cstring
  364. animationDelay*: cstring
  365. animationDirection*: cstring
  366. animationDuration*: cstring
  367. animationFillMode*: cstring
  368. animationIterationCount*: cstring
  369. animationName*: cstring
  370. animationPlayState*: cstring
  371. animationTimingFunction*: cstring
  372. backdropFilter*: cstring
  373. backfaceVisibility*: cstring
  374. background*: cstring
  375. backgroundAttachment*: cstring
  376. backgroundBlendMode*: cstring
  377. backgroundClip*: cstring
  378. backgroundColor*: cstring
  379. backgroundImage*: cstring
  380. backgroundOrigin*: cstring
  381. backgroundPosition*: cstring
  382. backgroundRepeat*: cstring
  383. backgroundSize*: cstring
  384. blockSize*: cstring
  385. border*: cstring
  386. borderBlock*: cstring
  387. borderBlockColor*: cstring
  388. borderBlockEnd*: cstring
  389. borderBlockEndColor*: cstring
  390. borderBlockEndStyle*: cstring
  391. borderBlockEndWidth*: cstring
  392. borderBlockStart*: cstring
  393. borderBlockStartColor*: cstring
  394. borderBlockStartStyle*: cstring
  395. borderBlockStartWidth*: cstring
  396. borderBlockStyle*: cstring
  397. borderBlockWidth*: cstring
  398. borderBottom*: cstring
  399. borderBottomColor*: cstring
  400. borderBottomLeftRadius*: cstring
  401. borderBottomRightRadius*: cstring
  402. borderBottomStyle*: cstring
  403. borderBottomWidth*: cstring
  404. borderCollapse*: cstring
  405. borderColor*: cstring
  406. borderEndEndRadius*: cstring
  407. borderEndStartRadius*: cstring
  408. borderImage*: cstring
  409. borderImageOutset*: cstring
  410. borderImageRepeat*: cstring
  411. borderImageSlice*: cstring
  412. borderImageSource*: cstring
  413. borderImageWidth*: cstring
  414. borderInline*: cstring
  415. borderInlineColor*: cstring
  416. borderInlineEnd*: cstring
  417. borderInlineEndColor*: cstring
  418. borderInlineEndStyle*: cstring
  419. borderInlineEndWidth*: cstring
  420. borderInlineStart*: cstring
  421. borderInlineStartColor*: cstring
  422. borderInlineStartStyle*: cstring
  423. borderInlineStartWidth*: cstring
  424. borderInlineStyle*: cstring
  425. borderInlineWidth*: cstring
  426. borderLeft*: cstring
  427. borderLeftColor*: cstring
  428. borderLeftStyle*: cstring
  429. borderLeftWidth*: cstring
  430. borderRadius*: cstring
  431. borderRight*: cstring
  432. borderRightColor*: cstring
  433. borderRightStyle*: cstring
  434. borderRightWidth*: cstring
  435. borderSpacing*: cstring
  436. borderStartEndRadius*: cstring
  437. borderStartStartRadius*: cstring
  438. borderStyle*: cstring
  439. borderTop*: cstring
  440. borderTopColor*: cstring
  441. borderTopLeftRadius*: cstring
  442. borderTopRightRadius*: cstring
  443. borderTopStyle*: cstring
  444. borderTopWidth*: cstring
  445. borderWidth*: cstring
  446. bottom*: cstring
  447. boxDecorationBreak*: cstring
  448. boxShadow*: cstring
  449. boxSizing*: cstring
  450. breakAfter*: cstring
  451. breakBefore*: cstring
  452. breakInside*: cstring
  453. captionSide*: cstring
  454. caretColor*: cstring
  455. clear*: cstring
  456. clip*: cstring
  457. clipPath*: cstring
  458. color*: cstring
  459. colorAdjust*: cstring
  460. columnCount*: cstring
  461. columnFill*: cstring
  462. columnGap*: cstring
  463. columnRule*: cstring
  464. columnRuleColor*: cstring
  465. columnRuleStyle*: cstring
  466. columnRuleWidth*: cstring
  467. columnSpan*: cstring
  468. columnWidth*: cstring
  469. columns*: cstring
  470. contain*: cstring
  471. content*: cstring
  472. counterIncrement*: cstring
  473. counterReset*: cstring
  474. counterSet*: cstring
  475. cursor*: cstring
  476. direction*: cstring
  477. display*: cstring
  478. emptyCells*: cstring
  479. filter*: cstring
  480. flex*: cstring
  481. flexBasis*: cstring
  482. flexDirection*: cstring
  483. flexFlow*: cstring
  484. flexGrow*: cstring
  485. flexShrink*: cstring
  486. flexWrap*: cstring
  487. cssFloat*: cstring
  488. font*: cstring
  489. fontFamily*: cstring
  490. fontFeatureSettings*: cstring
  491. fontKerning*: cstring
  492. fontLanguageOverride*: cstring
  493. fontOpticalSizing*: cstring
  494. fontSize*: cstring
  495. fontSizeAdjust*: cstring
  496. fontStretch*: cstring
  497. fontStyle*: cstring
  498. fontSynthesis*: cstring
  499. fontVariant*: cstring
  500. fontVariantAlternates*: cstring
  501. fontVariantCaps*: cstring
  502. fontVariantEastAsian*: cstring
  503. fontVariantLigatures*: cstring
  504. fontVariantNumeric*: cstring
  505. fontVariantPosition*: cstring
  506. fontVariationSettings*: cstring
  507. fontWeight*: cstring
  508. gap*: cstring
  509. grid*: cstring
  510. gridArea*: cstring
  511. gridAutoColumns*: cstring
  512. gridAutoFlow*: cstring
  513. gridAutoRows*: cstring
  514. gridColumn*: cstring
  515. gridColumnEnd*: cstring
  516. gridColumnStart*: cstring
  517. gridRow*: cstring
  518. gridRowEnd*: cstring
  519. gridRowStart*: cstring
  520. gridTemplate*: cstring
  521. gridTemplateAreas*: cstring
  522. gridTemplateColumns*: cstring
  523. gridTemplateRows*: cstring
  524. hangingPunctuation*: cstring
  525. height*: cstring
  526. hyphens*: cstring
  527. imageOrientation*: cstring
  528. imageRendering*: cstring
  529. inlineSize*: cstring
  530. inset*: cstring
  531. insetBlock*: cstring
  532. insetBlockEnd*: cstring
  533. insetBlockStart*: cstring
  534. insetInline*: cstring
  535. insetInlineEnd*: cstring
  536. insetInlineStart*: cstring
  537. isolation*: cstring
  538. justifyContent*: cstring
  539. justifyItems*: cstring
  540. justifySelf*: cstring
  541. left*: cstring
  542. letterSpacing*: cstring
  543. lineBreak*: cstring
  544. lineHeight*: cstring
  545. listStyle*: cstring
  546. listStyleImage*: cstring
  547. listStylePosition*: cstring
  548. listStyleType*: cstring
  549. margin*: cstring
  550. marginBlock*: cstring
  551. marginBlockEnd*: cstring
  552. marginBlockStart*: cstring
  553. marginBottom*: cstring
  554. marginInline*: cstring
  555. marginInlineEnd*: cstring
  556. marginInlineStart*: cstring
  557. marginLeft*: cstring
  558. marginRight*: cstring
  559. marginTop*: cstring
  560. mask*: cstring
  561. maskBorder*: cstring
  562. maskBorderMode*: cstring
  563. maskBorderOutset*: cstring
  564. maskBorderRepeat*: cstring
  565. maskBorderSlice*: cstring
  566. maskBorderSource*: cstring
  567. maskBorderWidth*: cstring
  568. maskClip*: cstring
  569. maskComposite*: cstring
  570. maskImage*: cstring
  571. maskMode*: cstring
  572. maskOrigin*: cstring
  573. maskPosition*: cstring
  574. maskRepeat*: cstring
  575. maskSize*: cstring
  576. maskType*: cstring
  577. maxBlockSize*: cstring
  578. maxHeight*: cstring
  579. maxInlineSize*: cstring
  580. maxWidth*: cstring
  581. minBlockSize*: cstring
  582. minHeight*: cstring
  583. minInlineSize*: cstring
  584. minWidth*: cstring
  585. mixBlendMode*: cstring
  586. objectFit*: cstring
  587. objectPosition*: cstring
  588. offset*: cstring
  589. offsetAnchor*: cstring
  590. offsetDistance*: cstring
  591. offsetPath*: cstring
  592. offsetRotate*: cstring
  593. opacity*: cstring
  594. order*: cstring
  595. orphans*: cstring
  596. outline*: cstring
  597. outlineColor*: cstring
  598. outlineOffset*: cstring
  599. outlineStyle*: cstring
  600. outlineWidth*: cstring
  601. overflow*: cstring
  602. overflowAnchor*: cstring
  603. overflowBlock*: cstring
  604. overflowInline*: cstring
  605. overflowWrap*: cstring
  606. overflowX*: cstring
  607. overflowY*: cstring
  608. overscrollBehavior*: cstring
  609. overscrollBehaviorBlock*: cstring
  610. overscrollBehaviorInline*: cstring
  611. overscrollBehaviorX*: cstring
  612. overscrollBehaviorY*: cstring
  613. padding*: cstring
  614. paddingBlock*: cstring
  615. paddingBlockEnd*: cstring
  616. paddingBlockStart*: cstring
  617. paddingBottom*: cstring
  618. paddingInline*: cstring
  619. paddingInlineEnd*: cstring
  620. paddingInlineStart*: cstring
  621. paddingLeft*: cstring
  622. paddingRight*: cstring
  623. paddingTop*: cstring
  624. pageBreakAfter*: cstring
  625. pageBreakBefore*: cstring
  626. pageBreakInside*: cstring
  627. paintOrder*: cstring
  628. perspective*: cstring
  629. perspectiveOrigin*: cstring
  630. placeContent*: cstring
  631. placeItems*: cstring
  632. placeSelf*: cstring
  633. pointerEvents*: cstring
  634. position*: cstring
  635. quotes*: cstring
  636. resize*: cstring
  637. right*: cstring
  638. rotate*: cstring
  639. rowGap*: cstring
  640. scale*: cstring
  641. scrollBehavior*: cstring
  642. scrollMargin*: cstring
  643. scrollMarginBlock*: cstring
  644. scrollMarginBlockEnd*: cstring
  645. scrollMarginBlockStart*: cstring
  646. scrollMarginBottom*: cstring
  647. scrollMarginInline*: cstring
  648. scrollMarginInlineEnd*: cstring
  649. scrollMarginInlineStart*: cstring
  650. scrollMarginLeft*: cstring
  651. scrollMarginRight*: cstring
  652. scrollMarginTop*: cstring
  653. scrollPadding*: cstring
  654. scrollPaddingBlock*: cstring
  655. scrollPaddingBlockEnd*: cstring
  656. scrollPaddingBlockStart*: cstring
  657. scrollPaddingBottom*: cstring
  658. scrollPaddingInline*: cstring
  659. scrollPaddingInlineEnd*: cstring
  660. scrollPaddingInlineStart*: cstring
  661. scrollPaddingLeft*: cstring
  662. scrollPaddingRight*: cstring
  663. scrollPaddingTop*: cstring
  664. scrollSnapAlign*: cstring
  665. scrollSnapStop*: cstring
  666. scrollSnapType*: cstring
  667. scrollbar3dLightColor*: cstring
  668. scrollbarArrowColor*: cstring
  669. scrollbarBaseColor*: cstring
  670. scrollbarColor*: cstring
  671. scrollbarDarkshadowColor*: cstring
  672. scrollbarFaceColor*: cstring
  673. scrollbarHighlightColor*: cstring
  674. scrollbarShadowColor*: cstring
  675. scrollbarTrackColor*: cstring
  676. scrollbarWidth*: cstring
  677. shapeImageThreshold*: cstring
  678. shapeMargin*: cstring
  679. shapeOutside*: cstring
  680. tabSize*: cstring
  681. tableLayout*: cstring
  682. textAlign*: cstring
  683. textAlignLast*: cstring
  684. textCombineUpright*: cstring
  685. textDecoration*: cstring
  686. textDecorationColor*: cstring
  687. textDecorationLine*: cstring
  688. textDecorationSkipInk*: cstring
  689. textDecorationStyle*: cstring
  690. textDecorationThickness*: cstring
  691. textEmphasis*: cstring
  692. textEmphasisColor*: cstring
  693. textEmphasisPosition*: cstring
  694. textEmphasisStyle*: cstring
  695. textIndent*: cstring
  696. textJustify*: cstring
  697. textOrientation*: cstring
  698. textOverflow*: cstring
  699. textRendering*: cstring
  700. textShadow*: cstring
  701. textTransform*: cstring
  702. textUnderlineOffset*: cstring
  703. textUnderlinePosition*: cstring
  704. top*: cstring
  705. touchAction*: cstring
  706. transform*: cstring
  707. transformBox*: cstring
  708. transformOrigin*: cstring
  709. transformStyle*: cstring
  710. transition*: cstring
  711. transitionDelay*: cstring
  712. transitionDuration*: cstring
  713. transitionProperty*: cstring
  714. transitionTimingFunction*: cstring
  715. translate*: cstring
  716. unicodeBidi*: cstring
  717. verticalAlign*: cstring
  718. visibility*: cstring
  719. whiteSpace*: cstring
  720. widows*: cstring
  721. width*: cstring
  722. willChange*: cstring
  723. wordBreak*: cstring
  724. wordSpacing*: cstring
  725. writingMode*: cstring
  726. zIndex*: cstring
  727. EventPhase* = enum
  728. None = 0,
  729. CapturingPhase,
  730. AtTarget,
  731. BubblingPhase
  732. Event* = ref EventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/Event>`_
  733. EventObj {.importc.} = object of RootObj
  734. bubbles*: bool
  735. cancelBubble*: bool
  736. cancelable*: bool
  737. composed*: bool
  738. currentTarget*: Node
  739. defaultPrevented*: bool
  740. eventPhase*: int
  741. target*: Node
  742. `type`*: cstring
  743. isTrusted*: bool
  744. UIEvent* = ref UIEventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/UIEvent>`_
  745. UIEventObj {.importc.} = object of Event
  746. detail*: int64
  747. view*: Window
  748. KeyboardEvent* = ref KeyboardEventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent>`_
  749. KeyboardEventObj {.importc.} = object of UIEvent
  750. altKey*, ctrlKey*, metaKey*, shiftKey*: bool
  751. code*: cstring
  752. isComposing*: bool
  753. key*: cstring
  754. keyCode*: int
  755. location*: int
  756. KeyboardEventKey* {.pure.} = enum ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>`_
  757. # Modifier keys
  758. Alt,
  759. AltGraph,
  760. CapsLock,
  761. Control,
  762. Fn,
  763. FnLock,
  764. Hyper,
  765. Meta,
  766. NumLock,
  767. ScrollLock,
  768. Shift,
  769. Super,
  770. Symbol,
  771. SymbolLock,
  772. # Whitespace keys
  773. ArrowDown,
  774. ArrowLeft,
  775. ArrowRight,
  776. ArrowUp,
  777. End,
  778. Home,
  779. PageDown,
  780. PageUp,
  781. # Editing keys
  782. Backspace,
  783. Clear,
  784. Copy,
  785. CrSel,
  786. Cut,
  787. Delete,
  788. EraseEof,
  789. ExSel,
  790. Insert,
  791. Paste,
  792. Redo,
  793. Undo,
  794. # UI keys
  795. Accept,
  796. Again,
  797. Attn,
  798. Cancel,
  799. ContextMenu,
  800. Escape,
  801. Execute,
  802. Find,
  803. Finish,
  804. Help,
  805. Pause,
  806. Play,
  807. Props,
  808. Select,
  809. ZoomIn,
  810. ZoomOut,
  811. # Device keys
  812. BrigtnessDown,
  813. BrigtnessUp,
  814. Eject,
  815. LogOff,
  816. Power,
  817. PowerOff,
  818. PrintScreen,
  819. Hibernate,
  820. Standby,
  821. WakeUp,
  822. # Common IME keys
  823. AllCandidates,
  824. Alphanumeric,
  825. CodeInput,
  826. Compose,
  827. Convert,
  828. Dead,
  829. FinalMode,
  830. GroupFirst,
  831. GroupLast,
  832. GroupNext,
  833. GroupPrevious,
  834. ModeChange,
  835. NextCandidate,
  836. NonConvert,
  837. PreviousCandidate,
  838. Process,
  839. SingleCandidate,
  840. # Korean keyboards only
  841. HangulMode,
  842. HanjaMode,
  843. JunjaMode,
  844. # Japanese keyboards only
  845. Eisu,
  846. Hankaku,
  847. Hiragana,
  848. HiraganaKatakana,
  849. KanaMode,
  850. KanjiMode,
  851. Katakana,
  852. Romaji,
  853. Zenkaku,
  854. ZenkakuHanaku,
  855. # Function keys
  856. F1,
  857. F2,
  858. F3,
  859. F4,
  860. F5,
  861. F6,
  862. F7,
  863. F8,
  864. F9,
  865. F10,
  866. F11,
  867. F12,
  868. F13,
  869. F14,
  870. F15,
  871. F16,
  872. F17,
  873. F18,
  874. F19,
  875. F20,
  876. Soft1,
  877. Soft2,
  878. Soft3,
  879. Soft4,
  880. # Phone keys
  881. AppSwitch,
  882. Call,
  883. Camera,
  884. CameraFocus,
  885. EndCall,
  886. GoBack,
  887. GoHome,
  888. HeadsetHook,
  889. LastNumberRedial,
  890. Notification,
  891. MannerMode,
  892. VoiceDial,
  893. # Multimedia keys
  894. ChannelDown,
  895. ChannelUp,
  896. MediaFastForward,
  897. MediaPause,
  898. MediaPlay,
  899. MediaPlayPause,
  900. MediaRecord,
  901. MediaRewind,
  902. MediaStop,
  903. MediaTrackNext,
  904. MediaTrackPrevious,
  905. # Audio control keys
  906. AudioBalanceLeft,
  907. AudioBalanceRight,
  908. AudioBassDown,
  909. AudioBassBoostDown,
  910. AudioBassBoostToggle,
  911. AudioBassBoostUp,
  912. AudioBassUp,
  913. AudioFaderFront,
  914. AudioFaderRear,
  915. AudioSurroundModeNext,
  916. AudioTrebleDown,
  917. AudioTrebleUp,
  918. AudioVolumeDown,
  919. AUdioVolumeMute,
  920. AudioVolumeUp,
  921. MicrophoneToggle,
  922. MicrophoneVolumeDown,
  923. MicrophoneVolumeMute,
  924. MicrophoneVolumeUp,
  925. # TV control keys
  926. TV,
  927. TV3DMode,
  928. TVAntennaCable,
  929. TVAudioDescription,
  930. TVAudioDescriptionMixDown,
  931. TVAudioDescriptionMixUp,
  932. TVContentsMenu,
  933. TVDataService,
  934. TVInput,
  935. TVInputComponent1,
  936. TVInputComponent2,
  937. TVInputComposite1,
  938. TVInputComposite2,
  939. TVInputHDMI1,
  940. TVInputHDMI2,
  941. TVInputHDMI3,
  942. TVInputHDMI4,
  943. TVInputVGA1,
  944. TVMediaContext,
  945. TVNetwork,
  946. TVNumberEntry,
  947. TVPower,
  948. TVRadioService,
  949. TVSatellite,
  950. TVSatelliteBS,
  951. TVSatelliteCS,
  952. TVSatelliteToggle,
  953. TVTerrestrialAnalog,
  954. TVTerrestrialDigital,
  955. TVTimer,
  956. # Media controller keys
  957. AVRInput,
  958. AVRPower,
  959. ColorF0Red,
  960. ColorF1Green,
  961. ColorF2Yellow,
  962. ColorF3Blue,
  963. ColorF4Grey,
  964. ColorF5Brown,
  965. ClosedCaptionToggle,
  966. Dimmer,
  967. DisplaySwap,
  968. DVR,
  969. Exit,
  970. FavoriteClear0,
  971. FavoriteClear1,
  972. FavoriteClear2,
  973. FavoriteClear3,
  974. FavoriteRecall0,
  975. FavoriteRecall1,
  976. FavoriteRecall2,
  977. FavoriteRecall3,
  978. FavoriteStore0,
  979. FavoriteStore1,
  980. FavoriteStore2,
  981. FavoriteStore3,
  982. Guide,
  983. GuideNextDay,
  984. GuidePreviousDay,
  985. Info,
  986. InstantReplay,
  987. Link,
  988. ListProgram,
  989. LiveContent,
  990. Lock,
  991. MediaApps,
  992. MediaAudioTrack,
  993. MediaLast,
  994. MediaSkipBackward,
  995. MediaSkipForward,
  996. MediaStepBackward,
  997. MediaStepForward,
  998. MediaTopMenu,
  999. NavigateIn,
  1000. NavigateNext,
  1001. NavigateOut,
  1002. NavigatePrevious,
  1003. NextFavoriteChannel,
  1004. NextUserProfile,
  1005. OnDemand,
  1006. Pairing,
  1007. PinPDown,
  1008. PinPMove,
  1009. PinPUp,
  1010. PlaySpeedDown,
  1011. PlaySpeedReset,
  1012. PlaySpeedUp,
  1013. RandomToggle,
  1014. RcLowBattery,
  1015. RecordSpeedNext,
  1016. RfBypass,
  1017. ScanChannelsToggle,
  1018. ScreenModeNext,
  1019. Settings,
  1020. SplitScreenToggle,
  1021. STBInput,
  1022. STBPower,
  1023. Subtitle,
  1024. Teletext,
  1025. VideoModeNext,
  1026. Wink,
  1027. ZoomToggle,
  1028. # Speech recognition keys
  1029. SpeechCorrectionList,
  1030. SpeechInputToggle,
  1031. # Document keys
  1032. Close,
  1033. New,
  1034. Open,
  1035. Print,
  1036. Save,
  1037. SpellCheck,
  1038. MailForward,
  1039. MailReply,
  1040. MailSend,
  1041. # Application selector keys
  1042. LaunchCalculator,
  1043. LaunchCalendar,
  1044. LaunchContacts,
  1045. LaunchMail,
  1046. LaunchMediaPlayer,
  1047. LaunchMusicPlayer,
  1048. LaunchMyComputer,
  1049. LaunchPhone,
  1050. LaunchScreenSaver,
  1051. LaunchSpreadsheet,
  1052. LaunchWebBrowser,
  1053. LaunchWebCam,
  1054. LaunchWordProcessor,
  1055. LaunchApplication1,
  1056. LaunchApplication2,
  1057. LaunchApplication3,
  1058. LaunchApplication4,
  1059. LaunchApplication5,
  1060. LaunchApplication6,
  1061. LaunchApplication7,
  1062. LaunchApplication8,
  1063. LaunchApplication9,
  1064. LaunchApplication10,
  1065. LaunchApplication11,
  1066. LaunchApplication12,
  1067. LaunchApplication13,
  1068. LaunchApplication14,
  1069. LaunchApplication15,
  1070. LaunchApplication16,
  1071. # Browser control keys
  1072. BrowserBack,
  1073. BrowserFavorites,
  1074. BrowserForward,
  1075. BrowserHome,
  1076. BrowserRefresh,
  1077. BrowserSearch,
  1078. BrowserStop,
  1079. # Numeric keypad keys
  1080. Key11,
  1081. Key12,
  1082. Separator
  1083. MouseButtons* = enum
  1084. NoButton = 0,
  1085. PrimaryButton = 1,
  1086. SecondaryButton = 2,
  1087. AuxilaryButton = 4,
  1088. FourthButton = 8,
  1089. FifthButton = 16
  1090. MouseEvent* = ref MouseEventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent>`_
  1091. MouseEventObj {.importc.} = object of UIEvent
  1092. altKey*, ctrlKey*, metaKey*, shiftKey*: bool
  1093. button*: int
  1094. buttons*: int
  1095. clientX*, clientY*: int
  1096. movementX*, movementY*: int
  1097. offsetX*, offsetY*: int
  1098. pageX*, pageY*: int
  1099. relatedTarget*: EventTarget
  1100. #region*: cstring
  1101. screenX*, screenY*: int
  1102. x*, y*: int
  1103. DataTransferItemKind* {.pure.} = enum
  1104. File = "file",
  1105. String = "string"
  1106. DataTransferItem* = ref DataTransferItemObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem>`_
  1107. DataTransferItemObj {.importc.} = object of RootObj
  1108. kind*: cstring
  1109. `type`*: cstring
  1110. DataTransfer* = ref DataTransferObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer>`_
  1111. DataTransferObj {.importc.} = object of RootObj
  1112. dropEffect*: cstring
  1113. effectAllowed*: cstring
  1114. files*: seq[Element]
  1115. items*: seq[DataTransferItem]
  1116. types*: seq[cstring]
  1117. DataTransferDropEffect* {.pure.} = enum
  1118. None = "none",
  1119. Copy = "copy",
  1120. Link = "link",
  1121. Move = "move"
  1122. DataTransferEffectAllowed* {.pure.} = enum
  1123. None = "none",
  1124. Copy = "copy",
  1125. CopyLink = "copyLink",
  1126. CopyMove = "copyMove",
  1127. Link = "link",
  1128. LinkMove = "linkMove",
  1129. Move = "move",
  1130. All = "all",
  1131. Uninitialized = "uninitialized"
  1132. DragEventTypes* = enum
  1133. Drag = "drag",
  1134. DragEnd = "dragend",
  1135. DragEnter = "dragenter",
  1136. DragExit = "dragexit",
  1137. DragLeave = "dragleave",
  1138. DragOver = "dragover",
  1139. DragStart = "dragstart",
  1140. Drop = "drop"
  1141. DragEvent* {.importc.} = object of MouseEvent
  1142. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/DragEvent>`_
  1143. dataTransfer*: DataTransfer
  1144. ClipboardEvent* {.importc.} = object of Event
  1145. ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent>`_
  1146. clipboardData*: DataTransfer
  1147. StorageEvent* = ref StorageEventObj ## see `docs<https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent>`_
  1148. StorageEventObj {.importc.} = object of Event
  1149. key*: cstring
  1150. newValue*, oldValue*: cstring
  1151. storageArea*: Storage
  1152. url*: cstring
  1153. TouchList* {.importc.} = ref object of RootObj
  1154. length*: int
  1155. Touch* = ref TouchObj
  1156. TouchObj {.importc.} = object of RootObj
  1157. identifier*: int
  1158. screenX*, screenY*, clientX*, clientY*, pageX*, pageY*: int
  1159. target*: Element
  1160. radiusX*, radiusY*: int
  1161. rotationAngle*: int
  1162. force*: float
  1163. TouchEvent* = ref TouchEventObj
  1164. TouchEventObj {.importc.} = object of UIEvent
  1165. changedTouches*, targetTouches*, touches*: seq[Touch]
  1166. Location* = ref LocationObj
  1167. LocationObj {.importc.} = object of RootObj
  1168. hash*: cstring
  1169. host*: cstring
  1170. hostname*: cstring
  1171. href*: cstring
  1172. pathname*: cstring
  1173. port*: cstring
  1174. protocol*: cstring
  1175. search*: cstring
  1176. origin*: cstring
  1177. History* = ref HistoryObj
  1178. HistoryObj {.importc.} = object of RootObj
  1179. length*: int
  1180. Navigator* = ref NavigatorObj
  1181. NavigatorObj {.importc.} = object of RootObj
  1182. appCodeName*: cstring
  1183. appName*: cstring
  1184. appVersion*: cstring
  1185. buildID*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/buildID
  1186. cookieEnabled*: bool
  1187. deviceMemory*: float ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory
  1188. doNotTrack*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack
  1189. language*: cstring
  1190. languages*: seq[cstring] ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages
  1191. maxTouchPoints*: cint ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/maxTouchPoints
  1192. onLine*: bool ## https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
  1193. oscpu*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/oscpu
  1194. platform*: cstring
  1195. userAgent*: cstring
  1196. vendor*: cstring ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vendor
  1197. webdriver*: bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver
  1198. mimeTypes*: seq[ref MimeType]
  1199. Plugin* {.importc.} = object of RootObj
  1200. description*: cstring
  1201. filename*: cstring
  1202. name*: cstring
  1203. MimeType* {.importc.} = object of RootObj
  1204. description*: cstring
  1205. enabledPlugin*: ref Plugin
  1206. suffixes*: seq[cstring]
  1207. `type`*: cstring
  1208. LocationBar* {.importc.} = object of RootObj
  1209. visible*: bool
  1210. MenuBar* = LocationBar
  1211. PersonalBar* = LocationBar
  1212. ScrollBars* = LocationBar
  1213. ToolBar* = LocationBar
  1214. StatusBar* = LocationBar
  1215. Screen = ref ScreenObj
  1216. ScreenObj {.importc.} = object of RootObj
  1217. availHeight*: int
  1218. availWidth*: int
  1219. colorDepth*: int
  1220. height*: int
  1221. pixelDepth*: int
  1222. width*: int
  1223. TimeOut* {.importc.} = ref object of RootObj
  1224. Interval* {.importc.} = ref object of RootObj
  1225. AddEventListenerOptions* = object
  1226. capture*: bool
  1227. once*: bool
  1228. passive*: bool
  1229. FontFaceSetReady* {.importc.} = ref object
  1230. ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/ready>`_
  1231. then*: proc(cb: proc())
  1232. FontFaceSet* {.importc.} = ref object
  1233. ## see: `docs<https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet>`_
  1234. ready*: FontFaceSetReady
  1235. onloadingdone*: proc(event: Event)
  1236. ScrollIntoViewOptions* = object
  1237. behavior*: cstring
  1238. `block`*: cstring
  1239. inline*: cstring
  1240. since (1, 3):
  1241. type
  1242. DomParser* = ref object
  1243. ## DOM Parser object (defined on browser only, may not be on NodeJS).
  1244. ## * https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  1245. ##
  1246. ## .. code-block:: nim
  1247. ## let prsr = newDomParser()
  1248. ## discard prsr.parseFromString("<html><marquee>Hello World</marquee></html>".cstring, "text/html".cstring)
  1249. DomException* = ref DOMExceptionObj
  1250. ## The DOMException interface represents an abnormal event (called an exception)
  1251. ## which occurs as a result of calling a method or accessing a property of a web API.
  1252. ## Each exception has a name, which is a short "CamelCase" style string identifying
  1253. ## the error or abnormal condition.
  1254. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException
  1255. DOMExceptionObj {.importc.} = object
  1256. FileReader* = ref FileReaderObj
  1257. ## The FileReader object lets web applications asynchronously read the contents of files
  1258. ## (or raw data buffers) stored on the user's computer, using File or Blob objects to specify
  1259. ## the file or data to read.
  1260. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader
  1261. FileReaderObj {.importc.} = object of EventTargetObj
  1262. FileReaderState* = distinct range[0'u16..2'u16]
  1263. RootNodeOptions* = object of RootObj
  1264. composed*: bool
  1265. DocumentOrShadowRoot* {.importc.} = object of RootObj
  1266. activeElement*: Element
  1267. # styleSheets*: StyleSheetList
  1268. ShadowRoot* = ref ShadowRootObj
  1269. ShadowRootObj {.importc.} = object of DocumentOrShadowRoot
  1270. delegatesFocus*: bool
  1271. host*: Element
  1272. innerHTML*: cstring
  1273. mode*: cstring # "open" or "closed"
  1274. ShadowRootInit* = object of RootObj
  1275. mode*: cstring
  1276. delegatesFocus*: bool
  1277. HTMLSlotElement* = ref HTMLSlotElementObj
  1278. HTMLSlotElementObj {.importc.} = object of RootObj
  1279. name*: cstring
  1280. SlotOptions* = object of RootObj
  1281. flatten*: bool
  1282. const
  1283. fileReaderEmpty* = 0.FileReaderState
  1284. fileReaderLoading* = 1.FileReaderState
  1285. fileReaderDone* = 2.FileReaderState
  1286. proc id*(n: Node): cstring {.importcpp: "#.id", nodecl.}
  1287. proc `id=`*(n: Node; x: cstring) {.importcpp: "#.id = #", nodecl.}
  1288. proc class*(n: Node): cstring {.importcpp: "#.className", nodecl.}
  1289. proc `class=`*(n: Node; v: cstring) {.importcpp: "#.className = #", nodecl.}
  1290. proc value*(n: Node): cstring {.importcpp: "#.value", nodecl.}
  1291. proc `value=`*(n: Node; v: cstring) {.importcpp: "#.value = #", nodecl.}
  1292. proc checked*(n: Node): bool {.importcpp: "#.checked", nodecl.}
  1293. proc `checked=`*(n: Node; v: bool) {.importcpp: "#.checked = #", nodecl.}
  1294. proc `disabled=`*(n: Node; v: bool) {.importcpp: "#.disabled = #", nodecl.}
  1295. when defined(nodejs):
  1296. # we provide a dummy DOM for nodejs for testing purposes
  1297. proc len*(x: Node): int = x.childNodes.len
  1298. proc `[]`*(x: Node; idx: int): Element =
  1299. assert idx >= 0 and idx < x.childNodes.len
  1300. result = cast[Element](x.childNodes[idx])
  1301. var document* = Document(nodeType: DocumentNode)
  1302. document.ownerDocument = document
  1303. proc getElem(x: Element; id: cstring): Element =
  1304. if x.id == id: return x
  1305. for i in 0..<x.len:
  1306. result = getElem(x[i], id)
  1307. if result != nil: return result
  1308. proc getElementById*(doc: Document; id: cstring): Element =
  1309. getElem(doc.body, id)
  1310. proc getElementById*(id: cstring): Element = document.getElementById(id)
  1311. proc appendChild*(parent, n: Node) =
  1312. n.parentNode = parent
  1313. n.ownerDocument = parent.ownerDocument
  1314. parent.childNodes.add n
  1315. proc replaceChild*(parent, newNode, oldNode: Node) =
  1316. newNode.parentNode = parent
  1317. oldNode.parentNode = nil
  1318. var i = 0
  1319. while i < parent.len:
  1320. if Node(parent[i]) == oldNode:
  1321. parent.childNodes[i] = newNode
  1322. return
  1323. inc i
  1324. doAssert false, "old node not in node list"
  1325. proc removeChild*(parent, child: Node) =
  1326. child.parentNode = nil
  1327. var i = 0
  1328. while i < parent.len:
  1329. if Node(parent[i]) == child:
  1330. parent.childNodes.delete(i)
  1331. return
  1332. inc i
  1333. doAssert false, "old node not in node list"
  1334. proc insertBefore*(parent, newNode, before: Node) =
  1335. appendChild(parent, newNode)
  1336. var i = 0
  1337. while i < parent.len-1:
  1338. if Node(parent[i]) == before:
  1339. for j in countdown(parent.len-1, i-1):
  1340. parent.childNodes[j] = parent.childNodes[j-1]
  1341. parent.childNodes[i-1] = newNode
  1342. return
  1343. inc i
  1344. #doAssert false, "before not in node list"
  1345. proc createElement*(d: Document, identifier: cstring): Element =
  1346. new(result)
  1347. result.nodeName = identifier
  1348. result.nodeType = NodeType.ElementNode
  1349. proc createTextNode*(d: Document, identifier: cstring): Node =
  1350. new(result)
  1351. result.nodeName = "#text"
  1352. result.nodeValue = identifier
  1353. result.nodeType = NodeType.TextNode
  1354. proc createComment*(d: Document, data: cstring): Node =
  1355. new(result)
  1356. result.nodeName = "#comment"
  1357. result.nodeValue = data
  1358. result.nodeType = NodeType.CommentNode
  1359. else:
  1360. proc len*(x: Node): int {.importcpp: "#.childNodes.length".}
  1361. proc `[]`*(x: Node; idx: int): Element {.importcpp: "#.childNodes[#]".}
  1362. proc getElementById*(id: cstring): Element {.importc: "document.getElementById", nodecl.}
  1363. proc appendChild*(n, child: Node) {.importcpp.}
  1364. proc removeChild*(n, child: Node) {.importcpp.}
  1365. proc remove*(child: Node) {.importcpp.}
  1366. proc replaceChild*(n, newNode, oldNode: Node) {.importcpp.}
  1367. proc insertBefore*(n, newNode, before: Node) {.importcpp.}
  1368. proc getElementById*(d: Document, id: cstring): Element {.importcpp.}
  1369. proc createElement*(d: Document, identifier: cstring): Element {.importcpp.}
  1370. proc createElementNS*(d: Document, namespaceURI, qualifiedIdentifier: cstring): Element {.importcpp.}
  1371. proc createTextNode*(d: Document, identifier: cstring): Node {.importcpp.}
  1372. proc createComment*(d: Document, data: cstring): Node {.importcpp.}
  1373. proc setTimeout*(action: proc(); ms: int): TimeOut {.importc, nodecl.}
  1374. proc clearTimeout*(t: TimeOut) {.importc, nodecl.}
  1375. proc setInterval*(action: proc(); ms: int): Interval {.importc, nodecl.}
  1376. proc clearInterval*(i: Interval) {.importc, nodecl.}
  1377. {.push importcpp.}
  1378. # EventTarget "methods"
  1379. proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false)
  1380. proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), options: AddEventListenerOptions)
  1381. proc dispatchEvent*(et: EventTarget, ev: Event)
  1382. proc removeEventListener*(et: EventTarget; ev: cstring; cb: proc(ev: Event))
  1383. # Window "methods"
  1384. proc alert*(w: Window, msg: cstring)
  1385. proc back*(w: Window)
  1386. proc blur*(w: Window)
  1387. proc clearInterval*(w: Window, interval: Interval)
  1388. proc clearTimeout*(w: Window, timeout: TimeOut)
  1389. proc close*(w: Window)
  1390. proc confirm*(w: Window, msg: cstring): bool
  1391. proc disableExternalCapture*(w: Window)
  1392. proc enableExternalCapture*(w: Window)
  1393. proc find*(w: Window, text: cstring, caseSensitive = false,
  1394. backwards = false)
  1395. proc focus*(w: Window)
  1396. proc forward*(w: Window)
  1397. proc getComputedStyle*(w: Window, e: Node, pe: Node = nil): Style
  1398. ## .. warning:: The returned Style may or may not be read-only at run-time in the browser. getComputedStyle is performance costly.
  1399. proc handleEvent*(w: Window, e: Event)
  1400. proc home*(w: Window)
  1401. proc moveBy*(w: Window, x, y: int)
  1402. proc moveTo*(w: Window, x, y: int)
  1403. proc open*(w: Window, uri, windowname: cstring,
  1404. properties: cstring = nil): Window
  1405. proc print*(w: Window)
  1406. proc prompt*(w: Window, text, default: cstring): cstring
  1407. proc resizeBy*(w: Window, x, y: int)
  1408. proc resizeTo*(w: Window, x, y: int)
  1409. proc routeEvent*(w: Window, event: Event)
  1410. proc scrollBy*(w: Window, x, y: int)
  1411. proc scrollTo*(w: Window, x, y: int)
  1412. proc setInterval*(w: Window, code: cstring, pause: int): Interval
  1413. proc setInterval*(w: Window, function: proc (), pause: int): Interval
  1414. proc setTimeout*(w: Window, code: cstring, pause: int): TimeOut
  1415. proc setTimeout*(w: Window, function: proc (), pause: int): Interval
  1416. proc stop*(w: Window)
  1417. proc requestAnimationFrame*(w: Window, function: proc (time: float)): int
  1418. proc cancelAnimationFrame*(w: Window, id: int)
  1419. # Node "methods"
  1420. proc appendData*(n: Node, data: cstring)
  1421. proc cloneNode*(n: Node, copyContent: bool): Node
  1422. proc deleteData*(n: Node, start, len: int)
  1423. proc focus*(e: Node)
  1424. proc getAttribute*(n: Node, attr: cstring): cstring
  1425. proc getAttributeNode*(n: Node, attr: cstring): Node
  1426. proc hasAttribute*(n: Node, attr: cstring): bool
  1427. proc hasChildNodes*(n: Node): bool
  1428. proc normalize*(n: Node)
  1429. proc insertData*(n: Node, position: int, data: cstring)
  1430. proc removeAttribute*(n: Node, attr: cstring)
  1431. proc removeAttributeNode*(n, attr: Node)
  1432. proc replaceData*(n: Node, start, len: int, text: cstring)
  1433. proc scrollIntoView*(n: Node)
  1434. proc scrollIntoView*(n: Node, options: ScrollIntoViewOptions)
  1435. proc setAttribute*(n: Node, name, value: cstring)
  1436. proc setAttributeNode*(n: Node, attr: Node)
  1437. proc querySelector*(n: Node, selectors: cstring): Element
  1438. proc querySelectorAll*(n: Node, selectors: cstring): seq[Element]
  1439. proc compareDocumentPosition*(n: Node, otherNode:Node): int
  1440. proc lookupPrefix*(n: Node): cstring
  1441. proc lookupNamespaceURI*(n: Node): cstring
  1442. proc isDefaultNamespace*(n: Node): bool
  1443. proc contains*(n: Node): bool
  1444. proc isEqualNode*(n: Node): bool
  1445. proc isSameNode*(n: Node): bool
  1446. since (1, 3):
  1447. proc getRootNode*(n: Node,options: RootNodeOptions): Node
  1448. # DocumentOrShadowRoot
  1449. proc getSelection*(n: DocumentOrShadowRoot): Selection
  1450. proc elementFromPoint*(n: DocumentOrShadowRoot; x, y: float): Element
  1451. # shadow dom
  1452. proc attachShadow*(n: Element): ShadowRoot
  1453. proc assignedNodes*(n: HTMLSlotElement; options: SlotOptions): seq[Node]
  1454. proc assignedElements*(n: HTMLSlotElement; options: SlotOptions): seq[Element]
  1455. # Document "methods"
  1456. proc createAttribute*(d: Document, identifier: cstring): Node
  1457. proc getElementsByName*(d: Document, name: cstring): seq[Element]
  1458. proc getElementsByTagName*(d: Document, name: cstring): seq[Element]
  1459. proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
  1460. proc insertNode*(range: Range, node: Node)
  1461. proc getSelection*(d: Document): Selection
  1462. proc handleEvent*(d: Document, event: Event)
  1463. proc open*(d: Document)
  1464. proc routeEvent*(d: Document, event: Event)
  1465. proc write*(d: Document, text: cstring)
  1466. proc writeln*(d: Document, text: cstring)
  1467. proc querySelector*(d: Document, selectors: cstring): Element
  1468. proc querySelectorAll*(d: Document, selectors: cstring): seq[Element]
  1469. # Element "methods"
  1470. proc blur*(e: Element)
  1471. proc click*(e: Element)
  1472. proc focus*(e: Element)
  1473. proc handleEvent*(e: Element, event: Event)
  1474. proc select*(e: Element)
  1475. proc getElementsByTagName*(e: Element, name: cstring): seq[Element]
  1476. proc getElementsByClassName*(e: Element, name: cstring): seq[Element]
  1477. # FormElement "methods"
  1478. proc reset*(f: FormElement)
  1479. proc submit*(f: FormElement)
  1480. proc checkValidity*(e: FormElement): bool
  1481. proc reportValidity*(e: FormElement): bool
  1482. # EmbedElement "methods"
  1483. proc play*(e: EmbedElement)
  1484. proc stop*(e: EmbedElement)
  1485. # Location "methods"
  1486. proc reload*(loc: Location)
  1487. proc replace*(loc: Location, s: cstring)
  1488. # History "methods"
  1489. proc back*(h: History)
  1490. proc forward*(h: History)
  1491. proc go*(h: History, pagesToJump: int)
  1492. proc pushState*[T](h: History, stateObject: T, title, url: cstring)
  1493. # Navigator "methods"
  1494. proc javaEnabled*(h: Navigator): bool
  1495. since (1, 3):
  1496. proc canShare*(self: Navigator; data: cstring): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/canShare
  1497. proc sendBeacon*(self: Navigator; url, data: cstring): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
  1498. proc vibrate*(self: Navigator; pattern: cint): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
  1499. proc vibrate*(self: Navigator; pattern: openArray[cint]): bool ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
  1500. proc registerProtocolHandler*(self: Navigator; scheme, url, title: cstring) ## https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
  1501. # ClassList "methods"
  1502. proc add*(c: ClassList, class: cstring)
  1503. proc remove*(c: ClassList, class: cstring)
  1504. proc contains*(c: ClassList, class: cstring): bool
  1505. proc toggle*(c: ClassList, class: cstring)
  1506. # Style "methods"
  1507. proc getPropertyValue*(s: Style, property: cstring): cstring
  1508. proc removeProperty*(s: Style, property: cstring)
  1509. proc setProperty*(s: Style, property, value: cstring, priority = "")
  1510. proc getPropertyPriority*(s: Style, property: cstring): cstring
  1511. # Event "methods"
  1512. proc preventDefault*(ev: Event)
  1513. proc stopImmediatePropagation*(ev: Event)
  1514. proc stopPropagation*(ev: Event)
  1515. # KeyboardEvent "methods"
  1516. proc getModifierState*(ev: KeyboardEvent, keyArg: cstring): bool
  1517. # MouseEvent "methods"
  1518. proc getModifierState*(ev: MouseEvent, keyArg: cstring): bool
  1519. # TouchEvent "methods"
  1520. proc identifiedTouch*(list: TouchList): Touch
  1521. proc item*(list: TouchList, i: int): Touch
  1522. # DataTransfer "methods"
  1523. proc clearData*(dt: DataTransfer, format: cstring)
  1524. proc getData*(dt: DataTransfer, format: cstring): cstring
  1525. proc setData*(dt: DataTransfer, format: cstring, data: cstring)
  1526. proc setDragImage*(dt: DataTransfer, img: Element, xOffset: int64, yOffset: int64)
  1527. # DataTransferItem "methods"
  1528. proc getAsFile*(dti: DataTransferItem): File
  1529. # InputElement "methods"
  1530. proc setSelectionRange*(e: InputElement, selectionStart: int, selectionEnd: int, selectionDirection: cstring = "none")
  1531. proc setRangeText*(e: InputElement, replacement: cstring, startindex: int = 0, endindex: int = 0, selectionMode: cstring = "preserve")
  1532. proc setCustomValidity*(e: InputElement, error: cstring)
  1533. proc checkValidity*(e: InputElement): bool
  1534. # Blob "methods"
  1535. proc slice*(e: Blob, startindex: int = 0, endindex: int = e.size, contentType: cstring = "")
  1536. # Performance "methods"
  1537. proc now*(p: Performance): float
  1538. # Selection "methods"
  1539. proc removeAllRanges*(s: Selection)
  1540. proc deleteFromDocument*(s: Selection)
  1541. proc getRangeAt*(s: Selection, index: int): Range
  1542. converter toString*(s: Selection): cstring
  1543. proc `$`*(s: Selection): string = $(s.toString())
  1544. # Storage "methods"
  1545. proc getItem*(s: Storage, key: cstring): cstring
  1546. proc setItem*(s: Storage, key, value: cstring)
  1547. proc hasItem*(s: Storage, key: cstring): bool
  1548. proc clear*(s: Storage)
  1549. proc removeItem*(s: Storage, key: cstring)
  1550. {.pop.}
  1551. proc setAttr*(n: Node; key, val: cstring) {.importcpp: "#.setAttribute(@)".}
  1552. var
  1553. window* {.importc, nodecl.}: Window
  1554. navigator* {.importc, nodecl.}: Navigator
  1555. screen* {.importc, nodecl.}: Screen
  1556. when not defined(nodejs):
  1557. var document* {.importc, nodecl.}: Document
  1558. proc decodeURI*(uri: cstring): cstring {.importc, nodecl.}
  1559. proc encodeURI*(uri: cstring): cstring {.importc, nodecl.}
  1560. proc escape*(uri: cstring): cstring {.importc, nodecl.}
  1561. proc unescape*(uri: cstring): cstring {.importc, nodecl.}
  1562. proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
  1563. proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
  1564. proc isFinite*(x: BiggestFloat): bool {.importc, nodecl.}
  1565. proc isNaN*(x: BiggestFloat): bool {.importc, nodecl.}
  1566. ## see also `math.isNaN`.
  1567. proc newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.}
  1568. proc getElementsByClass*(n: Node; name: cstring): seq[Node] {.
  1569. importcpp: "#.getElementsByClassName(#)", nodecl.}
  1570. type
  1571. BoundingRect* {.importc.} = object
  1572. top*, bottom*, left*, right*, x*, y*, width*, height*: float
  1573. proc getBoundingClientRect*(e: Node): BoundingRect {.
  1574. importcpp: "getBoundingClientRect", nodecl.}
  1575. proc clientHeight*(): int {.
  1576. importcpp: "(window.innerHeight || document.documentElement.clientHeight)@", nodecl.}
  1577. proc clientWidth*(): int {.
  1578. importcpp: "(window.innerWidth || document.documentElement.clientWidth)@", nodecl.}
  1579. proc inViewport*(el: Node): bool =
  1580. let rect = el.getBoundingClientRect()
  1581. result = rect.top >= 0 and rect.left >= 0 and
  1582. rect.bottom <= clientHeight().float and
  1583. rect.right <= clientWidth().float
  1584. proc scrollTop*(e: Node): int {.importcpp: "#.scrollTop", nodecl.}
  1585. proc `scrollTop=`*(e: Node, value: int) {.importcpp: "#.scrollTop = #", nodecl.}
  1586. proc scrollLeft*(e: Node): int {.importcpp: "#.scrollLeft", nodecl.}
  1587. proc scrollHeight*(e: Node): int {.importcpp: "#.scrollHeight", nodecl.}
  1588. proc scrollWidth*(e: Node): int {.importcpp: "#.scrollWidth", nodecl.}
  1589. proc offsetHeight*(e: Node): int {.importcpp: "#.offsetHeight", nodecl.}
  1590. proc offsetWidth*(e: Node): int {.importcpp: "#.offsetWidth", nodecl.}
  1591. proc offsetTop*(e: Node): int {.importcpp: "#.offsetTop", nodecl.}
  1592. proc offsetLeft*(e: Node): int {.importcpp: "#.offsetLeft", nodecl.}
  1593. since (1, 3):
  1594. func newDomParser*(): DomParser {.importcpp: "new DOMParser()".}
  1595. ## DOM Parser constructor.
  1596. func parseFromString*(this: DomParser; str: cstring; mimeType: cstring): Document {.importcpp.}
  1597. ## Parse from string to `Document`.
  1598. proc newDomException*(): DomException {.importcpp: "new DomException()", constructor.}
  1599. ## DOM Exception constructor
  1600. proc message*(ex: DomException): cstring {.importcpp: "#.message", nodecl.}
  1601. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/message
  1602. proc name*(ex: DomException): cstring {.importcpp: "#.name", nodecl.}
  1603. ## https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name
  1604. proc newFileReader*(): FileReader {.importcpp: "new FileReader()", constructor.}
  1605. ## File Reader constructor
  1606. proc error*(f: FileReader): DomException {.importcpp: "#.error", nodecl.}
  1607. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/error
  1608. proc readyState*(f: FileReader): FileReaderState {.importcpp: "#.readyState", nodecl.}
  1609. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readyState
  1610. proc resultAsString*(f: FileReader): cstring {.importcpp: "#.result", nodecl.}
  1611. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
  1612. proc abort*(f: FileReader) {.importcpp: "#.abort()".}
  1613. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/abort
  1614. proc readAsBinaryString*(f: FileReader, b: Blob) {.importcpp: "#.readAsBinaryString(#)".}
  1615. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsBinaryString
  1616. proc readAsDataURL*(f: FileReader, b: Blob) {.importcpp: "#.readAsDataURL(#)".}
  1617. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
  1618. proc readAsText*(f: FileReader, b: Blob|File, encoding = cstring"UTF-8") {.importcpp: "#.readAsText(#, #)".}
  1619. ## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText
  1620. since (1, 5):
  1621. proc elementsFromPoint*(n: DocumentOrShadowRoot; x, y: float): seq[Element] {.importcpp.}