Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc: prepare the release #1827

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
menhir
menhirLib
menhirSdk
(yojson (>= 1.6)))
(yojson (>= 2.1)))
(depopts
ocamlfind)
(conflicts
Expand Down
8 changes: 4 additions & 4 deletions examples/hyperbolic/hypertree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,14 @@ let default_language () =

let language =
ref
(Js.Opt.get
(Html.window##.localStorage##getItem (Js.string "hyp_lang"))
default_language)
(Js.Optdef.case Html.window##.localStorage default_language (fun st ->
Js.Opt.get (st##getItem (Js.string "hyp_lang")) default_language))

let _ = Console.console##log !language

let set_language lang =
Html.window##.localStorage##setItem (Js.string "hyp_lang") lang;
Js.Optdef.iter Html.window##.localStorage (fun st ->
st##setItem (Js.string "hyp_lang") lang);
language := lang

let load_messages () =
Expand Down
2 changes: 1 addition & 1 deletion js_of_ocaml-compiler.opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ depends: [
"menhir"
"menhirLib"
"menhirSdk"
"yojson" {>= "1.6"}
"yojson" {>= "2.1"}
"odoc" {with-doc}
]
depopts: ["ocamlfind"]
Expand Down
21 changes: 14 additions & 7 deletions lib/js_of_ocaml/dom_html.ml
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ and keyboardEvent = object

method location : int readonly_prop

method key : js_string t readonly_prop
method key : js_string t optdef readonly_prop

method code : js_string t readonly_prop
method code : js_string t optdef readonly_prop

method isComposing : bool t readonly_prop

Expand Down Expand Up @@ -2351,9 +2351,9 @@ class type window = object

method scrollBy : number_t -> number_t -> unit meth

method sessionStorage : storage t readonly_prop
method sessionStorage : storage t optdef readonly_prop

method localStorage : storage t readonly_prop
method localStorage : storage t optdef readonly_prop

method top : window t readonly_prop

Expand Down Expand Up @@ -3368,6 +3368,10 @@ module Keyboard_code = struct

let make_unidentified _ = Unidentified

let try_next value f = function
| Unidentified -> Optdef.case value make_unidentified f
| v -> v

let run_next value f = function
| Unidentified -> f value
| v -> v
Expand All @@ -3383,8 +3387,9 @@ module Keyboard_code = struct

let ( |> ) x f = f x

let of_event (evt : keyboardEvent Js.t) =
try_code evt##.code
let of_event evt =
Unidentified
|> try_next evt##.code try_code
|> try_key_location evt
|> run_next (get_key_code evt) try_key_code_normal

Expand All @@ -3397,10 +3402,12 @@ module Keyboard_key = struct
let char_of_int value =
if 0 < value then try Some (Uchar.of_int value) with _ -> None else None

let empty_string _ = Js.string ""

let none _ = None

let of_event evt =
let key = evt##.key in
let key = Optdef.get evt##.key empty_string in
match key##.length with
| 0 -> Optdef.case evt##.charCode none char_of_int
| 1 -> char_of_int (int_of_float (Js.to_float (key##charCodeAt 0)))
Expand Down
15 changes: 11 additions & 4 deletions lib/js_of_ocaml/dom_html.mli
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ and keyboardEvent = object

method location : int readonly_prop

method key : js_string t readonly_prop
(* Chrome can send fake keyboard events without any of the expected
properties (https://chromium-review.googlesource.com/771674), so
we keep the [optdef] annotation for now *)
method key : js_string t optdef readonly_prop

method code : js_string t readonly_prop
method code : js_string t optdef readonly_prop

method isComposing : bool t readonly_prop

Expand Down Expand Up @@ -2201,9 +2204,13 @@ class type window = object

method scrollBy : number_t -> number_t -> unit meth

method sessionStorage : storage t readonly_prop
(* These two properties are not available on non-Web environments
(for instance, Web workers, node). So we keep the [optdef]
annotation for now. *)

method localStorage : storage t readonly_prop
method sessionStorage : storage t optdef readonly_prop

method localStorage : storage t optdef readonly_prop

method top : window t readonly_prop

Expand Down
1 change: 0 additions & 1 deletion tools/ci_setup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ let forked_packages =
; "base_bigstring"
; "bin_prot"
; "bonsai_test"
; "bonsai_web"
; "bonsai_web_components"
; "bonsai_web_test"
; "core"
Expand Down
6 changes: 5 additions & 1 deletion toplevel/examples/lwt_toplevel/toplevel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ module History = struct

let idx = ref 0

let get_storage () = Dom_html.window##.localStorage
let get_storage () =
match Js.Optdef.to_option Dom_html.window##.localStorage with
| exception _ -> raise Not_found
| None -> raise Not_found
| Some t -> t

let setup () =
try
Expand Down
3 changes: 1 addition & 2 deletions wasm_of_ocaml-compiler.opam
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ conflicts: [
"ocamlfind" {< "1.5.1"}
"js_of_ocaml" {< "3.0"}
]
dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git"
build: [
["dune" "subst"] {dev}
[
Expand All @@ -44,8 +45,6 @@ build: [
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git"
13 changes: 13 additions & 0 deletions wasm_of_ocaml-compiler.opam.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@doc" {with-doc}
]
]
Loading