Skip to content

Commit 2097c92

Browse files
committed
remove EventTypes file
1 parent 535c6a1 commit 2097c92

37 files changed

Lines changed: 211 additions & 253 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ and add `@rescript/webapi` to your `rescript.json`:
2525
## Usage
2626

2727
```rescript
28-
let location = WebAPI.Base.window->WebAPI.Window.location
28+
let location = WebAPI.DOM_.window->WebAPI.Window.location
2929
let href = location.href
3030
location->WebAPI.Location.reload
3131
```

docs/content/docs/api-surface.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ add the package to `rescript.json`:
1313
}
1414
```
1515

16-
Use `WebAPI.Base.window` for the browser `window`. Interface-specific methods live on
16+
Use `WebAPI.DOM_.window` for the browser `window`. Interface-specific methods live on
1717
public modules such as `WebAPI.Window`, `WebAPI.Location`, `WebAPI.Document`,
1818
`WebAPI.Element`, `WebAPI.Request`, and `WebAPI.Response`.
1919

2020
```ReScript
21-
let location = WebAPI.Base.window->WebAPI.Window.location
21+
let location = WebAPI.DOM_.window->WebAPI.Window.location
2222
let href = location.href
2323
2424
location->WebAPI.Location.reload
@@ -32,7 +32,7 @@ helper modules.
3232
```ReScript
3333
let req: WebAPI.Request.t = WebAPI.Request.fromURL("https://example.com")
3434
let headers = WebAPI.Headers.make()
35-
let document = WebAPI.Base.window->WebAPI.Window.document
35+
let document = WebAPI.DOM_.window->WebAPI.Window.document
3636
let element = document->WebAPI.Document.createElement("button")
3737
```
3838

@@ -243,7 +243,7 @@ let redirect = WebAPI.Response.redirect(~url="/login", ~status=302)
243243
DOM values are operated on through public interface modules.
244244

245245
```ReScript
246-
let document = WebAPI.Base.window->WebAPI.Window.document
246+
let document = WebAPI.DOM_.window->WebAPI.Window.document
247247
248248
let maybeButton = document
249249
->WebAPI.Document.querySelector("button")
@@ -271,7 +271,7 @@ let node = element->WebAPI.Element.asNode
271271
`Window.visualViewport` returns a nullable `WebAPI.VisualViewport.t`.
272272

273273
```ReScript
274-
let maybeViewport = WebAPI.Base.window
274+
let maybeViewport = WebAPI.DOM_.window
275275
->WebAPI.Window.visualViewport
276276
->Null.toOption
277277

docs/content/docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const rescriptJson = `
5151
After installing the package , you can use bindings for the various Web APIs as defined in [MDN](https://developer.mozilla.org/en-US/docs/Web/API).
5252

5353
export const rescriptSample = `
54-
let location = WebAPI.Base.window->WebAPI.Window.location
54+
let location = WebAPI.DOM_.window->WebAPI.Window.location
5555
5656
// Access properties using \`.\`
5757
let href = location.href

docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ The unified build keeps the original flat module surface instead of adding gener
124124
- `WebAPI.Headers`
125125
- `WebAPI.URL`
126126

127-
Shared DOM base types should be owned by `DOM`, so common references stay short, for example `DOM.element` instead of `BaseDOM.element` or `Base.DOM.element`.
127+
Shared DOM base types should be owned by `DOM`, so common references stay short, for example `DOM.element` instead of `BaseDOM.element` or `DOM_.DOM.element`.
128128

129129
## Internal Module Naming
130130

src/Base/BaseCSSFontLoading.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type fontFaceSetLoadStatus =
1313
*/
1414
@editor.completeFrom(BaseCSSFontLoading.FontFaceSet)
1515
type rec fontFaceSet = private {
16-
...BaseEvent.eventTarget,
16+
...DOM_.eventTarget,
1717
/**
1818
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/ready)
1919
*/

src/Base/BaseEncryptedMediaExtensions.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This WebApiEncryptedMediaExtensions API interface represents a context for mess
6161
*/
6262
@editor.completeFrom(BaseEncryptedMediaExtensions.MediaKeySession)
6363
type mediaKeySession = private {
64-
...BaseEvent.eventTarget,
64+
...DOM_.eventTarget,
6565
/**
6666
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaKeySession/sessionId)
6767
*/

src/Base/DOM.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ type barProp = {
349349
*/
350350
@editor.completeFrom(DOM.ScreenOrientation)
351351
type screenOrientation = private {
352-
...BaseEvent.eventTarget,
352+
...DOM_.eventTarget,
353353
/**
354354
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/type)
355355
*/
@@ -2310,7 +2310,7 @@ TODO: mark as private once mutating fields of private records is allowed
23102310
*/
23112311
@editor.completeFrom(DOM.Node)
23122312
type rec node = {
2313-
...BaseEvent.eventTarget,
2313+
...DOM_.eventTarget,
23142314
/**
23152315
Returns the type of node.
23162316
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType)
@@ -6972,7 +6972,7 @@ Stores information on a media query applied to a document, and handles sending n
69726972
*/
69736973
@editor.completeFrom(DOM.MediaQueryList)
69746974
type mediaQueryList = private {
6975-
...BaseEvent.eventTarget,
6975+
...DOM_.eventTarget,
69766976
/**
69776977
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaQueryList/media)
69786978
*/
@@ -7045,7 +7045,7 @@ type timeRanges = private {
70457045
*/
70467046
@editor.completeFrom(DOM.TextTrackList)
70477047
type textTrackList = private {
7048-
...BaseEvent.eventTarget,
7048+
...DOM_.eventTarget,
70497049
/**
70507050
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextTrackList/length)
70517051
*/
Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,49 @@ type eventInit = {
8080
The ExtendableEvent interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle.
8181
[See ExtendableEvent on MDN](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
8282
*/
83+
@editor.completeFrom(ExtendableEvent)
8384
type extendableEvent = private {
8485
...event,
8586
}
8687

87-
type abortSignal = private {}
88+
/**
89+
A controller object that allows you to abort one or more WebApiDOM requests as and when desired.
90+
[See AbortController on MDN](https://developer.mozilla.org/docs/Web/API/AbortController)
91+
*/
92+
@editor.completeFrom(AbortController)
93+
type rec abortController = private {
94+
/**
95+
Returns the AbortSignal object associated with this object.
96+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
97+
*/
98+
signal: abortSignal,
99+
}
100+
/**
101+
A signal object that allows you to communicate with a WebApiDOM request (such as a WebApiFetch) and abort it if required via an AbortController object.
102+
[See AbortSignal on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal)
103+
*/
104+
and abortSignal = private {
105+
...eventTarget,
106+
/**
107+
Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
108+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
109+
*/
110+
aborted: bool,
111+
/**
112+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
113+
*/
114+
reason: JSON.t,
115+
}
88116

89-
type eventListener<'event> = 'event => unit
117+
module EventListener = {
118+
type t<'event> = 'event => unit
90119

91-
type eventListenerOptions = {mutable capture?: bool}
120+
type options = {mutable capture?: bool}
92121

93-
type addEventListenerOptions = {
94-
...eventListenerOptions,
95-
mutable passive?: bool,
96-
mutable once?: bool,
97-
mutable signal?: abortSignal,
122+
type addEventListenerOptions = {
123+
...options,
124+
mutable passive?: bool,
125+
mutable once?: bool,
126+
mutable signal?: abortSignal,
127+
}
98128
}

src/DOM/DomTypes.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ type barProp = {
334334
*/
335335
@editor.completeFrom(ScreenOrientation)
336336
type screenOrientation = private {
337-
...Base.eventTarget,
337+
...DOM_.eventTarget,
338338
/**
339339
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/type)
340340
*/
@@ -1804,7 +1804,7 @@ The CanvasRenderingContext2D interface, part of the WebApiCanvas API, provides t
18041804
type canvasRenderingContext2D
18051805

18061806
type rec animation = {
1807-
...Base.eventTarget,
1807+
...DOM_.eventTarget,
18081808
/**
18091809
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/id)
18101810
*/

src/DOM/Window.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type t = Base.window = private {...Base.window}
1+
type t = DOM_.window = private {...DOM_.window}
22
type windowPostMessageOptions = DomTypes.windowPostMessageOptions
33

44
include EventTarget.Impl({type t = t})

0 commit comments

Comments
 (0)