Skip to content

refactor: carry over post-monorepo pre-alpha cleanup#252

Merged
tsnobip merged 3 commits intomonorepofrom
carryover/post-249-pre-alpha
Apr 19, 2026
Merged

refactor: carry over post-monorepo pre-alpha cleanup#252
tsnobip merged 3 commits intomonorepofrom
carryover/post-249-pre-alpha

Conversation

@jderochervlk
Copy link
Copy Markdown
Collaborator

Summary

  • port the surviving post-pre-alpha cleanup onto the Split webAPI into multiple subpackages #249 monorepo split
  • add the missing concrete modules and translate the fetch/runtime/canvas/websocket/media API cleanup into package-local
    surfaces
  • keep the carryover green with the related test updates

Test Plan

  • npm run build
  • npm test

Port the surviving API cleanup from the final pre-alpha branch onto the monorepo split introduced in #249.

This adds the missing concrete modules, translates the fetch/runtime/canvas/websocket/media surface cleanup into the package layout, and keeps the branch green with updated tests.
*/
@new
external make2: Types.mediaStream => Types.mediaStream = "MediaStream"
external make2: t => t = "MediaStream"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
external make2: t => t = "MediaStream"
external makeFromMediaStream: t => t = "MediaStream"

*/
@new
external make3: array<Types.mediaStreamTrack> => Types.mediaStream = "MediaStream"
external make3: array<MediaStreamTrack.t> => t = "MediaStream"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
external make3: array<MediaStreamTrack.t> => t = "MediaStream"
external makeFromMediaStreams: array<MediaStreamTrack.t> => t = "MediaStream"

Comment on lines +1 to +14
type t = Types.formDataEntryValue

external fromString: string => t = "%identity"
external fromFile: WebApiFile.File.t => t = "%identity"

type decoded =
| String(string)
| File(WebApiFile.File.t)

let decode = (t: t): decoded =>
switch t {
| Types.String(value) => String(value)
| Types.File(file) => File(file)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formDataEntryValue can be replaced with a unboxed variant, was done here:
03277f7#diff-d4a2e4ec907d1df1e5420e4f844ef31a97a80624a93463ca8a52d6b0be08274eR220-R223

Comment on lines +5 to +21
type messageEvent<'t> = {
...event,
data: 't,
origin: string,
lastEventId: string,
source: Null.t<messageEventSource>,
ports: array<WebApiChannelMessaging.Types.messagePort>,
}

type messageEventInit<'t> = {
...WebApiEvent.Types.eventInit,
mutable data?: 't,
mutable origin?: string,
mutable lastEventId?: string,
mutable source?: Null.t<messageEventSource>,
mutable ports?: array<WebApiChannelMessaging.Types.messagePort>,
}
Copy link
Copy Markdown
Member

@tsnobip tsnobip Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be inside packages/WebSockets/src/Types.res

Comment thread tests/FetchAPI/Request__test.res Outdated
Comment on lines +3 to +14
let blob: WebApiFile.Blob.t = WebApiFile.Blob.make(~blobParts=[])
let file: WebApiFile.File.t = WebApiFile.File.make(~fileBits=[], ~fileName="hello.txt")
let params: WebApiURL.URLSearchParams.t = WebApiURL.URLSearchParams.fromString("greeting=hello")
let formData: WebApiFetch.FormData.t = WebApiFetch.FormData.make()
let stream: WebApiFile.ReadableStream.t<array<int>> = WebApiFile.ReadableStream.make()

let stringBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromString("hello")
let blobBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromBlob(blob)
let fileBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromFile(file)
let paramsBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromURLSearchParams(params)
let formDataBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromFormData(formData)
let streamBody: WebApiFetch.BodyInit.t = WebApiFetch.BodyInit.fromReadableStream(stream)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be annotated, probably better defined inline

Comment thread tests/FetchAPI/Response__test.res Outdated
Comment on lines +1 to +6
let headers: WebApiFetch.HeadersInit.t = WebApiFetch.HeadersInit.fromDict(dict{"X-Fruit": "Peach"})
let blob: WebApiFile.Blob.t = WebApiFile.Blob.make(~blobParts=[])
let file: WebApiFile.File.t = WebApiFile.File.make(~fileBits=[], ~fileName="pong.txt")
let params: WebApiURL.URLSearchParams.t = WebApiURL.URLSearchParams.fromString("fruit=peach")
let formData: WebApiFetch.FormData.t = WebApiFetch.FormData.make()
let stream: WebApiFile.ReadableStream.t<array<int>> = WebApiFile.ReadableStream.make()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread tests/Global__test.res Outdated
Comment on lines +53 to +58
let _setIntervalWithCallback = WebApiDOM.Window.setIntervalWithCallback
let _alertWithMessage = WebApiDOM.Window.alertWithMessage
let _postMessageWithOptions = WebApiDOM.Window.postMessageWithOptions
let _scrollXY = WebApiDOM.Window.scrollXY
let _scrollToXY = WebApiDOM.Window.scrollToXY
let _scrollByXY = WebApiDOM.Window.scrollByXY
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely useless

Comment thread packages/DOM/src/Window.res Outdated
@@ -402,6 +414,12 @@ external alert: Types.window => unit = "alert"
@send
external alert2: (Types.window, string) => unit = "alert"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be replaced by the following bindings

Comment thread packages/DOM/src/Window.res Outdated
Comment on lines 538 to 539
@send
external scroll2: (Types.window, ~x: float, ~y: float) => unit = "scroll"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be replaced by the following binding

Comment thread packages/DOM/src/Window.res Outdated
Comment on lines 556 to 557
@send
external scrollTo2: (Types.window, ~x: float, ~y: float) => unit = "scrollTo"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread packages/DOM/src/Window.res Outdated
Comment on lines 574 to 575
@send
external scrollBy2: (Types.window, ~x: float, ~y: float) => unit = "scrollBy"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

jderochervlk and others added 2 commits April 19, 2026 04:06
Drop scroll2/scrollTo2/scrollBy2 and keep the descriptive *XY overload names requested in review.

Co-authored-by: Codex <codex@openai.com>
…with-commits-and-responses

Address review feedback: rename constructors, unbox FormDataEntryValue, reuse MessageEvent types, simplify tests
@tsnobip tsnobip merged commit 33e5d39 into monorepo Apr 19, 2026
tsnobip added a commit that referenced this pull request Apr 19, 2026
* clean types in Prelude

* split into subpackages

* add back getter functions for Window

* move back Navigator to DOM

* remove globals package

* delete files that should not be versioned

* add some more typealiases in DOM/Types

* format

* delete JS files

* format package.json

* fix docs generation

* change namespace to `@rescript/webapi-[section]`

* publish all subpackages in CI

* refactor: carry over post-monorepo pre-alpha cleanup (#252)

* refactor: carry over post-monorepo pre-alpha cleanup

Port the surviving API cleanup from the final pre-alpha branch onto the monorepo split introduced in #249.

This adds the missing concrete modules, translates the fetch/runtime/canvas/websocket/media surface cleanup into the package layout, and keeps the branch green with updated tests.

* refactor(DOM): remove numeric scroll overloads

Drop scroll2/scrollTo2/scrollBy2 and keep the descriptive *XY overload names requested in review.

Co-authored-by: Codex <codex@openai.com>

---------

Co-authored-by: Codex <codex@openai.com>

* format

* simplify FOrmDataEntryValue type

* clean alert and postMessage

* fix CI

* remove useless namespace

* mark bindings of classes/interfaces as private records to prevent creation

records that have mutable fields were not marked as private for now
because mutating these mutable fields is not allowed

* format

* add missing getters for Navigator

* add Window.t type

---------

Co-authored-by: Josh Vlk <josh@vlkpack.com>
Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants