From 00460820ba627300bf236ed105513e465e957f85 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 19 Jan 2025 01:42:30 -0800 Subject: [PATCH] runtime(Js.{FormData,Blob,File}): port @mel.send externals to use @mel.this --- jscomp/runtime/js_blob.ml | 3 ++- jscomp/runtime/js_file.ml | 3 ++- jscomp/runtime/js_formData.ml | 16 ++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/jscomp/runtime/js_blob.ml b/jscomp/runtime/js_blob.ml index e130fb86e..0c27fad28 100644 --- a/jscomp/runtime/js_blob.ml +++ b/jscomp/runtime/js_blob.ml @@ -64,7 +64,8 @@ external bytes : t -> Js.uint8Array Js.promise = "bytes" (** [bytes t] returns a Promise that resolves with a [Js.uint8Array] containing the contents of the blob as an array of bytes. *) -external slice : ?start:int -> ?end_:int -> ?contentType:string -> t -> t +external slice : + ?start:int -> ?end_:int -> ?contentType:string -> (t[@mel.this]) -> t = "slice" [@@mel.send] (** [slice ?start ?end_ ?contentType t] creates and returns a new Blob object diff --git a/jscomp/runtime/js_file.ml b/jscomp/runtime/js_file.ml index 5d18fb726..c7785195b 100644 --- a/jscomp/runtime/js_file.ml +++ b/jscomp/runtime/js_file.ml @@ -87,7 +87,8 @@ external bytes : t -> Js.uint8Array Js.promise = "bytes" (** [bytes t] returns a Promise that resolves with a [Js.uint8Array] containing the contents of the file as an array of bytes. *) -external slice : ?start:int -> ?end_:int -> ?contentType:string -> t -> t +external slice : + ?start:int -> ?end_:int -> ?contentType:string -> (t[@mel.this]) -> t = "slice" [@@mel.send] (** [slice ?start ?end_ ?contentType t] creates and returns a new File object diff --git a/jscomp/runtime/js_formData.ml b/jscomp/runtime/js_formData.ml index 94d1deb8d..86abaa8bc 100644 --- a/jscomp/runtime/js_formData.ml +++ b/jscomp/runtime/js_formData.ml @@ -43,7 +43,7 @@ external append : value: ([ `String of string | `Object of < .. > Js.t | `Dict of _ Js.dict ] [@mel.unwrap]) -> - t -> + (t[@mel.this]) -> unit = "append" [@@mel.send] (** [append t ~name ~value] appends a new value onto an existing key inside a @@ -53,7 +53,7 @@ external appendBlob : name:string -> value:([ `Blob of Js.blob | `File of Js.file ][@mel.unwrap]) -> ?filename:string -> - t -> + (t[@mel.this]) -> unit = "append" [@@mel.send] (** [appendBlob t ~name ~value] appends a new value onto an existing key inside @@ -61,17 +61,17 @@ external appendBlob : method differs from [append] in that instances in the Blob hierarchy can pass a third filename argument. *) -external delete : name:string -> t -> unit = "delete" +external delete : name:string -> (t[@mel.this]) -> unit = "delete" [@@mel.send] (** [delete t ~name] deletes a key and its value(s) from a FormData object. *) -external get : name:string -> t -> entryValue option = "get" +external get : name:string -> (t[@mel.this]) -> entryValue option = "get" [@@mel.send] [@@mel.return null_to_opt] (** [get t ~name] returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use {!getAll} instead. *) -external getAll : name:string -> t -> entryValue array = "getAll" +external getAll : name:string -> (t[@mel.this]) -> entryValue array = "getAll" [@@mel.send] (** [getAll t ~name] returns all the values associated with a given key from within a FormData object. *) @@ -80,7 +80,7 @@ external set : name:string -> ([ `String of string | `Object of < .. > Js.t | `Dict of _ Js.dict ] [@mel.unwrap]) -> - t -> + (t[@mel.this]) -> unit = "set" [@@mel.send] (** [set t ~name ~value] sets a new value for an existing key inside a FormData @@ -90,7 +90,7 @@ external setBlob : name:string -> ([ `Blob of Js.blob | `File of Js.file ][@mel.unwrap]) -> ?filename:string -> - t -> + (t[@mel.this]) -> unit = "set" [@@mel.send] (** [setBlob t ~name ~value ?filename] sets a new value for an existing key @@ -98,7 +98,7 @@ external setBlob : exist. This method differs from [set] in that instances in the Blob hierarchy can pass a third filename argument. *) -external has : name:string -> t -> bool = "has" +external has : name:string -> (t[@mel.this]) -> bool = "has" [@@mel.send] (** [has ~name t] returns whether a FormData object contains a certain key. *)