Skip to content

refactor: restructure Event and related files#282

Open
jderochervlk wants to merge 23 commits into
mainfrom
codex/event-api-split
Open

refactor: restructure Event and related files#282
jderochervlk wants to merge 23 commits into
mainfrom
codex/event-api-split

Conversation

@jderochervlk

@jderochervlk jderochervlk commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

This started out as having AI try and re-approach the changes to my earlier PR, but it quickly failed to really grasp what I was trying to do. I took what it started to do and did a refactor without AI and I think it's finally moving into the right direction.

This removes the BaseTypes.res file to simplify and make what is shown in the IDE more consistent, for example you will always see DOM.event instead of BaseEvent.t or Event.t = private BaseEvent.t. I also removed the t alias in the event files. At first this seemed like a good idea so we could have Event.t instead of DOM.event, but it leads to more dependencies back to Event which we want to avoid. Now everywhere just references DOM.event.

After this PR I think that these are the next steps:

  • DOM.res will continue to evolve to be the file that just about everything depends on.
  • DomGlobal.res will go away. It's not useful to just have everything globally available with slighly different bindings when we can just use DOM.window->Window.scrollbars instead of DomGlobal.scrollbars. This means we can share bindings and also add in Self.scrollbars etc...
  • DomTypes will go away and be combined with DOM and spread out across modules better
  • DOM can be reduced in size by moving more out of it, such as location and navigator. These are modules that can be accessed by getting them from the module directly or from Window if needed. DOM should just be the essentials and mostly types.

@jderochervlk jderochervlk changed the base branch from main to codex/event-api-split-without-rescript-13 June 26, 2026 17:33
@jderochervlk jderochervlk changed the base branch from codex/event-api-split-without-rescript-13 to main June 26, 2026 17:34
Comment thread src/Base/DOM_.res Outdated
Comment thread src/DOM/DomGlobal.res
*/
@editor.completeFrom(BaseCSSFontLoading.FontFaceSet)
type rec fontFaceSet = private {
...BaseEvent.eventTarget,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was just spreading an empty object and creating a circular dependency.

Comment thread src/Base/DOM.res
Comment on lines +30 to +32
@editor.completeFrom(Window)
type window = private {}
external window: window = "window"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding this here allows accessing the window using DOM.window instead of Window.current.

Comment thread src/Base/DOM.res
@jderochervlk jderochervlk changed the base branch from main to remove-dom-prefix July 6, 2026 17:11
@jderochervlk jderochervlk changed the title [codex] split Event owner types refactor: restructure Event and related files Jul 6, 2026
…ntal-rescript-webapi into codex/event-api-split
@jderochervlk jderochervlk marked this pull request as ready for review July 6, 2026 19:23
@jderochervlk jderochervlk changed the base branch from remove-dom-prefix to main July 9, 2026 14:14
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.

1 participant