Skip to content

fix method parameter for requestInit with rescript v11 #129

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

Merged
merged 3 commits into from
Jan 16, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

## main

# 0.9.1

#### :bug: Bug Fix

- Fix binding compatibility with ReScript 11, which removed `_` variable mangling. https://github.com/TheSpyder/rescript-webapi/pull/129

## 0.9.0

#### :boom: Breaking Change
Expand Down
11 changes: 8 additions & 3 deletions src/Webapi/Webapi__Blob.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Impl = (

@get external size: T.t => float = "size"

@send external slice: (T.t, ~start: int=?, ~end_: int=?, ~contentType: string=?, unit) => T.t = "slice"
@send
external slice: (T.t, ~start: int=?, ~end_: int=?, ~contentType: string=?, unit) => T.t = "slice"

@send external stream: T.t => Webapi__ReadableStream.t = "stream"

Expand All @@ -27,7 +28,11 @@ type endingType = [#transparent | #native]
type blobPropertyBag

@obj
external makeBlobPropertyBag: (~_type: string=?, ~endings: endingType=?, unit) => blobPropertyBag = ""
external makeBlobPropertyBag: (
@as("type") ~_type: string=?,
~endings: endingType=?,
unit,
) => blobPropertyBag = ""

type blobPart

Expand All @@ -45,4 +50,4 @@ external int32ArrayToBlobPart: Js.Typed_array.Int32Array.t => blobPart = "%ident
external uint32ArrayToBlobPart: Js.Typed_array.Uint32Array.t => blobPart = "%identity"
external float32ToBlobPart: Js.Typed_array.Float32Array.t => blobPart = "%identity"
external float64ArrayToBlobPart: Js.Typed_array.Float64Array.t => blobPart = "%identity"
external dataViewToBlobPart: Js.Typed_array.DataView.t => blobPart = "%identity"
external dataViewToBlobPart: Js.Typed_array.DataView.t => blobPart = "%identity"
10 changes: 5 additions & 5 deletions src/Webapi/Webapi__Fetch.res
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ module RequestInit = {

@obj
external make: (
~_method: string=?,
@as("method") ~_method: string=?,
~headers: headersInit=?,
~body: bodyInit=?,
~referrer: string=?,
Expand All @@ -336,7 +336,7 @@ module RequestInit = {
~integrity: string="",
~keepalive: option<bool>=?,
~signal: option<signal>=?,
()
(),
) =>
make(
~_method=?map(encodeRequestMethod, method_),
Expand All @@ -351,7 +351,7 @@ module RequestInit = {
~integrity,
~keepalive?,
~signal?,
()
(),
)
}

Expand Down Expand Up @@ -403,7 +403,7 @@ module ResponseInit = {
~status: option<int>=?,
~statusText: option<string>=?,
~headers: option<headersInit>=?,
()
(),
) => make(~status?, ~statusText?, ~headers?, ())
}

Expand Down Expand Up @@ -436,4 +436,4 @@ module Response = {
@val external fetch: string => Js.Promise.t<response> = "fetch"
@val external fetchWithInit: (string, requestInit) => Js.Promise.t<response> = "fetch"
@val external fetchWithRequest: request => Js.Promise.t<response> = "fetch"
@val external fetchWithRequestInit: (request, requestInit) => Js.Promise.t<response> = "fetch"
@val external fetchWithRequestInit: (request, requestInit) => Js.Promise.t<response> = "fetch"
7 changes: 3 additions & 4 deletions src/Webapi/Webapi__File.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ include Webapi__Blob.Impl({
type t = t
})


type filePropertyBag

@obj
external makeFilePropertyBag: (
~endings: Webapi__Blob.endingType=?,
~_type: string=?,
@as("type") ~_type: string=?,
~lastModified: float=?,
unit,
) => filePropertyBag = ""

@@text("{1 File class}")

@new external make: (array<Webapi__Blob.blobPart>, string) => t = "File"
@new external makeWithOptions: (array<Webapi__Blob.blobPart>, string, filePropertyBag) => t = "File";
@new external makeWithOptions: (array<Webapi__Blob.blobPart>, string, filePropertyBag) => t = "File"

@get external lastModified: t => float = "lastModified"

@get external name: t => string = "name"
@get external name: t => string = "name"