dom.nim 50 KB

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