0 | module Web.Raw.File
  1 |
  2 | import JS
  3 | import Web.Internal.FilePrim
  4 | import Web.Internal.Types
  5 |
  6 | %default total
  7 |
  8 |
  9 | --------------------------------------------------------------------------------
 10 | --          Interfaces
 11 | --------------------------------------------------------------------------------
 12 |
 13 | namespace Blob
 14 |
 15 |   export
 16 |   new' :
 17 |        {auto 0 _ : JSType t2}
 18 |     -> {auto 0 _ : Elem BlobPropertyBag (Types t2)}
 19 |     -> (blobParts : Optional
 20 |                       (Array
 21 |                          (Union13
 22 |                             Int8Array
 23 |                             Int16Array
 24 |                             Int32Array
 25 |                             UInt8Array
 26 |                             UInt8Array
 27 |                             UInt8Array
 28 |                             UInt8ClampedArray
 29 |                             Float32Array
 30 |                             Float64Array
 31 |                             DataView
 32 |                             ArrayBuffer
 33 |                             Blob
 34 |                             String)))
 35 |     -> (options : Optional t2)
 36 |     -> JSIO Blob
 37 |   new' a b = primJS $ Blob.prim__new (toFFI a) (optUp b)
 38 |
 39 |   export
 40 |   new : JSIO Blob
 41 |   new = primJS $ Blob.prim__new undef undef
 42 |
 43 |
 44 |   export
 45 |   size :
 46 |        {auto 0 _ : JSType t1}
 47 |     -> {auto 0 _ : Elem Blob (Types t1)}
 48 |     -> (obj : t1)
 49 |     -> JSIO JSBits64
 50 |   size a = primJS $ Blob.prim__size (up a)
 51 |
 52 |
 53 |   export
 54 |   type :
 55 |        {auto 0 _ : JSType t1}
 56 |     -> {auto 0 _ : Elem Blob (Types t1)}
 57 |     -> (obj : t1)
 58 |     -> JSIO String
 59 |   type a = primJS $ Blob.prim__type (up a)
 60 |
 61 |
 62 |   export
 63 |   arrayBuffer :
 64 |        {auto 0 _ : JSType t1}
 65 |     -> {auto 0 _ : Elem Blob (Types t1)}
 66 |     -> (obj : t1)
 67 |     -> JSIO (Promise ArrayBuffer)
 68 |   arrayBuffer a = primJS $ Blob.prim__arrayBuffer (up a)
 69 |
 70 |
 71 |   export
 72 |   slice' :
 73 |        {auto 0 _ : JSType t1}
 74 |     -> {auto 0 _ : Elem Blob (Types t1)}
 75 |     -> (obj : t1)
 76 |     -> (start : Optional JSInt64)
 77 |     -> (end : Optional JSInt64)
 78 |     -> (contentType : Optional String)
 79 |     -> JSIO Blob
 80 |   slice' a b c d = primJS $
 81 |     Blob.prim__slice (up a) (toFFI b) (toFFI c) (toFFI d)
 82 |
 83 |   export
 84 |   slice :
 85 |        {auto 0 _ : JSType t1}
 86 |     -> {auto 0 _ : Elem Blob (Types t1)}
 87 |     -> (obj : t1)
 88 |     -> JSIO Blob
 89 |   slice a = primJS $ Blob.prim__slice (up a) undef undef undef
 90 |
 91 |
 92 |   export
 93 |   stream :
 94 |        {auto 0 _ : JSType t1}
 95 |     -> {auto 0 _ : Elem Blob (Types t1)}
 96 |     -> (obj : t1)
 97 |     -> JSIO ReadableStream
 98 |   stream a = primJS $ Blob.prim__stream (up a)
 99 |
100 |
101 |   export
102 |   text :
103 |        {auto 0 _ : JSType t1}
104 |     -> {auto 0 _ : Elem Blob (Types t1)}
105 |     -> (obj : t1)
106 |     -> JSIO (Promise String)
107 |   text a = primJS $ Blob.prim__text (up a)
108 |
109 |
110 |
111 | namespace File
112 |
113 |   export
114 |   new' :
115 |        {auto 0 _ : JSType t3}
116 |     -> {auto 0 _ : Elem FilePropertyBag (Types t3)}
117 |     -> (fileBits : Array
118 |                      (Union13
119 |                         Int8Array
120 |                         Int16Array
121 |                         Int32Array
122 |                         UInt8Array
123 |                         UInt8Array
124 |                         UInt8Array
125 |                         UInt8ClampedArray
126 |                         Float32Array
127 |                         Float64Array
128 |                         DataView
129 |                         ArrayBuffer
130 |                         Blob
131 |                         String))
132 |     -> (fileName : String)
133 |     -> (options : Optional t3)
134 |     -> JSIO File
135 |   new' a b c = primJS $ File.prim__new a b (optUp c)
136 |
137 |   export
138 |   new :
139 |        (fileBits : Array
140 |                      (Union13
141 |                         Int8Array
142 |                         Int16Array
143 |                         Int32Array
144 |                         UInt8Array
145 |                         UInt8Array
146 |                         UInt8Array
147 |                         UInt8ClampedArray
148 |                         Float32Array
149 |                         Float64Array
150 |                         DataView
151 |                         ArrayBuffer
152 |                         Blob
153 |                         String))
154 |     -> (fileName : String)
155 |     -> JSIO File
156 |   new a b = primJS $ File.prim__new a b undef
157 |
158 |
159 |   export
160 |   lastModified : (obj : File) -> JSIO JSInt64
161 |   lastModified a = primJS $ File.prim__lastModified a
162 |
163 |
164 |   export
165 |   name : (obj : File) -> JSIO String
166 |   name a = primJS $ File.prim__name a
167 |
168 |
169 |
170 | namespace FileList
171 |
172 |   export
173 |   length : (obj : FileList) -> JSIO Bits32
174 |   length a = primJS $ FileList.prim__length a
175 |
176 |
177 |   export
178 |   item : (obj : FileList) -> (index : Bits32) -> JSIO (Maybe File)
179 |   item a b = tryJS "FileList.item" $ FileList.prim__item a b
180 |
181 |
182 |
183 | namespace FileReader
184 |
185 |   public export
186 |   DONE : Bits16
187 |   DONE = 2
188 |
189 |
190 |   public export
191 |   EMPTY : Bits16
192 |   EMPTY = 0
193 |
194 |
195 |   public export
196 |   LOADING : Bits16
197 |   LOADING = 1
198 |
199 |
200 |   export
201 |   new : JSIO FileReader
202 |   new = primJS $ FileReader.prim__new
203 |
204 |
205 |   export
206 |   error : (obj : FileReader) -> JSIO (Maybe DOMException)
207 |   error a = tryJS "FileReader.error" $ FileReader.prim__error a
208 |
209 |
210 |   export
211 |   onabort : FileReader -> Attribute False Maybe EventHandlerNonNull
212 |   onabort v = fromNullablePrim
213 |                 "FileReader.getonabort"
214 |                 prim__onabort
215 |                 prim__setOnabort
216 |                 v
217 |
218 |
219 |   export
220 |   onerror : FileReader -> Attribute False Maybe EventHandlerNonNull
221 |   onerror v = fromNullablePrim
222 |                 "FileReader.getonerror"
223 |                 prim__onerror
224 |                 prim__setOnerror
225 |                 v
226 |
227 |
228 |   export
229 |   onload : FileReader -> Attribute False Maybe EventHandlerNonNull
230 |   onload v = fromNullablePrim
231 |                "FileReader.getonload"
232 |                prim__onload
233 |                prim__setOnload
234 |                v
235 |
236 |
237 |   export
238 |   onloadend : FileReader -> Attribute False Maybe EventHandlerNonNull
239 |   onloadend v = fromNullablePrim
240 |                   "FileReader.getonloadend"
241 |                   prim__onloadend
242 |                   prim__setOnloadend
243 |                   v
244 |
245 |
246 |   export
247 |   onloadstart : FileReader -> Attribute False Maybe EventHandlerNonNull
248 |   onloadstart v = fromNullablePrim
249 |                     "FileReader.getonloadstart"
250 |                     prim__onloadstart
251 |                     prim__setOnloadstart
252 |                     v
253 |
254 |
255 |   export
256 |   onprogress : FileReader -> Attribute False Maybe EventHandlerNonNull
257 |   onprogress v = fromNullablePrim
258 |                    "FileReader.getonprogress"
259 |                    prim__onprogress
260 |                    prim__setOnprogress
261 |                    v
262 |
263 |
264 |   export
265 |   readyState : (obj : FileReader) -> JSIO Bits16
266 |   readyState a = primJS $ FileReader.prim__readyState a
267 |
268 |
269 |   export
270 |   result : (obj : FileReader) -> JSIO (Maybe (Union2 String ArrayBuffer))
271 |   result a = tryJS "FileReader.result" $ FileReader.prim__result a
272 |
273 |
274 |   export
275 |   abort : (obj : FileReader) -> JSIO ()
276 |   abort a = primJS $ FileReader.prim__abort a
277 |
278 |
279 |   export
280 |   readAsArrayBuffer :
281 |        {auto 0 _ : JSType t2}
282 |     -> {auto 0 _ : Elem Blob (Types t2)}
283 |     -> (obj : FileReader)
284 |     -> (blob : t2)
285 |     -> JSIO ()
286 |   readAsArrayBuffer a b = primJS $ FileReader.prim__readAsArrayBuffer a (up b)
287 |
288 |
289 |   export
290 |   readAsBinaryString :
291 |        {auto 0 _ : JSType t2}
292 |     -> {auto 0 _ : Elem Blob (Types t2)}
293 |     -> (obj : FileReader)
294 |     -> (blob : t2)
295 |     -> JSIO ()
296 |   readAsBinaryString a b = primJS $ FileReader.prim__readAsBinaryString a (up b)
297 |
298 |
299 |   export
300 |   readAsDataURL :
301 |        {auto 0 _ : JSType t2}
302 |     -> {auto 0 _ : Elem Blob (Types t2)}
303 |     -> (obj : FileReader)
304 |     -> (blob : t2)
305 |     -> JSIO ()
306 |   readAsDataURL a b = primJS $ FileReader.prim__readAsDataURL a (up b)
307 |
308 |
309 |   export
310 |   readAsText' :
311 |        {auto 0 _ : JSType t2}
312 |     -> {auto 0 _ : Elem Blob (Types t2)}
313 |     -> (obj : FileReader)
314 |     -> (blob : t2)
315 |     -> (encoding : Optional String)
316 |     -> JSIO ()
317 |   readAsText' a b c = primJS $ FileReader.prim__readAsText a (up b) (toFFI c)
318 |
319 |   export
320 |   readAsText :
321 |        {auto 0 _ : JSType t2}
322 |     -> {auto 0 _ : Elem Blob (Types t2)}
323 |     -> (obj : FileReader)
324 |     -> (blob : t2)
325 |     -> JSIO ()
326 |   readAsText a b = primJS $ FileReader.prim__readAsText a (up b) undef
327 |
328 |
329 |
330 | namespace FileReaderSync
331 |
332 |   export
333 |   new : JSIO FileReaderSync
334 |   new = primJS $ FileReaderSync.prim__new
335 |
336 |
337 |   export
338 |   readAsArrayBuffer :
339 |        {auto 0 _ : JSType t2}
340 |     -> {auto 0 _ : Elem Blob (Types t2)}
341 |     -> (obj : FileReaderSync)
342 |     -> (blob : t2)
343 |     -> JSIO ArrayBuffer
344 |   readAsArrayBuffer a b = primJS $
345 |     FileReaderSync.prim__readAsArrayBuffer a (up b)
346 |
347 |
348 |   export
349 |   readAsBinaryString :
350 |        {auto 0 _ : JSType t2}
351 |     -> {auto 0 _ : Elem Blob (Types t2)}
352 |     -> (obj : FileReaderSync)
353 |     -> (blob : t2)
354 |     -> JSIO String
355 |   readAsBinaryString a b = primJS $
356 |     FileReaderSync.prim__readAsBinaryString a (up b)
357 |
358 |
359 |   export
360 |   readAsDataURL :
361 |        {auto 0 _ : JSType t2}
362 |     -> {auto 0 _ : Elem Blob (Types t2)}
363 |     -> (obj : FileReaderSync)
364 |     -> (blob : t2)
365 |     -> JSIO String
366 |   readAsDataURL a b = primJS $ FileReaderSync.prim__readAsDataURL a (up b)
367 |
368 |
369 |   export
370 |   readAsText' :
371 |        {auto 0 _ : JSType t2}
372 |     -> {auto 0 _ : Elem Blob (Types t2)}
373 |     -> (obj : FileReaderSync)
374 |     -> (blob : t2)
375 |     -> (encoding : Optional String)
376 |     -> JSIO String
377 |   readAsText' a b c = primJS $
378 |     FileReaderSync.prim__readAsText a (up b) (toFFI c)
379 |
380 |   export
381 |   readAsText :
382 |        {auto 0 _ : JSType t2}
383 |     -> {auto 0 _ : Elem Blob (Types t2)}
384 |     -> (obj : FileReaderSync)
385 |     -> (blob : t2)
386 |     -> JSIO String
387 |   readAsText a b = primJS $ FileReaderSync.prim__readAsText a (up b) undef
388 |
389 |
390 |
391 |
392 |
393 | --------------------------------------------------------------------------------
394 | --          Dictionaries
395 | --------------------------------------------------------------------------------
396 |
397 | namespace BlobPropertyBag
398 |
399 |   export
400 |   new' :
401 |        (type : Optional String)
402 |     -> (endings : Optional EndingType)
403 |     -> JSIO BlobPropertyBag
404 |   new' a b = primJS $ BlobPropertyBag.prim__new (toFFI a) (toFFI b)
405 |
406 |   export
407 |   new : JSIO BlobPropertyBag
408 |   new = primJS $ BlobPropertyBag.prim__new undef undef
409 |
410 |
411 |   export
412 |   endings :
413 |        {auto 0 _ : JSType t}
414 |     -> {auto 0 _ : Elem BlobPropertyBag (Types t)}
415 |     -> t
416 |     -> Attribute False Optional EndingType
417 |   endings v = fromUndefOrPrimNoDefault
418 |                 "BlobPropertyBag.getendings"
419 |                 prim__endings
420 |                 prim__setEndings
421 |                 (v :> BlobPropertyBag)
422 |
423 |
424 |   export
425 |   type :
426 |        {auto 0 _ : JSType t}
427 |     -> {auto 0 _ : Elem BlobPropertyBag (Types t)}
428 |     -> t
429 |     -> Attribute True Optional String
430 |   type v = fromUndefOrPrim
431 |              "BlobPropertyBag.gettype"
432 |              prim__type
433 |              prim__setType
434 |              ""
435 |              (v :> BlobPropertyBag)
436 |
437 |
438 |
439 | namespace FilePropertyBag
440 |
441 |   export
442 |   new' : (lastModified : Optional JSInt64) -> JSIO FilePropertyBag
443 |   new' a = primJS $ FilePropertyBag.prim__new (toFFI a)
444 |
445 |   export
446 |   new : JSIO FilePropertyBag
447 |   new = primJS $ FilePropertyBag.prim__new undef
448 |
449 |
450 |   export
451 |   lastModified :
452 |        {auto 0 _ : JSType t}
453 |     -> {auto 0 _ : Elem FilePropertyBag (Types t)}
454 |     -> t
455 |     -> Attribute False Optional JSInt64
456 |   lastModified v = fromUndefOrPrimNoDefault
457 |                      "FilePropertyBag.getlastModified"
458 |                      prim__lastModified
459 |                      prim__setLastModified
460 |                      (v :> FilePropertyBag)
461 |