tangled
alpha
login
or
join now
anil.recoil.org
/
ocaml-html5rw
1
fork
atom
OCaml HTML5 parser/serialiser based on Python's JustHTML
1
fork
atom
overview
issues
pulls
pipelines
async events
anil.recoil.org
2 months ago
f0ab67dd
8e4673cf
+23
-4
2 changed files
expand all
collapse all
unified
split
lib
js
dune
htmlrw_js.ml
+15
-3
lib/js/dune
···
24
24
(libraries htmlrw_js)
25
25
(js_of_ocaml
26
26
(javascript_files))
27
27
-
(modes js)
27
27
+
(modes js wasm)
28
28
(modules htmlrw_js_main))
29
29
30
30
; Web Worker for background validation
···
34
34
(libraries html5rw htmlrw_check bytesrw brr)
35
35
(js_of_ocaml
36
36
(javascript_files))
37
37
-
(modes js)
37
37
+
(modes js wasm)
38
38
(modules htmlrw_js_worker))
39
39
40
40
-
; Copy to nice filenames
40
40
+
; Copy to nice filenames (JS)
41
41
(rule
42
42
(targets htmlrw.js)
43
43
(deps htmlrw_js_main.bc.js)
···
47
47
(targets htmlrw-worker.js)
48
48
(deps htmlrw_js_worker.bc.js)
49
49
(action (copy %{deps} %{targets})))
50
50
+
51
51
+
; Copy to nice filenames (WASM)
52
52
+
; Note: requires wasm_of_ocaml-compiler to be installed
53
53
+
(rule
54
54
+
(targets htmlrw.wasm.js)
55
55
+
(deps htmlrw_js_main.bc.wasm.js)
56
56
+
(action (copy %{deps} %{targets})))
57
57
+
58
58
+
(rule
59
59
+
(targets htmlrw-worker.wasm.js)
60
60
+
(deps htmlrw_js_worker.bc.wasm.js)
61
61
+
(action (copy %{deps} %{targets})))
+8
-1
lib/js/htmlrw_js.ml
···
573
573
Jv.undefined
574
574
));
575
575
576
576
-
Jv.set Jv.global "html5rw" api
576
576
+
Jv.set Jv.global "html5rw" api;
577
577
+
578
578
+
(* Dispatch 'html5rwReady' event for async loaders (WASM) *)
579
579
+
let document = Jv.get Jv.global "document" in
580
580
+
let event_class = Jv.get Jv.global "CustomEvent" in
581
581
+
let event = Jv.new' event_class [| Jv.of_string "html5rwReady" |] in
582
582
+
ignore (Jv.call document "dispatchEvent" [| event |]);
583
583
+
console_log "[html5rw] API ready"