From 9248425f23e27008080be2a6aa3232d0e74a27e8 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 10:22:46 -0400 Subject: [PATCH 01/16] refactor: move DOM file out of base folder --- rescript.json | 4 ++-- src/{Base => DOM}/DOM.res | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{Base => DOM}/DOM.res (100%) diff --git a/rescript.json b/rescript.json index 965cdcf..653e0ea 100644 --- a/rescript.json +++ b/rescript.json @@ -11,8 +11,7 @@ "BaseEncryptedMediaExtensions", "BaseEvent", "BaseFile", - "BaseFileAndDirectoryEntries", - "DOM" + "BaseFileAndDirectoryEntries" ] }, { @@ -82,6 +81,7 @@ "CharacterData", "Comment", "CustomElementRegistry", + "DOM", "DOMException", "DOMImplementation", "DOMMatrix", diff --git a/src/Base/DOM.res b/src/DOM/DOM.res similarity index 100% rename from src/Base/DOM.res rename to src/DOM/DOM.res From bc1a0e79523da98f217f05f13c42cb15f46743e1 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 10:25:54 -0400 Subject: [PATCH 02/16] update package-lock.json --- package-lock.json | 559 +++++----------------------------------------- 1 file changed, 62 insertions(+), 497 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9f5018..c4d8f2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,13 @@ { - "name": "experimental-rescript-webapi", + "name": "@rescript/webapi", "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "experimental-rescript-webapi", + "name": "@rescript/webapi", "version": "0.1.0", "license": "MIT", - "workspaces": [ - "packages/*" - ], "devDependencies": { "@astrojs/starlight": "0.37.7", "astro": "^5.10.1", @@ -1614,182 +1611,6 @@ "win32" ] }, - "node_modules/@rescript-webapi/base": { - "resolved": "packages/Base", - "link": true - }, - "node_modules/@rescript-webapi/canvas": { - "resolved": "packages/Canvas", - "link": true - }, - "node_modules/@rescript-webapi/channel-messaging": { - "resolved": "packages/ChannelMessaging", - "link": true - }, - "node_modules/@rescript-webapi/clipboard": { - "resolved": "packages/Clipboard", - "link": true - }, - "node_modules/@rescript-webapi/credential-management": { - "resolved": "packages/CredentialManagement", - "link": true - }, - "node_modules/@rescript-webapi/css-font-loading": { - "resolved": "packages/CSSFontLoading", - "link": true - }, - "node_modules/@rescript-webapi/dom": { - "resolved": "packages/DOM", - "link": true - }, - "node_modules/@rescript-webapi/encrypted-media-extensions": { - "resolved": "packages/EncryptedMediaExtensions", - "link": true - }, - "node_modules/@rescript-webapi/event": { - "resolved": "packages/Event", - "link": true - }, - "node_modules/@rescript-webapi/fetch": { - "resolved": "packages/Fetch", - "link": true - }, - "node_modules/@rescript-webapi/file": { - "resolved": "packages/File", - "link": true - }, - "node_modules/@rescript-webapi/file-and-directory-entries": { - "resolved": "packages/FileAndDirectoryEntries", - "link": true - }, - "node_modules/@rescript-webapi/gamepad": { - "resolved": "packages/Gamepad", - "link": true - }, - "node_modules/@rescript-webapi/geolocation": { - "resolved": "packages/Geolocation", - "link": true - }, - "node_modules/@rescript-webapi/history": { - "resolved": "packages/History", - "link": true - }, - "node_modules/@rescript-webapi/indexed-db": { - "resolved": "packages/IndexedDB", - "link": true - }, - "node_modules/@rescript-webapi/intersection-observer": { - "resolved": "packages/IntersectionObserver", - "link": true - }, - "node_modules/@rescript-webapi/media-capabilities": { - "resolved": "packages/MediaCapabilities", - "link": true - }, - "node_modules/@rescript-webapi/media-capture-and-streams": { - "resolved": "packages/MediaCaptureAndStreams", - "link": true - }, - "node_modules/@rescript-webapi/media-session": { - "resolved": "packages/MediaSession", - "link": true - }, - "node_modules/@rescript-webapi/mutation-observer": { - "resolved": "packages/MutationObserver", - "link": true - }, - "node_modules/@rescript-webapi/notification": { - "resolved": "packages/Notification", - "link": true - }, - "node_modules/@rescript-webapi/performance": { - "resolved": "packages/Performance", - "link": true - }, - "node_modules/@rescript-webapi/permissions": { - "resolved": "packages/Permissions", - "link": true - }, - "node_modules/@rescript-webapi/picture-in-picture": { - "resolved": "packages/PictureInPicture", - "link": true - }, - "node_modules/@rescript-webapi/push": { - "resolved": "packages/Push", - "link": true - }, - "node_modules/@rescript-webapi/remote-playback": { - "resolved": "packages/RemotePlayback", - "link": true - }, - "node_modules/@rescript-webapi/resize-observer": { - "resolved": "packages/ResizeObserver", - "link": true - }, - "node_modules/@rescript-webapi/screen-wake-lock": { - "resolved": "packages/ScreenWakeLock", - "link": true - }, - "node_modules/@rescript-webapi/service-worker": { - "resolved": "packages/ServiceWorker", - "link": true - }, - "node_modules/@rescript-webapi/storage": { - "resolved": "packages/Storage", - "link": true - }, - "node_modules/@rescript-webapi/ui-events": { - "resolved": "packages/UIEvents", - "link": true - }, - "node_modules/@rescript-webapi/url": { - "resolved": "packages/URL", - "link": true - }, - "node_modules/@rescript-webapi/view-transitions": { - "resolved": "packages/ViewTransitions", - "link": true - }, - "node_modules/@rescript-webapi/visual-viewport": { - "resolved": "packages/VisualViewport", - "link": true - }, - "node_modules/@rescript-webapi/web-audio": { - "resolved": "packages/WebAudio", - "link": true - }, - "node_modules/@rescript-webapi/web-crypto": { - "resolved": "packages/WebCrypto", - "link": true - }, - "node_modules/@rescript-webapi/web-locks": { - "resolved": "packages/WebLocks", - "link": true - }, - "node_modules/@rescript-webapi/web-midi": { - "resolved": "packages/WebMIDI", - "link": true - }, - "node_modules/@rescript-webapi/web-sockets": { - "resolved": "packages/WebSockets", - "link": true - }, - "node_modules/@rescript-webapi/web-speech": { - "resolved": "packages/WebSpeech", - "link": true - }, - "node_modules/@rescript-webapi/web-storage": { - "resolved": "packages/WebStorage", - "link": true - }, - "node_modules/@rescript-webapi/web-vtt": { - "resolved": "packages/WebVTT", - "link": true - }, - "node_modules/@rescript-webapi/web-workers": { - "resolved": "packages/WebWorkers", - "link": true - }, "node_modules/@rescript/darwin-arm64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.2.0.tgz", @@ -1797,6 +1618,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -1812,6 +1634,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -1827,6 +1650,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1842,6 +1666,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "linux" @@ -1853,7 +1678,8 @@ "node_modules/@rescript/runtime": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-12.2.0.tgz", - "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==" + "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==", + "dev": true }, "node_modules/@rescript/win32-x64": { "version": "12.2.0", @@ -1862,6 +1688,7 @@ "cpu": [ "x64" ], + "dev": true, "optional": true, "os": [ "win32" @@ -6676,6 +6503,7 @@ "version": "12.2.0", "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.2.0.tgz", "integrity": "sha512-1Jf2cmNhyx5Mj2vwZ4XXPcXvNSjGj9D1jPBUcoqIOqRpLPo1ch2Ta/7eWh23xAHWHK5ow7BCDyYFjvZSjyjLzg==", + "dev": true, "dependencies": { "@rescript/runtime": "12.2.0" }, @@ -7668,6 +7496,7 @@ "packages/Base": { "name": "@rescript-webapi/base", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -7676,6 +7505,7 @@ "packages/Canvas": { "name": "@rescript-webapi/canvas", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7691,6 +7521,7 @@ "packages/ChannelMessaging": { "name": "@rescript-webapi/channel-messaging", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7702,6 +7533,7 @@ "packages/Clipboard": { "name": "@rescript-webapi/clipboard", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0", @@ -7714,6 +7546,7 @@ "packages/CredentialManagement": { "name": "@rescript-webapi/credential-management", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7726,6 +7559,7 @@ "packages/CSSFontLoading": { "name": "@rescript-webapi/css-font-loading", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7737,6 +7571,7 @@ "packages/DOM": { "name": "@rescript-webapi/dom", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7780,6 +7615,7 @@ "packages/EncryptedMediaExtensions": { "name": "@rescript-webapi/encrypted-media-extensions", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7793,6 +7629,7 @@ "packages/Event": { "name": "@rescript-webapi/event", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/dom": "0.1.0" @@ -7804,6 +7641,7 @@ "packages/Fetch": { "name": "@rescript-webapi/fetch", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7818,6 +7656,7 @@ "packages/File": { "name": "@rescript-webapi/file", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7829,6 +7668,7 @@ "packages/FileAndDirectoryEntries": { "name": "@rescript-webapi/file-and-directory-entries", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0" @@ -7840,6 +7680,7 @@ "packages/Gamepad": { "name": "@rescript-webapi/gamepad", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0" @@ -7851,6 +7692,7 @@ "packages/Geolocation": { "name": "@rescript-webapi/geolocation", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -7859,6 +7701,7 @@ "packages/History": { "name": "@rescript-webapi/history", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -7867,6 +7710,7 @@ "packages/IndexedDB": { "name": "@rescript-webapi/indexed-db", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -7879,6 +7723,7 @@ "packages/IntersectionObserver": { "name": "@rescript-webapi/intersection-observer", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/dom": "0.1.0" @@ -7890,6 +7735,7 @@ "packages/MediaCapabilities": { "name": "@rescript-webapi/media-capabilities", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -7898,6 +7744,7 @@ "packages/MediaCaptureAndStreams": { "name": "@rescript-webapi/media-capture-and-streams", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7909,6 +7756,7 @@ "packages/MediaSession": { "name": "@rescript-webapi/media-session", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -7917,6 +7765,7 @@ "packages/MutationObserver": { "name": "@rescript-webapi/mutation-observer", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/dom": "0.1.0" @@ -7928,6 +7777,7 @@ "packages/Notification": { "name": "@rescript-webapi/notification", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7939,6 +7789,7 @@ "packages/Performance": { "name": "@rescript-webapi/performance", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7950,6 +7801,7 @@ "packages/Permissions": { "name": "@rescript-webapi/permissions", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7961,6 +7813,7 @@ "packages/PictureInPicture": { "name": "@rescript-webapi/picture-in-picture", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7972,6 +7825,7 @@ "packages/Push": { "name": "@rescript-webapi/push", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7983,6 +7837,7 @@ "packages/RemotePlayback": { "name": "@rescript-webapi/remote-playback", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -7994,6 +7849,7 @@ "packages/ResizeObserver": { "name": "@rescript-webapi/resize-observer", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/dom": "0.1.0" @@ -8005,6 +7861,7 @@ "packages/ScreenWakeLock": { "name": "@rescript-webapi/screen-wake-lock", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8016,6 +7873,7 @@ "packages/ServiceWorker": { "name": "@rescript-webapi/service-worker", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -8033,6 +7891,7 @@ "packages/Storage": { "name": "@rescript-webapi/storage", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/file": "0.1.0" @@ -8044,6 +7903,7 @@ "packages/UIEvents": { "name": "@rescript-webapi/ui-events", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -8059,6 +7919,7 @@ "packages/URL": { "name": "@rescript-webapi/url", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -8067,6 +7928,7 @@ "packages/ViewTransitions": { "name": "@rescript-webapi/view-transitions", "version": "0.1.0", + "extraneous": true, "license": "MIT", "peerDependencies": { "rescript": ">=12.0.0 <13" @@ -8075,6 +7937,7 @@ "packages/VisualViewport": { "name": "@rescript-webapi/visual-viewport", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8086,6 +7949,7 @@ "packages/WebAudio": { "name": "@rescript-webapi/web-audio", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -8101,6 +7965,7 @@ "packages/WebCrypto": { "name": "@rescript-webapi/web-crypto", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0" @@ -8112,6 +7977,7 @@ "packages/WebLocks": { "name": "@rescript-webapi/web-locks", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8123,6 +7989,7 @@ "packages/WebMIDI": { "name": "@rescript-webapi/web-midi", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/base": "0.1.0", @@ -8135,6 +8002,7 @@ "packages/WebSockets": { "name": "@rescript-webapi/web-sockets", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/channel-messaging": "0.1.0", @@ -8148,6 +8016,7 @@ "packages/WebSpeech": { "name": "@rescript-webapi/web-speech", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8159,6 +8028,7 @@ "packages/WebStorage": { "name": "@rescript-webapi/web-storage", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8170,6 +8040,7 @@ "packages/WebVTT": { "name": "@rescript-webapi/web-vtt", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/event": "0.1.0" @@ -8181,6 +8052,7 @@ "packages/WebWorkers": { "name": "@rescript-webapi/web-workers", "version": "0.1.0", + "extraneous": true, "license": "MIT", "dependencies": { "@rescript-webapi/channel-messaging": "0.1.0", @@ -9035,353 +8907,45 @@ "dev": true, "optional": true }, - "@rescript-webapi/base": { - "version": "file:packages/Base", - "requires": {} - }, - "@rescript-webapi/canvas": { - "version": "file:packages/Canvas", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/dom": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/file": "0.1.0", - "@rescript-webapi/media-capture-and-streams": "0.1.0" - } - }, - "@rescript-webapi/channel-messaging": { - "version": "file:packages/ChannelMessaging", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/clipboard": { - "version": "file:packages/Clipboard", - "requires": { - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/file": "0.1.0" - } - }, - "@rescript-webapi/credential-management": { - "version": "file:packages/CredentialManagement", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/css-font-loading": { - "version": "file:packages/CSSFontLoading", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/dom": { - "version": "file:packages/DOM", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/channel-messaging": "0.1.0", - "@rescript-webapi/clipboard": "0.1.0", - "@rescript-webapi/credential-management": "0.1.0", - "@rescript-webapi/css-font-loading": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/fetch": "0.1.0", - "@rescript-webapi/file": "0.1.0", - "@rescript-webapi/file-and-directory-entries": "0.1.0", - "@rescript-webapi/gamepad": "0.1.0", - "@rescript-webapi/geolocation": "0.1.0", - "@rescript-webapi/history": "0.1.0", - "@rescript-webapi/indexed-db": "0.1.0", - "@rescript-webapi/media-capabilities": "0.1.0", - "@rescript-webapi/media-capture-and-streams": "0.1.0", - "@rescript-webapi/media-session": "0.1.0", - "@rescript-webapi/performance": "0.1.0", - "@rescript-webapi/permissions": "0.1.0", - "@rescript-webapi/picture-in-picture": "0.1.0", - "@rescript-webapi/remote-playback": "0.1.0", - "@rescript-webapi/screen-wake-lock": "0.1.0", - "@rescript-webapi/service-worker": "0.1.0", - "@rescript-webapi/storage": "0.1.0", - "@rescript-webapi/url": "0.1.0", - "@rescript-webapi/view-transitions": "0.1.0", - "@rescript-webapi/visual-viewport": "0.1.0", - "@rescript-webapi/web-crypto": "0.1.0", - "@rescript-webapi/web-locks": "0.1.0", - "@rescript-webapi/web-midi": "0.1.0", - "@rescript-webapi/web-speech": "0.1.0", - "@rescript-webapi/web-storage": "0.1.0", - "@rescript-webapi/web-vtt": "0.1.0", - "@rescript-webapi/web-workers": "0.1.0" - } - }, - "@rescript-webapi/encrypted-media-extensions": { - "version": "file:packages/EncryptedMediaExtensions", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/dom": "0.1.0", - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/event": { - "version": "file:packages/Event", - "requires": { - "@rescript-webapi/dom": "0.1.0" - } - }, - "@rescript-webapi/fetch": { - "version": "file:packages/Fetch", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/file": "0.1.0", - "@rescript-webapi/url": "0.1.0" - } - }, - "@rescript-webapi/file": { - "version": "file:packages/File", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/file-and-directory-entries": { - "version": "file:packages/FileAndDirectoryEntries", - "requires": { - "@rescript-webapi/base": "0.1.0" - } - }, - "@rescript-webapi/gamepad": { - "version": "file:packages/Gamepad", - "requires": { - "@rescript-webapi/base": "0.1.0" - } - }, - "@rescript-webapi/geolocation": { - "version": "file:packages/Geolocation", - "requires": {} - }, - "@rescript-webapi/history": { - "version": "file:packages/History", - "requires": {} - }, - "@rescript-webapi/indexed-db": { - "version": "file:packages/IndexedDB", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/intersection-observer": { - "version": "file:packages/IntersectionObserver", - "requires": { - "@rescript-webapi/dom": "0.1.0" - } - }, - "@rescript-webapi/media-capabilities": { - "version": "file:packages/MediaCapabilities", - "requires": {} - }, - "@rescript-webapi/media-capture-and-streams": { - "version": "file:packages/MediaCaptureAndStreams", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/media-session": { - "version": "file:packages/MediaSession", - "requires": {} - }, - "@rescript-webapi/mutation-observer": { - "version": "file:packages/MutationObserver", - "requires": { - "@rescript-webapi/dom": "0.1.0" - } - }, - "@rescript-webapi/notification": { - "version": "file:packages/Notification", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/performance": { - "version": "file:packages/Performance", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/permissions": { - "version": "file:packages/Permissions", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/picture-in-picture": { - "version": "file:packages/PictureInPicture", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/push": { - "version": "file:packages/Push", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/remote-playback": { - "version": "file:packages/RemotePlayback", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/resize-observer": { - "version": "file:packages/ResizeObserver", - "requires": { - "@rescript-webapi/dom": "0.1.0" - } - }, - "@rescript-webapi/screen-wake-lock": { - "version": "file:packages/ScreenWakeLock", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/service-worker": { - "version": "file:packages/ServiceWorker", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/channel-messaging": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/fetch": "0.1.0", - "@rescript-webapi/notification": "0.1.0", - "@rescript-webapi/push": "0.1.0", - "@rescript-webapi/web-workers": "0.1.0" - } - }, - "@rescript-webapi/storage": { - "version": "file:packages/Storage", - "requires": { - "@rescript-webapi/file": "0.1.0" - } - }, - "@rescript-webapi/ui-events": { - "version": "file:packages/UIEvents", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/dom": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/file": "0.1.0", - "@rescript-webapi/file-and-directory-entries": "0.1.0" - } - }, - "@rescript-webapi/url": { - "version": "file:packages/URL", - "requires": {} - }, - "@rescript-webapi/view-transitions": { - "version": "file:packages/ViewTransitions", - "requires": {} - }, - "@rescript-webapi/visual-viewport": { - "version": "file:packages/VisualViewport", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-audio": { - "version": "file:packages/WebAudio", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/channel-messaging": "0.1.0", - "@rescript-webapi/dom": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/media-capture-and-streams": "0.1.0" - } - }, - "@rescript-webapi/web-crypto": { - "version": "file:packages/WebCrypto", - "requires": { - "@rescript-webapi/base": "0.1.0" - } - }, - "@rescript-webapi/web-locks": { - "version": "file:packages/WebLocks", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-midi": { - "version": "file:packages/WebMIDI", - "requires": { - "@rescript-webapi/base": "0.1.0", - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-sockets": { - "version": "file:packages/WebSockets", - "requires": { - "@rescript-webapi/channel-messaging": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/file": "0.1.0" - } - }, - "@rescript-webapi/web-speech": { - "version": "file:packages/WebSpeech", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-storage": { - "version": "file:packages/WebStorage", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-vtt": { - "version": "file:packages/WebVTT", - "requires": { - "@rescript-webapi/event": "0.1.0" - } - }, - "@rescript-webapi/web-workers": { - "version": "file:packages/WebWorkers", - "requires": { - "@rescript-webapi/channel-messaging": "0.1.0", - "@rescript-webapi/event": "0.1.0", - "@rescript-webapi/fetch": "0.1.0", - "@rescript-webapi/url": "0.1.0" - } - }, "@rescript/darwin-arm64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.2.0.tgz", "integrity": "sha512-xc3K/J7Ujl1vPiFY2009mRf3kWRlUe/VZyJWprseKxlcEtUQv89ter7r6pY+YFbtYvA/fcaEncL9CVGEdattAg==", + "dev": true, "optional": true }, "@rescript/darwin-x64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-12.2.0.tgz", "integrity": "sha512-qqcTvnlSeoKkywLjG7cXfYvKZ1e4Gz2kUKcD6SiqDgCqm8TF+spwlFAiM6sloRUOFsc0bpC/0R0B3yr01FCB1A==", + "dev": true, "optional": true }, "@rescript/linux-arm64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-12.2.0.tgz", "integrity": "sha512-ODmpG3ji+Nj/8d5yvXkeHlfKkmbw1Q4t1iIjVuNwtmFpz7TiEa7n/sQqoYdE+WzbDX3DoJfmJNbp3Ob7qCUoOg==", + "dev": true, "optional": true }, "@rescript/linux-x64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-12.2.0.tgz", "integrity": "sha512-2W9Y9/g19Y4F/subl8yV3T8QBG2oRaP+HciNRcBjptyEdw9LmCKH8+rhWO6sp3E+nZLwoE2IAkwH0WKV3wqlxQ==", + "dev": true, "optional": true }, "@rescript/runtime": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-12.2.0.tgz", - "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==" + "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==", + "dev": true }, "@rescript/win32-x64": { "version": "12.2.0", "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-12.2.0.tgz", "integrity": "sha512-fhf8CBj3p1lkIXPeNko3mVTKQfXXm4BoxJtR1xAXxUn43wDpd8Lox4w8/EPBbbW6C/YFQW6H7rtpY+2AKuNaDA==", + "dev": true, "optional": true }, "@rollup/pluginutils": { @@ -12632,6 +12196,7 @@ "version": "12.2.0", "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.2.0.tgz", "integrity": "sha512-1Jf2cmNhyx5Mj2vwZ4XXPcXvNSjGj9D1jPBUcoqIOqRpLPo1ch2Ta/7eWh23xAHWHK5ow7BCDyYFjvZSjyjLzg==", + "dev": true, "requires": { "@rescript/darwin-arm64": "12.2.0", "@rescript/darwin-x64": "12.2.0", From 1519d886e72a3c55eaf7135f66668cc586f9e94a Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 11:00:55 -0400 Subject: [PATCH 03/16] update to rescript 13-beta.4 --- package-lock.json | 134 +++++++++++++---------- package.json | 4 +- src/Fetch/FormData.res | 4 +- src/URL/URLSearchParams.res | 6 +- tests/FetchAPI/FormData__test.res | 17 +-- tests/FetchAPI/URLSearchParams__test.res | 6 +- 6 files changed, 95 insertions(+), 76 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4d8f2c..bd7e5e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,11 +15,11 @@ "oxfmt": "^0.47.0", "prettier": "^3.8.3", "prettier-plugin-astro": "^0.14.1", - "rescript": ">=12.0.0 <13", + "rescript": "^13.0.0-alpha.4", "sharp": "^0.34.0" }, "peerDependencies": { - "rescript": ">=12.0.0 <13" + "rescript": ">=13" } }, "node_modules/@astrojs/compiler": { @@ -1612,13 +1612,14 @@ ] }, "node_modules/@rescript/darwin-arm64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.2.0.tgz", - "integrity": "sha512-xc3K/J7Ujl1vPiFY2009mRf3kWRlUe/VZyJWprseKxlcEtUQv89ter7r6pY+YFbtYvA/fcaEncL9CVGEdattAg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-13.0.0-alpha.4.tgz", + "integrity": "sha512-3+uPQvuPoweXQ2MatnADRa6PgXhRI/LtkdWkoy8DFSKN7lhtF3Pg+eVjKxY4x4OCECNvHYWLWBKaiVRa22tocA==", "cpu": [ "arm64" ], "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", "optional": true, "os": [ "darwin" @@ -1628,13 +1629,14 @@ } }, "node_modules/@rescript/darwin-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-12.2.0.tgz", - "integrity": "sha512-qqcTvnlSeoKkywLjG7cXfYvKZ1e4Gz2kUKcD6SiqDgCqm8TF+spwlFAiM6sloRUOFsc0bpC/0R0B3yr01FCB1A==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-L71KY+BfSgrMYPUEGMDmrtbrqgBnoYJ/2nJZQNhPV0FP9oQ23rHw8pPVO8+/OzHYPr/OklnB5RbaBphzMBnaxg==", "cpu": [ "x64" ], "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", "optional": true, "os": [ "darwin" @@ -1644,13 +1646,14 @@ } }, "node_modules/@rescript/linux-arm64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-12.2.0.tgz", - "integrity": "sha512-ODmpG3ji+Nj/8d5yvXkeHlfKkmbw1Q4t1iIjVuNwtmFpz7TiEa7n/sQqoYdE+WzbDX3DoJfmJNbp3Ob7qCUoOg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-13.0.0-alpha.4.tgz", + "integrity": "sha512-2sJ4+Ali2PHhNRwIW53jYSuRSbMoioawl1WKAKoH7sQ++1+bIzdMuB3TQpi9oOqTUGlm/5l6bK2Amf8nUiJQ7Q==", "cpu": [ "arm64" ], "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", "optional": true, "os": [ "linux" @@ -1660,13 +1663,14 @@ } }, "node_modules/@rescript/linux-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-12.2.0.tgz", - "integrity": "sha512-2W9Y9/g19Y4F/subl8yV3T8QBG2oRaP+HciNRcBjptyEdw9LmCKH8+rhWO6sp3E+nZLwoE2IAkwH0WKV3wqlxQ==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-Gbmk44xkW4+1qG5g2iAATwx/Y6fZvGgEGUFZw1wK1sDpn2DKblmXIV3JLcWROgpmQv4Mfp4RHPSzZdmcBdPUoQ==", "cpu": [ "x64" ], "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", "optional": true, "os": [ "linux" @@ -1676,19 +1680,21 @@ } }, "node_modules/@rescript/runtime": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-12.2.0.tgz", - "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==", - "dev": true + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-13.0.0-alpha.4.tgz", + "integrity": "sha512-pOGJdN0R3+PeB+tvxqmJB9qWPLTgitHmQY89lBbF3Ddtcbu/aUra9gEeFiX5gXGznEUcS1SVU24Zjr3GBqfy8w==", + "dev": true, + "license": "MIT" }, "node_modules/@rescript/win32-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-12.2.0.tgz", - "integrity": "sha512-fhf8CBj3p1lkIXPeNko3mVTKQfXXm4BoxJtR1xAXxUn43wDpd8Lox4w8/EPBbbW6C/YFQW6H7rtpY+2AKuNaDA==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-NadOoXUe4ek9ZMdHp1hvfc6U11HAOV4VKczCZuM13MvNM0RsmiFUG6jsSNt37ZQuC3iY6I/v3qeKglVv/LG11g==", "cpu": [ "x64" ], "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", "optional": true, "os": [ "win32" @@ -6500,29 +6506,39 @@ } }, "node_modules/rescript": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.2.0.tgz", - "integrity": "sha512-1Jf2cmNhyx5Mj2vwZ4XXPcXvNSjGj9D1jPBUcoqIOqRpLPo1ch2Ta/7eWh23xAHWHK5ow7BCDyYFjvZSjyjLzg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-13.0.0-alpha.4.tgz", + "integrity": "sha512-bkUiLFWxwwQ2cEjA9j3h0xQSgVk5ZngmhAhoB8oTyGrrzYzWoFaF0IEJhT0ZV0bqc+sen2xJtfqF1V8kyMql/A==", "dev": true, + "license": "(LGPL-3.0-or-later AND MIT)", + "workspaces": [ + "packages/playground", + "packages/@rescript/*", + "tests/dependencies/**", + "tests/analysis_tests/**", + "tests/docstring_tests", + "tests/gentype_tests/**", + "tests/tools_tests", + "tests/commonjs_tests", + "scripts/res" + ], "dependencies": { - "@rescript/runtime": "12.2.0" + "@rescript/runtime": "13.0.0-alpha.4" }, "bin": { "bsc": "cli/bsc.js", - "bstracing": "cli/bstracing.js", "rescript": "cli/rescript.js", - "rescript-legacy": "cli/rescript-legacy.js", "rescript-tools": "cli/rescript-tools.js" }, "engines": { "node": ">=20.11.0" }, "optionalDependencies": { - "@rescript/darwin-arm64": "12.2.0", - "@rescript/darwin-x64": "12.2.0", - "@rescript/linux-arm64": "12.2.0", - "@rescript/linux-x64": "12.2.0", - "@rescript/win32-x64": "12.2.0" + "@rescript/darwin-arm64": "13.0.0-alpha.4", + "@rescript/darwin-x64": "13.0.0-alpha.4", + "@rescript/linux-arm64": "13.0.0-alpha.4", + "@rescript/linux-x64": "13.0.0-alpha.4", + "@rescript/win32-x64": "13.0.0-alpha.4" } }, "node_modules/retext": { @@ -8908,43 +8924,43 @@ "optional": true }, "@rescript/darwin-arm64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-12.2.0.tgz", - "integrity": "sha512-xc3K/J7Ujl1vPiFY2009mRf3kWRlUe/VZyJWprseKxlcEtUQv89ter7r6pY+YFbtYvA/fcaEncL9CVGEdattAg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/darwin-arm64/-/darwin-arm64-13.0.0-alpha.4.tgz", + "integrity": "sha512-3+uPQvuPoweXQ2MatnADRa6PgXhRI/LtkdWkoy8DFSKN7lhtF3Pg+eVjKxY4x4OCECNvHYWLWBKaiVRa22tocA==", "dev": true, "optional": true }, "@rescript/darwin-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-12.2.0.tgz", - "integrity": "sha512-qqcTvnlSeoKkywLjG7cXfYvKZ1e4Gz2kUKcD6SiqDgCqm8TF+spwlFAiM6sloRUOFsc0bpC/0R0B3yr01FCB1A==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/darwin-x64/-/darwin-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-L71KY+BfSgrMYPUEGMDmrtbrqgBnoYJ/2nJZQNhPV0FP9oQ23rHw8pPVO8+/OzHYPr/OklnB5RbaBphzMBnaxg==", "dev": true, "optional": true }, "@rescript/linux-arm64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-12.2.0.tgz", - "integrity": "sha512-ODmpG3ji+Nj/8d5yvXkeHlfKkmbw1Q4t1iIjVuNwtmFpz7TiEa7n/sQqoYdE+WzbDX3DoJfmJNbp3Ob7qCUoOg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/linux-arm64/-/linux-arm64-13.0.0-alpha.4.tgz", + "integrity": "sha512-2sJ4+Ali2PHhNRwIW53jYSuRSbMoioawl1WKAKoH7sQ++1+bIzdMuB3TQpi9oOqTUGlm/5l6bK2Amf8nUiJQ7Q==", "dev": true, "optional": true }, "@rescript/linux-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-12.2.0.tgz", - "integrity": "sha512-2W9Y9/g19Y4F/subl8yV3T8QBG2oRaP+HciNRcBjptyEdw9LmCKH8+rhWO6sp3E+nZLwoE2IAkwH0WKV3wqlxQ==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/linux-x64/-/linux-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-Gbmk44xkW4+1qG5g2iAATwx/Y6fZvGgEGUFZw1wK1sDpn2DKblmXIV3JLcWROgpmQv4Mfp4RHPSzZdmcBdPUoQ==", "dev": true, "optional": true }, "@rescript/runtime": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-12.2.0.tgz", - "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/runtime/-/runtime-13.0.0-alpha.4.tgz", + "integrity": "sha512-pOGJdN0R3+PeB+tvxqmJB9qWPLTgitHmQY89lBbF3Ddtcbu/aUra9gEeFiX5gXGznEUcS1SVU24Zjr3GBqfy8w==", "dev": true }, "@rescript/win32-x64": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-12.2.0.tgz", - "integrity": "sha512-fhf8CBj3p1lkIXPeNko3mVTKQfXXm4BoxJtR1xAXxUn43wDpd8Lox4w8/EPBbbW6C/YFQW6H7rtpY+2AKuNaDA==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/@rescript/win32-x64/-/win32-x64-13.0.0-alpha.4.tgz", + "integrity": "sha512-NadOoXUe4ek9ZMdHp1hvfc6U11HAOV4VKczCZuM13MvNM0RsmiFUG6jsSNt37ZQuC3iY6I/v3qeKglVv/LG11g==", "dev": true, "optional": true }, @@ -12193,17 +12209,17 @@ } }, "rescript": { - "version": "12.2.0", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-12.2.0.tgz", - "integrity": "sha512-1Jf2cmNhyx5Mj2vwZ4XXPcXvNSjGj9D1jPBUcoqIOqRpLPo1ch2Ta/7eWh23xAHWHK5ow7BCDyYFjvZSjyjLzg==", + "version": "13.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-13.0.0-alpha.4.tgz", + "integrity": "sha512-bkUiLFWxwwQ2cEjA9j3h0xQSgVk5ZngmhAhoB8oTyGrrzYzWoFaF0IEJhT0ZV0bqc+sen2xJtfqF1V8kyMql/A==", "dev": true, "requires": { - "@rescript/darwin-arm64": "12.2.0", - "@rescript/darwin-x64": "12.2.0", - "@rescript/linux-arm64": "12.2.0", - "@rescript/linux-x64": "12.2.0", - "@rescript/runtime": "12.2.0", - "@rescript/win32-x64": "12.2.0" + "@rescript/darwin-arm64": "13.0.0-alpha.4", + "@rescript/darwin-x64": "13.0.0-alpha.4", + "@rescript/linux-arm64": "13.0.0-alpha.4", + "@rescript/linux-x64": "13.0.0-alpha.4", + "@rescript/runtime": "13.0.0-alpha.4", + "@rescript/win32-x64": "13.0.0-alpha.4" } }, "retext": { diff --git a/package.json b/package.json index 785c0a2..f7fae1d 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,10 @@ "oxfmt": "^0.47.0", "prettier": "^3.8.3", "prettier-plugin-astro": "^0.14.1", - "rescript": ">=12.0.0 <13", + "rescript": "^13.0.0-alpha.4", "sharp": "^0.34.0" }, "peerDependencies": { - "rescript": ">=12.0.0 <13" + "rescript": ">=13" } } diff --git a/src/Fetch/FormData.res b/src/Fetch/FormData.res index 709f310..09558e0 100644 --- a/src/Fetch/FormData.res +++ b/src/Fetch/FormData.res @@ -50,13 +50,13 @@ external has: (t, string) => bool = "has" [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/entries) */ @send -external entries: t => Iterator.t<(string, formDataEntryValue)> = "entries" +external entries: t => iterable<(string, formDataEntryValue)> = "entries" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/keys) */ @send -external keys: t => Iterator.t = "keys" +external keys: t => iterable = "keys" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/set) diff --git a/src/URL/URLSearchParams.res b/src/URL/URLSearchParams.res index 845a9f1..a06dae8 100644 --- a/src/URL/URLSearchParams.res +++ b/src/URL/URLSearchParams.res @@ -46,7 +46,7 @@ Returns key/value pairs in the same order as they appear in the query string. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries) */ @send -external entries: t => Iterator.t<(string, string)> = "entries" +external entries: t => iterable<(string, string)> = "entries" /** Returns the first value associated to the given search parameter. @@ -74,7 +74,7 @@ Returns an iterator allowing iteration through all keys contained in this object [Read more on MDN](https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys) */ @send -external keys: t => Iterator.t = "keys" +external keys: t => iterable = "keys" /** Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. @@ -101,4 +101,4 @@ Returns an iterator allowing iteration through all values contained in this obje [Read more on MDN](https://developer.mozilla.org/docs/Web/API/URLSearchParams/values) */ @send -external values: t => Iterator.t = "values" +external values: t => iterable = "values" diff --git a/tests/FetchAPI/FormData__test.res b/tests/FetchAPI/FormData__test.res index b699133..f76db71 100644 --- a/tests/FetchAPI/FormData__test.res +++ b/tests/FetchAPI/FormData__test.res @@ -43,10 +43,13 @@ logEntry(~stringPrefix="String entry: ", ~filePrefix="Unexpected file entry: ", logEntry(~stringPrefix="Unexpected string entry: ", ~filePrefix="File entry: ", fileEntry) // Iterate over all entries in the FormData -let entries: Iterator.t<(string, EntryValue.t)> = formData->FormData.entries -let _ = entries->Iterator.forEach(((key, value)) => { - switch value { - | String(s) => Console.log(`${key}: ${s}`) - | File(f) => Console.log(`${key}: [WebApiFile] ${f.name}`) - } -}) +let entries: iterable<(string, EntryValue.t)> = formData->FormData.entries +let _ = + entries + ->Array.fromIterable + ->Array.forEach(((key, value)) => { + switch value { + | String(s) => Console.log(`${key}: ${s}`) + | File(f) => Console.log(`${key}: [WebApiFile] ${f.name}`) + } + }) diff --git a/tests/FetchAPI/URLSearchParams__test.res b/tests/FetchAPI/URLSearchParams__test.res index 2bec637..c4532c4 100644 --- a/tests/FetchAPI/URLSearchParams__test.res +++ b/tests/FetchAPI/URLSearchParams__test.res @@ -1,13 +1,13 @@ let params1 = URLSearchParams.fromString("foo=1&bar=2") -params1->URLSearchParams.keys->Iterator.toArray->Array.forEach(Console.log) +params1->URLSearchParams.keys->Array.fromIterable->Array.forEach(Console.log) let params2 = URLSearchParams.fromKeyValueArray([("foo", "1"), ("bar", "b")]) -params2->URLSearchParams.values->Iterator.toArray->Array.forEach(Console.log) +params2->URLSearchParams.values->Array.fromIterable->Array.forEach(Console.log) let params3 = URLSearchParams.fromDict(dict{"foo": "1", "bar": "b"}) params3 ->URLSearchParams.entries -->Iterator.toArray +->Array.fromIterable ->Array.forEach(((key, value)) => Console.log2(key, value)) let paramStr = params3->URLSearchParams.toString From bd0ebf46c80e9ec15d002d1c1b155387635a2b08 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 11:07:16 -0400 Subject: [PATCH 04/16] add Base and element type --- src/Base/Base.res | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/Base/Base.res diff --git a/src/Base/Base.res b/src/Base/Base.res new file mode 100644 index 0000000..d78549e --- /dev/null +++ b/src/Base/Base.res @@ -0,0 +1 @@ +type element From bea1b18189e91c426c05b8eb862897c9a241d59c Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 13:29:33 -0400 Subject: [PATCH 05/16] split out element into sub modules --- src/Base/Base.res | 2 +- src/Base/Base__Element.res | 385 +++++++++++++++++++++++++++++++++++++ src/DOM/DOM.res | 2 +- src/DOM/DomTypes.res | 2 +- 4 files changed, 388 insertions(+), 3 deletions(-) create mode 100644 src/Base/Base__Element.res diff --git a/src/Base/Base.res b/src/Base/Base.res index d78549e..61febc9 100644 --- a/src/Base/Base.res +++ b/src/Base/Base.res @@ -1 +1 @@ -type element +type element = Base__Element.element diff --git a/src/Base/Base__Element.res b/src/Base/Base__Element.res new file mode 100644 index 0000000..7a705e5 --- /dev/null +++ b/src/Base/Base__Element.res @@ -0,0 +1,385 @@ +@@warning("-30") + +type document +type node +type htmlElement +type nodeList<'tNode> +type domTokenList +type namedNodeMap +type shadowRoot +type htmlCollection<'t> +type htmlSlotElement + +/** +Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. +[See Element on MDN](https://developer.mozilla.org/docs/Web/API/Element) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(DOM.Element) +type rec element = { + // Base properties from Node + /** + Returns the type of node. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType) + */ + nodeType: int, + /** + Returns a string appropriate for the type of node. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeName) + */ + nodeName: string, + /** + Returns node's node document's document base URL. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/baseURI) + */ + baseURI: string, + /** + Returns true if node is connected and false otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isConnected) + */ + isConnected: bool, + /** + Returns the node document. Returns null for documents. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument) + */ + ownerDocument: Null.t, + /** + Returns the parent. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentNode) + */ + parentNode: Null.t, + /** + Returns the parent element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentElement) + */ + parentElement: Null.t, + /** + Returns the children. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/childNodes) + */ + childNodes: nodeList, + /** + Returns the first child. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/firstChild) + */ + firstChild: Null.t, + /** + Returns the last child. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lastChild) + */ + lastChild: Null.t, + /** + Returns the previous sibling. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/previousSibling) + */ + previousSibling: Null.t, + /** + Returns the next sibling. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nextSibling) + */ + nextSibling: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) + */ + mutable nodeValue: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/textContent) + */ + mutable textContent: Null.t, + // End base properties from Node + + /** + Returns the namespace. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/namespaceURI) + */ + namespaceURI: Null.t, + /** + Returns the namespace prefix. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/prefix) + */ + prefix: Null.t, + /** + Returns the local name. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/localName) + */ + localName: string, + /** + Returns the HTML-uppercased qualified name. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/tagName) + */ + tagName: string, + /** + Returns the value of element's id content attribute. Can be set to change it. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/id) + */ + mutable id: string, + /** + Returns the value of element's class content attribute. Can be set to change it. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/className) + */ + mutable className: string, + /** + Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/classList) + */ + classList: domTokenList, + /** + Returns the value of element's slot content attribute. Can be set to change it. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/slot) + */ + mutable slot: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/attributes) + */ + attributes: namedNodeMap, + /** + Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/shadowRoot) + */ + shadowRoot: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/part) + */ + part: domTokenList, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollTop) + */ + mutable scrollTop: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollLeft) + */ + mutable scrollLeft: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollWidth) + */ + scrollWidth: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollHeight) + */ + scrollHeight: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientTop) + */ + clientTop: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientLeft) + */ + clientLeft: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientWidth) + */ + clientWidth: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientHeight) + */ + clientHeight: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/currentCSSZoom) + */ + currentCSSZoom: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML) + */ + mutable innerHTML: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML) + */ + mutable outerHTML: string, + /** + Returns the child elements. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/children) + */ + children: htmlCollection, + /** + Returns the first child that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/firstElementChild) + */ + firstElementChild: Null.t, + /** + Returns the last child that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastElementChild) + */ + lastElementChild: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/childElementCount) + */ + childElementCount: int, + /** + Returns the first preceding sibling that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/previousElementSibling) + */ + previousElementSibling: Null.t, + /** + Returns the first following sibling that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/nextElementSibling) + */ + nextElementSibling: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/assignedSlot) + */ + assignedSlot: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaAtomic) + */ + mutable ariaAtomic: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaAutoComplete) + */ + mutable ariaAutoComplete: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBrailleLabel) + */ + mutable ariaBrailleLabel: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBrailleRoleDescription) + */ + mutable ariaBrailleRoleDescription: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBusy) + */ + mutable ariaBusy: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaChecked) + */ + mutable ariaChecked: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColCount) + */ + mutable ariaColCount: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColIndex) + */ + mutable ariaColIndex: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColIndexText) + */ + mutable ariaColIndexText: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColSpan) + */ + mutable ariaColSpan: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaCurrent) + */ + mutable ariaCurrent: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaDescription) + */ + mutable ariaDescription: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaDisabled) + */ + mutable ariaDisabled: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaExpanded) + */ + mutable ariaExpanded: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaHasPopup) + */ + mutable ariaHasPopup: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaHidden) + */ + mutable ariaHidden: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaKeyShortcuts) + */ + mutable ariaKeyShortcuts: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLabel) + */ + mutable ariaLabel: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLevel) + */ + mutable ariaLevel: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLive) + */ + mutable ariaLive: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaModal) + */ + mutable ariaModal: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiLine) + */ + mutable ariaMultiLine: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiSelectable) + */ + mutable ariaMultiSelectable: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaOrientation) + */ + mutable ariaOrientation: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPlaceholder) + */ + mutable ariaPlaceholder: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPosInSet) + */ + mutable ariaPosInSet: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPressed) + */ + mutable ariaPressed: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaReadOnly) + */ + mutable ariaReadOnly: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRequired) + */ + mutable ariaRequired: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRoleDescription) + */ + mutable ariaRoleDescription: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowCount) + */ + mutable ariaRowCount: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowIndex) + */ + mutable ariaRowIndex: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowIndexText) + */ + mutable ariaRowIndexText: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowSpan) + */ + mutable ariaRowSpan: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSelected) + */ + mutable ariaSelected: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSetSize) + */ + mutable ariaSetSize: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSort) + */ + mutable ariaSort: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMax) + */ + mutable ariaValueMax: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMin) + */ + mutable ariaValueMin: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueNow) + */ + mutable ariaValueNow: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueText) + */ + mutable ariaValueText: Null.t, +} diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index 1a954a8..6b1ef60 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -5542,7 +5542,7 @@ Any web page loaded in the browser and serves as an entry point into the web pag TODO: mark as private once mutating fields of private records is allowed */ @editor.completeFrom(DOM.Document) and document = { - // Base properties from Node + // Base properties from Nodea /** Returns the type of node. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType) diff --git a/src/DOM/DomTypes.res b/src/DOM/DomTypes.res index 12ffacd..4c94f35 100644 --- a/src/DOM/DomTypes.res +++ b/src/DOM/DomTypes.res @@ -16,7 +16,7 @@ type timeRanges = DOM.timeRanges type textTrackList = DOM.textTrackList type htmlFormElement = DOM.htmlFormElement type htmlCollection<'a> = DOM.htmlCollection<'a> -type element = DOM.element +type element = Base.element type validityState = DOM.validityState type document = DOM.document type cssStyleSheet = DOM.cssStyleSheet From 6dce20711de48e9f93b2f1c06d9b0da9aca7db4e Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 14:05:55 -0400 Subject: [PATCH 06/16] update remaining element --- src/DOM/DOM.res | 368 +----------------------------------------------- 1 file changed, 1 insertion(+), 367 deletions(-) diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index 6b1ef60..5b29f8a 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -2398,373 +2398,7 @@ Element is the most general base class from which all objects in a Document inhe [See Element on MDN](https://developer.mozilla.org/docs/Web/API/Element) TODO: mark as private once mutating fields of private records is allowed */ -@editor.completeFrom(DOM.Element) and element = { - // Base properties from Node - /** - Returns the type of node. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType) - */ - nodeType: int, - /** - Returns a string appropriate for the type of node. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeName) - */ - nodeName: string, - /** - Returns node's node document's document base URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/baseURI) - */ - baseURI: string, - /** - Returns true if node is connected and false otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isConnected) - */ - isConnected: bool, - /** - Returns the node document. Returns null for documents. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument) - */ - ownerDocument: Null.t, - /** - Returns the parent. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentNode) - */ - parentNode: Null.t, - /** - Returns the parent element. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentElement) - */ - parentElement: Null.t, - /** - Returns the children. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/childNodes) - */ - childNodes: nodeList, - /** - Returns the first child. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/firstChild) - */ - firstChild: Null.t, - /** - Returns the last child. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lastChild) - */ - lastChild: Null.t, - /** - Returns the previous sibling. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/previousSibling) - */ - previousSibling: Null.t, - /** - Returns the next sibling. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nextSibling) - */ - nextSibling: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) - */ - mutable nodeValue: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/textContent) - */ - mutable textContent: Null.t, - // End base properties from Node - - /** - Returns the namespace. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/namespaceURI) - */ - namespaceURI: Null.t, - /** - Returns the namespace prefix. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/prefix) - */ - prefix: Null.t, - /** - Returns the local name. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/localName) - */ - localName: string, - /** - Returns the HTML-uppercased qualified name. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/tagName) - */ - tagName: string, - /** - Returns the value of element's id content attribute. Can be set to change it. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/id) - */ - mutable id: string, - /** - Returns the value of element's class content attribute. Can be set to change it. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/className) - */ - mutable className: string, - /** - Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/classList) - */ - classList: domTokenList, - /** - Returns the value of element's slot content attribute. Can be set to change it. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/slot) - */ - mutable slot: string, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/attributes) - */ - attributes: namedNodeMap, - /** - Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/shadowRoot) - */ - shadowRoot: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/part) - */ - part: domTokenList, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollTop) - */ - mutable scrollTop: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollLeft) - */ - mutable scrollLeft: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollWidth) - */ - scrollWidth: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollHeight) - */ - scrollHeight: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientTop) - */ - clientTop: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientLeft) - */ - clientLeft: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientWidth) - */ - clientWidth: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/clientHeight) - */ - clientHeight: int, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/currentCSSZoom) - */ - currentCSSZoom: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/innerHTML) - */ - mutable innerHTML: string, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/outerHTML) - */ - mutable outerHTML: string, - /** - Returns the child elements. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/children) - */ - children: htmlCollection, - /** - Returns the first child that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/firstElementChild) - */ - firstElementChild: Null.t, - /** - Returns the last child that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastElementChild) - */ - lastElementChild: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/childElementCount) - */ - childElementCount: int, - /** - Returns the first preceding sibling that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/previousElementSibling) - */ - previousElementSibling: Null.t, - /** - Returns the first following sibling that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/nextElementSibling) - */ - nextElementSibling: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/assignedSlot) - */ - assignedSlot: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaAtomic) - */ - mutable ariaAtomic: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaAutoComplete) - */ - mutable ariaAutoComplete: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBrailleLabel) - */ - mutable ariaBrailleLabel: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBrailleRoleDescription) - */ - mutable ariaBrailleRoleDescription: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaBusy) - */ - mutable ariaBusy: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaChecked) - */ - mutable ariaChecked: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColCount) - */ - mutable ariaColCount: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColIndex) - */ - mutable ariaColIndex: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColIndexText) - */ - mutable ariaColIndexText: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaColSpan) - */ - mutable ariaColSpan: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaCurrent) - */ - mutable ariaCurrent: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaDescription) - */ - mutable ariaDescription: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaDisabled) - */ - mutable ariaDisabled: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaExpanded) - */ - mutable ariaExpanded: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaHasPopup) - */ - mutable ariaHasPopup: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaHidden) - */ - mutable ariaHidden: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaKeyShortcuts) - */ - mutable ariaKeyShortcuts: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLabel) - */ - mutable ariaLabel: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLevel) - */ - mutable ariaLevel: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaLive) - */ - mutable ariaLive: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaModal) - */ - mutable ariaModal: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiLine) - */ - mutable ariaMultiLine: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaMultiSelectable) - */ - mutable ariaMultiSelectable: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaOrientation) - */ - mutable ariaOrientation: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPlaceholder) - */ - mutable ariaPlaceholder: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPosInSet) - */ - mutable ariaPosInSet: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaPressed) - */ - mutable ariaPressed: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaReadOnly) - */ - mutable ariaReadOnly: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRequired) - */ - mutable ariaRequired: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRoleDescription) - */ - mutable ariaRoleDescription: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowCount) - */ - mutable ariaRowCount: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowIndex) - */ - mutable ariaRowIndex: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowIndexText) - */ - mutable ariaRowIndexText: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaRowSpan) - */ - mutable ariaRowSpan: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSelected) - */ - mutable ariaSelected: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSetSize) - */ - mutable ariaSetSize: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaSort) - */ - mutable ariaSort: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMax) - */ - mutable ariaValueMax: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueMin) - */ - mutable ariaValueMin: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueNow) - */ - mutable ariaValueNow: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/ariaValueText) - */ - mutable ariaValueText: Null.t, -} +@editor.completeFrom(DOM.Element) and element = Base.element /** [See ShadowRoot on MDN](https://developer.mozilla.org/docs/Web/API/ShadowRoot) From e5d67a77b5c52d56a6cad4a27f0952b3b28db8ff Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 14:33:42 -0400 Subject: [PATCH 07/16] update Element docs --- docs/content/docs/api-surface.mdx | 5 +- .../contributing/api-module-structure.mdx | 12 +- .../contributing/module-type-structure.mdx | 39 ++++- docs/content/docs/philosophy.mdx | 9 +- .../2026-04-22-unmonorepo-webapi-design.md | 7 +- rescript.json | 140 ++++-------------- 6 files changed, 87 insertions(+), 125 deletions(-) diff --git a/docs/content/docs/api-surface.mdx b/docs/content/docs/api-surface.mdx index 3dc6ee1..07e14f3 100644 --- a/docs/content/docs/api-surface.mdx +++ b/docs/content/docs/api-surface.mdx @@ -241,6 +241,7 @@ let redirect = WebAPI.Response.redirect(~url="/login", ~status=302) ## DOM DOM values are operated on through public interface modules. +`WebAPI.Element` is the method module for element values. When you need to name the element type explicitly, use `WebAPI.DOM.element`; most examples can rely on inference from `Document.createElement`, `Document.querySelector`, and related DOM helpers. ```ReScript let document = WebAPI.Window.current->WebAPI.Window.document @@ -262,8 +263,8 @@ switch maybeButton { Use conversion helpers when moving between related DOM interface types. ```ReScript -let element = document->WebAPI.Document.createElement("div") -let node = element->WebAPI.Element.asNode +let element: WebAPI.DOM.element = document->WebAPI.Document.createElement("div") +let node: WebAPI.DOM.node = element->WebAPI.Element.asNode ``` ## Visual Viewport diff --git a/docs/content/docs/contributing/api-module-structure.mdx b/docs/content/docs/contributing/api-module-structure.mdx index 45781e8..f05cb47 100644 --- a/docs/content/docs/contributing/api-module-structure.mdx +++ b/docs/content/docs/contributing/api-module-structure.mdx @@ -51,8 +51,8 @@ type htmlSpanElement = { ``` ```ReScript @@ -61,13 +61,11 @@ type rec node = { // ... more properties } -and element = { - // duplicated property from node - nodeName: string - // ... more properties -} +and element = Base.element ``` +For shared DOM base interfaces such as `Element`, the structural record can live in a Base-owned module such as `Base__Element.res`. The DOM API module then keeps the familiar `DOM.element` alias while method modules use `DomTypes.element`. + ## Auxiliary Types Auxiliary types are used to represent types that are not directly related to the Web API but are used in the bindings. diff --git a/docs/content/docs/contributing/module-type-structure.mdx b/docs/content/docs/contributing/module-type-structure.mdx index bb5b58f..5f932a8 100644 --- a/docs/content/docs/contributing/module-type-structure.mdx +++ b/docs/content/docs/contributing/module-type-structure.mdx @@ -56,7 +56,11 @@ external focus: (T.t, ~options: focusOptions=?) => unit = "focus" include Impl({ type t = htmlElement }) `; - + export const buttonModule = ` open DOMAPI @@ -74,4 +78,35 @@ _/ external checkValidity: htmlButtonElement => bool = "checkValidity" `; - + + +## Shared element base + +`Element.res` is a method module. It does not define the `element` record type directly. The shared DOM element type is owned by Base and threaded back into DOM through aliases: + +```ReScript +// Base.res +type element = Base__Element.element + +// DomTypes.res +type element = Base.element + +// Element.res +include Impl({type t = DomTypes.element}) +``` + +This keeps `Element.Impl` reusable for element subtypes while giving the package one shared base element type. Subtype modules should continue to include the nearest base method implementation: + +```ReScript +// HTMLElement.res +include Element.Impl({type t = DomTypes.htmlElement}) + +// HTMLButtonElement.res +include HTMLElement.Impl({type t = DomTypes.htmlButtonElement}) +``` + +Use `asElement` when a subtype needs to be passed to a function that expects the shared element type. diff --git a/docs/content/docs/philosophy.mdx b/docs/content/docs/philosophy.mdx index 2b52fa6..c2c6a4c 100644 --- a/docs/content/docs/philosophy.mdx +++ b/docs/content/docs/philosophy.mdx @@ -21,7 +21,8 @@ The bindings are exposed under the `WebAPI` namespace with the same flat module ```ReScript open WebAPI.DOM -let myElement: WebAPI.Element.t = document->WebAPI.Document.createElement("div") +let myElement: WebAPI.DOM.element = document->WebAPI.Document.createElement("div") +let id = myElement.id ``` ## Interfaces @@ -34,6 +35,8 @@ Methods are modeled as functions in a separate module. The idea is that these wi Inherited methods are duplicated in the inheriting module to eliminate the need to cast the type to the base type. +For DOM elements, `WebAPI.Element` is the method module. The element type itself is exposed as `WebAPI.DOM.element`. Most code does not need to annotate the type because functions such as `Document.createElement` and `Document.querySelector` already return it. + ### Overloads JavaScript supports function overloads, where a function can have multiple signatures. In ReScript, this is not possible, and a method can have multiple bindings with slightly different names. By entering the correct name, tooling should detect all variations of the method. @@ -45,8 +48,8 @@ In some cases, type conversion will be required. Subtypes can safely be cast to ```ReScript open WebAPI.DOM -let element: WebAPI.Element.t = document->WebAPI.Document.createElement("div") -let node: WebAPI.Node.t = element->WebAPI.Element.asNode +let element: WebAPI.DOM.element = document->WebAPI.Document.createElement("div") +let node: WebAPI.DOM.node = element->WebAPI.Element.asNode ``` Any other conversions should be treated as unsafe casts and used with caution, because the type system cannot guarantee they are valid at runtime. diff --git a/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md b/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md index 5cb468f..40ba01e 100644 --- a/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md +++ b/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md @@ -97,7 +97,10 @@ Example: ```json { - "dependencies": ["@plain/dep", { "name": "@other/heavy", "features": ["WebAPI.WebCrypto"] }] + "dependencies": [ + "@plain/dep", + { "name": "@other/heavy", "features": ["WebAPI.WebCrypto"] } + ] } ``` @@ -124,7 +127,7 @@ The unified build keeps the original flat module surface instead of adding gener - `WebAPI.Headers` - `WebAPI.URL` -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`. +Shared DOM base types can be owned by `Base` when they are needed across feature boundaries, while `DOM` can keep short public aliases such as `DOM.element`. For example, `Base__Element.element` is exposed through `Base.element`, then reused as `DomTypes.element` and `DOM.element`. ## Internal Module Naming diff --git a/rescript.json b/rescript.json index 653e0ea..8f40cd3 100644 --- a/rescript.json +++ b/rescript.json @@ -1,5 +1,6 @@ { "name": "@rescript/webapi", + "namespace": "WebAPI", "sources": [ { "dir": "src/Base", @@ -18,10 +19,7 @@ "dir": "src/CSSFontLoading", "subdirs": true, "feature": "WebAPI.CSSFontLoading", - "public": [ - "FontFace", - "FontFaceSet" - ] + "public": ["FontFace", "FontFaceSet"] }, { "dir": "src/Canvas", @@ -45,26 +43,19 @@ "dir": "src/ChannelMessaging", "subdirs": true, "feature": "WebAPI.ChannelMessaging", - "public": [ - "MessagePort" - ] + "public": ["MessagePort"] }, { "dir": "src/Clipboard", "subdirs": true, "feature": "WebAPI.Clipboard", - "public": [ - "Clipboard", - "ClipboardItem" - ] + "public": ["Clipboard", "ClipboardItem"] }, { "dir": "src/CredentialManagement", "subdirs": true, "feature": "WebAPI.CredentialManagement", - "public": [ - "CredentialsContainer" - ] + "public": ["CredentialsContainer"] }, { "dir": "src/DOM", @@ -263,27 +254,19 @@ "dir": "src/Gamepad", "subdirs": true, "feature": "WebAPI.Gamepad", - "public": [ - "GamepadHapticActuator" - ] + "public": ["GamepadHapticActuator"] }, { "dir": "src/Geolocation", "subdirs": true, "feature": "WebAPI.Geolocation", - "public": [ - "Geolocation", - "GeolocationCoordinates", - "GeolocationPosition" - ] + "public": ["Geolocation", "GeolocationCoordinates", "GeolocationPosition"] }, { "dir": "src/History", "subdirs": true, "feature": "WebAPI.History", - "public": [ - "History" - ] + "public": ["History"] }, { "dir": "src/IndexedDB", @@ -301,18 +284,13 @@ "dir": "src/IntersectionObserver", "subdirs": true, "feature": "WebAPI.IntersectionObserver", - "public": [ - "IntersectionObserver", - "IntersectionObserverRoot" - ] + "public": ["IntersectionObserver", "IntersectionObserverRoot"] }, { "dir": "src/MediaCapabilities", "subdirs": true, "feature": "WebAPI.MediaCapabilities", - "public": [ - "MediaCapabilities" - ] + "public": ["MediaCapabilities"] }, { "dir": "src/MediaCaptureAndStreams", @@ -329,52 +307,37 @@ "dir": "src/MediaSession", "subdirs": true, "feature": "WebAPI.MediaSession", - "public": [ - "MediaMetadata", - "MediaSession" - ] + "public": ["MediaMetadata", "MediaSession"] }, { "dir": "src/MutationObserver", "subdirs": true, "feature": "WebAPI.MutationObserver", - "public": [ - "MutationObserver" - ] + "public": ["MutationObserver"] }, { "dir": "src/Notification", "subdirs": true, "feature": "WebAPI.Notification", - "public": [ - "Notification" - ] + "public": ["Notification"] }, { "dir": "src/Performance", "subdirs": true, "feature": "WebAPI.Performance", - "public": [ - "Performance", - "PerformanceEntry", - "PerformanceMark" - ] + "public": ["Performance", "PerformanceEntry", "PerformanceMark"] }, { "dir": "src/Permissions", "subdirs": true, "feature": "WebAPI.Permissions", - "public": [ - "Permissions" - ] + "public": ["Permissions"] }, { "dir": "src/PictureInPicture", "subdirs": true, "feature": "WebAPI.PictureInPicture", - "public": [ - "PictureInPicture" - ] + "public": ["PictureInPicture"] }, { "dir": "src/Push", @@ -392,26 +355,19 @@ "dir": "src/RemotePlayback", "subdirs": true, "feature": "WebAPI.RemotePlayback", - "public": [ - "RemotePlayback" - ] + "public": ["RemotePlayback"] }, { "dir": "src/ResizeObserver", "subdirs": true, "feature": "WebAPI.ResizeObserver", - "public": [ - "ResizeObserver" - ] + "public": ["ResizeObserver"] }, { "dir": "src/ScreenWakeLock", "subdirs": true, "feature": "WebAPI.ScreenWakeLock", - "public": [ - "WakeLock", - "WakeLockSentinel" - ] + "public": ["WakeLock", "WakeLockSentinel"] }, { "dir": "src/ServiceWorker", @@ -431,9 +387,7 @@ "dir": "src/Storage", "subdirs": true, "feature": "WebAPI.Storage", - "public": [ - "StorageManager" - ] + "public": ["StorageManager"] }, { "dir": "src/UIEvents", @@ -460,26 +414,19 @@ "dir": "src/URL", "subdirs": true, "feature": "WebAPI.URL", - "public": [ - "URL", - "URLSearchParams" - ] + "public": ["URL", "URLSearchParams"] }, { "dir": "src/ViewTransitions", "subdirs": true, "feature": "WebAPI.ViewTransitions", - "public": [ - "ViewTransition" - ] + "public": ["ViewTransition"] }, { "dir": "src/VisualViewport", "subdirs": true, "feature": "WebAPI.VisualViewport", - "public": [ - "VisualViewport" - ] + "public": ["VisualViewport"] }, { "dir": "src/WebAudio", @@ -523,74 +470,49 @@ "dir": "src/WebCrypto", "subdirs": true, "feature": "WebAPI.WebCrypto", - "public": [ - "Crypto", - "SubtleCrypto" - ] + "public": ["Crypto", "SubtleCrypto"] }, { "dir": "src/WebLocks", "subdirs": true, "feature": "WebAPI.WebLocks", - "public": [ - "LockManager" - ] + "public": ["LockManager"] }, { "dir": "src/WebMIDI", "subdirs": true, "feature": "WebAPI.WebMIDI", - "public": [ - "WebMIDI" - ] + "public": ["WebMIDI"] }, { "dir": "src/WebSockets", "subdirs": true, "feature": "WebAPI.WebSockets", - "public": [ - "CloseEvent", - "MessageEvent", - "WebSocket" - ] + "public": ["CloseEvent", "MessageEvent", "WebSocket"] }, { "dir": "src/WebSpeech", "subdirs": true, "feature": "WebAPI.WebSpeech", - "public": [ - "SpeechSynthesis", - "SpeechSynthesisUtterance" - ] + "public": ["SpeechSynthesis", "SpeechSynthesisUtterance"] }, { "dir": "src/WebStorage", "subdirs": true, "feature": "WebAPI.WebStorage", - "public": [ - "Storage", - "StorageEvent" - ] + "public": ["Storage", "StorageEvent"] }, { "dir": "src/WebVTT", "subdirs": true, "feature": "WebAPI.WebVTT", - "public": [ - "TextTrack", - "TextTrackCueList" - ] + "public": ["TextTrack", "TextTrackCueList"] }, { "dir": "src/WebWorkers", "subdirs": true, "feature": "WebAPI.WebWorkers", - "public": [ - "CacheStorage", - "SharedWorker", - "SharedWorkerScope", - "Worker" - ] + "public": ["CacheStorage", "SharedWorker", "SharedWorkerScope", "Worker"] }, { "dir": "tests", From 43fcf3d2bcfeb2e45737d0a40714c3949373167a Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 14:55:49 -0400 Subject: [PATCH 08/16] start splitting up document and switching to @scope --- rescript.json | 1 - src/Base/Base.res | 1 + src/Base/Base__Document.res | 403 ++++++++++++++++++ src/Canvas/VideoFrame.res | 2 +- .../CredentialManagementTypes.res | 12 +- src/DOM/DOM.res | 371 +--------------- src/DOM/DomTypes.res | 4 +- src/WebCrypto/Crypto.res | 15 +- src/WebCrypto/SubtleCrypto.res | 16 +- 9 files changed, 435 insertions(+), 390 deletions(-) create mode 100644 src/Base/Base__Document.res diff --git a/rescript.json b/rescript.json index 8f40cd3..6b9d84a 100644 --- a/rescript.json +++ b/rescript.json @@ -1,6 +1,5 @@ { "name": "@rescript/webapi", - "namespace": "WebAPI", "sources": [ { "dir": "src/Base", diff --git a/src/Base/Base.res b/src/Base/Base.res index 61febc9..c3f5e49 100644 --- a/src/Base/Base.res +++ b/src/Base/Base.res @@ -1 +1,2 @@ type element = Base__Element.element +type document = Base__Document.document diff --git a/src/Base/Base__Document.res b/src/Base/Base__Document.res new file mode 100644 index 0000000..f155ffb --- /dev/null +++ b/src/Base/Base__Document.res @@ -0,0 +1,403 @@ +@@warning("-30") + +type node +type htmlElement +type nodeList<'tNode> +type domImplementation +type documentType +type element = Base__Element.element +type domStringList = { + /** + Returns the number of strings in strings. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringList/length) + */ + length: int, +} + +/** +The location (WebApiURL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively. +[See Location on MDN](https://developer.mozilla.org/docs/Web/API/Location) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(DOM.Location) +type location = { + /** + Returns the Location object's URL. + +Can be set, to navigate to the given URL. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/href) + */ + mutable href: string, + /** + Returns the Location object's WebApiURL's origin. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/origin) + */ + origin: string, + /** + Returns the Location object's WebApiURL's scheme. + +Can be set, to navigate to the same WebApiURL with a changed scheme. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/protocol) + */ + mutable protocol: string, + /** + Returns the Location object's WebApiURL's host and port (if different from the default port for the scheme). + +Can be set, to navigate to the same WebApiURL with a changed host and port. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/host) + */ + mutable host: string, + /** + Returns the Location object's WebApiURL's host. + +Can be set, to navigate to the same WebApiURL with a changed host. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hostname) + */ + mutable hostname: string, + /** + Returns the Location object's WebApiURL's port. + +Can be set, to navigate to the same WebApiURL with a changed port. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/port) + */ + mutable port: string, + /** + Returns the Location object's WebApiURL's path. + +Can be set, to navigate to the same WebApiURL with a changed path. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/pathname) + */ + mutable pathname: string, + /** + Returns the Location object's WebApiURL's query (includes leading "?" if non-empty). + +Can be set, to navigate to the same WebApiURL with a changed query (ignores leading "?"). + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/search) + */ + mutable search: string, + /** + Returns the Location object's WebApiURL's fragment (includes leading "#" if non-empty). + +Can be set, to navigate to the same WebApiURL with a changed fragment (ignores leading "#"). + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hash) + */ + mutable hash: string, + /** + Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/ancestorOrigins) + */ + ancestorOrigins: domStringList, +} +type documentReadyState +type htmlHeadElement +type htmlCollection<'t> +type htmlImageElement +type htmlEmbedElement +type htmlFormElement +type htmlScriptElement +type window +type documentVisibilityState +type fragmentDirective +type documentTimeline +type styleSheetList +type cssStyleSheet + +/** +Any web page loaded in the browser and serves as an entry point into the web page's content, which is the WebApiDOM tree. +[See Document on MDN](https://developer.mozilla.org/docs/Web/API/Document) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(DOM.Document) +type rec document = { + // Base properties from Nodea + /** + Returns the type of node. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType) + */ + nodeType: int, + /** + Returns a string appropriate for the type of node. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeName) + */ + nodeName: string, + /** + Returns node's node document's document base URL. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/baseURI) + */ + baseURI: string, + /** + Returns true if node is connected and false otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isConnected) + */ + isConnected: bool, + /** + Returns the node document. Returns null for documents. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument) + */ + ownerDocument: Null.t, + /** + Returns the parent. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentNode) + */ + parentNode: Null.t, + /** + Returns the parent element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentElement) + */ + parentElement: Null.t, + /** + Returns the children. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/childNodes) + */ + childNodes: nodeList, + /** + Returns the first child. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/firstChild) + */ + firstChild: Null.t, + /** + Returns the last child. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lastChild) + */ + lastChild: Null.t, + /** + Returns the previous sibling. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/previousSibling) + */ + previousSibling: Null.t, + /** + Returns the next sibling. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nextSibling) + */ + nextSibling: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) + */ + mutable nodeValue: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/textContent) + */ + mutable textContent: Null.t, + // End base properties from Node + + /** + Gets the implementation object of the current document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/implementation) + */ + implementation: domImplementation, + /** + Sets or gets the URL for the current document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/URL) + */ + @as("URL") + url: string, + /** + Returns document's URL. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/documentURI) + */ + documentURI: string, + /** + Gets a value that indicates whether standards-compliant mode is switched on for the object. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/compatMode) + */ + compatMode: string, + /** + Returns document's encoding. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/characterSet) + */ + characterSet: string, + /** + Returns document's content type. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/contentType) + */ + contentType: string, + /** + Gets an object representing the document type declaration associated with the current document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/doctype) + */ + doctype: Null.t, + /** + Gets a reference to the root node of the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/documentElement) + */ + documentElement: htmlElement, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/scrollingElement) + */ + scrollingElement: Null.t, + /** + Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fullscreenEnabled) + */ + fullscreenEnabled: bool, + /** + Contains information about the current URL. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/location) + */ + mutable location: location, + /** + Gets the WebApiURL of the location that referred the user to the current page. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/referrer) + */ + referrer: string, + /** + Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned. + +Can be set, to add a new cookie to the element's set of HTTP cookies. + +If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/cookie) + */ + mutable cookie: string, + /** + Gets the date that the page was last modified, if the page supplies one. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastModified) + */ + lastModified: string, + /** + Retrieves a value that indicates the current state of the object. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/readyState) + */ + readyState: documentReadyState, + /** + Contains the title of the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/title) + */ + mutable title: string, + /** + Sets or retrieves a value that indicates the reading order of the object. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/dir) + */ + mutable dir: string, + /** + Specifies the beginning and end of the document body. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/body) + */ + mutable body: htmlElement, + /** + Returns the head element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/head) + */ + head: htmlHeadElement, + /** + Retrieves a collection, in source order, of img objects in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/images) + */ + images: htmlCollection, + /** + Retrieves a collection of all embed objects in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/embeds) + */ + embeds: htmlCollection, + /** + Return an HTMLCollection of the embed elements in the Document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/plugins) + */ + plugins: htmlCollection, + /** + Retrieves a collection of all a objects that specify the href property and all area objects in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/links) + */ + links: htmlCollection, + /** + Retrieves a collection, in source order, of all form objects in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/forms) + */ + forms: htmlCollection, + /** + Retrieves a collection of all script objects in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/scripts) + */ + scripts: htmlCollection, + /** + Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing. + +Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/currentScript) + */ + currentScript: Null.t, + /** + Returns the Window object of the active document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/defaultView) + */ + defaultView: Null.t, + /** + Sets or gets a value that indicates whether the document can be edited. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/designMode) + */ + mutable designMode: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/hidden) + */ + hidden: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/visibilityState) + */ + visibilityState: documentVisibilityState, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureEnabled) + */ + pictureInPictureEnabled: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fragmentDirective) + */ + fragmentDirective: fragmentDirective, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/timeline) + */ + timeline: documentTimeline, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fonts) + */ + fonts: BaseCSSFontLoading.fontFaceSet, + /** + Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/styleSheets) + */ + styleSheets: styleSheetList, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/adoptedStyleSheets) + */ + mutable adoptedStyleSheets: array, + /** + Returns document's fullscreen element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fullscreenElement) + */ + fullscreenElement: Null.t, + /** + Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document. + +For the purposes of this API, when a child browsing context is focused, its container is focused in the parent browsing context. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document. + +Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/activeElement) + */ + activeElement: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureElement) + */ + pictureInPictureElement: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pointerLockElement) + */ + pointerLockElement: Null.t, + /** + Returns the child elements. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/children) + */ + children: htmlCollection, + /** + Returns the first child that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/firstElementChild) + */ + firstElementChild: Null.t, + /** + Returns the last child that is an element, and null otherwise. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastElementChild) + */ + lastElementChild: Null.t, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/childElementCount) + */ + childElementCount: int, +} diff --git a/src/Canvas/VideoFrame.res b/src/Canvas/VideoFrame.res index a9c8475..75a4d74 100644 --- a/src/Canvas/VideoFrame.res +++ b/src/Canvas/VideoFrame.res @@ -196,7 +196,7 @@ external copyTo: ( @send external copyTo2: ( DomTypes.videoFrame, - ~destination: ArrayBufferTypedArrayOrDataView.t, + ~destination: ArrayBuffer.t, ~options: DomTypes.videoFrameCopyToOptions=?, ) => promise> = "copyTo" diff --git a/src/CredentialManagement/CredentialManagementTypes.res b/src/CredentialManagement/CredentialManagementTypes.res index 5fa16f2..45c0bfd 100644 --- a/src/CredentialManagement/CredentialManagementTypes.res +++ b/src/CredentialManagement/CredentialManagementTypes.res @@ -58,13 +58,13 @@ type credential = { type publicKeyCredentialDescriptor = { @as("type") mutable type_: publicKeyCredentialType, - mutable id: ArrayBufferTypedArrayOrDataView.t, + mutable id: ArrayBuffer.t, mutable transports?: array, } type authenticationExtensionsPRFValues = { - mutable first: ArrayBufferTypedArrayOrDataView.t, - mutable second?: ArrayBufferTypedArrayOrDataView.t, + mutable first: ArrayBuffer.t, + mutable second?: ArrayBuffer.t, } type authenticationExtensionsPRFInputs = { @@ -81,7 +81,7 @@ type authenticationExtensionsClientInputs = { } type publicKeyCredentialRequestOptions = { - mutable challenge: ArrayBufferTypedArrayOrDataView.t, + mutable challenge: ArrayBuffer.t, mutable timeout?: int, mutable rpId?: string, mutable allowCredentials?: array, @@ -104,7 +104,7 @@ type publicKeyCredentialRpEntity = { type publicKeyCredentialUserEntity = { ...publicKeyCredentialEntity, - mutable id: ArrayBufferTypedArrayOrDataView.t, + mutable id: ArrayBuffer.t, mutable displayName: string, } @@ -123,7 +123,7 @@ type authenticatorSelectionCriteria = { type publicKeyCredentialCreationOptions = { mutable rp: publicKeyCredentialRpEntity, mutable user: publicKeyCredentialUserEntity, - mutable challenge: ArrayBufferTypedArrayOrDataView.t, + mutable challenge: ArrayBuffer.t, mutable pubKeyCredParams: array, mutable timeout?: int, mutable excludeCredentials?: array, diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index 5b29f8a..9094835 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -19,13 +19,7 @@ type domException = { A type returned by some APIs which contains a list of DOMString (strings). [See DOMStringList on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringList) */ -type domStringList = { - /** - Returns the number of strings in strings. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringList/length) - */ - length: int, -} +type domStringList = Base__Document.domStringList type window @@ -204,74 +198,7 @@ The location (WebApiURL) of the object it is linked to. Changes done on it are r TODO: mark as private once mutating fields of private records is allowed */ @editor.completeFrom(DOM.Location) -type location = { - /** - Returns the Location object's URL. - -Can be set, to navigate to the given URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/href) - */ - mutable href: string, - /** - Returns the Location object's WebApiURL's origin. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/origin) - */ - origin: string, - /** - Returns the Location object's WebApiURL's scheme. - -Can be set, to navigate to the same WebApiURL with a changed scheme. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/protocol) - */ - mutable protocol: string, - /** - Returns the Location object's WebApiURL's host and port (if different from the default port for the scheme). - -Can be set, to navigate to the same WebApiURL with a changed host and port. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/host) - */ - mutable host: string, - /** - Returns the Location object's WebApiURL's host. - -Can be set, to navigate to the same WebApiURL with a changed host. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hostname) - */ - mutable hostname: string, - /** - Returns the Location object's WebApiURL's port. - -Can be set, to navigate to the same WebApiURL with a changed port. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/port) - */ - mutable port: string, - /** - Returns the Location object's WebApiURL's path. - -Can be set, to navigate to the same WebApiURL with a changed path. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/pathname) - */ - mutable pathname: string, - /** - Returns the Location object's WebApiURL's query (includes leading "?" if non-empty). - -Can be set, to navigate to the same WebApiURL with a changed query (ignores leading "?"). - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/search) - */ - mutable search: string, - /** - Returns the Location object's WebApiURL's fragment (includes leading "#" if non-empty). - -Can be set, to navigate to the same WebApiURL with a changed fragment (ignores leading "#"). - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hash) - */ - mutable hash: string, - /** - Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/ancestorOrigins) - */ - ancestorOrigins: domStringList, -} +type location = Base__Document.location /** [See UserActivation on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation) @@ -5175,299 +5102,7 @@ Any web page loaded in the browser and serves as an entry point into the web pag [See Document on MDN](https://developer.mozilla.org/docs/Web/API/Document) TODO: mark as private once mutating fields of private records is allowed */ -@editor.completeFrom(DOM.Document) and document = { - // Base properties from Nodea - /** - Returns the type of node. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeType) - */ - nodeType: int, - /** - Returns a string appropriate for the type of node. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeName) - */ - nodeName: string, - /** - Returns node's node document's document base URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/baseURI) - */ - baseURI: string, - /** - Returns true if node is connected and false otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isConnected) - */ - isConnected: bool, - /** - Returns the node document. Returns null for documents. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument) - */ - ownerDocument: Null.t, - /** - Returns the parent. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentNode) - */ - parentNode: Null.t, - /** - Returns the parent element. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/parentElement) - */ - parentElement: Null.t, - /** - Returns the children. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/childNodes) - */ - childNodes: nodeList, - /** - Returns the first child. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/firstChild) - */ - firstChild: Null.t, - /** - Returns the last child. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lastChild) - */ - lastChild: Null.t, - /** - Returns the previous sibling. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/previousSibling) - */ - previousSibling: Null.t, - /** - Returns the next sibling. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nextSibling) - */ - nextSibling: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) - */ - mutable nodeValue: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/textContent) - */ - mutable textContent: Null.t, - // End base properties from Node - - /** - Gets the implementation object of the current document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/implementation) - */ - implementation: domImplementation, - /** - Sets or gets the URL for the current document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/URL) - */ - @as("URL") - url: string, - /** - Returns document's URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/documentURI) - */ - documentURI: string, - /** - Gets a value that indicates whether standards-compliant mode is switched on for the object. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/compatMode) - */ - compatMode: string, - /** - Returns document's encoding. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/characterSet) - */ - characterSet: string, - /** - Returns document's content type. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/contentType) - */ - contentType: string, - /** - Gets an object representing the document type declaration associated with the current document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/doctype) - */ - doctype: Null.t, - /** - Gets a reference to the root node of the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/documentElement) - */ - documentElement: htmlElement, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/scrollingElement) - */ - scrollingElement: Null.t, - /** - Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fullscreenEnabled) - */ - fullscreenEnabled: bool, - /** - Contains information about the current URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/location) - */ - mutable location: location, - /** - Gets the WebApiURL of the location that referred the user to the current page. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/referrer) - */ - referrer: string, - /** - Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned. - -Can be set, to add a new cookie to the element's set of HTTP cookies. - -If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/cookie) - */ - mutable cookie: string, - /** - Gets the date that the page was last modified, if the page supplies one. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastModified) - */ - lastModified: string, - /** - Retrieves a value that indicates the current state of the object. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/readyState) - */ - readyState: documentReadyState, - /** - Contains the title of the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/title) - */ - mutable title: string, - /** - Sets or retrieves a value that indicates the reading order of the object. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/dir) - */ - mutable dir: string, - /** - Specifies the beginning and end of the document body. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/body) - */ - mutable body: htmlElement, - /** - Returns the head element. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/head) - */ - head: htmlHeadElement, - /** - Retrieves a collection, in source order, of img objects in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/images) - */ - images: htmlCollection, - /** - Retrieves a collection of all embed objects in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/embeds) - */ - embeds: htmlCollection, - /** - Return an HTMLCollection of the embed elements in the Document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/plugins) - */ - plugins: htmlCollection, - /** - Retrieves a collection of all a objects that specify the href property and all area objects in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/links) - */ - links: htmlCollection, - /** - Retrieves a collection, in source order, of all form objects in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/forms) - */ - forms: htmlCollection, - /** - Retrieves a collection of all script objects in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/scripts) - */ - scripts: htmlCollection, - /** - Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing. - -Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/currentScript) - */ - currentScript: Null.t, - /** - Returns the Window object of the active document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/defaultView) - */ - defaultView: Null.t, - /** - Sets or gets a value that indicates whether the document can be edited. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/designMode) - */ - mutable designMode: string, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/hidden) - */ - hidden: bool, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/visibilityState) - */ - visibilityState: documentVisibilityState, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureEnabled) - */ - pictureInPictureEnabled: bool, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fragmentDirective) - */ - fragmentDirective: fragmentDirective, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/timeline) - */ - timeline: documentTimeline, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fonts) - */ - fonts: BaseCSSFontLoading.fontFaceSet, - /** - Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/styleSheets) - */ - styleSheets: styleSheetList, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/adoptedStyleSheets) - */ - mutable adoptedStyleSheets: array, - /** - Returns document's fullscreen element. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/fullscreenElement) - */ - fullscreenElement: Null.t, - /** - Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document. - -For the purposes of this API, when a child browsing context is focused, its container is focused in the parent browsing context. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document. - -Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/activeElement) - */ - activeElement: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pictureInPictureElement) - */ - pictureInPictureElement: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/pointerLockElement) - */ - pointerLockElement: Null.t, - /** - Returns the child elements. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/children) - */ - children: htmlCollection, - /** - Returns the first child that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/firstElementChild) - */ - firstElementChild: Null.t, - /** - Returns the last child that is an element, and null otherwise. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/lastElementChild) - */ - lastElementChild: Null.t, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/childElementCount) - */ - childElementCount: int, -} +@editor.completeFrom(DOM.Document) and document = Base.document and mutationRecord = { /** diff --git a/src/DOM/DomTypes.res b/src/DOM/DomTypes.res index 4c94f35..10dadd5 100644 --- a/src/DOM/DomTypes.res +++ b/src/DOM/DomTypes.res @@ -18,7 +18,7 @@ type htmlFormElement = DOM.htmlFormElement type htmlCollection<'a> = DOM.htmlCollection<'a> type element = Base.element type validityState = DOM.validityState -type document = DOM.document +type document = Base.document type cssStyleSheet = DOM.cssStyleSheet type nodeList<'a> = DOM.nodeList<'a> type htmlLabelElement = DOM.htmlLabelElement @@ -258,7 +258,7 @@ type shareData = { [See Location on MDN](https://developer.mozilla.org/docs/Web/API/Location) */ @editor.completeFrom(Location) -type location = DOM.location = private {...DOM.location} +type location = Base__Document.location = private {...Base__Document.location} /** [See UserActivation on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation) diff --git a/src/WebCrypto/Crypto.res b/src/WebCrypto/Crypto.res index 5b56bde..274071f 100644 --- a/src/WebCrypto/Crypto.res +++ b/src/WebCrypto/Crypto.res @@ -1,11 +1,18 @@ +open WebCryptoTypes + /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) +TODO: the input type for this should be stricter than just an array<'a>' +> An integer-based TypedArray, that is one of: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array */ -@send -external getRandomValues: (WebCryptoTypes.crypto, 't) => 't = "getRandomValues" +@scope("crypto") +external getRandomValues: array<'t> => array<'t> = "getRandomValues" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) */ -@send -external randomUUID: WebCryptoTypes.crypto => string = "randomUUID" +@scope("crypto") +external randomUUID: unit => string = "randomUUID" + +@scope("crypto") +external subtle: subtleCrypto = "subtle" diff --git a/src/WebCrypto/SubtleCrypto.res b/src/WebCrypto/SubtleCrypto.res index 8f8dc48..a8d9f75 100644 --- a/src/WebCrypto/SubtleCrypto.res +++ b/src/WebCrypto/SubtleCrypto.res @@ -6,7 +6,7 @@ external encrypt: ( WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, - ~data: ArrayBufferTypedArrayOrDataView.t, + ~data: ArrayBuffer.t, ) => promise = "encrypt" /** @@ -17,7 +17,7 @@ external decrypt: ( WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, - ~data: ArrayBufferTypedArrayOrDataView.t, + ~data: ArrayBuffer.t, ) => promise = "decrypt" /** @@ -28,7 +28,7 @@ external sign: ( WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, - ~data: ArrayBufferTypedArrayOrDataView.t, + ~data: ArrayBuffer.t, ) => promise = "sign" /** @@ -39,8 +39,8 @@ external verify: ( WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, - ~signature: ArrayBufferTypedArrayOrDataView.t, - ~data: ArrayBufferTypedArrayOrDataView.t, + ~signature: ArrayBuffer.t, + ~data: ArrayBuffer.t, ) => promise = "verify" /** @@ -50,7 +50,7 @@ external verify: ( external digest: ( WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, - ~data: ArrayBufferTypedArrayOrDataView.t, + ~data: ArrayBuffer.t, ) => promise = "digest" /** @@ -117,7 +117,7 @@ external deriveBits2: ( external importKey: ( WebCryptoTypes.subtleCrypto, ~format: unknown, - ~keyData: ArrayBufferTypedArrayOrDataView.t, + ~keyData: ArrayBuffer.t, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~extractable: bool, ~keyUsages: array, @@ -164,7 +164,7 @@ external wrapKey2: ( external unwrapKey: ( WebCryptoTypes.subtleCrypto, ~format: WebCryptoTypes.keyFormat, - ~wrappedKey: ArrayBufferTypedArrayOrDataView.t, + ~wrappedKey: ArrayBuffer.t, ~unwrappingKey: WebCryptoTypes.cryptoKey, ~unwrapAlgorithm: WebCryptoTypes.algorithmIdentifier, ~unwrappedKeyAlgorithm: WebCryptoTypes.algorithmIdentifier, From d8dc3ce60808246109c6d89ed468319ce0d61be7 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 15:04:50 -0400 Subject: [PATCH 09/16] test out change to Document --- src/DOM/Document.res | 5 +++-- tests/DOMAPI/HTMLCanvasElement__test.res | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DOM/Document.res b/src/DOM/Document.res index abe9d20..654b824 100644 --- a/src/DOM/Document.res +++ b/src/DOM/Document.res @@ -9,9 +9,10 @@ include Node.Impl({type t = DomTypes.document}) /** Returns the first element within node's descendants whose ID is elementId. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementById) +TODO: prefer option as much as possible */ -@send -external getElementById: (DomTypes.document, string) => null = "getElementById" +@scope("globalThis.document") +external getElementById: string => null = "getElementById" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getAnimations) diff --git a/tests/DOMAPI/HTMLCanvasElement__test.res b/tests/DOMAPI/HTMLCanvasElement__test.res index dd0f01c..580018e 100644 --- a/tests/DOMAPI/HTMLCanvasElement__test.res +++ b/tests/DOMAPI/HTMLCanvasElement__test.res @@ -12,8 +12,7 @@ external setTextBaseline: ( CanvasTypes.canvasTextBaseline, ) => unit = "textBaseline" -let myCanvas: DomTypes.htmlCanvasElement = - DomGlobal.document->Document.getElementById("myCanvas")->toHTMLCanvasElement +let myCanvas: DomTypes.htmlCanvasElement = Document.getElementById("myCanvas")->toHTMLCanvasElement let ctx = myCanvas->HTMLCanvasElement.getContext2D ctx->setFillStyle(FillStyle.fromString("red")) From c83f19c23628510226ce63f5b4b0985d5ec698c3 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 15:42:04 -0400 Subject: [PATCH 10/16] refactor to break up modules --- ...26-05-20-global-singleton-access-design.md | 1051 +++++++++++++++++ rescript.json | 2 +- src/Clipboard/Clipboard.res | 17 +- .../CredentialsContainer.res | 18 +- src/DOM/CustomElementRegistry.res | 19 +- src/DOM/DomGlobal.res | 51 - src/DOM/Navigator.res | 122 +- src/DOM/Window.res | 61 - src/Geolocation/Geolocation.res | 10 +- src/History/History.res | 26 +- src/IndexedDB/IDBFactory.res | 22 +- src/MediaCapabilities/MediaCapabilities.res | 18 +- src/MediaCaptureAndStreams/MediaDevices.res | 16 +- src/MediaSession/MediaSession.res | 7 +- src/Performance/Performance.res | 50 +- src/Permissions/Permissions.res | 9 +- src/ScreenWakeLock/WakeLock.res | 3 +- src/ServiceWorker/ServiceWorkerContainer.res | 17 +- src/Storage/StorageManager.res | 17 +- src/WebCrypto/Crypto.res | 6 +- src/WebCrypto/SubtleCrypto.res | 45 +- src/WebCrypto/WebCryptoTypes.res | 2 +- src/WebLocks/LockManager.res | 16 +- src/WebSpeech/SpeechSynthesis.res | 22 +- src/WebStorage/LocalStorage.res | 49 + src/WebStorage/SessionStorage.res | 49 + src/WebWorkers/CacheStorage.res | 22 +- tests/Fetch__test.res | 5 +- .../GlobalSingleton__test.res | 50 + tests/WebStorageAPI/Storage__test.res | 18 +- 30 files changed, 1398 insertions(+), 422 deletions(-) create mode 100644 docs/superpowers/specs/2026-05-20-global-singleton-access-design.md create mode 100644 src/WebStorage/LocalStorage.res create mode 100644 src/WebStorage/SessionStorage.res create mode 100644 tests/GlobalSingletonAPI/GlobalSingleton__test.res diff --git a/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md b/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md new file mode 100644 index 0000000..6dc4f1b --- /dev/null +++ b/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md @@ -0,0 +1,1051 @@ +# Global Singleton Access Design + +**Date:** 2026-05-20 +**Status:** Draft plan for review before implementation + +## Context + +Many Web APIs in this package are currently modeled as instance methods on an explicit browser-owned receiver. For APIs such as `Crypto`, that forces users to first obtain a global object and then pipe it into the API module: + +```rescript +let id = DomGlobal.crypto->Crypto.randomUUID +``` + +In actual usage, these APIs are almost always accessed through singleton host objects that already exist on the global object or on `navigator`. The preferred public API should make that common case direct: + +```rescript +let id = Crypto.randomUUID() +``` + +The `Crypto` module has already been manually adjusted toward this model: + +```rescript +@scope("globalThis.crypto") +external randomUUID: unit => string = "randomUUID" +``` + +This plan identifies the rest of the API surface that should follow the same rule, while preserving receiver-based APIs for true instance objects such as `Element`, `Document`, `Request`, `Response`, `MediaStream`, `AudioContext`, and canvas contexts. + +All direct singleton bindings should scope through `globalThis`, not through bare globals such as `crypto`, `navigator`, or `performance`. + +## Goals + +- Replace explicit singleton receivers with direct scoped bindings for browser-owned singleton objects. +- Preserve receiver-based `@send` bindings for real instance APIs. +- Make the common browser usage path concise and hard to misuse. +- Keep API modules aligned with Web platform object names where possible. +- Add tests that compile the intended direct usage style. +- Avoid introducing broad global wrappers that hide whether an API is global, navigator-owned, or instance-owned. +- Use `globalThis` as the root for global and nested singleton scopes. +- Remove redundant singleton accessors from `DomGlobal`, `Window`, and `Document` once direct scoped APIs make those values unnecessary. + +## Non-Goals + +- This change does not convert all `@send` bindings. +- This change does not redesign unrelated type modeling. +- This change does not introduce runtime polyfills or availability checks. +- This change does not attempt to solve stricter typed-array typing for `Crypto.getRandomValues`. +- This change does not remove useful raw instance values when users still need the value itself, rather than just the singleton's methods. + +## Core Rule + +Convert a binding from receiver-based `@send` to direct `@scope` only when the receiver is a singleton host object that users should not normally need to pass around. + +Every converted singleton binding should use a `globalThis`-rooted scope: + +```rescript +@scope("globalThis.crypto") +external randomUUID: unit => string = "randomUUID" +``` + +Avoid bare scopes: + +```rescript +@scope("crypto") +external randomUUID: unit => string = "randomUUID" +``` + +The `globalThis` form is preferred because it is explicit about which global object is being read, works better across windows and worker-like globals, and is easier for tests or consumers to mock by replacing `globalThis.`. + +Keep `@send` when: + +- The receiver is a user-created instance. +- The receiver can naturally come from many places. +- The same module is intended to work with arbitrary instances of that Web API object. +- The operation is inherited from a generic protocol such as `EventTarget` and the direct singleton shape has not been deliberately designed yet. + +## Binding Patterns + +### Direct Global Singleton + +Use this when the object is a direct global such as `globalThis.crypto`, `globalThis.performance`, `globalThis.history`, `globalThis.indexedDB`, or `globalThis.caches`. + +Before: + +```rescript +@send +external now: PerformanceTypes.performance => float = "now" +``` + +After: + +```rescript +@scope("globalThis.performance") +external now: unit => float = "now" +``` + +Target usage: + +```rescript +let timestamp = Performance.now() +``` + +### Nested Singleton + +Use this when the object is a singleton property under another singleton, most commonly `globalThis.navigator`. + +Before: + +```rescript +@send +external readText: ClipboardTypes.clipboard => promise = "readText" +``` + +After: + +```rescript +@scope("globalThis.navigator.clipboard") +external readText: unit => promise = "readText" +``` + +Target usage: + +```rescript +let text = await Clipboard.readText() +``` + +### Singleton Property Access + +Use this when a global singleton exposes another object that is useful as a value, such as `globalThis.crypto.subtle`. + +```rescript +@scope("globalThis.crypto") +external subtle: WebCryptoTypes.subtleCrypto = "subtle" +``` + +This can remain available even if `SubtleCrypto` also exposes direct scoped operations. + +### Static Constructor Or Static Class Method + +Do not change existing static bindings that are already modeled with class or constructor scopes. +Do apply the `globalThis` root to those scopes when they are touched by this migration. + +Examples that should remain conceptually unchanged: + +```rescript +@scope("globalThis.URL") +external createObjectURL: unknown => string = "createObjectURL" + +@scope("globalThis.Response") +external error: unit => Response.t = "error" +``` + +These are not singleton object methods. They are static methods on constructors. + +## Candidate Modules + +### WebCrypto + +Current singleton: + +- `DomGlobal.crypto` + +Target direct API: + +```rescript +Crypto.randomUUID() +Crypto.getRandomValues(values) +Crypto.subtle +``` + +Already changed: + +- `Crypto.getRandomValues` +- `Crypto.randomUUID` +- `Crypto.subtle` + +Likely next change: + +- Convert `SubtleCrypto` methods to `@scope("globalThis.crypto.subtle")`. + +Target direct API: + +```rescript +SubtleCrypto.digest(~algorithm, ~data) +SubtleCrypto.encrypt(~algorithm, ~key, ~data) +SubtleCrypto.importKey(...) +``` + +Open question: + +- Keep `Crypto.subtle->SubtleCrypto.digest(...)` compatibility temporarily, or make `SubtleCrypto` direct-only? + +Recommended approach: + +- Convert `SubtleCrypto` to direct scoped bindings. +- Keep `Crypto.subtle` as a value accessor for users who need the raw `subtleCrypto` value. +- Do not add duplicate receiver-based wrappers unless compatibility becomes a release requirement. + +### Performance + +Current singleton: + +- `DomGlobal.performance` + +Current usage shape: + +```rescript +DomGlobal.performance->Performance.now() +DomGlobal.performance->Performance.mark(~markName="start") +``` + +Target direct API: + +```rescript +Performance.now() +Performance.mark(~markName="start") +Performance.getEntries() +Performance.clearMarks() +``` + +Implementation: + +- Convert `Performance.res` methods from `@send` to `@scope("globalThis.performance")`. +- Remove the explicit `PerformanceTypes.performance` receiver from function signatures. + +Special handling: + +- `Performance` currently includes `EventTarget.Impl`. +- Decide separately whether singleton `Performance.addEventListener(...)` wrappers are needed. +- Do not let generic event-target support block the method conversion. + +### History + +Current singleton: + +- `DomGlobal.history` + +Target direct API: + +```rescript +History.back() +History.forward() +History.go(~delta=-1) +History.pushState(~data, ~unused="", ~url="?page=2") +History.replaceState(~data, ~unused="", ~url="?page=3") +``` + +Implementation: + +- Convert all `History.res` methods to `@scope("globalThis.history")`. + +### IndexedDB + +Current singleton: + +- `DomGlobal.indexedDB` + +Target direct API: + +```rescript +IDBFactory.open_(~name="app-db") +IDBFactory.deleteDatabase("app-db") +IDBFactory.databases() +IDBFactory.cmp(~first, ~second) +``` + +Implementation: + +- Convert `IDBFactory.res` from `@send` to `@scope("globalThis.indexedDB")`. + +Keep receiver-based: + +- `IDBDatabase` +- `IDBObjectStore` +- `IDBIndex` +- `IDBTransaction` + +Those are real IndexedDB instances and should remain pipe-friendly. + +### CacheStorage + +Current singleton: + +- `DomGlobal.caches` + +Target direct API: + +```rescript +CacheStorage.open_("assets") +CacheStorage.keys() +CacheStorage.has("assets") +CacheStorage.delete("assets") +``` + +Implementation: + +- Convert `WebWorkers/CacheStorage.res` methods to `@scope("globalThis.caches")`. + +Keep receiver-based: + +- `ServiceWorker/Cache.res` + +`Cache` instances returned by `CacheStorage.open_` should remain instance APIs. + +### WebSpeech + +Current singleton: + +- `DomGlobal.speechSynthesis` + +Target direct API: + +```rescript +SpeechSynthesis.speak(utterance) +SpeechSynthesis.cancel() +SpeechSynthesis.pause() +SpeechSynthesis.resume() +SpeechSynthesis.getVoices() +``` + +Implementation: + +- Convert methods in `SpeechSynthesis.res` to `@scope("globalThis.speechSynthesis")`. + +Special handling: + +- `SpeechSynthesis` currently includes `EventTarget.Impl`. +- Decide whether to add direct event listener wrappers for `speechSynthesis` events. + +### CustomElementRegistry + +Current singleton: + +- `DomGlobal.customElements` + +Target direct API: + +```rescript +CustomElementRegistry.define(~name, ~constructor, ~options=?) +CustomElementRegistry.whenDefined("my-element") +CustomElementRegistry.getName(constructor) +CustomElementRegistry.upgrade(node) +``` + +Implementation: + +- Convert `CustomElementRegistry.res` to `@scope("globalThis.customElements")`. + +Open naming question: + +- The module name is technically the interface name, but user-facing usage may read better as `CustomElements.define(...)`. +- Recommended for now: keep `CustomElementRegistry` to avoid a public module rename in the same change. + +## Navigator-Owned Candidate Modules + +These modules currently require this general shape: + +```rescript +DomGlobal.navigator->Navigator.someProperty->SomeModule.someMethod(...) +``` + +They should be converted to nested scopes where the Web API object is a singleton property of `globalThis.navigator`. + +### Clipboard + +Current singleton path: + +- `navigator.clipboard` + +Target direct API: + +```rescript +Clipboard.read() +Clipboard.readText() +Clipboard.write(items) +Clipboard.writeText("text") +``` + +Implementation: + +- Convert `Clipboard.res` methods to `@scope("globalThis.navigator.clipboard")`. + +Keep receiver-based: + +- `ClipboardItem.res` + +### CredentialsContainer + +Current singleton path: + +- `navigator.credentials` + +Target direct API: + +```rescript +CredentialsContainer.get(~options) +CredentialsContainer.create(~options) +CredentialsContainer.store(credential) +CredentialsContainer.preventSilentAccess() +``` + +Implementation: + +- Convert `CredentialsContainer.res` to `@scope("globalThis.navigator.credentials")`. + +### Geolocation + +Current singleton path: + +- `navigator.geolocation` + +Target direct API: + +```rescript +Geolocation.getCurrentPosition(~successCallback, ~errorCallback=?, ~options=?) +Geolocation.watchPosition(~successCallback, ~errorCallback=?, ~options=?) +Geolocation.clearWatch(id) +``` + +Implementation: + +- Convert `Geolocation.res` to `@scope("globalThis.navigator.geolocation")`. + +Keep receiver-based: + +- `GeolocationCoordinates` +- `GeolocationPosition` + +### MediaCapabilities + +Current singleton path: + +- `navigator.mediaCapabilities` + +Target direct API: + +```rescript +MediaCapabilities.decodingInfo(configuration) +MediaCapabilities.encodingInfo(configuration) +``` + +Implementation: + +- Convert `MediaCapabilities.res` to `@scope("globalThis.navigator.mediaCapabilities")`. + +### MediaDevices + +Current singleton path: + +- `navigator.mediaDevices` + +Target direct API: + +```rescript +MediaDevices.enumerateDevices() +MediaDevices.getSupportedConstraints() +MediaDevices.getUserMedia(~constraints) +MediaDevices.getDisplayMedia(~options) +``` + +Implementation: + +- Convert `MediaDevices.res` methods to `@scope("globalThis.navigator.mediaDevices")`. + +Special handling: + +- `MediaDevices` currently includes `EventTarget.Impl`. +- Decide whether to add direct singleton event wrappers. + +Keep receiver-based: + +- `MediaStream` +- `MediaStreamTrack` +- `MediaDeviceInfo` + +### MediaSession + +Current singleton path: + +- `navigator.mediaSession` + +Target direct API: + +```rescript +MediaSession.setActionHandler(~action, ~handler) +MediaSession.setPositionState(~state) +``` + +Implementation: + +- Convert `MediaSession.res` to `@scope("globalThis.navigator.mediaSession")`. + +### Permissions + +Current singleton path: + +- `navigator.permissions` + +Target direct API: + +```rescript +Permissions.query(descriptor) +``` + +Implementation: + +- Convert `Permissions.res` to `@scope("globalThis.navigator.permissions")`. + +### ScreenWakeLock + +Current singleton path: + +- `navigator.wakeLock` + +Target direct API: + +```rescript +WakeLock.request(~type_=Screen) +``` + +Implementation: + +- Convert `WakeLock.res` to `@scope("globalThis.navigator.wakeLock")`. + +Keep receiver-based: + +- `WakeLockSentinel.release` + +### ServiceWorkerContainer + +Current singleton path: + +- `navigator.serviceWorker` + +Target direct API: + +```rescript +ServiceWorkerContainer.register("/sw.js") +ServiceWorkerContainer.getRegistration() +ServiceWorkerContainer.getRegistrations() +ServiceWorkerContainer.startMessages() +``` + +Implementation: + +- Convert `ServiceWorkerContainer.res` to `@scope("globalThis.navigator.serviceWorker")`. + +Special handling: + +- `ServiceWorkerContainer` currently includes `EventTarget.Impl`. +- Decide whether direct event listener wrappers are needed. + +Keep receiver-based: + +- `ServiceWorker` +- `ServiceWorkerRegistration` +- `NavigationPreloadManager` +- `Clients` +- `Cache` + +### StorageManager + +Current singleton path: + +- `navigator.storage` + +Target direct API: + +```rescript +StorageManager.persisted() +StorageManager.persist() +StorageManager.estimate() +StorageManager.getDirectory() +``` + +Implementation: + +- Convert `StorageManager.res` to `@scope("globalThis.navigator.storage")`. + +### LockManager + +Current singleton path: + +- `navigator.locks` + +Target direct API: + +```rescript +LockManager.request(~name, ~callback) +LockManager.request2(~name, ~options, ~callback) +LockManager.query() +``` + +Implementation: + +- Convert `LockManager.res` to `@scope("globalThis.navigator.locks")`. + +## WebStorage Decision + +`Storage` is a special case because there are two common singleton instances: + +- `localStorage` +- `sessionStorage` + +Current usage: + +```rescript +DomGlobal.localStorage->Storage.getItem("key") +DomGlobal.sessionStorage->Storage.setItem(~key="key", ~value="value") +``` + +A single direct `Storage.getItem("key")` would be ambiguous. + +Recommended design: + +- Keep `Storage.res` receiver-based for arbitrary `Storage` instances. +- Add separate singleton modules: + - `LocalStorage` + - `SessionStorage` + +Target direct API: + +```rescript +LocalStorage.getItem("key") +LocalStorage.setItem(~key="key", ~value="value") +LocalStorage.clear() + +SessionStorage.getItem("key") +SessionStorage.setItem(~key="key", ~value="value") +SessionStorage.clear() +``` + +Potential implementation: + +```rescript +@scope("globalThis.localStorage") +external getItem: string => Null.t = "getItem" + +@scope("globalThis.sessionStorage") +external getItem: string => Null.t = "getItem" +``` + +Length access needs special handling because `length` is a property, not a method. + +Possible shape: + +```rescript +@scope("globalThis.localStorage") @val +external length: int = "length" +``` + +Open questions: + +- Should `LocalStorage` and `SessionStorage` be public modules in `rescript.json`? +- Should their implementations duplicate bindings or share an internal functor/helper? +- Should `Storage` retain all current tests while new tests cover the singleton modules? + +## Navigator Module Itself + +`Navigator.res` has two categories of bindings: + +- Property accessors such as `clipboard`, `permissions`, `mediaDevices`, and `storage`. +- Methods on the singleton `navigator` such as `sendBeacon`, `getGamepads`, `requestMediaKeySystemAccess`, and `requestMIDIAccess`. + +Recommended design: + +- Keep property accessors receiver-based for users who have an explicit navigator value from a non-standard context. +- Add or convert direct methods for the singleton `navigator` methods. + +Target direct API: + +```rescript +Navigator.sendBeacon(~url, ~data=?) +Navigator.getGamepads() +Navigator.requestMediaKeySystemAccess(~keySystem, ~supportedConfigurations) +Navigator.requestMIDIAccess(~options=?) +``` + +Open question: + +- Should global navigator property reads also be exposed directly, for example `Navigator.userAgent` or `Navigator.language`? + +Recommended approach: + +- Convert singleton methods first. +- Defer direct property reads until there is a clear naming convention for property values versus functions. + +## Modules To Leave Receiver-Based + +These modules should not be converted wholesale because they model normal instances: + +- `Document` +- `Element` +- `Node` +- `Event` +- `EventTarget` +- `Request` +- `Response` +- `Headers` +- `FormData` +- `URLSearchParams` +- `MediaStream` +- `MediaStreamTrack` +- `IDBDatabase` +- `IDBObjectStore` +- `IDBIndex` +- `IDBTransaction` +- `Cache` +- `ServiceWorker` +- `ServiceWorkerRegistration` +- `AudioContext` +- `BaseAudioContext` +- `AudioNode` +- `AudioParam` +- `CanvasRenderingContext2D` +- `HTMLCanvasElement` +- `MutationObserver` +- `ResizeObserver` +- `IntersectionObserver` + +This list is intentionally conservative. A module should move out of this category only when there is a single browser-owned global object that clearly owns its methods. + +## EventTarget Handling + +Some singleton objects are also event targets: + +- `SpeechSynthesis` +- `Clipboard` +- `MediaDevices` +- `ServiceWorkerContainer` +- possibly `Performance` + +Current modules often include: + +```rescript +include EventTarget.Impl({type t = SomeTypes.someSingleton}) +``` + +That exposes receiver-based event target methods such as: + +```rescript +someSingleton->SomeModule.addEventListener(...) +``` + +There are three possible approaches: + +1. Leave event target methods receiver-based and only convert API-specific methods. +2. Add scoped singleton wrappers for event target methods in each singleton module. +3. Generalize `EventTarget.Impl` so it can generate both receiver-based and scoped singleton bindings. + +Recommended first implementation: + +- Use option 1. +- Convert only API-specific methods first. +- Add direct event target wrappers later if tests or docs show a strong need. + +Rationale: + +- It avoids duplicating a large event target surface in the first migration. +- It keeps the main access-shape change small enough to review. +- It preserves a path for explicit event target values. + +## Compatibility Strategy + +This is a breaking public API change for converted modules because functions lose their receiver argument. + +Possible compatibility options: + +1. Direct replacement only. +2. Keep deprecated receiver-based functions under old names. +3. Keep receiver-based variants under explicit names such as `nowOn`, `openOn`, or `readTextOn`. + +Recommended approach: + +- Use direct replacement for modules where the receiver was only exposed through a singleton global. +- Add compatibility wrappers only when there is evidence that arbitrary instances are useful or tests require them. +- Document the migration pattern in release notes: + +```rescript +// Before +DomGlobal.performance->Performance.now() + +// After +Performance.now() +``` + +## Implementation Phases + +### Phase 1: Confirm Scope Syntax + +Before changing the full surface, add or temporarily compile a small set of representative scoped bindings: + +- `@scope("globalThis.crypto")` +- `@scope("globalThis.performance")` +- `@scope("globalThis.navigator.clipboard")` +- `@scope("globalThis.crypto.subtle")` +- property access through `@scope("globalThis.localStorage")` if `LocalStorage` is approved + +Verification: + +- `npm run build` +- inspect generated JavaScript for representative modules +- confirm generated JavaScript reads from `globalThis.`, not from a bare global + +### Phase 2: Convert Direct Global Singletons + +Convert the lowest-risk direct globals: + +- `Crypto` +- `Performance` +- `History` +- `IDBFactory` +- `CacheStorage` +- `SpeechSynthesis` +- `CustomElementRegistry` + +Update tests or add compile-only test coverage for intended usage. + +### Phase 3: Convert Navigator-Owned Singletons + +Convert nested navigator-owned modules: + +- `Clipboard` +- `CredentialsContainer` +- `Geolocation` +- `MediaCapabilities` +- `MediaDevices` +- `MediaSession` +- `Permissions` +- `WakeLock` +- `ServiceWorkerContainer` +- `StorageManager` +- `LockManager` + +Update tests with direct `Module.method(...)` calls. + +### Phase 4: Resolve WebStorage + +After agreeing on the public shape: + +- Add `LocalStorage.res` +- Add `SessionStorage.res` +- Add both modules to the `WebAPI.WebStorage` public list in `rescript.json` +- Keep `Storage.res` receiver-based +- Update WebStorage tests to cover direct singleton usage and generic receiver usage + +### Phase 5: Documentation And Migration Notes + +Update docs and examples: + +- Replace `DomGlobal.->Module.method(...)` examples. +- Add a short migration note for singleton access. +- Document the `globalThis` scoping policy and the reason for it. +- Keep examples for instance APIs unchanged. + +### Phase 6: Global Accessor Cleanup + +After all conversions: + +- Search for stale `DomGlobal.->` usages in tests and docs. +- Search for singleton modules still accepting their singleton receiver as the first argument. +- Remove redundant singleton values from `DomGlobal` when the direct module now covers the intended usage. +- Audit `Window` and remove redundant singleton accessors that only duplicate global singleton module access. +- Audit `Document` and remove redundant paths to singleton APIs if any exist. +- Keep raw values only when there is a concrete multi-instance use case or the value itself is useful. +- If a raw value is kept, document why it remains receiver-based or value-based. + +The cleanup bias should be removal. `DomGlobal`, `Window`, and `Document` should not remain as alternate routes to APIs that now have direct `globalThis`-scoped modules. + +Likely `DomGlobal` removal candidates after conversion: + +- `crypto` +- `performance` +- `history` +- `indexedDB` +- `caches` +- `speechSynthesis` +- `customElements` +- `localStorage`, if `LocalStorage` is added +- `sessionStorage`, if `SessionStorage` is added + +Likely `Window` removal candidates mirror the same singleton properties when they only provide another route to the current realm's singleton: + +- `window->Window.crypto` +- `window->Window.performance` +- `window->Window.history` +- `window->Window.indexedDB` +- `window->Window.caches` +- `window->Window.speechSynthesis` +- `window->Window.customElements` +- `window->Window.localStorage`, if `LocalStorage` is added +- `window->Window.sessionStorage`, if `SessionStorage` is added + +Keep a `Window` accessor only when supporting explicit alternate `Window` values is a deliberate use case, for example an iframe or popup window. Do not keep it solely as a compatibility path to the current global singleton. + +`Document` should stay mostly receiver-based because documents are real instances. The cleanup pass should only remove `Document` shortcuts that exist to reach the current global document or another singleton indirectly. Any direct global-document convenience should use `globalThis.document` explicitly and should be documented as current-document-only. + +Likely `Navigator` property cleanup candidates depend on whether explicit navigator values remain supported: + +- `clipboard` +- `credentials` +- `geolocation` +- `mediaCapabilities` +- `mediaDevices` +- `mediaSession` +- `permissions` +- `wakeLock` +- `serviceWorker` +- `storage` +- `locks` + +## Testing Plan + +Add or update tests to compile these representative usages: + +```rescript +Crypto.randomUUID() +Crypto.getRandomValues([1, 2, 3]) + +Performance.now() +Performance.mark(~markName="start") +Performance.clearMarks() + +History.back() +History.pushState(~data=JSON.Encode.null, ~unused="") + +IDBFactory.open_(~name="test-db") +IDBFactory.databases() + +CacheStorage.open_("test-cache") +CacheStorage.keys() + +Clipboard.readText() +Clipboard.writeText("hello") + +Permissions.query(descriptor) + +MediaDevices.enumerateDevices() +StorageManager.estimate() +LockManager.query() +``` + +Where runtime availability is unreliable in the test environment, prefer compile-only tests or guard runtime calls behind feature checks. + +Existing WebStorage tests should be updated after the `LocalStorage` and `SessionStorage` decision. + +## Verification Commands + +Run after each phase: + +```sh +npm run build +npm test +``` + +Run before finalizing: + +```sh +npm run format:check +``` + +If formatting is expected to rewrite generated or hand-written files, run: + +```sh +npm run format +``` + +## Search Checklist + +Use these searches to find remaining old-style singleton usage: + +```sh +grep -RIn "DomGlobal.crypto->" src tests docs +grep -RIn "DomGlobal.performance->" src tests docs +grep -RIn "DomGlobal.history->" src tests docs +grep -RIn "DomGlobal.indexedDB->" src tests docs +grep -RIn "DomGlobal.caches->" src tests docs +grep -RIn "DomGlobal.speechSynthesis->" src tests docs +grep -RIn "DomGlobal.navigator->Navigator" src tests docs +``` + +Use these searches to find singleton modules that still take explicit receivers: + +```sh +grep -RIn "external .*PerformanceTypes.performance" src/Performance +grep -RIn "external .*HistoryTypes.history" src/History +grep -RIn "external .*IndexedDbTypes.idbFactory" src/IndexedDB +grep -RIn "external .*WebWorkersTypes.cacheStorage" src/WebWorkers +grep -RIn "external .*WebSpeechTypes.speechSynthesis" src/WebSpeech +grep -RIn "external .*ClipboardTypes.clipboard" src/Clipboard +grep -RIn "external .*PermissionsTypes.permissions" src/Permissions +``` + +Use these searches to catch bare singleton scopes that should be rooted at `globalThis`: + +```sh +grep -RIn '@scope("crypto")' src tests docs +grep -RIn '@scope("performance")' src tests docs +grep -RIn '@scope("history")' src tests docs +grep -RIn '@scope("indexedDB")' src tests docs +grep -RIn '@scope("caches")' src tests docs +grep -RIn '@scope(("navigator"' src tests docs +``` + +Use these searches during the cleanup pass: + +```sh +grep -RIn "external crypto:" src/DOM +grep -RIn "external performance:" src/DOM +grep -RIn "external history:" src/DOM +grep -RIn "external indexedDB:" src/DOM +grep -RIn "external caches:" src/DOM +grep -RIn "external speechSynthesis:" src/DOM +grep -RIn "external customElements:" src/DOM +grep -RIn "external localStorage:" src/DOM +grep -RIn "external sessionStorage:" src/DOM +``` + +## Risks + +- Over-converting instance APIs would remove useful pipe-based usage. +- `globalThis`-rooted `@scope` syntax must be verified against generated JavaScript before large-scale conversion. +- Event target support may feel inconsistent if API methods become direct but event methods remain receiver-based. +- WebStorage can become confusing if `Storage` is made direct without distinguishing `localStorage` from `sessionStorage`. +- Removing raw `Window`, `Document`, or `DomGlobal` accessors too aggressively could break legitimate multi-window or explicit-value use cases. +- Some APIs may not exist in all runtimes used by tests, so runtime tests need guards. + +## Open Decisions + +- Should `SubtleCrypto` become direct-only or keep receiver-based compatibility? +- Should singleton event target methods get direct wrappers in this migration? +- Should `Navigator` expose direct global property reads such as `Navigator.userAgent`? +- Should `CustomElementRegistry` keep its current module name or gain a `CustomElements` alias? +- Should WebStorage add public `LocalStorage` and `SessionStorage` modules? +- Should compatibility wrappers exist for any converted modules? +- Which `DomGlobal`, `Window`, and `Document` singleton accessors have a concrete reason to remain after direct `globalThis`-scoped modules exist? + +## Recommended Initial Scope + +The first implementation should convert only: + +- `Crypto` +- `SubtleCrypto` +- `Performance` +- `History` +- `IDBFactory` +- `CacheStorage` +- `Clipboard` +- `Permissions` + +This covers direct globals and one nested navigator-owned API without touching the more ambiguous WebStorage and event-heavy surfaces. Once this compiles and tests cleanly, continue with the remaining navigator-owned modules. diff --git a/rescript.json b/rescript.json index 6b9d84a..c97eb25 100644 --- a/rescript.json +++ b/rescript.json @@ -499,7 +499,7 @@ "dir": "src/WebStorage", "subdirs": true, "feature": "WebAPI.WebStorage", - "public": ["Storage", "StorageEvent"] + "public": ["LocalStorage", "SessionStorage", "Storage", "StorageEvent"] }, { "dir": "src/WebVTT", diff --git a/src/Clipboard/Clipboard.res b/src/Clipboard/Clipboard.res index 7e7135d..d7a9a80 100644 --- a/src/Clipboard/Clipboard.res +++ b/src/Clipboard/Clipboard.res @@ -3,27 +3,26 @@ include EventTarget.Impl({type t = ClipboardTypes.clipboard}) /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/read) */ -@send -external read: ClipboardTypes.clipboard => promise> = "read" +@scope("globalThis.navigator.clipboard") +external read: unit => promise> = "read" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/readText) */ -@send -external readText: ClipboardTypes.clipboard => promise = "readText" +@scope("globalThis.navigator.clipboard") +external readText: unit => promise = "readText" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/write) */ -@send -external write: (ClipboardTypes.clipboard, array) => promise = - "write" +@scope("globalThis.navigator.clipboard") +external write: array => promise = "write" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Clipboard/writeText) */ -@send -external writeText: (ClipboardTypes.clipboard, string) => promise = "writeText" +@scope("globalThis.navigator.clipboard") +external writeText: string => promise = "writeText" module ClipboardItem = ClipboardItem module Types = ClipboardTypes diff --git a/src/CredentialManagement/CredentialsContainer.res b/src/CredentialManagement/CredentialsContainer.res index 5e3405d..3a5fe95 100644 --- a/src/CredentialManagement/CredentialsContainer.res +++ b/src/CredentialManagement/CredentialsContainer.res @@ -1,33 +1,27 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get) */ -@send +@scope("globalThis.navigator.credentials") external get: ( - CredentialManagementTypes.credentialsContainer, ~options: CredentialManagementTypes.credentialRequestOptions=?, ) => promise = "get" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store) */ -@send -external store: ( - CredentialManagementTypes.credentialsContainer, - CredentialManagementTypes.credential, -) => promise = "store" +@scope("globalThis.navigator.credentials") +external store: CredentialManagementTypes.credential => promise = "store" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/create) */ -@send +@scope("globalThis.navigator.credentials") external create: ( - CredentialManagementTypes.credentialsContainer, ~options: CredentialManagementTypes.credentialCreationOptions=?, ) => promise = "create" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/preventSilentAccess) */ -@send -external preventSilentAccess: CredentialManagementTypes.credentialsContainer => promise = - "preventSilentAccess" +@scope("globalThis.navigator.credentials") +external preventSilentAccess: unit => promise = "preventSilentAccess" diff --git a/src/DOM/CustomElementRegistry.res b/src/DOM/CustomElementRegistry.res index eede652..5af21f9 100644 --- a/src/DOM/CustomElementRegistry.res +++ b/src/DOM/CustomElementRegistry.res @@ -1,9 +1,8 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/define) */ -@send +@scope("globalThis.customElements") external define: ( - DomTypes.customElementRegistry, ~name: string, ~constructor: DomTypes.htmlElement, ~options: DomTypes.elementDefinitionOptions=?, @@ -12,21 +11,17 @@ external define: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/getName) */ -@send -external getName: (DomTypes.customElementRegistry, DomTypes.customElementConstructor) => string = - "getName" +@scope("globalThis.customElements") +external getName: DomTypes.customElementConstructor => string = "getName" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/whenDefined) */ -@send -external whenDefined: ( - DomTypes.customElementRegistry, - string, -) => promise = "whenDefined" +@scope("globalThis.customElements") +external whenDefined: string => promise = "whenDefined" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/upgrade) */ -@send -external upgrade: (DomTypes.customElementRegistry, DomTypes.node) => unit = "upgrade" +@scope("globalThis.customElements") +external upgrade: DomTypes.node => unit = "upgrade" diff --git a/src/DOM/DomGlobal.res b/src/DOM/DomGlobal.res index d6e7cf2..a0bf3f6 100644 --- a/src/DOM/DomGlobal.res +++ b/src/DOM/DomGlobal.res @@ -23,17 +23,6 @@ external name: string = "name" */ external location: DomTypes.location = "location" -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/history) -*/ -external history: HistoryTypes.history = "history" - -/** -Defines a new custom element, mapping the given name to the given constructor as an autonomous custom element. -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/customElements) -*/ -external customElements: DomTypes.customElementRegistry = "customElements" - /** Returns true if the location bar is visible; otherwise, returns false. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/locationbar) @@ -109,11 +98,6 @@ external parent: DomTypes.window = "parent" */ external frameElement: DomTypes.element = "frameElement" -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/navigator) -*/ -external navigator: DomTypes.navigator = "navigator" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screen) */ @@ -179,11 +163,6 @@ external outerHeight: int = "outerHeight" */ external devicePixelRatio: float = "devicePixelRatio" -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/speechSynthesis) -*/ -external speechSynthesis: WebSpeechTypes.speechSynthesis = "speechSynthesis" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/origin) */ @@ -199,36 +178,6 @@ external isSecureContext: bool = "isSecureContext" */ external crossOriginIsolated: bool = "crossOriginIsolated" -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) -*/ -external indexedDB: IndexedDbTypes.idbFactory = "indexedDB" - -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/crypto) -*/ -external crypto: WebCryptoTypes.crypto = "crypto" - -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/performance) -*/ -external performance: PerformanceTypes.performance = "performance" - -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/caches) -*/ -external caches: WebWorkersTypes.cacheStorage = "caches" - -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) -*/ -external sessionStorage: WebStorageTypes.storage = "sessionStorage" - -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/localStorage) -*/ -external localStorage: WebStorageTypes.storage = "localStorage" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/reportError) */ diff --git a/src/DOM/Navigator.res b/src/DOM/Navigator.res index 2f2fe0b..66537eb 100644 --- a/src/DOM/Navigator.res +++ b/src/DOM/Navigator.res @@ -1,157 +1,112 @@ type t = DomTypes.navigator -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/clipboard) - */ -@get external clipboard: t => ClipboardTypes.clipboard = "clipboard" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/credentials) - */ -@get external credentials: t => CredentialManagementTypes.credentialsContainer = "credentials" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/geolocation) - */ -@get external geolocation: t => GeolocationTypes.geolocation = "geolocation" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/userActivation) */ -@get external userActivation: t => DomTypes.userActivation = "userActivation" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaCapabilities) - */ -@get external mediaCapabilities: t => MediaCapabilitiesTypes.mediaCapabilities = "mediaCapabilities" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaDevices) - */ -@get external mediaDevices: t => MediaCaptureAndStreamsTypes.mediaDevices = "mediaDevices" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaSession) - */ -@get external mediaSession: t => MediaSessionTypes.mediaSession = "mediaSession" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/permissions) - */ -@get external permissions: t => PermissionsTypes.permissions = "permissions" +@scope("globalThis.navigator") @val +external userActivation: DomTypes.userActivation = "userActivation" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/maxTouchPoints) */ -@get external maxTouchPoints: t => int = "maxTouchPoints" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/wakeLock) - */ -@get external wakeLock: t => ScreenWakeLockTypes.wakeLock = "wakeLock" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/serviceWorker) - */ -@get external serviceWorker: t => ServiceWorkerTypes.serviceWorkerContainer = "serviceWorker" +@scope("globalThis.navigator") @val +external maxTouchPoints: int = "maxTouchPoints" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/userAgent) */ -@get external userAgent: t => string = "userAgent" +@scope("globalThis.navigator") @val +external userAgent: string = "userAgent" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/language) */ -@get external language: t => string = "language" +@scope("globalThis.navigator") @val +external language: string = "language" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/languages) */ -@get external languages: t => array = "languages" +@scope("globalThis.navigator") @val +external languages: array = "languages" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/onLine) */ -@get external onLine: t => bool = "onLine" +@scope("globalThis.navigator") @val +external onLine: bool = "onLine" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/cookieEnabled) */ -@get external cookieEnabled: t => bool = "cookieEnabled" +@scope("globalThis.navigator") @val +external cookieEnabled: bool = "cookieEnabled" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/pdfViewerEnabled) */ -@get external pdfViewerEnabled: t => bool = "pdfViewerEnabled" +@scope("globalThis.navigator") @val +external pdfViewerEnabled: bool = "pdfViewerEnabled" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/hardwareConcurrency) */ -@get external hardwareConcurrency: t => int = "hardwareConcurrency" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/storage) - */ -@get external storage: t => StorageTypes.storageManager = "storage" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/locks) - */ -@get external locks: t => WebLocksTypes.lockManager = "locks" +@scope("globalThis.navigator") @val +external hardwareConcurrency: int = "hardwareConcurrency" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/webdriver) */ -@get external webdriver: t => bool = "webdriver" +@scope("globalThis.navigator") @val +external webdriver: bool = "webdriver" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon: (t, ~url: string, ~data: FileTypes.readableStream=?) => bool = - "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon: (~url: string, ~data: FileTypes.readableStream=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon2: (t, ~url: string, ~data: FileTypes.blob=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon2: (~url: string, ~data: FileTypes.blob=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon3: (t, ~url: string, ~data: DataView.t=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon3: (~url: string, ~data: DataView.t=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon4: (t, ~url: string, ~data: ArrayBuffer.t=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon4: (~url: string, ~data: ArrayBuffer.t=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon5: (t, ~url: string, ~data: FetchTypes.formData=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon5: (~url: string, ~data: FetchTypes.formData=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon6: (t, ~url: string, ~data: UrlTypes.urlSearchParams=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon6: (~url: string, ~data: UrlTypes.urlSearchParams=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) */ -@send -external sendBeacon7: (t, ~url: string, ~data: string=?) => bool = "sendBeacon" +@scope("globalThis.navigator") +external sendBeacon7: (~url: string, ~data: string=?) => bool = "sendBeacon" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/getGamepads) */ -@send -external getGamepads: t => array = "getGamepads" +@scope("globalThis.navigator") +external getGamepads: unit => array = "getGamepads" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/requestMediaKeySystemAccess) */ -@send +@scope("globalThis.navigator") external requestMediaKeySystemAccess: ( - t, ~keySystem: string, ~supportedConfigurations: array, ) => promise<'mediaKeySystemAccess> = "requestMediaKeySystemAccess" @@ -159,8 +114,7 @@ external requestMediaKeySystemAccess: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/requestMIDIAccess) */ -@send +@scope("globalThis.navigator") external requestMIDIAccess: ( - t, ~options: WebMidiTypes.midiOptions=?, ) => promise = "requestMIDIAccess" diff --git a/src/DOM/Window.res b/src/DOM/Window.res index 62c8576..98a0574 100644 --- a/src/DOM/Window.res +++ b/src/DOM/Window.res @@ -35,19 +35,6 @@ external name: t => string = "name" @get external location: t => DomTypes.location = "location" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/history) - */ -@get -external history: t => HistoryTypes.history = "history" - -/** - Defines a new custom element, mapping the given name to the given constructor as an autonomous custom element. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/customElements) - */ -@get -external customElements: t => DomTypes.customElementRegistry = "customElements" - /** Returns true if the location bar is visible; otherwise, returns false. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/locationbar) @@ -136,12 +123,6 @@ external parent: t => t = "parent" @get external frameElement: t => Null.t = "frameElement" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/navigator) - */ -@get -external navigator: t => DomTypes.navigator = "navigator" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screen) */ @@ -220,12 +201,6 @@ external outerHeight: t => int = "outerHeight" @get external devicePixelRatio: t => float = "devicePixelRatio" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/speechSynthesis) - */ -@get -external speechSynthesis: t => WebSpeechTypes.speechSynthesis = "speechSynthesis" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/origin) */ @@ -244,42 +219,6 @@ external isSecureContext: t => bool = "isSecureContext" @get external crossOriginIsolated: t => bool = "crossOriginIsolated" -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) - */ -@get -external indexedDB: t => IndexedDbTypes.idbFactory = "indexedDB" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/crypto) - */ -@get -external crypto: t => WebCryptoTypes.crypto = "crypto" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/performance) - */ -@get -external performance: t => PerformanceTypes.performance = "performance" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/caches) - */ -@get -external caches: t => WebWorkersTypes.cacheStorage = "caches" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) - */ -@get -external sessionStorage: t => WebStorageTypes.storage = "sessionStorage" - -/** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/localStorage) - */ -@get -external localStorage: t => WebStorageTypes.storage = "localStorage" - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/reportError) */ diff --git a/src/Geolocation/Geolocation.res b/src/Geolocation/Geolocation.res index 18904fb..d920140 100644 --- a/src/Geolocation/Geolocation.res +++ b/src/Geolocation/Geolocation.res @@ -1,9 +1,8 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Geolocation/getCurrentPosition) */ -@send +@scope("globalThis.navigator.geolocation") external getCurrentPosition: ( - GeolocationTypes.geolocation, ~successCallback: GeolocationTypes.positionCallback, ~errorCallback: GeolocationTypes.positionErrorCallback=?, ~options: GeolocationTypes.positionOptions=?, @@ -12,9 +11,8 @@ external getCurrentPosition: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Geolocation/watchPosition) */ -@send +@scope("globalThis.navigator.geolocation") external watchPosition: ( - GeolocationTypes.geolocation, ~successCallback: GeolocationTypes.positionCallback, ~errorCallback: GeolocationTypes.positionErrorCallback=?, ~options: GeolocationTypes.positionOptions=?, @@ -23,8 +21,8 @@ external watchPosition: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Geolocation/clearWatch) */ -@send -external clearWatch: (GeolocationTypes.geolocation, int) => unit = "clearWatch" +@scope("globalThis.navigator.geolocation") +external clearWatch: int => unit = "clearWatch" module GeolocationCoordinates = GeolocationCoordinates module GeolocationPosition = GeolocationPosition diff --git a/src/History/History.res b/src/History/History.res index 2738bad..40c64a7 100644 --- a/src/History/History.res +++ b/src/History/History.res @@ -1,37 +1,31 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/go) */ -@send -external go: (HistoryTypes.history, ~delta: int=?) => unit = "go" +@scope("globalThis.history") +external go: (~delta: int=?) => unit = "go" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/back) */ -@send -external back: HistoryTypes.history => unit = "back" +@scope("globalThis.history") +external back: unit => unit = "back" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/forward) */ -@send -external forward: HistoryTypes.history => unit = "forward" +@scope("globalThis.history") +external forward: unit => unit = "forward" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/pushState) */ -@send -external pushState: (HistoryTypes.history, ~data: JSON.t, ~unused: string, ~url: string=?) => unit = - "pushState" +@scope("globalThis.history") +external pushState: (~data: JSON.t, ~unused: string, ~url: string=?) => unit = "pushState" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/History/replaceState) */ -@send -external replaceState: ( - HistoryTypes.history, - ~data: JSON.t, - ~unused: string, - ~url: string=?, -) => unit = "replaceState" +@scope("globalThis.history") +external replaceState: (~data: JSON.t, ~unused: string, ~url: string=?) => unit = "replaceState" module Types = HistoryTypes diff --git a/src/IndexedDB/IDBFactory.res b/src/IndexedDB/IDBFactory.res index d6a5b05..f94221f 100644 --- a/src/IndexedDB/IDBFactory.res +++ b/src/IndexedDB/IDBFactory.res @@ -2,27 +2,21 @@ Attempts to open a connection to the named database with the current version, or 1 if it does not already exist. If the request is successful request's result will be the connection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/open) */ -@send -external open_: ( - IndexedDbTypes.idbFactory, - ~name: string, - ~version: int=?, -) => IndexedDbTypes.idbOpenDBRequest = "open" +@scope("globalThis.indexedDB") +external open_: (~name: string, ~version: int=?) => IndexedDbTypes.idbOpenDBRequest = "open" /** Attempts to delete the named database. If the database already exists and there are open connections that don't close in response to a versionchange event, the request will be blocked until all they close. If the request is successful request's result will be null. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/deleteDatabase) */ -@send -external deleteDatabase: (IndexedDbTypes.idbFactory, string) => IndexedDbTypes.idbOpenDBRequest = - "deleteDatabase" +@scope("globalThis.indexedDB") +external deleteDatabase: string => IndexedDbTypes.idbOpenDBRequest = "deleteDatabase" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/databases) */ -@send -external databases: IndexedDbTypes.idbFactory => promise> = - "databases" +@scope("globalThis.indexedDB") +external databases: unit => promise> = "databases" /** Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if the keys are equal. @@ -30,5 +24,5 @@ Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precede Throws a "DataError" DOMException if either input is not a valid key. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBFactory/cmp) */ -@send -external cmp: (IndexedDbTypes.idbFactory, ~first: JSON.t, ~second: JSON.t) => int = "cmp" +@scope("globalThis.indexedDB") +external cmp: (~first: JSON.t, ~second: JSON.t) => int = "cmp" diff --git a/src/MediaCapabilities/MediaCapabilities.res b/src/MediaCapabilities/MediaCapabilities.res index 5646269..04a4e29 100644 --- a/src/MediaCapabilities/MediaCapabilities.res +++ b/src/MediaCapabilities/MediaCapabilities.res @@ -1,19 +1,17 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaCapabilities/decodingInfo) */ -@send -external decodingInfo: ( - MediaCapabilitiesTypes.mediaCapabilities, - MediaCapabilitiesTypes.mediaDecodingConfiguration, -) => promise = "decodingInfo" +@scope("globalThis.navigator.mediaCapabilities") +external decodingInfo: MediaCapabilitiesTypes.mediaDecodingConfiguration => promise< + MediaCapabilitiesTypes.mediaCapabilitiesDecodingInfo, +> = "decodingInfo" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaCapabilities/encodingInfo) */ -@send -external encodingInfo: ( - MediaCapabilitiesTypes.mediaCapabilities, - MediaCapabilitiesTypes.mediaEncodingConfiguration, -) => promise = "encodingInfo" +@scope("globalThis.navigator.mediaCapabilities") +external encodingInfo: MediaCapabilitiesTypes.mediaEncodingConfiguration => promise< + MediaCapabilitiesTypes.mediaCapabilitiesEncodingInfo, +> = "encodingInfo" module Types = MediaCapabilitiesTypes diff --git a/src/MediaCaptureAndStreams/MediaDevices.res b/src/MediaCaptureAndStreams/MediaDevices.res index 648d964..c6d71bc 100644 --- a/src/MediaCaptureAndStreams/MediaDevices.res +++ b/src/MediaCaptureAndStreams/MediaDevices.res @@ -16,25 +16,25 @@ include EventTarget.Impl({type t = t}) /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaDevices/enumerateDevices) */ -@send -external enumerateDevices: t => promise> = "enumerateDevices" +@scope("globalThis.navigator.mediaDevices") +external enumerateDevices: unit => promise> = "enumerateDevices" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaDevices/getSupportedConstraints) */ -@send -external getSupportedConstraints: t => mediaTrackSupportedConstraints = "getSupportedConstraints" +@scope("globalThis.navigator.mediaDevices") +external getSupportedConstraints: unit => mediaTrackSupportedConstraints = "getSupportedConstraints" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaDevices/getUserMedia) */ -@send -external getUserMedia: (t, ~constraints: mediaStreamConstraints=?) => promise = +@scope("globalThis.navigator.mediaDevices") +external getUserMedia: (~constraints: mediaStreamConstraints=?) => promise = "getUserMedia" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaDevices/getDisplayMedia) */ -@send -external getDisplayMedia: (t, ~options: displayMediaStreamOptions=?) => promise = +@scope("globalThis.navigator.mediaDevices") +external getDisplayMedia: (~options: displayMediaStreamOptions=?) => promise = "getDisplayMedia" diff --git a/src/MediaSession/MediaSession.res b/src/MediaSession/MediaSession.res index 491003a..397076b 100644 --- a/src/MediaSession/MediaSession.res +++ b/src/MediaSession/MediaSession.res @@ -8,9 +8,8 @@ type mediaSessionActionHandler = MediaSessionTypes.mediaSessionActionHandler /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaSession/setActionHandler) */ -@send +@scope("globalThis.navigator.mediaSession") external setActionHandler: ( - t, ~action: mediaSessionAction, ~handler: mediaSessionActionHandler, ) => unit = "setActionHandler" @@ -18,8 +17,8 @@ external setActionHandler: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaSession/setPositionState) */ -@send -external setPositionState: (t, ~state: mediaPositionState=?) => unit = "setPositionState" +@scope("globalThis.navigator.mediaSession") +external setPositionState: (~state: mediaPositionState=?) => unit = "setPositionState" module MediaMetadata = MediaMetadata module Types = MediaSessionTypes diff --git a/src/Performance/Performance.res b/src/Performance/Performance.res index bcdefaf..a4f828c 100644 --- a/src/Performance/Performance.res +++ b/src/Performance/Performance.res @@ -3,37 +3,32 @@ include EventTarget.Impl({type t = PerformanceTypes.performance}) /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/now) */ -@send -external now: PerformanceTypes.performance => float = "now" +@scope("globalThis.performance") +external now: unit => float = "now" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/toJSON) */ -@send -external toJSON: PerformanceTypes.performance => Dict.t = "toJSON" +@scope("globalThis.performance") +external toJSON: unit => Dict.t = "toJSON" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */ -@send -external getEntries: PerformanceTypes.performance => PerformanceTypes.performanceEntryList = - "getEntries" +@scope("globalThis.performance") +external getEntries: unit => PerformanceTypes.performanceEntryList = "getEntries" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */ -@send -external getEntriesByType: ( - PerformanceTypes.performance, - string, -) => PerformanceTypes.performanceEntryList = "getEntriesByType" +@scope("globalThis.performance") +external getEntriesByType: string => PerformanceTypes.performanceEntryList = "getEntriesByType" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */ -@send +@scope("globalThis.performance") external getEntriesByName: ( - PerformanceTypes.performance, ~name: string, ~type_: string=?, ) => PerformanceTypes.performanceEntryList = "getEntriesByName" @@ -41,22 +36,20 @@ external getEntriesByName: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings) */ -@send -external clearResourceTimings: PerformanceTypes.performance => unit = "clearResourceTimings" +@scope("globalThis.performance") +external clearResourceTimings: unit => unit = "clearResourceTimings" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */ -@send -external setResourceTimingBufferSize: (PerformanceTypes.performance, int) => unit = - "setResourceTimingBufferSize" +@scope("globalThis.performance") +external setResourceTimingBufferSize: int => unit = "setResourceTimingBufferSize" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/mark) */ -@send +@scope("globalThis.performance") external mark: ( - PerformanceTypes.performance, ~markName: string, ~markOptions: PerformanceTypes.performanceMarkOptions=?, ) => PerformanceTypes.performanceMark = "mark" @@ -64,15 +57,14 @@ external mark: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks) */ -@send -external clearMarks: (PerformanceTypes.performance, ~markName: string=?) => unit = "clearMarks" +@scope("globalThis.performance") +external clearMarks: (~markName: string=?) => unit = "clearMarks" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/measure) */ -@send +@scope("globalThis.performance") external measure: ( - PerformanceTypes.performance, ~measureName: string, ~startOrMeasureOptions: string=?, ~endMark: string=?, @@ -81,9 +73,8 @@ external measure: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/measure) */ -@send +@scope("globalThis.performance") external measure2: ( - PerformanceTypes.performance, ~measureName: string, ~startOrMeasureOptions: PerformanceTypes.performanceMeasureOptions=?, ~endMark: string=?, @@ -92,9 +83,8 @@ external measure2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures) */ -@send -external clearMeasures: (PerformanceTypes.performance, ~measureName: string=?) => unit = - "clearMeasures" +@scope("globalThis.performance") +external clearMeasures: (~measureName: string=?) => unit = "clearMeasures" module PerformanceEntry = PerformanceEntry module PerformanceMark = PerformanceMark diff --git a/src/Permissions/Permissions.res b/src/Permissions/Permissions.res index 7b653ab..2c77046 100644 --- a/src/Permissions/Permissions.res +++ b/src/Permissions/Permissions.res @@ -1,10 +1,9 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Permissions/query) */ -@send -external query: ( - PermissionsTypes.permissions, - PermissionsTypes.permissionDescriptor, -) => promise = "query" +@scope("globalThis.navigator.permissions") +external query: PermissionsTypes.permissionDescriptor => promise< + PermissionsTypes.permissionStatus, +> = "query" module Types = PermissionsTypes diff --git a/src/ScreenWakeLock/WakeLock.res b/src/ScreenWakeLock/WakeLock.res index 412e7da..9d0832d 100644 --- a/src/ScreenWakeLock/WakeLock.res +++ b/src/ScreenWakeLock/WakeLock.res @@ -1,8 +1,7 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WakeLock/request) */ -@send +@scope("globalThis.navigator.wakeLock") external request: ( - ScreenWakeLockTypes.wakeLock, ~type_: ScreenWakeLockTypes.wakeLockType=?, ) => promise = "request" diff --git a/src/ServiceWorker/ServiceWorkerContainer.res b/src/ServiceWorker/ServiceWorkerContainer.res index 49311dd..9e1af1c 100644 --- a/src/ServiceWorker/ServiceWorkerContainer.res +++ b/src/ServiceWorker/ServiceWorkerContainer.res @@ -3,9 +3,8 @@ include EventTarget.Impl({type t = ServiceWorkerTypes.serviceWorkerContainer}) /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/register) */ -@send +@scope("globalThis.navigator.serviceWorker") external register: ( - ServiceWorkerTypes.serviceWorkerContainer, string, ~options: ServiceWorkerTypes.registrationOptions=?, ) => promise = "register" @@ -13,22 +12,20 @@ external register: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/getRegistration) */ -@send +@scope("globalThis.navigator.serviceWorker") external getRegistration: ( - ServiceWorkerTypes.serviceWorkerContainer, ~clientURL: string=?, ) => Nullable.t = "getRegistration" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/getRegistrations) */ -@send -external getRegistrations: ServiceWorkerTypes.serviceWorkerContainer => promise< - array, -> = "getRegistrations" +@scope("globalThis.navigator.serviceWorker") +external getRegistrations: unit => promise> = + "getRegistrations" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ServiceWorkerContainer/startMessages) */ -@send -external startMessages: ServiceWorkerTypes.serviceWorkerContainer => unit = "startMessages" +@scope("globalThis.navigator.serviceWorker") +external startMessages: unit => unit = "startMessages" diff --git a/src/Storage/StorageManager.res b/src/Storage/StorageManager.res index 0e744cc..c88ccd7 100644 --- a/src/Storage/StorageManager.res +++ b/src/Storage/StorageManager.res @@ -1,24 +1,23 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StorageManager/persisted) */ -@send -external persisted: StorageTypes.storageManager => promise = "persisted" +@scope("globalThis.navigator.storage") +external persisted: unit => promise = "persisted" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StorageManager/persist) */ -@send -external persist: StorageTypes.storageManager => promise = "persist" +@scope("globalThis.navigator.storage") +external persist: unit => promise = "persist" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StorageManager/estimate) */ -@send -external estimate: StorageTypes.storageManager => promise = "estimate" +@scope("globalThis.navigator.storage") +external estimate: unit => promise = "estimate" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StorageManager/getDirectory) */ -@send -external getDirectory: StorageTypes.storageManager => promise = - "getDirectory" +@scope("globalThis.navigator.storage") +external getDirectory: unit => promise = "getDirectory" diff --git a/src/WebCrypto/Crypto.res b/src/WebCrypto/Crypto.res index 274071f..80a65e5 100644 --- a/src/WebCrypto/Crypto.res +++ b/src/WebCrypto/Crypto.res @@ -5,14 +5,14 @@ open WebCryptoTypes TODO: the input type for this should be stricter than just an array<'a>' > An integer-based TypedArray, that is one of: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array */ -@scope("crypto") +@scope("globalThis.crypto") external getRandomValues: array<'t> => array<'t> = "getRandomValues" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) */ -@scope("crypto") +@scope("globalThis.crypto") external randomUUID: unit => string = "randomUUID" -@scope("crypto") +@scope("globalThis.crypto") external subtle: subtleCrypto = "subtle" diff --git a/src/WebCrypto/SubtleCrypto.res b/src/WebCrypto/SubtleCrypto.res index a8d9f75..7e1ea57 100644 --- a/src/WebCrypto/SubtleCrypto.res +++ b/src/WebCrypto/SubtleCrypto.res @@ -1,9 +1,8 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */ -@send +@scope("globalThis.crypto.subtle") external encrypt: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, ~data: ArrayBuffer.t, @@ -12,9 +11,8 @@ external encrypt: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */ -@send +@scope("globalThis.crypto.subtle") external decrypt: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, ~data: ArrayBuffer.t, @@ -23,9 +21,8 @@ external decrypt: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */ -@send +@scope("globalThis.crypto.subtle") external sign: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, ~data: ArrayBuffer.t, @@ -34,9 +31,8 @@ external sign: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */ -@send +@scope("globalThis.crypto.subtle") external verify: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~key: WebCryptoTypes.cryptoKey, ~signature: ArrayBuffer.t, @@ -46,9 +42,8 @@ external verify: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */ -@send +@scope("globalThis.crypto.subtle") external digest: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~data: ArrayBuffer.t, ) => promise = "digest" @@ -56,9 +51,8 @@ external digest: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */ -@send +@scope("globalThis.crypto.subtle") external generateKey: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithm, ~extractable: bool, ~keyUsages: array, @@ -67,9 +61,8 @@ external generateKey: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */ -@send +@scope("globalThis.crypto.subtle") external generateKey2: ( - WebCryptoTypes.subtleCrypto, ~algorithm: string, ~extractable: bool, ~keyUsages: array, @@ -78,9 +71,8 @@ external generateKey2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */ -@send +@scope("globalThis.crypto.subtle") external deriveKey: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithmIdentifier, ~baseKey: WebCryptoTypes.cryptoKey, ~derivedKeyType: WebCryptoTypes.algorithmIdentifier, @@ -91,9 +83,8 @@ external deriveKey: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */ -@send +@scope("globalThis.crypto.subtle") external deriveBits: ( - WebCryptoTypes.subtleCrypto, ~algorithm: WebCryptoTypes.algorithm, ~baseKey: WebCryptoTypes.cryptoKey, ~length: int=?, @@ -102,9 +93,8 @@ external deriveBits: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */ -@send +@scope("globalThis.crypto.subtle") external deriveBits2: ( - WebCryptoTypes.subtleCrypto, ~algorithm: string, ~baseKey: WebCryptoTypes.cryptoKey, ~length: int=?, @@ -113,9 +103,8 @@ external deriveBits2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */ -@send +@scope("globalThis.crypto.subtle") external importKey: ( - WebCryptoTypes.subtleCrypto, ~format: unknown, ~keyData: ArrayBuffer.t, ~algorithm: WebCryptoTypes.algorithmIdentifier, @@ -126,9 +115,8 @@ external importKey: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */ -@send +@scope("globalThis.crypto.subtle") external exportKey: ( - WebCryptoTypes.subtleCrypto, ~format: WebCryptoTypes.keyFormat, ~key: WebCryptoTypes.cryptoKey, ) => promise = "exportKey" @@ -136,9 +124,8 @@ external exportKey: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */ -@send +@scope("globalThis.crypto.subtle") external wrapKey: ( - WebCryptoTypes.subtleCrypto, ~format: WebCryptoTypes.keyFormat, ~key: WebCryptoTypes.cryptoKey, ~wrappingKey: WebCryptoTypes.cryptoKey, @@ -148,9 +135,8 @@ external wrapKey: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */ -@send +@scope("globalThis.crypto.subtle") external wrapKey2: ( - WebCryptoTypes.subtleCrypto, ~format: WebCryptoTypes.keyFormat, ~key: WebCryptoTypes.cryptoKey, ~wrappingKey: WebCryptoTypes.cryptoKey, @@ -160,9 +146,8 @@ external wrapKey2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */ -@send +@scope("globalThis.crypto.subtle") external unwrapKey: ( - WebCryptoTypes.subtleCrypto, ~format: WebCryptoTypes.keyFormat, ~wrappedKey: ArrayBuffer.t, ~unwrappingKey: WebCryptoTypes.cryptoKey, diff --git a/src/WebCrypto/WebCryptoTypes.res b/src/WebCrypto/WebCryptoTypes.res index 2d69697..fab0fc4 100644 --- a/src/WebCrypto/WebCryptoTypes.res +++ b/src/WebCrypto/WebCryptoTypes.res @@ -24,7 +24,7 @@ type keyFormat = type keyAlgorithm = {mutable name: string} /** -This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto). +This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in the current global context (via globalThis.crypto). [See SubtleCrypto on MDN](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) */ @editor.completeFrom(SubtleCrypto) diff --git a/src/WebLocks/LockManager.res b/src/WebLocks/LockManager.res index 0959a1f..28b4153 100644 --- a/src/WebLocks/LockManager.res +++ b/src/WebLocks/LockManager.res @@ -1,19 +1,15 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/LockManager/request) */ -@send -external request: ( - WebLocksTypes.lockManager, - ~name: string, - ~callback: WebLocksTypes.lockGrantedCallback, -) => promise = "request" +@scope("globalThis.navigator.locks") +external request: (~name: string, ~callback: WebLocksTypes.lockGrantedCallback) => promise = + "request" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/LockManager/request) */ -@send +@scope("globalThis.navigator.locks") external request2: ( - WebLocksTypes.lockManager, ~name: string, ~options: WebLocksTypes.lockOptions, ~callback: WebLocksTypes.lockGrantedCallback, @@ -22,5 +18,5 @@ external request2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/LockManager/query) */ -@send -external query: WebLocksTypes.lockManager => promise = "query" +@scope("globalThis.navigator.locks") +external query: unit => promise = "query" diff --git a/src/WebSpeech/SpeechSynthesis.res b/src/WebSpeech/SpeechSynthesis.res index 3738e2c..8b7f5be 100644 --- a/src/WebSpeech/SpeechSynthesis.res +++ b/src/WebSpeech/SpeechSynthesis.res @@ -3,31 +3,29 @@ include EventTarget.Impl({type t = WebSpeechTypes.speechSynthesis}) /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/speak) */ -@send -external speak: (WebSpeechTypes.speechSynthesis, WebSpeechTypes.speechSynthesisUtterance) => unit = - "speak" +@scope("globalThis.speechSynthesis") +external speak: WebSpeechTypes.speechSynthesisUtterance => unit = "speak" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/cancel) */ -@send -external cancel: WebSpeechTypes.speechSynthesis => unit = "cancel" +@scope("globalThis.speechSynthesis") +external cancel: unit => unit = "cancel" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/pause) */ -@send -external pause: WebSpeechTypes.speechSynthesis => unit = "pause" +@scope("globalThis.speechSynthesis") +external pause: unit => unit = "pause" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/resume) */ -@send -external resume: WebSpeechTypes.speechSynthesis => unit = "resume" +@scope("globalThis.speechSynthesis") +external resume: unit => unit = "resume" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/SpeechSynthesis/getVoices) */ -@send -external getVoices: WebSpeechTypes.speechSynthesis => array = - "getVoices" +@scope("globalThis.speechSynthesis") +external getVoices: unit => array = "getVoices" diff --git a/src/WebStorage/LocalStorage.res b/src/WebStorage/LocalStorage.res new file mode 100644 index 0000000..25f1db9 --- /dev/null +++ b/src/WebStorage/LocalStorage.res @@ -0,0 +1,49 @@ +/** +Returns the number of key/value pairs in localStorage. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/length) +*/ +@scope("globalThis.localStorage") @val +external length: int = "length" + +/** +Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/key) +*/ +@scope("globalThis.localStorage") +external key: int => Null.t = "key" + +/** +Returns the current value associated with the given key, or null if the given key does not exist. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/getItem) +*/ +@scope("globalThis.localStorage") +external getItem: string => Null.t = "getItem" + +/** +Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously. + +Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.) + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/setItem) +*/ +@scope("globalThis.localStorage") +external setItem: (~key: string, ~value: string) => unit = "setItem" + +/** +Removes the key/value pair with the given key, if a key/value pair with the given key exists. + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/removeItem) +*/ +@scope("globalThis.localStorage") +external removeItem: string => unit = "removeItem" + +/** +Removes all key/value pairs, if there are any. + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/clear) +*/ +@scope("globalThis.localStorage") +external clear: unit => unit = "clear" diff --git a/src/WebStorage/SessionStorage.res b/src/WebStorage/SessionStorage.res new file mode 100644 index 0000000..1eb615b --- /dev/null +++ b/src/WebStorage/SessionStorage.res @@ -0,0 +1,49 @@ +/** +Returns the number of key/value pairs in sessionStorage. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/length) +*/ +@scope("globalThis.sessionStorage") @val +external length: int = "length" + +/** +Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/key) +*/ +@scope("globalThis.sessionStorage") +external key: int => Null.t = "key" + +/** +Returns the current value associated with the given key, or null if the given key does not exist. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/getItem) +*/ +@scope("globalThis.sessionStorage") +external getItem: string => Null.t = "getItem" + +/** +Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously. + +Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.) + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/setItem) +*/ +@scope("globalThis.sessionStorage") +external setItem: (~key: string, ~value: string) => unit = "setItem" + +/** +Removes the key/value pair with the given key, if a key/value pair with the given key exists. + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/removeItem) +*/ +@scope("globalThis.sessionStorage") +external removeItem: string => unit = "removeItem" + +/** +Removes all key/value pairs, if there are any. + +Dispatches a storage event on Window objects holding an equivalent WebApiStorage object. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Storage/clear) +*/ +@scope("globalThis.sessionStorage") +external clear: unit => unit = "clear" diff --git a/src/WebWorkers/CacheStorage.res b/src/WebWorkers/CacheStorage.res index f77aa9e..b601316 100644 --- a/src/WebWorkers/CacheStorage.res +++ b/src/WebWorkers/CacheStorage.res @@ -1,9 +1,8 @@ /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/match) */ -@send +@scope("globalThis.caches") external match: ( - WebWorkersTypes.cacheStorage, ~request: FetchTypes.request, ~options: WebWorkersTypes.multiCacheQueryOptions=?, ) => Nullable.t = "match" @@ -11,9 +10,8 @@ external match: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/match) */ -@send +@scope("globalThis.caches") external match2: ( - WebWorkersTypes.cacheStorage, ~request: string, ~options: WebWorkersTypes.multiCacheQueryOptions=?, ) => Nullable.t = "match" @@ -21,23 +19,23 @@ external match2: ( /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/has) */ -@send -external has: (WebWorkersTypes.cacheStorage, string) => promise = "has" +@scope("globalThis.caches") +external has: string => promise = "has" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */ -@send -external open_: (WebWorkersTypes.cacheStorage, string) => promise = "open" +@scope("globalThis.caches") +external open_: string => promise = "open" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/delete) */ -@send -external delete: (WebWorkersTypes.cacheStorage, string) => promise = "delete" +@scope("globalThis.caches") +external delete: string => promise = "delete" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CacheStorage/keys) */ -@send -external keys: WebWorkersTypes.cacheStorage => promise> = "keys" +@scope("globalThis.caches") +external keys: unit => promise> = "keys" diff --git a/tests/Fetch__test.res b/tests/Fetch__test.res index 9428890..d10fca5 100644 --- a/tests/Fetch__test.res +++ b/tests/Fetch__test.res @@ -32,10 +32,7 @@ DomGlobal.removeEventListener( ~options={capture: false}, ) -let registrationResult = await Window.current -->Window.navigator -->Navigator.serviceWorker -->ServiceWorkerContainer.register("/sw.js") +let registrationResult = await ServiceWorkerContainer.register("/sw.js") let subscription = await registrationResult.pushManager->PushManager.subscribe( ~options={ userVisibleOnly: true, diff --git a/tests/GlobalSingletonAPI/GlobalSingleton__test.res b/tests/GlobalSingletonAPI/GlobalSingleton__test.res new file mode 100644 index 0000000..aa86751 --- /dev/null +++ b/tests/GlobalSingletonAPI/GlobalSingleton__test.res @@ -0,0 +1,50 @@ +let cryptoRandomUUID: unit => string = Crypto.randomUUID +let cryptoGetRandomValues: array => array = Crypto.getRandomValues +let cryptoSubtle: WebCryptoTypes.subtleCrypto = Crypto.subtle + +let subtleDigest: ( + ~algorithm: WebCryptoTypes.algorithmIdentifier, + ~data: ArrayBuffer.t, +) => promise = SubtleCrypto.digest + +let performanceNow: unit => float = Performance.now +let performanceMark: ( + ~markName: string, + ~markOptions: PerformanceTypes.performanceMarkOptions=?, +) => PerformanceTypes.performanceMark = Performance.mark + +let historyBack: unit => unit = History.back +let historyPushState: (~data: JSON.t, ~unused: string, ~url: string=?) => unit = History.pushState + +let indexedDbOpen: ( + ~name: string, + ~version: int=?, +) => IndexedDbTypes.idbOpenDBRequest = IDBFactory.open_ +let indexedDbDatabases: unit => promise< + array, +> = IDBFactory.databases + +let cacheStorageOpen: string => promise = CacheStorage.open_ +let cacheStorageKeys: unit => promise> = CacheStorage.keys + +let clipboardReadText: unit => promise = Clipboard.readText +let permissionsQuery: PermissionsTypes.permissionDescriptor => promise< + PermissionsTypes.permissionStatus, +> = Permissions.query + +let mediaDevicesEnumerate: unit => promise> = MediaDevices.enumerateDevices +let storageEstimate: unit => promise = StorageManager.estimate +let lockQuery: unit => promise = LockManager.query + +let serviceWorkerRegister: ( + string, + ~options: ServiceWorkerTypes.registrationOptions=?, +) => promise = ServiceWorkerContainer.register + +let navigatorUserAgent: string = Navigator.userAgent +let navigatorGetGamepads: unit => array = Navigator.getGamepads + +let localStorageLength: int = LocalStorage.length +let localStorageGetItem: string => Null.t = LocalStorage.getItem +let sessionStorageLength: int = SessionStorage.length +let sessionStorageGetItem: string => Null.t = SessionStorage.getItem diff --git a/tests/WebStorageAPI/Storage__test.res b/tests/WebStorageAPI/Storage__test.res index 070d6aa..a42b786 100644 --- a/tests/WebStorageAPI/Storage__test.res +++ b/tests/WebStorageAPI/Storage__test.res @@ -1,11 +1,17 @@ -for i in 0 to DomGlobal.localStorage.length - 1 { - DomGlobal.localStorage->Storage.key(i)->Null.getOr("nothing")->Console.log +for i in 0 to LocalStorage.length - 1 { + LocalStorage.key(i)->Null.getOr("nothing")->Console.log } -let item1 = DomGlobal.localStorage->Storage.getItem("foo")->Null.getOr("nothing") +let item1 = LocalStorage.getItem("foo")->Null.getOr("nothing") -DomGlobal.localStorage->Storage.setItem(~key="bar", ~value="...") +LocalStorage.setItem(~key="bar", ~value="...") -DomGlobal.localStorage->Storage.removeItem("bar") +LocalStorage.removeItem("bar") -DomGlobal.localStorage->Storage.clear +LocalStorage.clear() + +SessionStorage.setItem(~key="session", ~value="...") + +let sessionItem = SessionStorage.getItem("session")->Null.getOr("nothing") + +SessionStorage.removeItem("session") From 29ead8e97277209a27673ac087c68765fb16828d Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 15:53:41 -0400 Subject: [PATCH 11/16] even more changes --- rescript.json | 18 +++++++++++++++++- src/DOM/DOM.res | 21 --------------------- src/DOM/DomTypes.res | 21 --------------------- src/{DOM => Navigator}/Navigator.res | 25 ++++++++++++++++++++++--- src/WebCrypto/Crypto.res | 8 +++++++- 5 files changed, 46 insertions(+), 47 deletions(-) rename src/{DOM => Navigator}/Navigator.res (83%) diff --git a/rescript.json b/rescript.json index c97eb25..68a7805 100644 --- a/rescript.json +++ b/rescript.json @@ -1,5 +1,16 @@ { "name": "@rescript/webapi", + "features": { + "WebAPI.Navigator": [ + "WebAPI.Base", + "WebAPI.Event", + "WebAPI.File", + "WebAPI.Fetch", + "WebAPI.Gamepad", + "WebAPI.URL", + "WebAPI.WebMIDI" + ] + }, "sources": [ { "dir": "src/Base", @@ -160,7 +171,6 @@ "MediaList", "MediaQueryList", "NamedNodeMap", - "Navigator", "Node", "NodeFilter", "NodeIterator", @@ -314,6 +324,12 @@ "feature": "WebAPI.MutationObserver", "public": ["MutationObserver"] }, + { + "dir": "src/Navigator", + "subdirs": true, + "feature": "WebAPI.Navigator", + "public": ["Navigator"] + }, { "dir": "src/Notification", "subdirs": true, diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index 9094835..4e27b83 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -200,27 +200,6 @@ TODO: mark as private once mutating fields of private records is allowed @editor.completeFrom(DOM.Location) type location = Base__Document.location -/** -[See UserActivation on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation) -*/ -type userActivation = { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/hasBeenActive) - */ - hasBeenActive: bool, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/isActive) - */ - isActive: bool, -} - -/** -The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. -[See Navigator on MDN](https://developer.mozilla.org/docs/Web/API/Navigator) -*/ -@editor.completeFrom(DOM.Navigator) -type navigator - // TODO: mark as private once mutating fields of private records is allowed @editor.completeFrom(DOM.DOMTokenList) type domTokenList = { diff --git a/src/DOM/DomTypes.res b/src/DOM/DomTypes.res index 10dadd5..c347084 100644 --- a/src/DOM/DomTypes.res +++ b/src/DOM/DomTypes.res @@ -260,27 +260,6 @@ type shareData = { @editor.completeFrom(Location) type location = Base__Document.location = private {...Base__Document.location} -/** -[See UserActivation on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation) -*/ -type userActivation = { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/hasBeenActive) - */ - hasBeenActive: bool, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/isActive) - */ - isActive: bool, -} - -/** -The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. -[See Navigator on MDN](https://developer.mozilla.org/docs/Web/API/Navigator) -*/ -@editor.completeFrom(Navigator) -type navigator = DOM.navigator - // TODO: mark as private once mutating fields of private records is allowed @editor.completeFrom(DOMTokenList) type domTokenList = { diff --git a/src/DOM/Navigator.res b/src/Navigator/Navigator.res similarity index 83% rename from src/DOM/Navigator.res rename to src/Navigator/Navigator.res index 66537eb..4268df2 100644 --- a/src/DOM/Navigator.res +++ b/src/Navigator/Navigator.res @@ -1,10 +1,29 @@ -type t = DomTypes.navigator +/** +The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. +[See Navigator on MDN](https://developer.mozilla.org/docs/Web/API/Navigator) +*/ +@editor.completeFrom(Navigator) +type t + +/** +[See UserActivation on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation) +*/ +type userActivation = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/hasBeenActive) + */ + hasBeenActive: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/UserActivation/isActive) + */ + isActive: bool, +} /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/userActivation) */ @scope("globalThis.navigator") @val -external userActivation: DomTypes.userActivation = "userActivation" +external userActivation: userActivation = "userActivation" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/maxTouchPoints) @@ -108,7 +127,7 @@ external getGamepads: unit => array = "getGamepads" @scope("globalThis.navigator") external requestMediaKeySystemAccess: ( ~keySystem: string, - ~supportedConfigurations: array, + ~supportedConfigurations: array, ) => promise<'mediaKeySystemAccess> = "requestMediaKeySystemAccess" /** diff --git a/src/WebCrypto/Crypto.res b/src/WebCrypto/Crypto.res index 80a65e5..e003ba3 100644 --- a/src/WebCrypto/Crypto.res +++ b/src/WebCrypto/Crypto.res @@ -2,14 +2,20 @@ open WebCryptoTypes /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) + TODO: the input type for this should be stricter than just an array<'a>' -> An integer-based TypedArray, that is one of: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, BigUint64Array +It should be an integer-based TypedArray, that is one of: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array */ @scope("globalThis.crypto") external getRandomValues: array<'t> => array<'t> = "getRandomValues" +let _ = getRandomValues([]) + /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) +```rescript +let uuid = Crypto.randomUUID() +``` */ @scope("globalThis.crypto") external randomUUID: unit => string = "randomUUID" From c8ffac8b3bd185cf1511556305a381110194d035 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 16:45:25 -0400 Subject: [PATCH 12/16] break up dom features --- rescript.json | 293 ++++++++++++------ src/{DOM => CSSOM}/CSSRuleList.res | 0 src/{DOM => CSSOM}/CSSStyleDeclaration.res | 0 src/{DOM => CSSOM}/CSSStyleSheet.res | 0 src/{DOM => CSSOM}/MediaList.res | 0 src/{DOM => CSSOM}/MediaQueryList.res | 0 src/{DOM => CSSOM}/StyleSheetList.res | 0 src/{DOM => CSSTypedOM}/CSSStyleValue.res | 0 src/{DOM => CSSTypedOM}/StylePropertyMap.res | 0 .../StylePropertyMapReadOnly.res | 0 src/{DOM => Canvas}/ImageData.res | 0 src/{DOM => Canvas}/VideoColorSpace.res | 0 .../CustomElementRegistry.res | 0 .../ElementInternals.res | 0 src/{DOM => FileList}/FileList.res | 0 src/{DOM => Geometry}/DOMMatrix.res | 0 src/{DOM => Geometry}/DOMMatrixReadOnly.res | 0 src/{DOM => Geometry}/DOMPoint.res | 0 src/{DOM => Geometry}/DOMPointReadOnly.res | 0 src/{DOM => Geometry}/DOMRect.res | 0 src/{DOM => Geometry}/DOMRectList.res | 0 src/{DOM => Geometry}/DOMRectReadOnly.res | 0 src/{DOM => HTML}/DomHTMLMediaElement.res | 0 src/{DOM => HTML}/HTMLAnchorElement.res | 0 src/{DOM => HTML}/HTMLAreaElement.res | 0 src/{DOM => HTML}/HTMLAudioElement.res | 0 src/{DOM => HTML}/HTMLBRElement.res | 0 src/{DOM => HTML}/HTMLBaseElement.res | 0 src/{DOM => HTML}/HTMLBodyElement.res | 0 src/{DOM => HTML}/HTMLButtonElement.res | 0 src/{DOM => HTML}/HTMLCollection.res | 0 src/{DOM => HTML}/HTMLDListElement.res | 0 src/{DOM => HTML}/HTMLDataElement.res | 0 src/{DOM => HTML}/HTMLDataListElement.res | 0 src/{DOM => HTML}/HTMLDialogElement.res | 0 src/{DOM => HTML}/HTMLDivElement.res | 0 src/{DOM => HTML}/HTMLElement.res | 0 src/{DOM => HTML}/HTMLEmbedElement.res | 0 src/{DOM => HTML}/HTMLFieldSetElement.res | 0 .../HTMLFormControlsCollection.res | 0 src/{DOM => HTML}/HTMLFormElement.res | 0 src/{DOM => HTML}/HTMLFrameSetElement.res | 0 src/{DOM => HTML}/HTMLHRElement.res | 0 src/{DOM => HTML}/HTMLHeadElement.res | 0 src/{DOM => HTML}/HTMLHeadingElement.res | 0 src/{DOM => HTML}/HTMLHtmlElement.res | 0 src/{DOM => HTML}/HTMLIFrameElement.res | 0 src/{DOM => HTML}/HTMLImageElement.res | 0 src/{DOM => HTML}/HTMLInputElement.res | 0 src/{DOM => HTML}/HTMLLIElement.res | 0 src/{DOM => HTML}/HTMLLabelElement.res | 0 src/{DOM => HTML}/HTMLLegendElement.res | 0 src/{DOM => HTML}/HTMLLinkElement.res | 0 src/{DOM => HTML}/HTMLMapElement.res | 0 src/{DOM => HTML}/HTMLMenuElement.res | 0 src/{DOM => HTML}/HTMLMetaElement.res | 0 src/{DOM => HTML}/HTMLMeterElement.res | 0 src/{DOM => HTML}/HTMLModElement.res | 0 src/{DOM => HTML}/HTMLOListElement.res | 0 src/{DOM => HTML}/HTMLObjectElement.res | 0 src/{DOM => HTML}/HTMLOptGroupElement.res | 0 src/{DOM => HTML}/HTMLOptionElement.res | 0 src/{DOM => HTML}/HTMLOptionsCollection.res | 0 src/{DOM => HTML}/HTMLOutputElement.res | 0 src/{DOM => HTML}/HTMLParagraphElement.res | 0 src/{DOM => HTML}/HTMLPictureElement.res | 0 src/{DOM => HTML}/HTMLPreElement.res | 0 src/{DOM => HTML}/HTMLProgressElement.res | 0 src/{DOM => HTML}/HTMLQuoteElement.res | 0 src/{DOM => HTML}/HTMLScriptElement.res | 0 src/{DOM => HTML}/HTMLSelectElement.res | 0 src/{DOM => HTML}/HTMLSlotElement.res | 0 src/{DOM => HTML}/HTMLSourceElement.res | 0 src/{DOM => HTML}/HTMLSpanElement.res | 0 src/{DOM => HTML}/HTMLStyleElement.res | 0 src/{DOM => HTML}/HTMLTableCaptionElement.res | 0 src/{DOM => HTML}/HTMLTableCellElement.res | 0 src/{DOM => HTML}/HTMLTableElement.res | 0 src/{DOM => HTML}/HTMLTableRowElement.res | 0 src/{DOM => HTML}/HTMLTableSectionElement.res | 0 src/{DOM => HTML}/HTMLTemplateElement.res | 0 src/{DOM => HTML}/HTMLTextAreaElement.res | 0 src/{DOM => HTML}/HTMLTimeElement.res | 0 src/{DOM => HTML}/HTMLTitleElement.res | 0 src/{DOM => HTML}/HTMLTrackElement.res | 0 src/{DOM => HTML}/HTMLUListElement.res | 0 src/{DOM => HTML}/HTMLVideoElement.res | 0 src/{DOM => HTML}/TimeRanges.res | 0 src/{DOM => SVG}/SVGGraphicsElement.res | 0 src/{DOM => SVG}/SVGLength.res | 0 .../ScreenOrientation.res | 0 src/{DOM => WebAnimations}/Animation.res | 0 .../AnimationEffect.res | 0 .../DocumentTimeline.res | 0 src/{DOM => WebVTT}/TextTrackList.res | 0 src/{DOM => Window}/IdleDeadline.res | 0 src/{DOM => Window}/Location.res | 0 src/{DOM => Window}/Window.res | 0 src/{DOM => XPath}/XPathExpression.res | 0 src/{DOM => XPath}/XPathResult.res | 0 100 files changed, 191 insertions(+), 102 deletions(-) rename src/{DOM => CSSOM}/CSSRuleList.res (100%) rename src/{DOM => CSSOM}/CSSStyleDeclaration.res (100%) rename src/{DOM => CSSOM}/CSSStyleSheet.res (100%) rename src/{DOM => CSSOM}/MediaList.res (100%) rename src/{DOM => CSSOM}/MediaQueryList.res (100%) rename src/{DOM => CSSOM}/StyleSheetList.res (100%) rename src/{DOM => CSSTypedOM}/CSSStyleValue.res (100%) rename src/{DOM => CSSTypedOM}/StylePropertyMap.res (100%) rename src/{DOM => CSSTypedOM}/StylePropertyMapReadOnly.res (100%) rename src/{DOM => Canvas}/ImageData.res (100%) rename src/{DOM => Canvas}/VideoColorSpace.res (100%) rename src/{DOM => CustomElements}/CustomElementRegistry.res (100%) rename src/{DOM => CustomElements}/ElementInternals.res (100%) rename src/{DOM => FileList}/FileList.res (100%) rename src/{DOM => Geometry}/DOMMatrix.res (100%) rename src/{DOM => Geometry}/DOMMatrixReadOnly.res (100%) rename src/{DOM => Geometry}/DOMPoint.res (100%) rename src/{DOM => Geometry}/DOMPointReadOnly.res (100%) rename src/{DOM => Geometry}/DOMRect.res (100%) rename src/{DOM => Geometry}/DOMRectList.res (100%) rename src/{DOM => Geometry}/DOMRectReadOnly.res (100%) rename src/{DOM => HTML}/DomHTMLMediaElement.res (100%) rename src/{DOM => HTML}/HTMLAnchorElement.res (100%) rename src/{DOM => HTML}/HTMLAreaElement.res (100%) rename src/{DOM => HTML}/HTMLAudioElement.res (100%) rename src/{DOM => HTML}/HTMLBRElement.res (100%) rename src/{DOM => HTML}/HTMLBaseElement.res (100%) rename src/{DOM => HTML}/HTMLBodyElement.res (100%) rename src/{DOM => HTML}/HTMLButtonElement.res (100%) rename src/{DOM => HTML}/HTMLCollection.res (100%) rename src/{DOM => HTML}/HTMLDListElement.res (100%) rename src/{DOM => HTML}/HTMLDataElement.res (100%) rename src/{DOM => HTML}/HTMLDataListElement.res (100%) rename src/{DOM => HTML}/HTMLDialogElement.res (100%) rename src/{DOM => HTML}/HTMLDivElement.res (100%) rename src/{DOM => HTML}/HTMLElement.res (100%) rename src/{DOM => HTML}/HTMLEmbedElement.res (100%) rename src/{DOM => HTML}/HTMLFieldSetElement.res (100%) rename src/{DOM => HTML}/HTMLFormControlsCollection.res (100%) rename src/{DOM => HTML}/HTMLFormElement.res (100%) rename src/{DOM => HTML}/HTMLFrameSetElement.res (100%) rename src/{DOM => HTML}/HTMLHRElement.res (100%) rename src/{DOM => HTML}/HTMLHeadElement.res (100%) rename src/{DOM => HTML}/HTMLHeadingElement.res (100%) rename src/{DOM => HTML}/HTMLHtmlElement.res (100%) rename src/{DOM => HTML}/HTMLIFrameElement.res (100%) rename src/{DOM => HTML}/HTMLImageElement.res (100%) rename src/{DOM => HTML}/HTMLInputElement.res (100%) rename src/{DOM => HTML}/HTMLLIElement.res (100%) rename src/{DOM => HTML}/HTMLLabelElement.res (100%) rename src/{DOM => HTML}/HTMLLegendElement.res (100%) rename src/{DOM => HTML}/HTMLLinkElement.res (100%) rename src/{DOM => HTML}/HTMLMapElement.res (100%) rename src/{DOM => HTML}/HTMLMenuElement.res (100%) rename src/{DOM => HTML}/HTMLMetaElement.res (100%) rename src/{DOM => HTML}/HTMLMeterElement.res (100%) rename src/{DOM => HTML}/HTMLModElement.res (100%) rename src/{DOM => HTML}/HTMLOListElement.res (100%) rename src/{DOM => HTML}/HTMLObjectElement.res (100%) rename src/{DOM => HTML}/HTMLOptGroupElement.res (100%) rename src/{DOM => HTML}/HTMLOptionElement.res (100%) rename src/{DOM => HTML}/HTMLOptionsCollection.res (100%) rename src/{DOM => HTML}/HTMLOutputElement.res (100%) rename src/{DOM => HTML}/HTMLParagraphElement.res (100%) rename src/{DOM => HTML}/HTMLPictureElement.res (100%) rename src/{DOM => HTML}/HTMLPreElement.res (100%) rename src/{DOM => HTML}/HTMLProgressElement.res (100%) rename src/{DOM => HTML}/HTMLQuoteElement.res (100%) rename src/{DOM => HTML}/HTMLScriptElement.res (100%) rename src/{DOM => HTML}/HTMLSelectElement.res (100%) rename src/{DOM => HTML}/HTMLSlotElement.res (100%) rename src/{DOM => HTML}/HTMLSourceElement.res (100%) rename src/{DOM => HTML}/HTMLSpanElement.res (100%) rename src/{DOM => HTML}/HTMLStyleElement.res (100%) rename src/{DOM => HTML}/HTMLTableCaptionElement.res (100%) rename src/{DOM => HTML}/HTMLTableCellElement.res (100%) rename src/{DOM => HTML}/HTMLTableElement.res (100%) rename src/{DOM => HTML}/HTMLTableRowElement.res (100%) rename src/{DOM => HTML}/HTMLTableSectionElement.res (100%) rename src/{DOM => HTML}/HTMLTemplateElement.res (100%) rename src/{DOM => HTML}/HTMLTextAreaElement.res (100%) rename src/{DOM => HTML}/HTMLTimeElement.res (100%) rename src/{DOM => HTML}/HTMLTitleElement.res (100%) rename src/{DOM => HTML}/HTMLTrackElement.res (100%) rename src/{DOM => HTML}/HTMLUListElement.res (100%) rename src/{DOM => HTML}/HTMLVideoElement.res (100%) rename src/{DOM => HTML}/TimeRanges.res (100%) rename src/{DOM => SVG}/SVGGraphicsElement.res (100%) rename src/{DOM => SVG}/SVGLength.res (100%) rename src/{DOM => ScreenOrientation}/ScreenOrientation.res (100%) rename src/{DOM => WebAnimations}/Animation.res (100%) rename src/{DOM => WebAnimations}/AnimationEffect.res (100%) rename src/{DOM => WebAnimations}/DocumentTimeline.res (100%) rename src/{DOM => WebVTT}/TextTrackList.res (100%) rename src/{DOM => Window}/IdleDeadline.res (100%) rename src/{DOM => Window}/Location.res (100%) rename src/{DOM => Window}/Window.res (100%) rename src/{DOM => XPath}/XPathExpression.res (100%) rename src/{DOM => XPath}/XPathResult.res (100%) diff --git a/rescript.json b/rescript.json index 68a7805..544baa6 100644 --- a/rescript.json +++ b/rescript.json @@ -1,6 +1,34 @@ { "name": "@rescript/webapi", "features": { + "WebAPI.DOM": [ + "WebAPI.Base", + "WebAPI.CSSFontLoading", + "WebAPI.ChannelMessaging", + "WebAPI.Event", + "WebAPI.File", + "WebAPI.FileAndDirectoryEntries", + "WebAPI.RemotePlayback", + "WebAPI.ViewTransitions", + "WebAPI.VisualViewport" + ], + "WebAPI.Canvas": [ + "WebAPI.DOM", + "WebAPI.Event", + "WebAPI.File", + "WebAPI.HTML", + "WebAPI.MediaCaptureAndStreams" + ], + "WebAPI.CSSOM": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.CSSTypedOM": ["WebAPI.DOM"], + "WebAPI.CustomElements": ["WebAPI.DOM"], + "WebAPI.FileList": ["WebAPI.DOM", "WebAPI.File"], + "WebAPI.Geometry": ["WebAPI.DOM"], + "WebAPI.HTML": [ + "WebAPI.DOM", + "WebAPI.PictureInPicture", + "WebAPI.WebVTT" + ], "WebAPI.Navigator": [ "WebAPI.Base", "WebAPI.Event", @@ -9,7 +37,17 @@ "WebAPI.Gamepad", "WebAPI.URL", "WebAPI.WebMIDI" - ] + ], + "WebAPI.ScreenOrientation": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.SVG": ["WebAPI.DOM", "WebAPI.Geometry"], + "WebAPI.WebAnimations": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.WebVTT": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.Window": [ + "WebAPI.ChannelMessaging", + "WebAPI.DOM", + "WebAPI.Event" + ], + "WebAPI.XPath": ["WebAPI.DOM"] }, "sources": [ { @@ -44,8 +82,10 @@ "HTMLCanvasElement", "ImageBitmap", "ImageBitmapRenderingContext", + "ImageData", "OffscreenCanvas", "Path2D", + "VideoColorSpace", "VideoFrame" ] }, @@ -72,128 +112,54 @@ "subdirs": true, "feature": "WebAPI.DOM", "public": [ - "Animation", - "AnimationEffect", - "CSSRuleList", - "CSSStyleDeclaration", - "CSSStyleSheet", - "CSSStyleValue", "CaretPosition", "CharacterData", "Comment", - "CustomElementRegistry", "DOM", "DOMException", "DOMImplementation", - "DOMMatrix", - "DOMMatrixReadOnly", - "DOMPoint", - "DOMPointReadOnly", - "DOMRect", - "DOMRectList", - "DOMRectReadOnly", "DOMStringList", "DOMTokenList", "Document", "DocumentFragment", - "DocumentTimeline", - "DomHTMLMediaElement", "Element", - "ElementInternals", - "FileList", - "HTMLAnchorElement", - "HTMLAreaElement", - "HTMLAudioElement", - "HTMLBRElement", - "HTMLBaseElement", - "HTMLBodyElement", - "HTMLButtonElement", - "HTMLCollection", - "HTMLDListElement", - "HTMLDataElement", - "HTMLDataListElement", - "HTMLDialogElement", - "HTMLDivElement", - "HTMLElement", - "HTMLEmbedElement", - "HTMLFieldSetElement", - "HTMLFormControlsCollection", - "HTMLFormElement", - "HTMLFrameSetElement", - "HTMLHRElement", - "HTMLHeadElement", - "HTMLHeadingElement", - "HTMLHtmlElement", - "HTMLIFrameElement", - "HTMLImageElement", - "HTMLInputElement", - "HTMLLIElement", - "HTMLLabelElement", - "HTMLLegendElement", - "HTMLLinkElement", - "HTMLMapElement", - "HTMLMenuElement", - "HTMLMetaElement", - "HTMLMeterElement", - "HTMLModElement", - "HTMLOListElement", - "HTMLObjectElement", - "HTMLOptGroupElement", - "HTMLOptionElement", - "HTMLOptionsCollection", - "HTMLOutputElement", - "HTMLParagraphElement", - "HTMLPictureElement", - "HTMLPreElement", - "HTMLProgressElement", - "HTMLQuoteElement", - "HTMLScriptElement", - "HTMLSelectElement", - "HTMLSlotElement", - "HTMLSourceElement", - "HTMLSpanElement", - "HTMLStyleElement", - "HTMLTableCaptionElement", - "HTMLTableCellElement", - "HTMLTableElement", - "HTMLTableRowElement", - "HTMLTableSectionElement", - "HTMLTemplateElement", - "HTMLTextAreaElement", - "HTMLTimeElement", - "HTMLTitleElement", - "HTMLTrackElement", - "HTMLUListElement", - "HTMLVideoElement", - "IdleDeadline", - "ImageData", - "Location", - "MediaList", - "MediaQueryList", "NamedNodeMap", "Node", "NodeFilter", "NodeIterator", "NodeList", "Range", - "SVGGraphicsElement", - "SVGLength", - "ScreenOrientation", "Selection", "ShadowRoot", - "StylePropertyMap", - "StylePropertyMapReadOnly", - "StyleSheetList", "Text", - "TextTrackList", - "TimeRanges", - "TreeWalker", - "VideoColorSpace", - "Window", - "XPathExpression", - "XPathResult" + "TreeWalker" ] }, + { + "dir": "src/CSSOM", + "subdirs": true, + "feature": "WebAPI.CSSOM", + "public": [ + "CSSRuleList", + "CSSStyleDeclaration", + "CSSStyleSheet", + "MediaList", + "MediaQueryList", + "StyleSheetList" + ] + }, + { + "dir": "src/CSSTypedOM", + "subdirs": true, + "feature": "WebAPI.CSSTypedOM", + "public": ["CSSStyleValue", "StylePropertyMap", "StylePropertyMapReadOnly"] + }, + { + "dir": "src/CustomElements", + "subdirs": true, + "feature": "WebAPI.CustomElements", + "public": ["CustomElementRegistry", "ElementInternals"] + }, { "dir": "src/EncryptedMediaExtensions", "subdirs": true, @@ -249,6 +215,12 @@ "WritableStreamDefaultController" ] }, + { + "dir": "src/FileList", + "subdirs": true, + "feature": "WebAPI.FileList", + "public": ["FileList"] + }, { "dir": "src/FileAndDirectoryEntries", "subdirs": true, @@ -271,12 +243,99 @@ "feature": "WebAPI.Geolocation", "public": ["Geolocation", "GeolocationCoordinates", "GeolocationPosition"] }, + { + "dir": "src/Geometry", + "subdirs": true, + "feature": "WebAPI.Geometry", + "public": [ + "DOMMatrix", + "DOMMatrixReadOnly", + "DOMPoint", + "DOMPointReadOnly", + "DOMRect", + "DOMRectList", + "DOMRectReadOnly" + ] + }, { "dir": "src/History", "subdirs": true, "feature": "WebAPI.History", "public": ["History"] }, + { + "dir": "src/HTML", + "subdirs": true, + "feature": "WebAPI.HTML", + "public": [ + "DomHTMLMediaElement", + "HTMLAnchorElement", + "HTMLAreaElement", + "HTMLAudioElement", + "HTMLBRElement", + "HTMLBaseElement", + "HTMLBodyElement", + "HTMLButtonElement", + "HTMLCollection", + "HTMLDListElement", + "HTMLDataElement", + "HTMLDataListElement", + "HTMLDialogElement", + "HTMLDivElement", + "HTMLElement", + "HTMLEmbedElement", + "HTMLFieldSetElement", + "HTMLFormControlsCollection", + "HTMLFormElement", + "HTMLFrameSetElement", + "HTMLHRElement", + "HTMLHeadElement", + "HTMLHeadingElement", + "HTMLHtmlElement", + "HTMLIFrameElement", + "HTMLImageElement", + "HTMLInputElement", + "HTMLLIElement", + "HTMLLabelElement", + "HTMLLegendElement", + "HTMLLinkElement", + "HTMLMapElement", + "HTMLMenuElement", + "HTMLMetaElement", + "HTMLMeterElement", + "HTMLModElement", + "HTMLOListElement", + "HTMLObjectElement", + "HTMLOptGroupElement", + "HTMLOptionElement", + "HTMLOptionsCollection", + "HTMLOutputElement", + "HTMLParagraphElement", + "HTMLPictureElement", + "HTMLPreElement", + "HTMLProgressElement", + "HTMLQuoteElement", + "HTMLScriptElement", + "HTMLSelectElement", + "HTMLSlotElement", + "HTMLSourceElement", + "HTMLSpanElement", + "HTMLStyleElement", + "HTMLTableCaptionElement", + "HTMLTableCellElement", + "HTMLTableElement", + "HTMLTableRowElement", + "HTMLTableSectionElement", + "HTMLTemplateElement", + "HTMLTextAreaElement", + "HTMLTimeElement", + "HTMLTitleElement", + "HTMLTrackElement", + "HTMLUListElement", + "HTMLVideoElement", + "TimeRanges" + ] + }, { "dir": "src/IndexedDB", "subdirs": true, @@ -378,6 +437,12 @@ "feature": "WebAPI.ResizeObserver", "public": ["ResizeObserver"] }, + { + "dir": "src/ScreenOrientation", + "subdirs": true, + "feature": "WebAPI.ScreenOrientation", + "public": ["ScreenOrientation"] + }, { "dir": "src/ScreenWakeLock", "subdirs": true, @@ -404,6 +469,12 @@ "feature": "WebAPI.Storage", "public": ["StorageManager"] }, + { + "dir": "src/SVG", + "subdirs": true, + "feature": "WebAPI.SVG", + "public": ["SVGGraphicsElement", "SVGLength"] + }, { "dir": "src/UIEvents", "subdirs": true, @@ -443,6 +514,12 @@ "feature": "WebAPI.VisualViewport", "public": ["VisualViewport"] }, + { + "dir": "src/WebAnimations", + "subdirs": true, + "feature": "WebAPI.WebAnimations", + "public": ["Animation", "AnimationEffect", "DocumentTimeline"] + }, { "dir": "src/WebAudio", "subdirs": true, @@ -521,7 +598,7 @@ "dir": "src/WebVTT", "subdirs": true, "feature": "WebAPI.WebVTT", - "public": ["TextTrack", "TextTrackCueList"] + "public": ["TextTrack", "TextTrackCueList", "TextTrackList"] }, { "dir": "src/WebWorkers", @@ -529,6 +606,18 @@ "feature": "WebAPI.WebWorkers", "public": ["CacheStorage", "SharedWorker", "SharedWorkerScope", "Worker"] }, + { + "dir": "src/Window", + "subdirs": true, + "feature": "WebAPI.Window", + "public": ["IdleDeadline", "Location", "Window"] + }, + { + "dir": "src/XPath", + "subdirs": true, + "feature": "WebAPI.XPath", + "public": ["XPathExpression", "XPathResult"] + }, { "dir": "tests", "subdirs": true, diff --git a/src/DOM/CSSRuleList.res b/src/CSSOM/CSSRuleList.res similarity index 100% rename from src/DOM/CSSRuleList.res rename to src/CSSOM/CSSRuleList.res diff --git a/src/DOM/CSSStyleDeclaration.res b/src/CSSOM/CSSStyleDeclaration.res similarity index 100% rename from src/DOM/CSSStyleDeclaration.res rename to src/CSSOM/CSSStyleDeclaration.res diff --git a/src/DOM/CSSStyleSheet.res b/src/CSSOM/CSSStyleSheet.res similarity index 100% rename from src/DOM/CSSStyleSheet.res rename to src/CSSOM/CSSStyleSheet.res diff --git a/src/DOM/MediaList.res b/src/CSSOM/MediaList.res similarity index 100% rename from src/DOM/MediaList.res rename to src/CSSOM/MediaList.res diff --git a/src/DOM/MediaQueryList.res b/src/CSSOM/MediaQueryList.res similarity index 100% rename from src/DOM/MediaQueryList.res rename to src/CSSOM/MediaQueryList.res diff --git a/src/DOM/StyleSheetList.res b/src/CSSOM/StyleSheetList.res similarity index 100% rename from src/DOM/StyleSheetList.res rename to src/CSSOM/StyleSheetList.res diff --git a/src/DOM/CSSStyleValue.res b/src/CSSTypedOM/CSSStyleValue.res similarity index 100% rename from src/DOM/CSSStyleValue.res rename to src/CSSTypedOM/CSSStyleValue.res diff --git a/src/DOM/StylePropertyMap.res b/src/CSSTypedOM/StylePropertyMap.res similarity index 100% rename from src/DOM/StylePropertyMap.res rename to src/CSSTypedOM/StylePropertyMap.res diff --git a/src/DOM/StylePropertyMapReadOnly.res b/src/CSSTypedOM/StylePropertyMapReadOnly.res similarity index 100% rename from src/DOM/StylePropertyMapReadOnly.res rename to src/CSSTypedOM/StylePropertyMapReadOnly.res diff --git a/src/DOM/ImageData.res b/src/Canvas/ImageData.res similarity index 100% rename from src/DOM/ImageData.res rename to src/Canvas/ImageData.res diff --git a/src/DOM/VideoColorSpace.res b/src/Canvas/VideoColorSpace.res similarity index 100% rename from src/DOM/VideoColorSpace.res rename to src/Canvas/VideoColorSpace.res diff --git a/src/DOM/CustomElementRegistry.res b/src/CustomElements/CustomElementRegistry.res similarity index 100% rename from src/DOM/CustomElementRegistry.res rename to src/CustomElements/CustomElementRegistry.res diff --git a/src/DOM/ElementInternals.res b/src/CustomElements/ElementInternals.res similarity index 100% rename from src/DOM/ElementInternals.res rename to src/CustomElements/ElementInternals.res diff --git a/src/DOM/FileList.res b/src/FileList/FileList.res similarity index 100% rename from src/DOM/FileList.res rename to src/FileList/FileList.res diff --git a/src/DOM/DOMMatrix.res b/src/Geometry/DOMMatrix.res similarity index 100% rename from src/DOM/DOMMatrix.res rename to src/Geometry/DOMMatrix.res diff --git a/src/DOM/DOMMatrixReadOnly.res b/src/Geometry/DOMMatrixReadOnly.res similarity index 100% rename from src/DOM/DOMMatrixReadOnly.res rename to src/Geometry/DOMMatrixReadOnly.res diff --git a/src/DOM/DOMPoint.res b/src/Geometry/DOMPoint.res similarity index 100% rename from src/DOM/DOMPoint.res rename to src/Geometry/DOMPoint.res diff --git a/src/DOM/DOMPointReadOnly.res b/src/Geometry/DOMPointReadOnly.res similarity index 100% rename from src/DOM/DOMPointReadOnly.res rename to src/Geometry/DOMPointReadOnly.res diff --git a/src/DOM/DOMRect.res b/src/Geometry/DOMRect.res similarity index 100% rename from src/DOM/DOMRect.res rename to src/Geometry/DOMRect.res diff --git a/src/DOM/DOMRectList.res b/src/Geometry/DOMRectList.res similarity index 100% rename from src/DOM/DOMRectList.res rename to src/Geometry/DOMRectList.res diff --git a/src/DOM/DOMRectReadOnly.res b/src/Geometry/DOMRectReadOnly.res similarity index 100% rename from src/DOM/DOMRectReadOnly.res rename to src/Geometry/DOMRectReadOnly.res diff --git a/src/DOM/DomHTMLMediaElement.res b/src/HTML/DomHTMLMediaElement.res similarity index 100% rename from src/DOM/DomHTMLMediaElement.res rename to src/HTML/DomHTMLMediaElement.res diff --git a/src/DOM/HTMLAnchorElement.res b/src/HTML/HTMLAnchorElement.res similarity index 100% rename from src/DOM/HTMLAnchorElement.res rename to src/HTML/HTMLAnchorElement.res diff --git a/src/DOM/HTMLAreaElement.res b/src/HTML/HTMLAreaElement.res similarity index 100% rename from src/DOM/HTMLAreaElement.res rename to src/HTML/HTMLAreaElement.res diff --git a/src/DOM/HTMLAudioElement.res b/src/HTML/HTMLAudioElement.res similarity index 100% rename from src/DOM/HTMLAudioElement.res rename to src/HTML/HTMLAudioElement.res diff --git a/src/DOM/HTMLBRElement.res b/src/HTML/HTMLBRElement.res similarity index 100% rename from src/DOM/HTMLBRElement.res rename to src/HTML/HTMLBRElement.res diff --git a/src/DOM/HTMLBaseElement.res b/src/HTML/HTMLBaseElement.res similarity index 100% rename from src/DOM/HTMLBaseElement.res rename to src/HTML/HTMLBaseElement.res diff --git a/src/DOM/HTMLBodyElement.res b/src/HTML/HTMLBodyElement.res similarity index 100% rename from src/DOM/HTMLBodyElement.res rename to src/HTML/HTMLBodyElement.res diff --git a/src/DOM/HTMLButtonElement.res b/src/HTML/HTMLButtonElement.res similarity index 100% rename from src/DOM/HTMLButtonElement.res rename to src/HTML/HTMLButtonElement.res diff --git a/src/DOM/HTMLCollection.res b/src/HTML/HTMLCollection.res similarity index 100% rename from src/DOM/HTMLCollection.res rename to src/HTML/HTMLCollection.res diff --git a/src/DOM/HTMLDListElement.res b/src/HTML/HTMLDListElement.res similarity index 100% rename from src/DOM/HTMLDListElement.res rename to src/HTML/HTMLDListElement.res diff --git a/src/DOM/HTMLDataElement.res b/src/HTML/HTMLDataElement.res similarity index 100% rename from src/DOM/HTMLDataElement.res rename to src/HTML/HTMLDataElement.res diff --git a/src/DOM/HTMLDataListElement.res b/src/HTML/HTMLDataListElement.res similarity index 100% rename from src/DOM/HTMLDataListElement.res rename to src/HTML/HTMLDataListElement.res diff --git a/src/DOM/HTMLDialogElement.res b/src/HTML/HTMLDialogElement.res similarity index 100% rename from src/DOM/HTMLDialogElement.res rename to src/HTML/HTMLDialogElement.res diff --git a/src/DOM/HTMLDivElement.res b/src/HTML/HTMLDivElement.res similarity index 100% rename from src/DOM/HTMLDivElement.res rename to src/HTML/HTMLDivElement.res diff --git a/src/DOM/HTMLElement.res b/src/HTML/HTMLElement.res similarity index 100% rename from src/DOM/HTMLElement.res rename to src/HTML/HTMLElement.res diff --git a/src/DOM/HTMLEmbedElement.res b/src/HTML/HTMLEmbedElement.res similarity index 100% rename from src/DOM/HTMLEmbedElement.res rename to src/HTML/HTMLEmbedElement.res diff --git a/src/DOM/HTMLFieldSetElement.res b/src/HTML/HTMLFieldSetElement.res similarity index 100% rename from src/DOM/HTMLFieldSetElement.res rename to src/HTML/HTMLFieldSetElement.res diff --git a/src/DOM/HTMLFormControlsCollection.res b/src/HTML/HTMLFormControlsCollection.res similarity index 100% rename from src/DOM/HTMLFormControlsCollection.res rename to src/HTML/HTMLFormControlsCollection.res diff --git a/src/DOM/HTMLFormElement.res b/src/HTML/HTMLFormElement.res similarity index 100% rename from src/DOM/HTMLFormElement.res rename to src/HTML/HTMLFormElement.res diff --git a/src/DOM/HTMLFrameSetElement.res b/src/HTML/HTMLFrameSetElement.res similarity index 100% rename from src/DOM/HTMLFrameSetElement.res rename to src/HTML/HTMLFrameSetElement.res diff --git a/src/DOM/HTMLHRElement.res b/src/HTML/HTMLHRElement.res similarity index 100% rename from src/DOM/HTMLHRElement.res rename to src/HTML/HTMLHRElement.res diff --git a/src/DOM/HTMLHeadElement.res b/src/HTML/HTMLHeadElement.res similarity index 100% rename from src/DOM/HTMLHeadElement.res rename to src/HTML/HTMLHeadElement.res diff --git a/src/DOM/HTMLHeadingElement.res b/src/HTML/HTMLHeadingElement.res similarity index 100% rename from src/DOM/HTMLHeadingElement.res rename to src/HTML/HTMLHeadingElement.res diff --git a/src/DOM/HTMLHtmlElement.res b/src/HTML/HTMLHtmlElement.res similarity index 100% rename from src/DOM/HTMLHtmlElement.res rename to src/HTML/HTMLHtmlElement.res diff --git a/src/DOM/HTMLIFrameElement.res b/src/HTML/HTMLIFrameElement.res similarity index 100% rename from src/DOM/HTMLIFrameElement.res rename to src/HTML/HTMLIFrameElement.res diff --git a/src/DOM/HTMLImageElement.res b/src/HTML/HTMLImageElement.res similarity index 100% rename from src/DOM/HTMLImageElement.res rename to src/HTML/HTMLImageElement.res diff --git a/src/DOM/HTMLInputElement.res b/src/HTML/HTMLInputElement.res similarity index 100% rename from src/DOM/HTMLInputElement.res rename to src/HTML/HTMLInputElement.res diff --git a/src/DOM/HTMLLIElement.res b/src/HTML/HTMLLIElement.res similarity index 100% rename from src/DOM/HTMLLIElement.res rename to src/HTML/HTMLLIElement.res diff --git a/src/DOM/HTMLLabelElement.res b/src/HTML/HTMLLabelElement.res similarity index 100% rename from src/DOM/HTMLLabelElement.res rename to src/HTML/HTMLLabelElement.res diff --git a/src/DOM/HTMLLegendElement.res b/src/HTML/HTMLLegendElement.res similarity index 100% rename from src/DOM/HTMLLegendElement.res rename to src/HTML/HTMLLegendElement.res diff --git a/src/DOM/HTMLLinkElement.res b/src/HTML/HTMLLinkElement.res similarity index 100% rename from src/DOM/HTMLLinkElement.res rename to src/HTML/HTMLLinkElement.res diff --git a/src/DOM/HTMLMapElement.res b/src/HTML/HTMLMapElement.res similarity index 100% rename from src/DOM/HTMLMapElement.res rename to src/HTML/HTMLMapElement.res diff --git a/src/DOM/HTMLMenuElement.res b/src/HTML/HTMLMenuElement.res similarity index 100% rename from src/DOM/HTMLMenuElement.res rename to src/HTML/HTMLMenuElement.res diff --git a/src/DOM/HTMLMetaElement.res b/src/HTML/HTMLMetaElement.res similarity index 100% rename from src/DOM/HTMLMetaElement.res rename to src/HTML/HTMLMetaElement.res diff --git a/src/DOM/HTMLMeterElement.res b/src/HTML/HTMLMeterElement.res similarity index 100% rename from src/DOM/HTMLMeterElement.res rename to src/HTML/HTMLMeterElement.res diff --git a/src/DOM/HTMLModElement.res b/src/HTML/HTMLModElement.res similarity index 100% rename from src/DOM/HTMLModElement.res rename to src/HTML/HTMLModElement.res diff --git a/src/DOM/HTMLOListElement.res b/src/HTML/HTMLOListElement.res similarity index 100% rename from src/DOM/HTMLOListElement.res rename to src/HTML/HTMLOListElement.res diff --git a/src/DOM/HTMLObjectElement.res b/src/HTML/HTMLObjectElement.res similarity index 100% rename from src/DOM/HTMLObjectElement.res rename to src/HTML/HTMLObjectElement.res diff --git a/src/DOM/HTMLOptGroupElement.res b/src/HTML/HTMLOptGroupElement.res similarity index 100% rename from src/DOM/HTMLOptGroupElement.res rename to src/HTML/HTMLOptGroupElement.res diff --git a/src/DOM/HTMLOptionElement.res b/src/HTML/HTMLOptionElement.res similarity index 100% rename from src/DOM/HTMLOptionElement.res rename to src/HTML/HTMLOptionElement.res diff --git a/src/DOM/HTMLOptionsCollection.res b/src/HTML/HTMLOptionsCollection.res similarity index 100% rename from src/DOM/HTMLOptionsCollection.res rename to src/HTML/HTMLOptionsCollection.res diff --git a/src/DOM/HTMLOutputElement.res b/src/HTML/HTMLOutputElement.res similarity index 100% rename from src/DOM/HTMLOutputElement.res rename to src/HTML/HTMLOutputElement.res diff --git a/src/DOM/HTMLParagraphElement.res b/src/HTML/HTMLParagraphElement.res similarity index 100% rename from src/DOM/HTMLParagraphElement.res rename to src/HTML/HTMLParagraphElement.res diff --git a/src/DOM/HTMLPictureElement.res b/src/HTML/HTMLPictureElement.res similarity index 100% rename from src/DOM/HTMLPictureElement.res rename to src/HTML/HTMLPictureElement.res diff --git a/src/DOM/HTMLPreElement.res b/src/HTML/HTMLPreElement.res similarity index 100% rename from src/DOM/HTMLPreElement.res rename to src/HTML/HTMLPreElement.res diff --git a/src/DOM/HTMLProgressElement.res b/src/HTML/HTMLProgressElement.res similarity index 100% rename from src/DOM/HTMLProgressElement.res rename to src/HTML/HTMLProgressElement.res diff --git a/src/DOM/HTMLQuoteElement.res b/src/HTML/HTMLQuoteElement.res similarity index 100% rename from src/DOM/HTMLQuoteElement.res rename to src/HTML/HTMLQuoteElement.res diff --git a/src/DOM/HTMLScriptElement.res b/src/HTML/HTMLScriptElement.res similarity index 100% rename from src/DOM/HTMLScriptElement.res rename to src/HTML/HTMLScriptElement.res diff --git a/src/DOM/HTMLSelectElement.res b/src/HTML/HTMLSelectElement.res similarity index 100% rename from src/DOM/HTMLSelectElement.res rename to src/HTML/HTMLSelectElement.res diff --git a/src/DOM/HTMLSlotElement.res b/src/HTML/HTMLSlotElement.res similarity index 100% rename from src/DOM/HTMLSlotElement.res rename to src/HTML/HTMLSlotElement.res diff --git a/src/DOM/HTMLSourceElement.res b/src/HTML/HTMLSourceElement.res similarity index 100% rename from src/DOM/HTMLSourceElement.res rename to src/HTML/HTMLSourceElement.res diff --git a/src/DOM/HTMLSpanElement.res b/src/HTML/HTMLSpanElement.res similarity index 100% rename from src/DOM/HTMLSpanElement.res rename to src/HTML/HTMLSpanElement.res diff --git a/src/DOM/HTMLStyleElement.res b/src/HTML/HTMLStyleElement.res similarity index 100% rename from src/DOM/HTMLStyleElement.res rename to src/HTML/HTMLStyleElement.res diff --git a/src/DOM/HTMLTableCaptionElement.res b/src/HTML/HTMLTableCaptionElement.res similarity index 100% rename from src/DOM/HTMLTableCaptionElement.res rename to src/HTML/HTMLTableCaptionElement.res diff --git a/src/DOM/HTMLTableCellElement.res b/src/HTML/HTMLTableCellElement.res similarity index 100% rename from src/DOM/HTMLTableCellElement.res rename to src/HTML/HTMLTableCellElement.res diff --git a/src/DOM/HTMLTableElement.res b/src/HTML/HTMLTableElement.res similarity index 100% rename from src/DOM/HTMLTableElement.res rename to src/HTML/HTMLTableElement.res diff --git a/src/DOM/HTMLTableRowElement.res b/src/HTML/HTMLTableRowElement.res similarity index 100% rename from src/DOM/HTMLTableRowElement.res rename to src/HTML/HTMLTableRowElement.res diff --git a/src/DOM/HTMLTableSectionElement.res b/src/HTML/HTMLTableSectionElement.res similarity index 100% rename from src/DOM/HTMLTableSectionElement.res rename to src/HTML/HTMLTableSectionElement.res diff --git a/src/DOM/HTMLTemplateElement.res b/src/HTML/HTMLTemplateElement.res similarity index 100% rename from src/DOM/HTMLTemplateElement.res rename to src/HTML/HTMLTemplateElement.res diff --git a/src/DOM/HTMLTextAreaElement.res b/src/HTML/HTMLTextAreaElement.res similarity index 100% rename from src/DOM/HTMLTextAreaElement.res rename to src/HTML/HTMLTextAreaElement.res diff --git a/src/DOM/HTMLTimeElement.res b/src/HTML/HTMLTimeElement.res similarity index 100% rename from src/DOM/HTMLTimeElement.res rename to src/HTML/HTMLTimeElement.res diff --git a/src/DOM/HTMLTitleElement.res b/src/HTML/HTMLTitleElement.res similarity index 100% rename from src/DOM/HTMLTitleElement.res rename to src/HTML/HTMLTitleElement.res diff --git a/src/DOM/HTMLTrackElement.res b/src/HTML/HTMLTrackElement.res similarity index 100% rename from src/DOM/HTMLTrackElement.res rename to src/HTML/HTMLTrackElement.res diff --git a/src/DOM/HTMLUListElement.res b/src/HTML/HTMLUListElement.res similarity index 100% rename from src/DOM/HTMLUListElement.res rename to src/HTML/HTMLUListElement.res diff --git a/src/DOM/HTMLVideoElement.res b/src/HTML/HTMLVideoElement.res similarity index 100% rename from src/DOM/HTMLVideoElement.res rename to src/HTML/HTMLVideoElement.res diff --git a/src/DOM/TimeRanges.res b/src/HTML/TimeRanges.res similarity index 100% rename from src/DOM/TimeRanges.res rename to src/HTML/TimeRanges.res diff --git a/src/DOM/SVGGraphicsElement.res b/src/SVG/SVGGraphicsElement.res similarity index 100% rename from src/DOM/SVGGraphicsElement.res rename to src/SVG/SVGGraphicsElement.res diff --git a/src/DOM/SVGLength.res b/src/SVG/SVGLength.res similarity index 100% rename from src/DOM/SVGLength.res rename to src/SVG/SVGLength.res diff --git a/src/DOM/ScreenOrientation.res b/src/ScreenOrientation/ScreenOrientation.res similarity index 100% rename from src/DOM/ScreenOrientation.res rename to src/ScreenOrientation/ScreenOrientation.res diff --git a/src/DOM/Animation.res b/src/WebAnimations/Animation.res similarity index 100% rename from src/DOM/Animation.res rename to src/WebAnimations/Animation.res diff --git a/src/DOM/AnimationEffect.res b/src/WebAnimations/AnimationEffect.res similarity index 100% rename from src/DOM/AnimationEffect.res rename to src/WebAnimations/AnimationEffect.res diff --git a/src/DOM/DocumentTimeline.res b/src/WebAnimations/DocumentTimeline.res similarity index 100% rename from src/DOM/DocumentTimeline.res rename to src/WebAnimations/DocumentTimeline.res diff --git a/src/DOM/TextTrackList.res b/src/WebVTT/TextTrackList.res similarity index 100% rename from src/DOM/TextTrackList.res rename to src/WebVTT/TextTrackList.res diff --git a/src/DOM/IdleDeadline.res b/src/Window/IdleDeadline.res similarity index 100% rename from src/DOM/IdleDeadline.res rename to src/Window/IdleDeadline.res diff --git a/src/DOM/Location.res b/src/Window/Location.res similarity index 100% rename from src/DOM/Location.res rename to src/Window/Location.res diff --git a/src/DOM/Window.res b/src/Window/Window.res similarity index 100% rename from src/DOM/Window.res rename to src/Window/Window.res diff --git a/src/DOM/XPathExpression.res b/src/XPath/XPathExpression.res similarity index 100% rename from src/DOM/XPathExpression.res rename to src/XPath/XPathExpression.res diff --git a/src/DOM/XPathResult.res b/src/XPath/XPathResult.res similarity index 100% rename from src/DOM/XPathResult.res rename to src/XPath/XPathResult.res From 5b10b90b73aec68604c23a1ee89dfb229d60ffc1 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 16:52:21 -0400 Subject: [PATCH 13/16] rename features --- .../contributing/api-module-structure.mdx | 4 +- .../contributing/module-type-structure.mdx | 12 +---- .../2026-04-22-unmonorepo-webapi-design.md | 7 +-- ...26-05-20-global-singleton-access-design.md | 2 +- rescript.json | 47 +++++++++++++------ 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/docs/content/docs/contributing/api-module-structure.mdx b/docs/content/docs/contributing/api-module-structure.mdx index f05cb47..3545862 100644 --- a/docs/content/docs/contributing/api-module-structure.mdx +++ b/docs/content/docs/contributing/api-module-structure.mdx @@ -51,8 +51,8 @@ type htmlSpanElement = { ``` ```ReScript diff --git a/docs/content/docs/contributing/module-type-structure.mdx b/docs/content/docs/contributing/module-type-structure.mdx index 5f932a8..f1d224d 100644 --- a/docs/content/docs/contributing/module-type-structure.mdx +++ b/docs/content/docs/contributing/module-type-structure.mdx @@ -56,11 +56,7 @@ external focus: (T.t, ~options: focusOptions=?) => unit = "focus" include Impl({ type t = htmlElement }) `; - + export const buttonModule = ` open DOMAPI @@ -78,11 +74,7 @@ _/ external checkValidity: htmlButtonElement => bool = "checkValidity" `; - + ## Shared element base diff --git a/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md b/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md index 40ba01e..f20b41b 100644 --- a/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md +++ b/docs/superpowers/specs/2026-04-22-unmonorepo-webapi-design.md @@ -97,10 +97,7 @@ Example: ```json { - "dependencies": [ - "@plain/dep", - { "name": "@other/heavy", "features": ["WebAPI.WebCrypto"] } - ] + "dependencies": ["@plain/dep", { "name": "@other/heavy", "features": ["WebAPI.Crypto"] }] } ``` @@ -117,7 +114,7 @@ The build remains feature-oriented: - `WebAPI.Base` - `WebAPI.DOM` - `WebAPI.Fetch` -- `WebAPI.WebCrypto` +- `WebAPI.Crypto` - and the rest of the former package surfaces The unified build keeps the original flat module surface instead of adding generated feature entry modules. For example, consumers should use modules such as: diff --git a/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md b/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md index 6dc4f1b..8f2495a 100644 --- a/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md +++ b/docs/superpowers/specs/2026-05-20-global-singleton-access-design.md @@ -840,7 +840,7 @@ After agreeing on the public shape: - Add `LocalStorage.res` - Add `SessionStorage.res` -- Add both modules to the `WebAPI.WebStorage` public list in `rescript.json` +- Add both modules to the `WebAPI.Storage` public list in `rescript.json` - Keep `Storage.res` receiver-based - Update WebStorage tests to cover direct singleton usage and generic receiver usage diff --git a/rescript.json b/rescript.json index 544baa6..6496a99 100644 --- a/rescript.json +++ b/rescript.json @@ -22,12 +22,15 @@ "WebAPI.CSSOM": ["WebAPI.DOM", "WebAPI.Event"], "WebAPI.CSSTypedOM": ["WebAPI.DOM"], "WebAPI.CustomElements": ["WebAPI.DOM"], + "WebAPI.Event": ["WebAPI.Base"], + "WebAPI.Fetch": ["WebAPI.Event", "WebAPI.File", "WebAPI.URL"], + "WebAPI.File": ["WebAPI.Base", "WebAPI.Event"], "WebAPI.FileList": ["WebAPI.DOM", "WebAPI.File"], "WebAPI.Geometry": ["WebAPI.DOM"], "WebAPI.HTML": [ "WebAPI.DOM", "WebAPI.PictureInPicture", - "WebAPI.WebVTT" + "WebAPI.VTT" ], "WebAPI.Navigator": [ "WebAPI.Base", @@ -36,12 +39,26 @@ "WebAPI.Fetch", "WebAPI.Gamepad", "WebAPI.URL", - "WebAPI.WebMIDI" + "WebAPI.MIDI" ], "WebAPI.ScreenOrientation": ["WebAPI.DOM", "WebAPI.Event"], "WebAPI.SVG": ["WebAPI.DOM", "WebAPI.Geometry"], - "WebAPI.WebAnimations": ["WebAPI.DOM", "WebAPI.Event"], - "WebAPI.WebVTT": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.Animations": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.Audio": [ + "WebAPI.ChannelMessaging", + "WebAPI.DOM", + "WebAPI.Event", + "WebAPI.HTML", + "WebAPI.MediaCaptureAndStreams" + ], + "WebAPI.Locks": ["WebAPI.Event"], + "WebAPI.MIDI": ["WebAPI.Event"], + "WebAPI.Sockets": ["WebAPI.ChannelMessaging", "WebAPI.Event", "WebAPI.File"], + "WebAPI.Speech": ["WebAPI.Event"], + "WebAPI.Storage": ["WebAPI.Event"], + "WebAPI.StorageManager": ["WebAPI.File"], + "WebAPI.VTT": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.Workers": ["WebAPI.ChannelMessaging", "WebAPI.Event", "WebAPI.Fetch"], "WebAPI.Window": [ "WebAPI.ChannelMessaging", "WebAPI.DOM", @@ -466,7 +483,7 @@ { "dir": "src/Storage", "subdirs": true, - "feature": "WebAPI.Storage", + "feature": "WebAPI.StorageManager", "public": ["StorageManager"] }, { @@ -517,13 +534,13 @@ { "dir": "src/WebAnimations", "subdirs": true, - "feature": "WebAPI.WebAnimations", + "feature": "WebAPI.Animations", "public": ["Animation", "AnimationEffect", "DocumentTimeline"] }, { "dir": "src/WebAudio", "subdirs": true, - "feature": "WebAPI.WebAudio", + "feature": "WebAPI.Audio", "public": [ "AnalyserNode", "AudioBuffer", @@ -561,49 +578,49 @@ { "dir": "src/WebCrypto", "subdirs": true, - "feature": "WebAPI.WebCrypto", + "feature": "WebAPI.Crypto", "public": ["Crypto", "SubtleCrypto"] }, { "dir": "src/WebLocks", "subdirs": true, - "feature": "WebAPI.WebLocks", + "feature": "WebAPI.Locks", "public": ["LockManager"] }, { "dir": "src/WebMIDI", "subdirs": true, - "feature": "WebAPI.WebMIDI", + "feature": "WebAPI.MIDI", "public": ["WebMIDI"] }, { "dir": "src/WebSockets", "subdirs": true, - "feature": "WebAPI.WebSockets", + "feature": "WebAPI.Sockets", "public": ["CloseEvent", "MessageEvent", "WebSocket"] }, { "dir": "src/WebSpeech", "subdirs": true, - "feature": "WebAPI.WebSpeech", + "feature": "WebAPI.Speech", "public": ["SpeechSynthesis", "SpeechSynthesisUtterance"] }, { "dir": "src/WebStorage", "subdirs": true, - "feature": "WebAPI.WebStorage", + "feature": "WebAPI.Storage", "public": ["LocalStorage", "SessionStorage", "Storage", "StorageEvent"] }, { "dir": "src/WebVTT", "subdirs": true, - "feature": "WebAPI.WebVTT", + "feature": "WebAPI.VTT", "public": ["TextTrack", "TextTrackCueList", "TextTrackList"] }, { "dir": "src/WebWorkers", "subdirs": true, - "feature": "WebAPI.WebWorkers", + "feature": "WebAPI.Workers", "public": ["CacheStorage", "SharedWorker", "SharedWorkerScope", "Worker"] }, { From fdc8e56656c7159e8cccc3c221c7d7d692110b5a Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 17:00:14 -0400 Subject: [PATCH 14/16] breakup location and idledealing --- rescript.json | 20 ++++++++++++++++++-- src/DOM/DOM.res | 11 ----------- src/DOM/DomGlobal.res | 4 ++-- src/DOM/DomTypes.res | 3 --- src/IdleDeadline/IdleDeadline.res | 18 ++++++++++++++++++ src/{Window => Location}/Location.res | 17 +++++++++++------ src/Window/IdleDeadline.res | 5 ----- src/Window/Window.res | 4 ++-- tests/DOMAPI/Location__test.res | 4 ++-- 9 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 src/IdleDeadline/IdleDeadline.res rename src/{Window => Location}/Location.res (56%) delete mode 100644 src/Window/IdleDeadline.res diff --git a/rescript.json b/rescript.json index 6496a99..c4555c1 100644 --- a/rescript.json +++ b/rescript.json @@ -8,6 +8,7 @@ "WebAPI.Event", "WebAPI.File", "WebAPI.FileAndDirectoryEntries", + "WebAPI.IdleDeadline", "WebAPI.RemotePlayback", "WebAPI.ViewTransitions", "WebAPI.VisualViewport" @@ -27,6 +28,7 @@ "WebAPI.File": ["WebAPI.Base", "WebAPI.Event"], "WebAPI.FileList": ["WebAPI.DOM", "WebAPI.File"], "WebAPI.Geometry": ["WebAPI.DOM"], + "WebAPI.Location": ["WebAPI.DOM"], "WebAPI.HTML": [ "WebAPI.DOM", "WebAPI.PictureInPicture", @@ -62,7 +64,9 @@ "WebAPI.Window": [ "WebAPI.ChannelMessaging", "WebAPI.DOM", - "WebAPI.Event" + "WebAPI.Event", + "WebAPI.IdleDeadline", + "WebAPI.Location" ], "WebAPI.XPath": ["WebAPI.DOM"] }, @@ -280,6 +284,12 @@ "feature": "WebAPI.History", "public": ["History"] }, + { + "dir": "src/IdleDeadline", + "subdirs": true, + "feature": "WebAPI.IdleDeadline", + "public": ["IdleDeadline"] + }, { "dir": "src/HTML", "subdirs": true, @@ -353,6 +363,12 @@ "TimeRanges" ] }, + { + "dir": "src/Location", + "subdirs": true, + "feature": "WebAPI.Location", + "public": ["Location"] + }, { "dir": "src/IndexedDB", "subdirs": true, @@ -627,7 +643,7 @@ "dir": "src/Window", "subdirs": true, "feature": "WebAPI.Window", - "public": ["IdleDeadline", "Location", "Window"] + "public": ["Window"] }, { "dir": "src/XPath", diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index 4e27b83..e191097 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -6231,17 +6231,6 @@ type mediaQueryList = private { matches: bool, } -/** -[See IdleDeadline on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline) -*/ -@editor.completeFrom(DOM.IdleDeadline) -type idleDeadline = private { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline/didTimeout) - */ - didTimeout: bool, -} - /** [See CSSStyleValue on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleValue) */ diff --git a/src/DOM/DomGlobal.res b/src/DOM/DomGlobal.res index a0bf3f6..cee8269 100644 --- a/src/DOM/DomGlobal.res +++ b/src/DOM/DomGlobal.res @@ -458,8 +458,8 @@ external getComputedStyle: ( [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/requestIdleCallback) */ external requestIdleCallback: ( - ~callback: DomTypes.idleDeadline => unit, - ~options: DomTypes.idleRequestOptions=?, + ~callback: IdleDeadline.t => unit, + ~options: IdleDeadline.requestOptions=?, ) => int = "requestIdleCallback" /** diff --git a/src/DOM/DomTypes.res b/src/DOM/DomTypes.res index c347084..d9781eb 100644 --- a/src/DOM/DomTypes.res +++ b/src/DOM/DomTypes.res @@ -74,7 +74,6 @@ type htmlTableRowElement = DOM.htmlTableRowElement type htmlImageElement = DOM.htmlImageElement type htmlAreaElement = DOM.htmlAreaElement type videoPlaybackQuality = DOM.videoPlaybackQuality -type idleDeadline = DOM.idleDeadline type cssRuleList = DOM.cssRuleList type mediaKeySystemConfiguration = BaseEncryptedMediaExtensions.mediaKeySystemConfiguration @@ -1872,8 +1871,6 @@ type pointerLockOptions = {mutable unadjustedMovement?: bool} type caretPositionFromPointOptions = {mutable shadowRoots?: array} -type idleRequestOptions = {mutable timeout?: int} - type domRectInit = { mutable x?: float, mutable y?: float, diff --git a/src/IdleDeadline/IdleDeadline.res b/src/IdleDeadline/IdleDeadline.res new file mode 100644 index 0000000..6c1d6b1 --- /dev/null +++ b/src/IdleDeadline/IdleDeadline.res @@ -0,0 +1,18 @@ +/** +[See IdleDeadline on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline) +*/ +@editor.completeFrom(IdleDeadline) +type t = private { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline/didTimeout) + */ + didTimeout: bool, +} + +type requestOptions = {mutable timeout?: int} + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline/timeRemaining) +*/ +@send +external timeRemaining: t => float = "timeRemaining" diff --git a/src/Window/Location.res b/src/Location/Location.res similarity index 56% rename from src/Window/Location.res rename to src/Location/Location.res index 3cd14fd..4e3cb51 100644 --- a/src/Window/Location.res +++ b/src/Location/Location.res @@ -1,20 +1,25 @@ +type t = DomTypes.location + +@scope("globalThis") +external current: t = "location" + /** Navigates to the given URL. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/assign) */ -@send -external assign: (DomTypes.location, string) => unit = "assign" +@scope("globalThis.location") +external assign: string => unit = "assign" /** Removes the current page from the session history and navigates to the given URL. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/replace) */ -@send -external replace: (DomTypes.location, string) => unit = "replace" +@scope("globalThis.location") +external replace: string => unit = "replace" /** Reloads the current page. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/reload) */ -@send -external reload: DomTypes.location => unit = "reload" +@scope("globalThis.location") +external reload: unit => unit = "reload" diff --git a/src/Window/IdleDeadline.res b/src/Window/IdleDeadline.res deleted file mode 100644 index 43097ea..0000000 --- a/src/Window/IdleDeadline.res +++ /dev/null @@ -1,5 +0,0 @@ -/** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline/timeRemaining) -*/ -@send -external timeRemaining: DomTypes.idleDeadline => float = "timeRemaining" diff --git a/src/Window/Window.res b/src/Window/Window.res index 98a0574..2c33532 100644 --- a/src/Window/Window.res +++ b/src/Window/Window.res @@ -479,8 +479,8 @@ external getComputedStyle: ( @send external requestIdleCallback: ( t, - ~callback: DomTypes.idleDeadline => unit, - ~options: DomTypes.idleRequestOptions=?, + ~callback: IdleDeadline.t => unit, + ~options: IdleDeadline.requestOptions=?, ) => int = "requestIdleCallback" /** diff --git a/tests/DOMAPI/Location__test.res b/tests/DOMAPI/Location__test.res index 29b588f..5660442 100644 --- a/tests/DOMAPI/Location__test.res +++ b/tests/DOMAPI/Location__test.res @@ -3,7 +3,7 @@ let location = DomGlobal.document.location // Access properties using `.` let href = location.href -// Invoke methods using the `->TypeModule` -location->Location.reload +// Invoke global location methods directly. +Location.reload() let a = 0 From ef46bda5ccde573d558c65faaea19a6ebb29626b Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 17:50:02 -0400 Subject: [PATCH 15/16] refactor location --- rescript.json | 25 ++++++++++++++++--------- src/Base/Base__Document.res | 2 +- src/DOM/DOM.res | 2 +- src/Location/Location.res | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/rescript.json b/rescript.json index c4555c1..ba03b31 100644 --- a/rescript.json +++ b/rescript.json @@ -28,12 +28,7 @@ "WebAPI.File": ["WebAPI.Base", "WebAPI.Event"], "WebAPI.FileList": ["WebAPI.DOM", "WebAPI.File"], "WebAPI.Geometry": ["WebAPI.DOM"], - "WebAPI.Location": ["WebAPI.DOM"], - "WebAPI.HTML": [ - "WebAPI.DOM", - "WebAPI.PictureInPicture", - "WebAPI.VTT" - ], + "WebAPI.HTML": ["WebAPI.DOM", "WebAPI.PictureInPicture", "WebAPI.VTT"], "WebAPI.Navigator": [ "WebAPI.Base", "WebAPI.Event", @@ -55,12 +50,20 @@ ], "WebAPI.Locks": ["WebAPI.Event"], "WebAPI.MIDI": ["WebAPI.Event"], - "WebAPI.Sockets": ["WebAPI.ChannelMessaging", "WebAPI.Event", "WebAPI.File"], + "WebAPI.Sockets": [ + "WebAPI.ChannelMessaging", + "WebAPI.Event", + "WebAPI.File" + ], "WebAPI.Speech": ["WebAPI.Event"], "WebAPI.Storage": ["WebAPI.Event"], "WebAPI.StorageManager": ["WebAPI.File"], "WebAPI.VTT": ["WebAPI.DOM", "WebAPI.Event"], - "WebAPI.Workers": ["WebAPI.ChannelMessaging", "WebAPI.Event", "WebAPI.Fetch"], + "WebAPI.Workers": [ + "WebAPI.ChannelMessaging", + "WebAPI.Event", + "WebAPI.Fetch" + ], "WebAPI.Window": [ "WebAPI.ChannelMessaging", "WebAPI.DOM", @@ -173,7 +176,11 @@ "dir": "src/CSSTypedOM", "subdirs": true, "feature": "WebAPI.CSSTypedOM", - "public": ["CSSStyleValue", "StylePropertyMap", "StylePropertyMapReadOnly"] + "public": [ + "CSSStyleValue", + "StylePropertyMap", + "StylePropertyMapReadOnly" + ] }, { "dir": "src/CustomElements", diff --git a/src/Base/Base__Document.res b/src/Base/Base__Document.res index f155ffb..e170764 100644 --- a/src/Base/Base__Document.res +++ b/src/Base/Base__Document.res @@ -19,7 +19,7 @@ The location (WebApiURL) of the object it is linked to. Changes done on it are r [See Location on MDN](https://developer.mozilla.org/docs/Web/API/Location) TODO: mark as private once mutating fields of private records is allowed */ -@editor.completeFrom(DOM.Location) +@editor.completeFrom(Location) type location = { /** Returns the Location object's URL. diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index e191097..c06405b 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -197,7 +197,7 @@ The location (WebApiURL) of the object it is linked to. Changes done on it are r [See Location on MDN](https://developer.mozilla.org/docs/Web/API/Location) TODO: mark as private once mutating fields of private records is allowed */ -@editor.completeFrom(DOM.Location) +@editor.completeFrom(Location) type location = Base__Document.location // TODO: mark as private once mutating fields of private records is allowed diff --git a/src/Location/Location.res b/src/Location/Location.res index 4e3cb51..c48857e 100644 --- a/src/Location/Location.res +++ b/src/Location/Location.res @@ -1,4 +1,4 @@ -type t = DomTypes.location +type t = Base__Document.location @scope("globalThis") external current: t = "location" From c7621453845a2bcd19c25c5e84177ddd492d1c53 Mon Sep 17 00:00:00 2001 From: Josh Derocher-Vlk Date: Wed, 20 May 2026 19:33:39 -0400 Subject: [PATCH 16/16] break up more of dom --- rescript.json | 42 +++- src/Base/Base__Document.res | 76 +----- src/CSSTypedOM/CSSStyleValue.res | 8 +- src/CSSTypedOM/StylePropertyMap.res | 32 ++- src/CSSTypedOM/StylePropertyMapReadOnly.res | 10 +- src/DOM/DOM.res | 107 +-------- src/DOM/DOMException.res | 7 - src/DOM/DomGlobal.res | 2 +- src/DOM/DomTypes.res | 226 ++---------------- src/DOM/Element.res | 2 +- src/DOMException/DOMException.res | 21 ++ src/{DOM => DOMStringList}/DOMStringList.res | 13 +- .../FileAndDirectoryEntriesTypes.res | 2 +- src/FileList/FileList.res | 14 +- src/Geometry/DOMMatrix.res | 141 ++++------- src/Geometry/DOMMatrixReadOnly.res | 81 +++---- src/Geometry/DOMPoint.res | 23 +- src/Geometry/DOMPointReadOnly.res | 19 +- src/Geometry/DOMRect.res | 18 +- src/Geometry/DOMRectList.res | 4 +- src/Geometry/DOMRectReadOnly.res | 18 +- src/Geometry/GeometryTypes.res | 100 ++++++++ src/IndexedDB/IndexedDbTypes.res | 10 +- src/Location/Location.res | 75 +++++- src/ScreenOrientation/ScreenOrientation.res | 27 ++- src/WebAudio/WebAudioTypes.res | 2 +- src/WebVTT/TextTrackList.res | 10 +- src/Window/Window.res | 2 +- 28 files changed, 496 insertions(+), 596 deletions(-) delete mode 100644 src/DOM/DOMException.res create mode 100644 src/DOMException/DOMException.res rename src/{DOM => DOMStringList}/DOMStringList.res (51%) create mode 100644 src/Geometry/GeometryTypes.res diff --git a/rescript.json b/rescript.json index ba03b31..3d07b12 100644 --- a/rescript.json +++ b/rescript.json @@ -1,15 +1,24 @@ { "name": "@rescript/webapi", "features": { + "WebAPI.Base": ["WebAPI.Location"], "WebAPI.DOM": [ "WebAPI.Base", "WebAPI.CSSFontLoading", "WebAPI.ChannelMessaging", + "WebAPI.CSSTypedOM", + "WebAPI.DOMException", + "WebAPI.DOMStringList", "WebAPI.Event", "WebAPI.File", "WebAPI.FileAndDirectoryEntries", + "WebAPI.FileList", + "WebAPI.Geometry", "WebAPI.IdleDeadline", + "WebAPI.Location", "WebAPI.RemotePlayback", + "WebAPI.ScreenOrientation", + "WebAPI.VTT", "WebAPI.ViewTransitions", "WebAPI.VisualViewport" ], @@ -21,13 +30,21 @@ "WebAPI.MediaCaptureAndStreams" ], "WebAPI.CSSOM": ["WebAPI.DOM", "WebAPI.Event"], - "WebAPI.CSSTypedOM": ["WebAPI.DOM"], "WebAPI.CustomElements": ["WebAPI.DOM"], "WebAPI.Event": ["WebAPI.Base"], "WebAPI.Fetch": ["WebAPI.Event", "WebAPI.File", "WebAPI.URL"], "WebAPI.File": ["WebAPI.Base", "WebAPI.Event"], - "WebAPI.FileList": ["WebAPI.DOM", "WebAPI.File"], - "WebAPI.Geometry": ["WebAPI.DOM"], + "WebAPI.FileAndDirectoryEntries": [ + "WebAPI.Base", + "WebAPI.DOMException" + ], + "WebAPI.FileList": ["WebAPI.File"], + "WebAPI.IndexedDB": [ + "WebAPI.DOMException", + "WebAPI.DOMStringList", + "WebAPI.Event" + ], + "WebAPI.Location": ["WebAPI.DOMStringList"], "WebAPI.HTML": ["WebAPI.DOM", "WebAPI.PictureInPicture", "WebAPI.VTT"], "WebAPI.Navigator": [ "WebAPI.Base", @@ -38,11 +55,12 @@ "WebAPI.URL", "WebAPI.MIDI" ], - "WebAPI.ScreenOrientation": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.ScreenOrientation": ["WebAPI.Event"], "WebAPI.SVG": ["WebAPI.DOM", "WebAPI.Geometry"], "WebAPI.Animations": ["WebAPI.DOM", "WebAPI.Event"], "WebAPI.Audio": [ "WebAPI.ChannelMessaging", + "WebAPI.DOMException", "WebAPI.DOM", "WebAPI.Event", "WebAPI.HTML", @@ -58,7 +76,7 @@ "WebAPI.Speech": ["WebAPI.Event"], "WebAPI.Storage": ["WebAPI.Event"], "WebAPI.StorageManager": ["WebAPI.File"], - "WebAPI.VTT": ["WebAPI.DOM", "WebAPI.Event"], + "WebAPI.VTT": ["WebAPI.Event"], "WebAPI.Workers": [ "WebAPI.ChannelMessaging", "WebAPI.Event", @@ -140,9 +158,7 @@ "CharacterData", "Comment", "DOM", - "DOMException", "DOMImplementation", - "DOMStringList", "DOMTokenList", "Document", "DocumentFragment", @@ -159,6 +175,18 @@ "TreeWalker" ] }, + { + "dir": "src/DOMException", + "subdirs": true, + "feature": "WebAPI.DOMException", + "public": ["DOMException"] + }, + { + "dir": "src/DOMStringList", + "subdirs": true, + "feature": "WebAPI.DOMStringList", + "public": ["DOMStringList"] + }, { "dir": "src/CSSOM", "subdirs": true, diff --git a/src/Base/Base__Document.res b/src/Base/Base__Document.res index e170764..9384ca8 100644 --- a/src/Base/Base__Document.res +++ b/src/Base/Base__Document.res @@ -6,13 +6,6 @@ type nodeList<'tNode> type domImplementation type documentType type element = Base__Element.element -type domStringList = { - /** - Returns the number of strings in strings. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringList/length) - */ - length: int, -} /** The location (WebApiURL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively. @@ -20,74 +13,7 @@ The location (WebApiURL) of the object it is linked to. Changes done on it are r TODO: mark as private once mutating fields of private records is allowed */ @editor.completeFrom(Location) -type location = { - /** - Returns the Location object's URL. - -Can be set, to navigate to the given URL. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/href) - */ - mutable href: string, - /** - Returns the Location object's WebApiURL's origin. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/origin) - */ - origin: string, - /** - Returns the Location object's WebApiURL's scheme. - -Can be set, to navigate to the same WebApiURL with a changed scheme. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/protocol) - */ - mutable protocol: string, - /** - Returns the Location object's WebApiURL's host and port (if different from the default port for the scheme). - -Can be set, to navigate to the same WebApiURL with a changed host and port. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/host) - */ - mutable host: string, - /** - Returns the Location object's WebApiURL's host. - -Can be set, to navigate to the same WebApiURL with a changed host. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hostname) - */ - mutable hostname: string, - /** - Returns the Location object's WebApiURL's port. - -Can be set, to navigate to the same WebApiURL with a changed port. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/port) - */ - mutable port: string, - /** - Returns the Location object's WebApiURL's path. - -Can be set, to navigate to the same WebApiURL with a changed path. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/pathname) - */ - mutable pathname: string, - /** - Returns the Location object's WebApiURL's query (includes leading "?" if non-empty). - -Can be set, to navigate to the same WebApiURL with a changed query (ignores leading "?"). - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/search) - */ - mutable search: string, - /** - Returns the Location object's WebApiURL's fragment (includes leading "#" if non-empty). - -Can be set, to navigate to the same WebApiURL with a changed fragment (ignores leading "#"). - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/hash) - */ - mutable hash: string, - /** - Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context. - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/ancestorOrigins) - */ - ancestorOrigins: domStringList, -} +type location = Location.t type documentReadyState type htmlHeadElement type htmlCollection<'t> diff --git a/src/CSSTypedOM/CSSStyleValue.res b/src/CSSTypedOM/CSSStyleValue.res index b2b1c4c..501564d 100644 --- a/src/CSSTypedOM/CSSStyleValue.res +++ b/src/CSSTypedOM/CSSStyleValue.res @@ -1,12 +1,14 @@ +@editor.completeFrom(CSSStyleValue) +type t = private {} + /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleValue/parse_static) */ @scope("CSSStyleValue") -external parse: (~property: string, ~cssText: string) => DomTypes.cssStyleValue = "parse" +external parse: (~property: string, ~cssText: string) => t = "parse" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleValue/parseAll_static) */ @scope("CSSStyleValue") -external parseAll: (~property: string, ~cssText: string) => array = - "parseAll" +external parseAll: (~property: string, ~cssText: string) => array = "parseAll" diff --git a/src/CSSTypedOM/StylePropertyMap.res b/src/CSSTypedOM/StylePropertyMap.res index b838610..b95f4bb 100644 --- a/src/CSSTypedOM/StylePropertyMap.res +++ b/src/CSSTypedOM/StylePropertyMap.res @@ -1,57 +1,53 @@ -external asStylePropertyMapReadOnly: DomTypes.stylePropertyMap => DomTypes.stylePropertyMapReadOnly = - "%identity" +@editor.completeFrom(StylePropertyMap) +type t = private { + ...StylePropertyMapReadOnly.t, +} + +external asStylePropertyMapReadOnly: t => StylePropertyMapReadOnly.t = "%identity" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/getAll) */ @send -external getAll: (DomTypes.stylePropertyMap, string) => array = "getAll" +external getAll: (t, string) => array = "getAll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/has) */ @send -external has: (DomTypes.stylePropertyMap, string) => bool = "has" +external has: (t, string) => bool = "has" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/set) */ @send -external set: ( - DomTypes.stylePropertyMap, - ~property: string, - ~values: DomTypes.cssStyleValue, -) => unit = "set" +external set: (t, ~property: string, ~values: CSSStyleValue.t) => unit = "set" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/set) */ @send -external set2: (DomTypes.stylePropertyMap, ~property: string, ~values: string) => unit = "set" +external set2: (t, ~property: string, ~values: string) => unit = "set" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/append) */ @send -external append: ( - DomTypes.stylePropertyMap, - ~property: string, - ~values: DomTypes.cssStyleValue, -) => unit = "append" +external append: (t, ~property: string, ~values: CSSStyleValue.t) => unit = "append" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/append) */ @send -external append2: (DomTypes.stylePropertyMap, ~property: string, ~values: string) => unit = "append" +external append2: (t, ~property: string, ~values: string) => unit = "append" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/delete) */ @send -external delete: (DomTypes.stylePropertyMap, string) => unit = "delete" +external delete: (t, string) => unit = "delete" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/clear) */ @send -external clear: DomTypes.stylePropertyMap => unit = "clear" +external clear: t => unit = "clear" diff --git a/src/CSSTypedOM/StylePropertyMapReadOnly.res b/src/CSSTypedOM/StylePropertyMapReadOnly.res index d53efc4..b35a136 100644 --- a/src/CSSTypedOM/StylePropertyMapReadOnly.res +++ b/src/CSSTypedOM/StylePropertyMapReadOnly.res @@ -1,12 +1,16 @@ +@editor.completeFrom(StylePropertyMapReadOnly) +type t = private { + size: int, +} + /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/getAll) */ @send -external getAll: (DomTypes.stylePropertyMapReadOnly, string) => array = - "getAll" +external getAll: (t, string) => array = "getAll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/has) */ @send -external has: (DomTypes.stylePropertyMapReadOnly, string) => bool = "has" +external has: (t, string) => bool = "has" diff --git a/src/DOM/DOM.res b/src/DOM/DOM.res index c06405b..63101df 100644 --- a/src/DOM/DOM.res +++ b/src/DOM/DOM.res @@ -1,25 +1,12 @@ @@warning("-30") -/** -An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. -[See DOMException on MDN](https://developer.mozilla.org/docs/Web/API/DOMException) -*/ -type domException = { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMException/name) - */ - name: string, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMException/message) - */ - message: string, -} +type domException = DOMException.t /** A type returned by some APIs which contains a list of DOMString (strings). [See DOMStringList on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringList) */ -type domStringList = Base__Document.domStringList +type domStringList = DOMStringList.t type window @@ -44,11 +31,7 @@ type documentVisibilityState = | @as("hidden") Hidden | @as("visible") Visible -type orientationType = - | @as("landscape-primary") LandscapePrimary - | @as("landscape-secondary") LandscapeSecondary - | @as("portrait-primary") PortraitPrimary - | @as("portrait-secondary") PortraitSecondary +type orientationType = ScreenOrientation.orientationType type insertPosition = | @as("afterbegin") Afterbegin @@ -198,7 +181,7 @@ The location (WebApiURL) of the object it is linked to. Changes done on it are r TODO: mark as private once mutating fields of private records is allowed */ @editor.completeFrom(Location) -type location = Base__Document.location +type location = Location.t // TODO: mark as private once mutating fields of private records is allowed @editor.completeFrom(DOM.DOMTokenList) @@ -254,18 +237,7 @@ type barProp = { [See ScreenOrientation on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation) */ @editor.completeFrom(DOM.ScreenOrientation) -type screenOrientation = private { - ...BaseEvent.eventTarget, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/type) - */ - @as("type") - type_: orientationType, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/angle) - */ - angle: int, -} +type screenOrientation = ScreenOrientation.t /** A screen, usually the one on which the current window is being rendered, and is obtained using window.screen. @@ -354,20 +326,13 @@ type mediaList = { [See StylePropertyMapReadOnly on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly) */ @editor.completeFrom(DOM.StylePropertyMapReadOnly) -type stylePropertyMapReadOnly = private { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/size) - */ - size: int, -} +type stylePropertyMapReadOnly = StylePropertyMapReadOnly.t /** [See StylePropertyMap on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap) */ @editor.completeFrom(DOM.StylePropertyMap) -type stylePropertyMap = private { - ...stylePropertyMapReadOnly, -} +type stylePropertyMap = StylePropertyMap.t /** Used by the dataset HTML attribute to represent data for custom attributes added to elements. @@ -5694,50 +5659,15 @@ TODO: mark as private once mutating fields of private records is allowed [See DOMRectReadOnly on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly) */ @editor.completeFrom(DOM.DOMRectReadOnly) -type domRectReadOnly = private { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/x) - */ - x: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/y) - */ - y: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/width) - */ - width: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/height) - */ - height: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/top) - */ - top: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/right) - */ - right: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/bottom) - */ - bottom: float, - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/left) - */ - left: float, -} +type domRectReadOnly = DOMRectReadOnly.t /** [See DOMRect on MDN](https://developer.mozilla.org/docs/Web/API/DOMRect) */ @editor.completeFrom(DOM.DOMRect) -type domRect = private { - ...domRectReadOnly, -} +type domRect = DOMRect.t -@editor.completeFrom(DOM.DOMRectList) type domRectList = private {} +@editor.completeFrom(DOM.DOMRectList) type domRectList = DOMRectList.t /** The validity states that an element can be in, with respect to constraint validation. Together, they help explain why an element's value fails to validate, if it's not valid. @@ -6235,19 +6165,14 @@ type mediaQueryList = private { [See CSSStyleValue on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleValue) */ @editor.completeFrom(DOM.CSSStyleValue) -type cssStyleValue = private {} +type cssStyleValue = CSSStyleValue.t /** An object of this type is returned by the files property of the HTML element; this lets you access the list of files selected with the element. It's also used for a list of files dropped into web content when using the drag and drop API; see the DataTransfer object for details on this usage. [See FileList on MDN](https://developer.mozilla.org/docs/Web/API/FileList) */ @editor.completeFrom(DOM.FileList) -type fileList = private { - /** - [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FileList/length) - */ - length: int, -} +type fileList = FileList.t /** An error which occurred while handling media in an HTML media element based on HTMLMediaElement, such as