text
stringlengths
0
601k
let iovec string = let off = 0 in let len = String . length string in { H . IOVec . buffer = Bigstringaf . of_string ~ off ~ len string ; off ; len }
let body strings = { Reqd . Body . chunks = Array . map iovec strings ; length = Array . length strings ; index = 0 ; curr = None ; }
let request ( ? headers [ ] ) = body_strings = let headers = H . Headers . of_list headers in Request . make " " ( H . Request . create ~ headers ` GET " " , body body_strings )
let to_string { H . IOVec . buffer ; off ; len } = Bigstringaf . substring ~ off ~ len buffer
let cookies = list ( pair string string )
let form_raw = result ( list ( pair string ( list string ) ) ) string
let s = " ReWeb . Request " , [ test_case " body - empty " ` Quick begin fun ( ) -> let stream , _ = [ ] || |> request |> Request . body |> Piaf . Body . to_stream in stream |> Lwt_stream . is_empty |> Lwt . map @@ check bool " " true |> Lwt_main . run end ; test_case " body - single chunk " ` Quick begin fun ( ) -> le...
module S = struct open Core_kernel . Result open Lwt open Tiny_json let graph_api_version = " 1 . 0 " let endpoint = Printf . sprintf " https :// graph . facebook . com / v % s " graph_api_version type t = { uri : Uri . t } let create access_token = { uri = Uri . add_query_param ' ( Uri . of_string endpoint ) ( " acces...
module Graphql_cohttp_lwt = Graphql_cohttp . Make ( Graphql_lwt . Schema ) ( Cohttp_lwt_unix . IO ) ( Cohttp_lwt . Body )
let schema = Graphql_lwt . Schema . ( schema [ field " hello " ~ typ ( : non_null string ) ~ args : Arg . [ arg " name " ~ typ : string ] ~ resolve ( : fun _ ( ) -> function None -> " world " | Some name -> name ) ; ] )
let response_check = Alcotest . of_pp Cohttp . Response . pp_hum
let check_body actual expected = Cohttp_lwt . Body . to_string actual >|= fun body -> Alcotest . ( check string ) " body " body expected
let check_response_action ~ rsp ~ rsp_body actual = match actual with | ` Expert _ -> Alcotest . fail " Got expert , expected response " | ` Response ( rsp ' , body ' ) -> Alcotest . check response_check " response " rsp ' rsp ; check_body body ' rsp_body
let default_uri = Uri . of_string " / graphql "
let json_content_type = Cohttp . Header . init_with " Content - Type " " application / json "
let graphql_content_type = Cohttp . Header . init_with " Content - Type " " application / graphql "
let default_response_body = Yojson . Basic . to_string ( ` Assoc [ ( " data " , ` Assoc [ ( " hello " , ` String " world " ) ] ) ] )
let test_case ~ req ~ req_body ~ rsp ~ rsp_body = Lwt_main . run ( Graphql_cohttp_lwt . execute_request schema ( ) req req_body >>= check_response_action ~ rsp ~ rsp_body )
let suite = [ ( " POST with empty body " , ` Quick , fun ( ) -> test_case ~ req ( : Cohttp . Request . make ~ meth ` : POST default_uri ) ~ req_body : Cohttp_lwt . Body . empty ~ rsp ( : Cohttp . Response . make ~ status ` : Bad_request ( ) ) ~ rsp_body " : Must provide query string " ) ; ( " POST with json body " , ` ...
module type Require_explicit_time_source = sig include module type of struct include From_kernel end module Scheduler : sig include module type of struct include Scheduler end val cycle_start : unit -> Time . t [ @@ deprecated " [ since 2016 - 02 ] Use [ Time_source ] " ] end module Date : sig include module type of st...
let capability = ( " handleTypedHoles " , ` Bool true )
module Request_params = struct type t = Uri . t let expected_params = ` Assoc [ ( " uri " , ` String " < DocumentUri " ) > ] let t_of_structured_json params : t option = match params with | ` Assoc [ ( " uri " , uri ) ] -> let uri = Uri . t_of_yojson uri in Some uri | _ -> None let parse_exn ( params : Jsonrpc . Messag...
let on_request ( ~ params : Jsonrpc . Message . Structured . t option ) ( state : State . t ) = Fiber . of_thunk ( fun ( ) -> let uri = Request_params . parse_exn params in let store = state . store in let doc = Document_store . get_opt store uri in match doc with | None -> Jsonrpc . Response . Error . raise @@ Jsonrpc...
let capability = ( " handleWrappingAstNode " , ` Bool true )
module Request_params = struct type t = { text_document_uri : Uri . t ; cursor_position : Position . t } let params_schema = ` Assoc [ ( " uri " , ` String " < DocumentUri " ) ; > ( " position " , ` String " < Position " ) > ] let of_jsonrpc_params params : t option = match params with | ` Assoc [ ( " uri " , uri ) ; (...
let on_request ~ params state = Fiber . of_thunk ( fun ( ) -> let { Request_params . text_document_uri ; cursor_position } = Request_params . of_jsonrpc_params_exn params in let doc = Document_store . get state . State . store text_document_uri in let pos = Position . logical cursor_position in let + node = Document . ...
module Paths = struct let bsconfig = " bsconfig . json " let bsbProjectRoot = ref " " let projectRoot = ref " " let rec findProjectRoot ~ dir = if Sys . file_exists ( Filename . concat dir bsconfig ) then dir else let parent = dir |> Filename . dirname in if parent = dir then if not ( Ppx_config . native ( ) ) then ( p...
let defaultConfig = let open Ppx_config in { verbose_logging = false ; output_mode = Ppx_config . String ; verbose_error_handling = ( match Sys . getenv " NODE_ENV " with | " production " -> false | _ -> true | exception Not_found -> true ) ; apollo_mode = false ; schema_file = " graphql_schema . json " ; root_director...
module JsonHelper = struct open Json . Util let mapBool option update json = try update ( json |> fun json -> json |> member option |> to_bool ) with | Json . Util . Type_error _ -> ( ) | other -> raise other let mapString option update json = try update ( json |> fun json -> json |> member option |> to_string ) with |...
let read_custom_fields json = let open Json . Util in let custom_fields = Ppx_config . custom_fields ( ) |> Hashtbl . copy in let custom_fields_result_depr = try json |> member " custom - fields " |> to_assoc with | Json . Util . Type_error _ -> [ ] | other -> raise other in let custom_fields_result = try json |> membe...
let read_config ( ) = Ppx_config . set_config defaultConfig ; Paths . setProjectRoot ( ) ; let open Json . Util in let parseConfig ( json : Json . t ) = let ppxConfig = json |> member " graphql " in let handleVerboseLogging verbose_logging = Ppx_config . update_config ( fun current -> { current with verbose_logging } )...
let keyword = List . fold_left ~ f ( : fun acc x -> StringSet . add x acc ) ~ init : StringSet . empty [ " break " ; " case " ; " catch " ; " continue " ; " debugger " ; " default " ; " delete " ; " do " ; " else " ; " finally " ; " for " ; " function " ; " if " ; " in " ; " instanceof " ; " new " ; " return " ; " swit...
let provided = List . fold_left ~ f ( : fun acc x -> StringSet . add x acc ) ~ init : StringSet . empty [ " event " ; " location " ; " window " ; " document " ; " eval " ; " navigator " ; " self " ; " Array " ; " Function " ; " Date " ; " Math " ; " JSON " ; " Object " ; " globalThis " ; " RegExp " ; " String " ; " Boo...
let rec static { e_desc = desc } = match desc with | Econst _ | Econstr0 _ -> true | Etuple ( e_list ) -> List . for_all static e_list | Erecord ( qual_e_list ) -> List . for_all ( fun ( _ , e ) -> static e ) qual_e_list | Erecord_access ( e , _ ) -> static e | _ -> false
let intro = function None -> Zident . fresh " i " | Some ( i ) -> i
let reset i_opt eq = let equation i = { eq with eq_desc = EQreset ( [ eq ] , last i Initial . typ_bool ) } in let i = intro i_opt in equation i , Some ( i )
let condition i_opt = let i = intro i_opt in last i Initial . typ_bool , Some ( i )
let intro_equation ( i_names , i_opt ) eq_list = match i_opt with | None -> eq_list , i_names | Some ( i ) -> Zaux . init i eq_list , i :: i_names
let intro ( i_names , i_opt ) n_list env eq_list = let add ( acc_n_list , acc_env_list ) i = ( Zaux . vardec i ) :: acc_n_list , Env . add i ( Deftypes . entry Deftypes . memory Initial . typ_bool ) acc_env_list in let eq_list , i_names = intro_equation ( i_names , i_opt ) eq_list in let n_list , env = List . fold_left...
let rec equation ( i_names , i_opt ) ( { eq_desc = desc } as eq ) = match desc with | EQeq ( p , ( { e_desc = Eop ( Eminusgreater , [ e1 ; e2 ] ) } as e ) ) -> let cond , i_opt = condition i_opt in { eq with eq_desc = ( i_names , i_opt ) | EQeq ( { p_desc = Evarpat ( x ) } as p , { e_desc = Eop ( Einitial , [ ] ) } ) -...
let exp ( { e_desc = desc } as e ) = let desc = match desc with | Elet ( l , e ) -> Elet ( local l , e ) | _ -> desc in { e with e_desc = desc }
let implementation impl = match impl . desc with | Efundecl ( n , ( { f_kind = D | C ; f_body = e } as body ) ) -> { impl with desc = Efundecl ( n , { body with f_body = exp e } ) } | Eopen _ | Etypedecl _ | Econstdecl _ | Efundecl _ -> impl
let implementation_list impl_list = Zmisc . iter implementation impl_list
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2015 - 02 - 02 " ] ) ; ( " Action " , [ " ResetCacheParameterGroup " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " ResetCacheParameterGroupResponse " ( snd xml ) ) ( Xml . member " ResetCacheParameterGroupResult " ) in try Util . or_error ( Util . option_bind resp CacheParameterGroupNameMessage . parse ) ( let open Error in ...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " ResetDBClusterParameterGroup " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Q...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " ResetDBClusterParameterGroupResponse " ( snd xml ) ) ( Xml . member " ResetDBClusterParameterGroupResult " ) in try Util . or_error ( Util . option_bind resp DBClusterParameterGroupNameMessage . parse ) ( let op...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2014 - 10 - 31 " ] ) ; ( " Action " , [ " ResetDBParameterGroup " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query . ...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Util . option_bind ( Xml . member " ResetDBParameterGroupResponse " ( snd xml ) ) ( Xml . member " ResetDBParameterGroupResult " ) in try Util . or_error ( Util . option_bind resp DBParameterGroupNameMessage . parse ) ( let open Error in BadRespon...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " ResetEbsDefaultKmsKeyId " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " ResetEbsDefaultKmsKeyIdResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp ResetEbsDefaultKmsKeyIdResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed ResetEbsDefaultKm...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let to_http service region req = let uri = Uri . add_query_params ( Uri . of_string ( Aws . Util . of_option_exn ( Endpoints . url_of service region ) ) ) ( List . append [ ( " Version " , [ " 2016 - 11 - 15 " ] ) ; ( " Action " , [ " ResetFpgaImageAttribute " ] ) ] ( Util . drop_empty ( Uri . query_of_encoded ( Query ...
let of_http body = try let xml = Ezxmlm . from_string body in let resp = Xml . member " ResetFpgaImageAttributeResponse " ( snd xml ) in try Util . or_error ( Util . option_bind resp ResetFpgaImageAttributeResult . parse ) ( let open Error in BadResponse { body ; message = " Could not find well formed ResetFpgaImageAtt...
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
type ' a t = { default : ' a ; init : int -> ' a ; mutable size : int ; mutable table : ' a array }
let make capacity default init = assert ( capacity >= 0 ) ; let capacity = if capacity = 0 then 1 else capacity in let table = Array . make capacity default in { default ; init ; size = 0 ; table }
let make_ capacity default = make capacity default ( fun _ -> default )
let length a = a . size
let get a i = assert ( 0 <= i && i < a . size ) ; Array . unsafe_get a . table ( i )
let set a i x = assert ( 0 <= i && i < a . size ) ; Array . unsafe_set a . table ( i ) x
let shrink a s = Array . fill a . table s ( a . size - s ) a . default ; a . size <- s
let grow a s = let n = Array . length a . table in if s > n then begin let table = Array . make ( max ( 2 * n ) s ) a . default in Array . blit a . table 0 table 0 n ; a . table <- table end ; let init = a . init and table = a . table in for i = a . size to s - 1 do Array . unsafe_set table i ( init i ) done ; a . size...
let resize a s = assert ( 0 <= s ) ; if s < a . size then shrink a s else if s > a . size then grow a s
let push a x = let s = a . size in begin let s = s + 1 in let n = Array . length a . table in if s > n then begin let table = Array . make ( 2 * n ) a . default in Array . blit a . table 0 table 0 n ; a . table <- table end ; a . size <- s end ; Array . unsafe_set a . table ( s ) x
let pop a = let s = a . size in assert ( s > 0 ) ; let s = s - 1 in a . size <- s ; let table = a . table in let x = Array . unsafe_get table ( s ) in Array . unsafe_set table ( s ) a . default ; x
let default a = a . default
object method inlineSize : float Js . readonly_prop method blockSize : float Js . readonly_prop end object method target : Dom . node Js . t Js . readonly_prop method contentRect : Dom_html . clientRect Js . t Js . readonly_prop method borderBoxSize : resizeObserverSize Js . t Js . js_array Js . t Js . readonly_prop me...
let empty_resize_observer_options ( ) : resizeObserverOptions Js . t = Js . Unsafe . obj [ ] ||
let is_supported ( ) = Js . Optdef . test resizeObserver
let resizeObserver : ( ( resizeObserverEntry Js . t Js . js_array Js . t -> resizeObserver Js . t -> unit ) Js . callback -> resizeObserver Js . t ) Js . constr = resizeObserver
let observe ( ~ node : # Dom . node Js . t ) ( ~ f : resizeObserverEntry Js . t Js . js_array Js . t -> resizeObserver Js . t -> unit ) ( ? box : Js . js_string Js . t option ) ( ) : resizeObserver Js . t = let obs = new % js resizeObserver ( Js . wrap_callback f ) in ( match box with | None -> obs ## observe node | So...
let set_cursor s = Dom_html . window . ## document . ## body . ## style . ## cursor := Js . string s
module Mouse_event = struct module T = struct type t = | Down | Up | Move [ @@ deriving sexp , compare , equal ] end include T include Comparable . Make ( T ) let to_dom_html = function | Down -> Dom_html . Event . mousedown | Up -> Dom_html . Event . mouseup | Move -> Dom_html . Event . mousemove ; ; end
module State = struct type t = { mutable listeners : Dom . event_listener_id Mouse_event . Map . t ; mutable animation_id : Dom_html . animation_frame_request_id ; mutable mouse_x : int option } [ @@ deriving fields ] let create ( ) = let animation_id = request_animation_frame ( Fn . const ( ) ) in Fields . create ~ li...
let get_parent element = let % bind . Option parent = Js . Opt . to_option element . ## parentNode in Js . Opt . to_option ( Dom_html . CoerceTo . element parent ) ; ;
let rec do_update_width target state = let ( _ : unit option ) = let open Option . Let_syntax in let % bind mouse_x = State . mouse_x state in let % bind target = Js . Opt . to_option target in let % bind parent = get_parent target in let rect = parent ## getBoundingClientRect in let left = rect . ## left in let new_wi...
module T = struct module Input = struct include Unit let combine ( ) ( ) = ( ) end module State = State let init ( ) element = let state = State . create ( ) in let on_mouse_move _ event = State . set_mouse_x state event . ## clientX in let on_mouse_up _ _ = set_cursor " initial " ; State . remove_mouse_event state ~ e...
module Hook = Vdom . Attr . Hooks . Make ( T )
let attr = Vdom . Attr . create_hook " resizer " ( Hook . create ( ) )
' a array -> int -> ' a array -> int -> int -> unit = " caml_array_blit "
module Make ( Resize : Vec_gen . ResizeType ) ResizeType = struct type elt = Resize . t let null = Resize . null
type t = { mutable arr : elt array ; mutable len : int ; }
let length d = d . len
let compact d = let d_arr = d . arr in if d . len <> Array . length d_arr then begin let newarr = unsafe_sub d_arr 0 d . len in d . arr <- newarr end
let singleton v = { len = 1 ; arr = [ | v ] | }
let empty ( ) = { len = 0 ; arr = [ ] ; || }
let is_empty d = d . len = 0
let reset d = d . len <- 0 ; d . arr <- [ ] ||
let to_list d = let rec loop ( d_arr : elt array ) array idx accum = if idx < 0 then accum else loop d_arr ( idx - 1 ) 1 ( Array . unsafe_get d_arr idx :: accum ) accum in loop d . arr ( d . len - 1 ) 1 [ ]
let of_list lst = let arr = Array . of_list lst in { arr ; len = Array . length arr } arr
let to_array d = unsafe_sub d . arr 0 d . len
let of_array src = { len = Array . length src ; arr = Array . copy src ; }
let of_sub_array arr off len = { len = len ; arr = Array . sub arr off len }
let unsafe_internal_array v = v . arr
let copy src = let len = src . len in { len ; arr = unsafe_sub src . arr 0 len ; }
let reverse_in_place src = Ext_array . reverse_range src . arr 0 src . len