Skip to content

Commit

Permalink
Move brr-lwd-ui to its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Aug 21, 2024
1 parent ffe4021 commit 0376562
Show file tree
Hide file tree
Showing 47 changed files with 112 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bin/db_worker/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
(js_of_ocaml
(flags
(:standard --no-inline --source-map-inline --pretty)))
(libraries js_of_ocaml brrer lib data_source db))
(libraries js_of_ocaml brr-lwd-ui.brrer lib data_source db))
4 changes: 2 additions & 2 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
(flags :standard -open Brrer)
(libraries
js_of_ocaml
brrer
lwd
brr-lwd
ocamix.brr-lwd-ui
brr-lwd-ui
brr-lwd-ui.brrer
lib
data_source
db
Expand Down
6 changes: 0 additions & 6 deletions lib/brr_lwd_ui/dune

This file was deleted.

2 changes: 1 addition & 1 deletion lib/db/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name db)
(libraries std brrer yojson data_source worker_api)
(libraries std brr-lwd-ui.brrer yojson data_source worker_api)
(flags :standard -open Ppx_yojson_conv_lib.Yojson_conv.Primitives)
(preprocess
(pps ppx_yojson_conv)))
1 change: 0 additions & 1 deletion lib/std/std.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include ContainersLabels
module FFCache = FFCache

module String = struct
include String
Expand Down
1 change: 1 addition & 0 deletions vendor/brr_lwd_ui/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.26.2
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/brrer/dune → vendor/brr_lwd_ui/brrer/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name brrer)
(public_name ocamix.brrer)
(public_name brr-lwd-ui.brrer)
(libraries brr))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions vendor/brr_lwd_ui/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(lang dune 3.11)

(generate_opam_files)

(source
(github voodoos/brr-lwd-ui))

(license AGPL-3.0)

(authors "Ulysse G\195\169rard")

(maintainers "")

(package
(allow_empty)
(name brr-lwd-ui)
(synopsis "UI components for use with with brr_lwd")
(description "A _really_ long description")
(depends containers js_of_ocaml js_of_ocaml-ppx brr lwd brr-lwd))
8 changes: 8 additions & 0 deletions vendor/brr_lwd_ui/examples/virtual-table/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(executable
(name main)
(modes js)
(promote (until-clean))
(js_of_ocaml
(flags
(:standard --no-inline)))
(libraries js_of_ocaml lwd brr-lwd brr-lwd-ui))
14 changes: 14 additions & 0 deletions vendor/brr_lwd_ui/examples/virtual-table/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<title>OCAMIX</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./brr_lwd_ui.css">
</head>

<body>
<script src="main.bc.js"></script>
</body>

</html>
16 changes: 16 additions & 0 deletions vendor/brr_lwd_ui/examples/virtual-table/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
open Brr
open Brr_lwd

let app = Elwd.div [ `P (El.txt' "toto") ]

let _ =
let on_load _ =
let app = Lwd.observe @@ app in
let on_invalidate _ =
ignore @@ G.request_animation_frame
@@ fun _ -> ignore @@ Lwd.quick_sample app
in
El.append_children (Document.body G.document) [ Lwd.quick_sample app ];
Lwd.set_on_invalidate app on_invalidate
in
Ev.listen Ev.dom_content_loaded on_load (Window.as_target G.window)
2 changes: 1 addition & 1 deletion lib/brr_lwd_ui/attrs.ml → vendor/brr_lwd_ui/lib/attrs.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Std
open Import

module Classes = struct
include String.Set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open! Std
open! Import
open Brr
open Brr_lwd

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open! Std
open! Import
open Brr
open Brr_lwd

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions vendor/brr_lwd_ui/lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(include_subdirs unqualified)

(library
(name brr_lwd_ui)
(public_name brr-lwd-ui)
(libraries containers containers-data brrer lwd brr-lwd base64))
13 changes: 13 additions & 0 deletions vendor/brr_lwd_ui/lib/encodings.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
open Import

let to_jstr t = Jv.repr t |> Brr.Json.encode
let to_jv t = to_jstr t |> Jv.of_jstr

let of_jstr jstr =
match Brr.Json.decode jstr with
| Ok v -> Ok (Obj.magic v)
| Error err ->
Brr.Console.error [ err ];
Error (`Msg "Failed to unmarshal data")

let of_jv jv = Jv.to_jstr jv |> of_jstr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open! Std
open! Brrer.Brr
open! Import
open Brrer.Brr
open! Brr_lwd
module A = Attrs

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
open! Std
open! Brrer
open! Import
open! Brr
open! Brr_lwd

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open! Std
open! Import
open! Brrer
open! Brr
open! Brr_lwd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open! Std
open! Import
open! Brrer
open! Brr
open! Brr_lwd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Std
open Import
open Brrer.Brr
open Brr_lwd
module Field = Field
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions vendor/brr_lwd_ui/lib/import.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include ContainersLabels
module Brr = Brrer.Brr

(** [tee f x] applies [f] to [x] and returns [x] *)
let tee f x =
let () = f x in
x

module String = struct
include String
module Set = Set.Make (String)
end

module Lwd = struct
include Lwd
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open! Std
open Import
module B64 = Base64
open! Brr
module Storage = Brr_io.Storage
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
open Std
open Brrer
open Import
open Brr
open Brr_lwd

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
might be possible to optimize it (especially the "uniqueue" LRU thingy),
but having too large a lwd_table is probably a hard limit. *)

open Std
open Import
open Brrer
open Brr
open Brr_lwd
Expand Down Expand Up @@ -141,7 +141,7 @@ let make (type data) ~(ui_table : Schema.fixed_row_height)
(* todo: We do way too much work and rebuild the queue each
time... it's very ineficient *)
add ~fetch ~max_items:(4 * List.length visible_rows) visible_rows)
in
in
Lwd.map2 total_items update ~f:(fun total_items update ->
prepare ~total_items ~render;
update)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/brr_lwd_ui/utils.ml → vendor/brr_lwd_ui/lib/utils.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Std
open Import
open Brr

type 'a one_maybe_reactive = [ `P of 'a | `R of 'a Lwd.t ]
Expand Down

0 comments on commit 0376562

Please sign in to comment.