dom.nim 50 KB

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