diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94e45d27..a67c7054 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,23 +56,62 @@ jobs: id: vars run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Update version to - - run: npm version --no-git-tag-version "${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }}" - - - name: Package npm project - run: npm pack + - name: Update workspace versions to - + env: + PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }} + run: | + node <<'NODE' + const fs = require("node:fs"); + const path = require("node:path"); + + const packagesDir = path.join(process.cwd(), "packages"); + const version = process.env.PACKAGE_VERSION; + const packages = fs + .readdirSync(packagesDir) + .filter((dir) => fs.existsSync(path.join(packagesDir, dir, "package.json"))) + .map((dir) => { + const packageJsonPath = path.join(packagesDir, dir, "package.json"); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); + return { packageJsonPath, packageJson }; + }); + const workspaceNames = new Set(packages.map(({ packageJson }) => packageJson.name)); + + for (const { packageJsonPath, packageJson } of packages) { + packageJson.version = version; + + for (const field of ["dependencies", "peerDependencies", "devDependencies"]) { + if (!packageJson[field]) continue; + + for (const dependencyName of Object.keys(packageJson[field])) { + if (workspaceNames.has(dependencyName)) { + packageJson[field][dependencyName] = version; + } + } + } + + fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`); + } + NODE + + - name: Package npm workspaces + run: npm pack --workspaces - name: Upload npm package artifact uses: actions/upload-artifact@v7 with: - name: npm-package + name: npm-packages path: "*.tgz" - - name: Publish to npm + - name: Publish npm packages if: github.ref == 'refs/heads/main' && github.event_name == 'push' env: NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} - run: npm publish --access public ./*.tgz --tag experimental + run: | + for package in packages/*; do + if [ -f "$package/package.json" ]; then + npm publish --workspace "$package" --access public --tag experimental + fi + done deploy-docs: needs: build diff --git a/.gitignore b/.gitignore index f4fca422..80164aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,12 @@ dist/ tmp/ docs/public/llm.txt *~ + +**/lib/bs/ +**/lib/ocaml + +.DS_Store + +rescript.lock + +**/*.res.js \ No newline at end of file diff --git a/docs/llm.js b/docs/llm.js index 582db230..b84eb524 100644 --- a/docs/llm.js +++ b/docs/llm.js @@ -32,8 +32,11 @@ async function getDocJson(filePath) { async function processFile(filePath) { const json = await getDocJson(filePath); - - const moduleName = "WebAPI." + json.name.replace("-WebAPI", ""); + const relativePath = path.relative(path.join(import.meta.dirname, ".."), filePath); + const parts = relativePath.split(path.sep); + const packageName = parts[1]; + const leafName = path.basename(filePath, ".res"); + const moduleName = leafName === "Types" ? packageName : `${packageName}.${leafName}`; const types = []; const functions = []; @@ -89,12 +92,12 @@ async function processFile(filePath) { functionString = "\n\nFunctions:\n\n" + functions.join("\n\n"); } - return `File: ${json.source.filepath} + return `WebApiFile: ${json.source.filepath} Module: ${moduleName}${typeString}${functionString} `; } -const pattern = "../src/**/*.res"; +const pattern = "../packages/*/src/**/*.res"; const files = []; for await (const file of fs.glob(pattern, { recursive: true, cwd: import.meta.dirname })) { files.push(path.join(import.meta.dirname, file)); diff --git a/docs/utils.js b/docs/utils.js index ed3711ad..9209d5c6 100644 --- a/docs/utils.js +++ b/docs/utils.js @@ -24,7 +24,7 @@ export function createTypeModuleLink(parentModuleLink, typeName) { } function mapTypeModules(parentModuleLink, file) { - const folder = file.replace(".res", ""); + const folder = path.dirname(file); if (!existsSync(folder)) { return []; @@ -32,11 +32,11 @@ function mapTypeModules(parentModuleLink, file) { const files = readdirSync(folder); return files - .filter((f) => f.endsWith(".res")) + .filter((f) => f.endsWith(".res") && f !== "Types.res") .map((file) => { const filePath = path.join(folder, file); - const moduleName = file.replace("$", "").replace(folder, "").replace(".res", ""); + const moduleName = file.replace("$", "").replace(".res", ""); const apiRouteParameter = toKebabCase(moduleName); const link = createTypeModuleLink(parentModuleLink, moduleName); const typeName = moduleName[0].toLocaleLowerCase() + moduleName.slice(1); @@ -54,8 +54,8 @@ function mapTypeModules(parentModuleLink, file) { } function mapRescriptFile(srcDir, file) { - const moduleName = path.basename(file, ".res").replace("$", ""); const filePath = path.join(srcDir, file); + const moduleName = path.basename(path.dirname(srcDir)).replace("$", ""); const link = createAPIModuleLink(moduleName); const items = Object.fromEntries(mapTypeModules(link, filePath)); @@ -68,10 +68,13 @@ function mapRescriptFile(srcDir, file) { }; } -const srcDir = path.resolve(process.cwd(), "src"); -export const apiModules = readdirSync(srcDir) - .filter((f) => f.endsWith(".res")) - .map((r) => mapRescriptFile(srcDir, r)); +const packagesDir = path.resolve(process.cwd(), "packages"); +export const apiModules = readdirSync(packagesDir, { withFileTypes: true }) + .filter((entry) => entry.isDirectory()) + .map((entry) => path.join(packagesDir, entry.name, "src")) + .filter((srcDir) => existsSync(path.join(srcDir, "Types.res"))) + .map((srcDir) => mapRescriptFile(srcDir, "Types.res")) + .sort((a, b) => a.moduleName.localeCompare(b.moduleName)); async function getRescriptDoc(absoluteFilePath) { const { stdout, stderr } = await execAsync(`rescript-tools doc ${absoluteFilePath}`, { @@ -149,11 +152,11 @@ export const testFiles = readdirSync(testDir, { recursive: true }) .map((tf) => { const sourcePath = path.join(testDir, tf); const source = readFileSync(sourcePath, "utf-8"); - const outputPath = sourcePath.replace(".res", ".js"); + const outputPath = sourcePath.replace(".res", ".res.js"); const output = readFileSync(outputPath, "utf-8"); const parts = tf.split(path.sep); - const name = parts[parts.length - 1].replace("__tests.res", ""); + const name = parts[parts.length - 1].replace(".res", ""); return { sourcePath: sourcePath.replace(testDir, ""), diff --git a/package-lock.json b/package-lock.json index 5e779246..653abaa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,16 @@ { - "name": "@rescript/webapi", + "name": "experimental-rescript-webapi", "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@rescript/webapi", + "name": "experimental-rescript-webapi", "version": "0.1.0", "license": "MIT", + "workspaces": [ + "packages/*" + ], "devDependencies": { "@astrojs/starlight": "0.37.7", "astro": "^5.10.1", @@ -1618,7 +1621,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -1634,7 +1636,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -1650,7 +1651,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -1666,7 +1666,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -1678,8 +1677,183 @@ "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 + "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==" + }, + "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-prelude": { + "resolved": "packages/Prelude", + "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/win32-x64": { "version": "12.2.0", @@ -1688,7 +1862,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "win32" @@ -6503,7 +6676,6 @@ "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" }, @@ -7492,165 +7664,692 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } - } - }, - "dependencies": { - "@astrojs/compiler": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz", - "integrity": "sha512-mqVORhUJViA28fwHYaWmsXSzLO9osbdZ5ImUfxBarqsYdMlPbqAqGJCxsNzvppp1BEzc1mJNjOVvQqeDN8Vspw==", - "dev": true }, - "@astrojs/internal-helpers": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.6.1.tgz", - "integrity": "sha512-l5Pqf6uZu31aG+3Lv8nl/3s4DbUzdlxTWDof4pEpto6GUJNhhCbelVi9dEyurOVyqaelwmS9oSyOWOENSfgo9A==", - "dev": true + "packages/Canvas": { + "name": "@rescript/webapi-canvas", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } }, - "@astrojs/markdown-remark": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-6.3.1.tgz", - "integrity": "sha512-c5F5gGrkczUaTVgmMW9g1YMJGzOtRvjjhw6IfGuxarM6ct09MpwysP10US729dy07gg8y+ofVifezvP3BNsWZg==", - "dev": true, - "requires": { - "@astrojs/internal-helpers": "0.6.1", - "@astrojs/prism": "3.2.0", - "github-slugger": "^2.0.0", - "hast-util-from-html": "^2.0.3", - "hast-util-to-text": "^4.0.2", - "import-meta-resolve": "^4.1.0", - "js-yaml": "^4.1.0", - "mdast-util-definitions": "^6.0.0", - "rehype-raw": "^7.0.0", - "rehype-stringify": "^10.0.1", - "remark-gfm": "^4.0.1", - "remark-parse": "^11.0.0", - "remark-rehype": "^11.1.1", - "remark-smartypants": "^3.0.2", - "shiki": "^3.0.0", - "smol-toml": "^1.3.1", - "unified": "^11.0.5", - "unist-util-remove-position": "^5.0.0", - "unist-util-visit": "^5.0.0", - "unist-util-visit-parents": "^6.0.1", - "vfile": "^6.0.3" + "packages/ChannelMessaging": { + "name": "@rescript/webapi-channel-messaging", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@astrojs/mdx": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/@astrojs/mdx/-/mdx-4.2.4.tgz", - "integrity": "sha512-c832AWpiMCcuPY8j+yr5T+hOf8n5RlKLFHlNTt15xxkOk3zjFJP81TIYKrMrbhD5rMzJ09Ixi+xM0m68w2Q0DQ==", - "dev": true, - "requires": { - "@astrojs/markdown-remark": "6.3.1", - "@mdx-js/mdx": "^3.1.0", - "acorn": "^8.14.1", - "es-module-lexer": "^1.6.0", - "estree-util-visit": "^2.0.0", - "hast-util-to-html": "^9.0.5", - "kleur": "^4.1.5", - "rehype-raw": "^7.0.0", - "remark-gfm": "^4.0.1", - "remark-smartypants": "^3.0.2", - "source-map": "^0.7.4", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.3" + "packages/Clipboard": { + "name": "@rescript/webapi-clipboard", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-file": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@astrojs/prism": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.2.0.tgz", - "integrity": "sha512-GilTHKGCW6HMq7y3BUv9Ac7GMe/MO9gi9GW62GzKtth0SwukCu/qp2wLiGpEujhY+VVhaG9v7kv/5vFzvf4NYw==", - "dev": true, - "requires": { - "prismjs": "^1.29.0" + "packages/CredentialManagement": { + "name": "@rescript/webapi-credential-management", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@astrojs/sitemap": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.3.0.tgz", - "integrity": "sha512-nYE4lKQtk+Kbrw/w0G0TTgT724co0jUsU4tPlHY9au5HmTBKbwiCLwO/15b1/y13aZ4Kr9ZbMeMHlXuwn0ty4Q==", - "dev": true, - "requires": { - "sitemap": "^8.0.0", - "stream-replace-string": "^2.0.0", - "zod": "^3.24.2" + "packages/CSSFontLoading": { + "name": "@rescript/webapi-css-font-loading", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@astrojs/starlight": { - "version": "0.37.7", - "resolved": "https://registry.npmjs.org/@astrojs/starlight/-/starlight-0.37.7.tgz", - "integrity": "sha512-KyBnou8aKIlPJUSNx6a1SN7XyH22oj/VAvTGC+Edld4Bnei1A//pmCRTBvSrSeoGrdUjK0ErFUfaEhhO1bPfDg==", - "dev": true, - "requires": { - "@astrojs/markdown-remark": "^6.3.1", - "@astrojs/mdx": "^4.2.3", - "@astrojs/sitemap": "^3.3.0", - "@pagefind/default-ui": "^1.3.0", - "@types/hast": "^3.0.4", - "@types/js-yaml": "^4.0.9", - "@types/mdast": "^4.0.4", - "astro-expressive-code": "^0.41.1", - "bcp-47": "^2.1.0", - "hast-util-from-html": "^2.0.1", - "hast-util-select": "^6.0.2", - "hast-util-to-string": "^3.0.0", - "hastscript": "^9.0.0", - "i18next": "^23.11.5", - "js-yaml": "^4.1.0", - "klona": "^2.0.6", - "magic-string": "^0.30.17", - "mdast-util-directive": "^3.0.0", - "mdast-util-to-markdown": "^2.1.0", - "mdast-util-to-string": "^4.0.0", - "pagefind": "^1.3.0", - "rehype": "^13.0.1", - "rehype-format": "^5.0.0", - "remark-directive": "^3.0.0", - "ultrahtml": "^1.6.0", - "unified": "^11.0.5", - "unist-util-visit": "^5.0.0", - "vfile": "^6.0.2" + "packages/DOM": { + "name": "@rescript/webapi-dom", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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-prelude": "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" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@astrojs/telemetry": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.3.0.tgz", - "integrity": "sha512-UFBgfeldP06qu6khs/yY+q1cDAaArM2/7AEIqQ9Cuvf7B1hNLq0xDrZkct+QoIGyjq56y8IaE2I3CTvG99mlhQ==", - "dev": true, - "requires": { - "ci-info": "^4.2.0", - "debug": "^4.4.0", - "dlv": "^1.1.3", - "dset": "^3.1.4", - "is-docker": "^3.0.0", - "is-wsl": "^3.1.0", - "which-pm-runs": "^1.1.0" + "packages/EncryptedMediaExtensions": { + "name": "@rescript/webapi-encrypted-media-extensions", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-dom": "0.1.0", + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", - "dev": true + "packages/Event": { + "name": "@rescript/webapi-event", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-dom": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } }, - "@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", - "dev": true + "packages/Fetch": { + "name": "@rescript/webapi-fetch", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-file": "0.1.0", + "@rescript/webapi-prelude": "0.1.0", + "@rescript/webapi-url": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } }, - "@babel/parser": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", - "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", - "dev": true, - "requires": { - "@babel/types": "^7.28.5" + "packages/File": { + "name": "@rescript/webapi-file", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" } }, - "@babel/runtime": { - "version": "7.27.6", + "packages/FileAndDirectoryEntries": { + "name": "@rescript/webapi-file-and-directory-entries", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Gamepad": { + "name": "@rescript/webapi-gamepad", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Geolocation": { + "name": "@rescript/webapi-geolocation", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/History": { + "name": "@rescript/webapi-history", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/IndexedDB": { + "name": "@rescript/webapi-indexed-db", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/IntersectionObserver": { + "name": "@rescript/webapi-intersection-observer", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-dom": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/MediaCapabilities": { + "name": "@rescript/webapi-media-capabilities", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/MediaCaptureAndStreams": { + "name": "@rescript/webapi-media-capture-and-streams", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/MediaSession": { + "name": "@rescript/webapi-media-session", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/MutationObserver": { + "name": "@rescript/webapi-mutation-observer", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-dom": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Notification": { + "name": "@rescript/webapi-notification", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Performance": { + "name": "@rescript/webapi-performance", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Permissions": { + "name": "@rescript/webapi-permissions", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/PictureInPicture": { + "name": "@rescript/webapi-picture-in-picture", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Prelude": { + "name": "@rescript/webapi-prelude", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Push": { + "name": "@rescript/webapi-push", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/RemotePlayback": { + "name": "@rescript/webapi-remote-playback", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/ResizeObserver": { + "name": "@rescript/webapi-resize-observer", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-dom": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/ScreenWakeLock": { + "name": "@rescript/webapi-screen-wake-lock", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/ServiceWorker": { + "name": "@rescript/webapi-service-worker", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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-prelude": "0.1.0", + "@rescript/webapi-push": "0.1.0", + "@rescript/webapi-web-workers": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/Storage": { + "name": "@rescript/webapi-storage", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-file": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/UIEvents": { + "name": "@rescript/webapi-ui-events", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/URL": { + "name": "@rescript/webapi-url", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/ViewTransitions": { + "name": "@rescript/webapi-view-transitions", + "version": "0.1.0", + "license": "MIT", + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/VisualViewport": { + "name": "@rescript/webapi-visual-viewport", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebAudio": { + "name": "@rescript/webapi-web-audio", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebCrypto": { + "name": "@rescript/webapi-web-crypto", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebLocks": { + "name": "@rescript/webapi-web-locks", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebMIDI": { + "name": "@rescript/webapi-web-midi", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebSockets": { + "name": "@rescript/webapi-web-sockets", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-channel-messaging": "0.1.0", + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-file": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebSpeech": { + "name": "@rescript/webapi-web-speech", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebStorage": { + "name": "@rescript/webapi-web-storage", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebVTT": { + "name": "@rescript/webapi-web-vtt", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@rescript/webapi-event": "0.1.0" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + }, + "packages/WebWorkers": { + "name": "@rescript/webapi-web-workers", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@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" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + } + } + }, + "dependencies": { + "@astrojs/compiler": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.13.0.tgz", + "integrity": "sha512-mqVORhUJViA28fwHYaWmsXSzLO9osbdZ5ImUfxBarqsYdMlPbqAqGJCxsNzvppp1BEzc1mJNjOVvQqeDN8Vspw==", + "dev": true + }, + "@astrojs/internal-helpers": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.6.1.tgz", + "integrity": "sha512-l5Pqf6uZu31aG+3Lv8nl/3s4DbUzdlxTWDof4pEpto6GUJNhhCbelVi9dEyurOVyqaelwmS9oSyOWOENSfgo9A==", + "dev": true + }, + "@astrojs/markdown-remark": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-6.3.1.tgz", + "integrity": "sha512-c5F5gGrkczUaTVgmMW9g1YMJGzOtRvjjhw6IfGuxarM6ct09MpwysP10US729dy07gg8y+ofVifezvP3BNsWZg==", + "dev": true, + "requires": { + "@astrojs/internal-helpers": "0.6.1", + "@astrojs/prism": "3.2.0", + "github-slugger": "^2.0.0", + "hast-util-from-html": "^2.0.3", + "hast-util-to-text": "^4.0.2", + "import-meta-resolve": "^4.1.0", + "js-yaml": "^4.1.0", + "mdast-util-definitions": "^6.0.0", + "rehype-raw": "^7.0.0", + "rehype-stringify": "^10.0.1", + "remark-gfm": "^4.0.1", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.1.1", + "remark-smartypants": "^3.0.2", + "shiki": "^3.0.0", + "smol-toml": "^1.3.1", + "unified": "^11.0.5", + "unist-util-remove-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "unist-util-visit-parents": "^6.0.1", + "vfile": "^6.0.3" + } + }, + "@astrojs/mdx": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/@astrojs/mdx/-/mdx-4.2.4.tgz", + "integrity": "sha512-c832AWpiMCcuPY8j+yr5T+hOf8n5RlKLFHlNTt15xxkOk3zjFJP81TIYKrMrbhD5rMzJ09Ixi+xM0m68w2Q0DQ==", + "dev": true, + "requires": { + "@astrojs/markdown-remark": "6.3.1", + "@mdx-js/mdx": "^3.1.0", + "acorn": "^8.14.1", + "es-module-lexer": "^1.6.0", + "estree-util-visit": "^2.0.0", + "hast-util-to-html": "^9.0.5", + "kleur": "^4.1.5", + "rehype-raw": "^7.0.0", + "remark-gfm": "^4.0.1", + "remark-smartypants": "^3.0.2", + "source-map": "^0.7.4", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.3" + } + }, + "@astrojs/prism": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.2.0.tgz", + "integrity": "sha512-GilTHKGCW6HMq7y3BUv9Ac7GMe/MO9gi9GW62GzKtth0SwukCu/qp2wLiGpEujhY+VVhaG9v7kv/5vFzvf4NYw==", + "dev": true, + "requires": { + "prismjs": "^1.29.0" + } + }, + "@astrojs/sitemap": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.3.0.tgz", + "integrity": "sha512-nYE4lKQtk+Kbrw/w0G0TTgT724co0jUsU4tPlHY9au5HmTBKbwiCLwO/15b1/y13aZ4Kr9ZbMeMHlXuwn0ty4Q==", + "dev": true, + "requires": { + "sitemap": "^8.0.0", + "stream-replace-string": "^2.0.0", + "zod": "^3.24.2" + } + }, + "@astrojs/starlight": { + "version": "0.37.7", + "resolved": "https://registry.npmjs.org/@astrojs/starlight/-/starlight-0.37.7.tgz", + "integrity": "sha512-KyBnou8aKIlPJUSNx6a1SN7XyH22oj/VAvTGC+Edld4Bnei1A//pmCRTBvSrSeoGrdUjK0ErFUfaEhhO1bPfDg==", + "dev": true, + "requires": { + "@astrojs/markdown-remark": "^6.3.1", + "@astrojs/mdx": "^4.2.3", + "@astrojs/sitemap": "^3.3.0", + "@pagefind/default-ui": "^1.3.0", + "@types/hast": "^3.0.4", + "@types/js-yaml": "^4.0.9", + "@types/mdast": "^4.0.4", + "astro-expressive-code": "^0.41.1", + "bcp-47": "^2.1.0", + "hast-util-from-html": "^2.0.1", + "hast-util-select": "^6.0.2", + "hast-util-to-string": "^3.0.0", + "hastscript": "^9.0.0", + "i18next": "^23.11.5", + "js-yaml": "^4.1.0", + "klona": "^2.0.6", + "magic-string": "^0.30.17", + "mdast-util-directive": "^3.0.0", + "mdast-util-to-markdown": "^2.1.0", + "mdast-util-to-string": "^4.0.0", + "pagefind": "^1.3.0", + "rehype": "^13.0.1", + "rehype-format": "^5.0.0", + "remark-directive": "^3.0.0", + "ultrahtml": "^1.6.0", + "unified": "^11.0.5", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.2" + } + }, + "@astrojs/telemetry": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@astrojs/telemetry/-/telemetry-3.3.0.tgz", + "integrity": "sha512-UFBgfeldP06qu6khs/yY+q1cDAaArM2/7AEIqQ9Cuvf7B1hNLq0xDrZkct+QoIGyjq56y8IaE2I3CTvG99mlhQ==", + "dev": true, + "requires": { + "ci-info": "^4.2.0", + "debug": "^4.4.0", + "dlv": "^1.1.3", + "dset": "^3.1.4", + "is-docker": "^3.0.0", + "is-wsl": "^3.1.0", + "which-pm-runs": "^1.1.0" + } + }, + "@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true + }, + "@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true + }, + "@babel/parser": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", + "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", + "dev": true, + "requires": { + "@babel/types": "^7.28.5" + } + }, + "@babel/runtime": { + "version": "7.27.6", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz", "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==", "dev": true @@ -8340,41 +9039,349 @@ "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==", - "dev": true + "integrity": "sha512-NwfljDRq1rjFPHUaca1nzFz13xsa9ZGkBkLvMhvVgavJT5+A4rMcLu8XAaVTi/oAhO/tlHf9ZDoOTF1AfyAk9Q==" + }, + "@rescript/webapi-canvas": { + "version": "file:packages/Canvas", + "requires": { + "@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-prelude": "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-event": "0.1.0", + "@rescript/webapi-prelude": "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-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-prelude": "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-dom": "0.1.0", + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "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-event": "0.1.0", + "@rescript/webapi-file": "0.1.0", + "@rescript/webapi-prelude": "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-prelude": "0.1.0" + } + }, + "@rescript/webapi-gamepad": { + "version": "file:packages/Gamepad", + "requires": { + "@rescript/webapi-prelude": "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-event": "0.1.0", + "@rescript/webapi-prelude": "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-prelude": { + "version": "file:packages/Prelude", + "requires": {} + }, + "@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-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-prelude": "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-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-prelude": "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-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-prelude": "0.1.0" + } + }, + "@rescript/webapi-web-crypto": { + "version": "file:packages/WebCrypto", + "requires": { + "@rescript/webapi-prelude": "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-event": "0.1.0", + "@rescript/webapi-prelude": "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/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": { @@ -11625,7 +12632,6 @@ "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", diff --git a/package.json b/package.json index 9ef9cb43..d3c8d46e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { - "name": "@rescript/webapi", + "name": "experimental-rescript-webapi", "version": "0.1.0", + "private": true, "description": "Experimental successor to [rescript-webapi](https://github.com/TheSpyder/rescript-webapi)", "keywords": [ "dom", @@ -22,9 +23,8 @@ "type": "git", "url": "git+https://github.com/rescript-lang/experimental-rescript-webapi.git" }, - "files": [ - "rescript.json", - "src/**/*.res" + "workspaces": [ + "packages/*" ], "type": "module", "publishConfig": { @@ -34,6 +34,7 @@ "scripts": { "test": "node tests/index.js", "build": "rescript", + "build:packages": "npm run build --workspaces --if-present", "format": "rescript format && oxfmt ./tests/index.js ./package.json ./docs && prettier --write ./docs/pages", "format:check": "rescript format --check && oxfmt ./tests/index.js ./package.json ./docs --check && prettier --check ./docs/pages", "docs": "astro dev", diff --git a/packages/CSSFontLoading/package.json b/packages/CSSFontLoading/package.json new file mode 100644 index 00000000..de31da82 --- /dev/null +++ b/packages/CSSFontLoading/package.json @@ -0,0 +1,23 @@ +{ + "name": "@rescript/webapi-css-font-loading", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@rescript/webapi-event": "0.1.0" + } +} diff --git a/packages/CSSFontLoading/rescript.json b/packages/CSSFontLoading/rescript.json new file mode 100644 index 00000000..2413e429 --- /dev/null +++ b/packages/CSSFontLoading/rescript.json @@ -0,0 +1,19 @@ +{ + "name": "@rescript/webapi-css-font-loading", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-event", + "@rescript/webapi-prelude" + ], + "namespace": "WebApiCSSFontLoading" +} diff --git a/packages/CSSFontLoading/src/FontFace.res b/packages/CSSFontLoading/src/FontFace.res new file mode 100644 index 00000000..d777e109 --- /dev/null +++ b/packages/CSSFontLoading/src/FontFace.res @@ -0,0 +1,35 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) +*/ +@new +external make: ( + ~family: string, + ~source: string, + ~descriptors: Types.fontFaceDescriptors=?, +) => Types.fontFace = "FontFace" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) +*/ +@new +external make2: ( + ~family: string, + ~source: DataView.t, + ~descriptors: Types.fontFaceDescriptors=?, +) => Types.fontFace = "FontFace" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) +*/ +@new +external make3: ( + ~family: string, + ~source: ArrayBuffer.t, + ~descriptors: Types.fontFaceDescriptors=?, +) => Types.fontFace = "FontFace" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/load) +*/ +@send +external load: Types.fontFace => promise = "load" diff --git a/packages/CSSFontLoading/src/FontFaceSet.res b/packages/CSSFontLoading/src/FontFaceSet.res new file mode 100644 index 00000000..a0d32199 --- /dev/null +++ b/packages/CSSFontLoading/src/FontFaceSet.res @@ -0,0 +1,35 @@ +include WebApiEvent.EventTarget.Impl({type t = Types.fontFaceSet}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/add) +*/ +@send +external add: (Types.fontFaceSet, Types.fontFace) => Types.fontFaceSet = "add" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/delete) +*/ +@send +external delete: (Types.fontFaceSet, Types.fontFace) => bool = "delete" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/clear) +*/ +@send +external clear: Types.fontFaceSet => unit = "clear" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/load) +*/ +@send +external load: ( + Types.fontFaceSet, + ~font: string, + ~text: string=?, +) => promise> = "load" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet/check) +*/ +@send +external check: (Types.fontFaceSet, ~font: string, ~text: string=?) => bool = "check" diff --git a/packages/CSSFontLoading/src/Types.res b/packages/CSSFontLoading/src/Types.res new file mode 100644 index 00000000..59b79a27 --- /dev/null +++ b/packages/CSSFontLoading/src/Types.res @@ -0,0 +1,92 @@ +@@warning("-30") + +type fontDisplay = + | @as("auto") Auto + | @as("block") Block + | @as("fallback") Fallback + | @as("optional") Optional + | @as("swap") Swap + +type fontFaceLoadStatus = WebApiPrelude.Types.fontFaceLoadStatus = + | @as("error") Error + | @as("loaded") Loaded + | @as("loading") Loading + | @as("unloaded") Unloaded + +type fontFaceSetLoadStatus = WebApiPrelude.Types.fontFaceSetLoadStatus = + | @as("loaded") Loaded + | @as("loading") Loading + +/** +[See FontFace on MDN](https://developer.mozilla.org/docs/Web/API/FontFace) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(FontFace) +type rec fontFace = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/family) + */ + mutable family: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/style) + */ + mutable style: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/weight) + */ + mutable weight: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/stretch) + */ + mutable stretch: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/unicodeRange) + */ + mutable unicodeRange: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/featureSettings) + */ + mutable featureSettings: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/display) + */ + mutable display: fontDisplay, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/ascentOverride) + */ + mutable ascentOverride: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/descentOverride) + */ + mutable descentOverride: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/lineGapOverride) + */ + mutable lineGapOverride: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/status) + */ + status: fontFaceLoadStatus, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace/loaded) + */ + loaded: promise, +} + +/** +[See FontFaceSet on MDN](https://developer.mozilla.org/docs/Web/API/FontFaceSet) +*/ +@editor.completeFrom(FontFaceSet) +type fontFaceSet = WebApiPrelude.Types.fontFaceSet + +type fontFaceDescriptors = { + mutable style?: string, + mutable weight?: string, + mutable stretch?: string, + mutable unicodeRange?: string, + mutable featureSettings?: string, + mutable display?: fontDisplay, + mutable ascentOverride?: string, + mutable descentOverride?: string, + mutable lineGapOverride?: string, +} diff --git a/packages/Canvas/package.json b/packages/Canvas/package.json new file mode 100644 index 00000000..ef7bdbc8 --- /dev/null +++ b/packages/Canvas/package.json @@ -0,0 +1,27 @@ +{ + "name": "@rescript/webapi-canvas", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@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-prelude": "0.1.0" + } +} diff --git a/packages/Canvas/rescript.json b/packages/Canvas/rescript.json new file mode 100644 index 00000000..a53c2d8a --- /dev/null +++ b/packages/Canvas/rescript.json @@ -0,0 +1,22 @@ +{ + "name": "@rescript/webapi-canvas", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-dom", + "@rescript/webapi-event", + "@rescript/webapi-file", + "@rescript/webapi-media-capture-and-streams", + "@rescript/webapi-prelude" + ], + "namespace": "WebApiCanvas" +} diff --git a/src/CanvasAPI/CanvasGradient.res b/packages/Canvas/src/CanvasGradient.res similarity index 80% rename from src/CanvasAPI/CanvasGradient.res rename to packages/Canvas/src/CanvasGradient.res index 86347e0a..015790d4 100644 --- a/src/CanvasAPI/CanvasGradient.res +++ b/packages/Canvas/src/CanvasGradient.res @@ -1,5 +1,3 @@ -open CanvasAPI - /** Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. @@ -7,6 +5,7 @@ Throws an "IndexSizeError" DOMException if the offset is out of range. Throws a [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasGradient/addColorStop) */ @send -external addColorStop: (canvasGradient, ~offset: float, ~color: string) => unit = "addColorStop" +external addColorStop: (Types.canvasGradient, ~offset: float, ~color: string) => unit = + "addColorStop" let isInstanceOf = (_: 't): bool => %raw(`param instanceof CanvasGradient`) diff --git a/packages/Canvas/src/CanvasPattern.res b/packages/Canvas/src/CanvasPattern.res new file mode 100644 index 00000000..94d1fa46 --- /dev/null +++ b/packages/Canvas/src/CanvasPattern.res @@ -0,0 +1,10 @@ +type domMatrix2DInit = WebApiDOM.Types.domMatrix2DInit + +/** +Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasPattern/setTransform) +*/ +@send +external setTransform: (Types.canvasPattern, ~transform: domMatrix2DInit=?) => unit = "setTransform" + +let isInstanceOf = (_: 't): bool => %raw(`param instanceof CanvasPattern`) diff --git a/packages/Canvas/src/CanvasRenderingContext2D.res b/packages/Canvas/src/CanvasRenderingContext2D.res new file mode 100644 index 00000000..7076540a --- /dev/null +++ b/packages/Canvas/src/CanvasRenderingContext2D.res @@ -0,0 +1,886 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/save) +*/ +@send +external save: WebApiDOM.Types.canvasRenderingContext2D => unit = "save" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/restore) +*/ +@send +external restore: WebApiDOM.Types.canvasRenderingContext2D => unit = "restore" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/reset) +*/ +@send +external reset: WebApiDOM.Types.canvasRenderingContext2D => unit = "reset" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isContextLost) +*/ +@send +external isContextLost: WebApiDOM.Types.canvasRenderingContext2D => bool = "isContextLost" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/scale) +*/ +@send +external scale: (WebApiDOM.Types.canvasRenderingContext2D, ~x: float, ~y: float) => unit = "scale" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rotate) +*/ +@send +external rotate: (WebApiDOM.Types.canvasRenderingContext2D, float) => unit = "rotate" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/translate) +*/ +@send +external translate: (WebApiDOM.Types.canvasRenderingContext2D, ~x: float, ~y: float) => unit = + "translate" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/transform) +*/ +@send +external transform: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~a: float, + ~b: float, + ~c: float, + ~d: float, + ~e: float, + ~f: float, +) => unit = "transform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getTransform) +*/ +@send +external getTransform: WebApiDOM.Types.canvasRenderingContext2D => WebApiDOM.Types.domMatrix = + "getTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setTransform) +*/ +@send +external setTransform: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~a: float, + ~b: float, + ~c: float, + ~d: float, + ~e: float, + ~f: float, +) => unit = "setTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setTransform) +*/ +@send +external setTransform2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~transform: WebApiDOM.Types.domMatrix2DInit=?, +) => unit = "setTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/resetTransform) +*/ +@send +external resetTransform: WebApiDOM.Types.canvasRenderingContext2D => unit = "resetTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createLinearGradient) +*/ +@send +external createLinearGradient: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x0: float, + ~y0: float, + ~x1: float, + ~y1: float, +) => Types.canvasGradient = "createLinearGradient" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createRadialGradient) +*/ +@send +external createRadialGradient: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x0: float, + ~y0: float, + ~r0: float, + ~x1: float, + ~y1: float, + ~r1: float, +) => Types.canvasGradient = "createRadialGradient" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createConicGradient) +*/ +@send +external createConicGradient: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~startAngle: float, + ~x: float, + ~y: float, +) => Types.canvasGradient = "createConicGradient" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlImageElement, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.svgImageElement, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern3: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlVideoElement, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern4: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlCanvasElement, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern5: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.imageBitmap, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern6: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.offscreenCanvas, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createPattern) +*/ +@send +external createPattern7: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.videoFrame, + ~repetition: string, +) => Types.canvasPattern = "createPattern" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clearRect) +*/ +@send +external clearRect: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, +) => unit = "clearRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillRect) +*/ +@send +external fillRect: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, +) => unit = "fillRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeRect) +*/ +@send +external strokeRect: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, +) => unit = "strokeRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/beginPath) +*/ +@send +external beginPath: WebApiDOM.Types.canvasRenderingContext2D => unit = "beginPath" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fill) +*/ +@send +external fill: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~fillRule: Types.canvasFillRule=?, +) => unit = "fill" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fill) +*/ +@send +external fill2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~path: Types.path2D, + ~fillRule: Types.canvasFillRule=?, +) => unit = "fill" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/stroke) +*/ +@send +external stroke: WebApiDOM.Types.canvasRenderingContext2D => unit = "stroke" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/stroke) +*/ +@send +external stroke2: (WebApiDOM.Types.canvasRenderingContext2D, Types.path2D) => unit = "stroke" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clip) +*/ +@send +external clip: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~fillRule: Types.canvasFillRule=?, +) => unit = "clip" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clip) +*/ +@send +external clip2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~path: Types.path2D, + ~fillRule: Types.canvasFillRule=?, +) => unit = "clip" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInPath) +*/ +@send +external isPointInPath: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~fillRule: Types.canvasFillRule=?, +) => bool = "isPointInPath" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInPath) +*/ +@send +external isPointInPath2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~path: Types.path2D, + ~x: float, + ~y: float, + ~fillRule: Types.canvasFillRule=?, +) => bool = "isPointInPath" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInStroke) +*/ +@send +external isPointInStroke: (WebApiDOM.Types.canvasRenderingContext2D, ~x: float, ~y: float) => bool = + "isPointInStroke" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInStroke) +*/ +@send +external isPointInStroke2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~path: Types.path2D, + ~x: float, + ~y: float, +) => bool = "isPointInStroke" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded) +*/ +@send +external drawFocusIfNeeded: ( + WebApiDOM.Types.canvasRenderingContext2D, + WebApiDOM.Types.element, +) => unit = "drawFocusIfNeeded" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded) +*/ +@send +external drawFocusIfNeeded2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~path: Types.path2D, + ~element: WebApiDOM.Types.element, +) => unit = "drawFocusIfNeeded" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillText) +*/ +@send +external fillText: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~text: string, + ~x: float, + ~y: float, + ~maxWidth: float=?, +) => unit = "fillText" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeText) +*/ +@send +external strokeText: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~text: string, + ~x: float, + ~y: float, + ~maxWidth: float=?, +) => unit = "strokeText" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/measureText) +*/ +@send +external measureText: (WebApiDOM.Types.canvasRenderingContext2D, string) => Types.textMetrics = + "measureText" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImage: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlImageElement, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithSvg: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.svgImageElement, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideo: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlVideoElement, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithCanvas: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlCanvasElement, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithImageBitmap: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.imageBitmap, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithOffscreenCanvas: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.offscreenCanvas, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideoFrame: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.videoFrame, + ~dx: float, + ~dy: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlImageElement, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithSvgDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.svgImageElement, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideoDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlVideoElement, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithCanvasDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlCanvasElement, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithImageBitmapDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.imageBitmap, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithOffscreenCanvasDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.offscreenCanvas, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideoFrameDimensions: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.videoFrame, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlImageElement, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithSvgSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.svgImageElement, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideoSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlVideoElement, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithCanvasSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.htmlCanvasElement, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithImageBitmapSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.imageBitmap, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithOffscreenCanvasSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: Types.offscreenCanvas, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/drawImage) +*/ +@send +external drawImageWithVideoFrameSubRectangle: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~image: WebApiDOM.Types.videoFrame, + ~sx: float, + ~sy: float, + ~sw: float, + ~sh: float, + ~dx: float, + ~dy: float, + ~dw: float, + ~dh: float, +) => unit = "drawImage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createImageData) +*/ +@send +external createImageData: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~sw: int, + ~sh: int, + ~settings: WebApiDOM.Types.imageDataSettings=?, +) => WebApiDOM.Types.imageData = "createImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/createImageData) +*/ +@send +external createImageData2: ( + WebApiDOM.Types.canvasRenderingContext2D, + WebApiDOM.Types.imageData, +) => WebApiDOM.Types.imageData = "createImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getImageData) +*/ +@send +external getImageData: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~settings: WebApiDOM.Types.imageDataSettings=?, +) => WebApiDOM.Types.imageData = "getImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/putImageData) +*/ +@send +external putImageData: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~imagedata: WebApiDOM.Types.imageData, + ~dx: int, + ~dy: int, +) => unit = "putImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/putImageData) +*/ +@send +external putImageData2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~imagedata: WebApiDOM.Types.imageData, + ~dx: int, + ~dy: int, + ~dirtyX: int, + ~dirtyY: int, + ~dirtyWidth: int, + ~dirtyHeight: int, +) => unit = "putImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash) +*/ +@send +external setLineDash: (WebApiDOM.Types.canvasRenderingContext2D, array) => unit = + "setLineDash" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getLineDash) +*/ +@send +external getLineDash: WebApiDOM.Types.canvasRenderingContext2D => array = "getLineDash" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/closePath) +*/ +@send +external closePath: WebApiDOM.Types.canvasRenderingContext2D => unit = "closePath" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/moveTo) +*/ +@send +external moveTo: (WebApiDOM.Types.canvasRenderingContext2D, ~x: float, ~y: float) => unit = "moveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineTo) +*/ +@send +external lineTo: (WebApiDOM.Types.canvasRenderingContext2D, ~x: float, ~y: float) => unit = "lineTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo) +*/ +@send +external quadraticCurveTo: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~cpx: float, + ~cpy: float, + ~x: float, + ~y: float, +) => unit = "quadraticCurveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo) +*/ +@send +external bezierCurveTo: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~cp1x: float, + ~cp1y: float, + ~cp2x: float, + ~cp2y: float, + ~x: float, + ~y: float, +) => unit = "bezierCurveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arcTo) +*/ +@send +external arcTo: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x1: float, + ~y1: float, + ~x2: float, + ~y2: float, + ~radius: float, +) => unit = "arcTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rect) +*/ +@send +external rect: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, +) => unit = "rect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect2: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect3: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arc) +*/ +@send +external arc: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~radius: float, + ~startAngle: float, + ~endAngle: float, + ~counterclockwise: bool=?, +) => unit = "arc" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/ellipse) +*/ +@send +external ellipse: ( + WebApiDOM.Types.canvasRenderingContext2D, + ~x: float, + ~y: float, + ~radiusX: float, + ~radiusY: float, + ~rotation: float, + ~startAngle: float, + ~endAngle: float, + ~counterclockwise: bool=?, +) => unit = "ellipse" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/getContextAttributes) +*/ +@send +external getContextAttributes: WebApiDOM.Types.canvasRenderingContext2D => Types.canvasRenderingContext2DSettings = + "getContextAttributes" diff --git a/packages/Canvas/src/FillStyle.res b/packages/Canvas/src/FillStyle.res new file mode 100644 index 00000000..aa5141ed --- /dev/null +++ b/packages/Canvas/src/FillStyle.res @@ -0,0 +1,25 @@ +external fromString: string => Types.fillStyle = "%identity" +external fromCanvasGradient: Types.canvasGradient => Types.fillStyle = "%identity" +external fromCanvasPattern: Types.canvasPattern => Types.fillStyle = "%identity" + +external toString: Types.fillStyle => string = "%identity" +external toCanvasGradient: Types.fillStyle => Types.canvasGradient = "%identity" +external toCanvasPattern: Types.fillStyle => Types.canvasPattern = "%identity" + +/** +Represents a decoded version of the abstract `fillStyle` type, used in Context2D. + */ +type decoded = + | String(string) + | CanvasGradient(Types.canvasGradient) + | CanvasPattern(Types.canvasPattern) + +let decode = (t: Types.fillStyle): decoded => { + if CanvasGradient.isInstanceOf(t) { + CanvasGradient(toCanvasGradient(t)) + } else if CanvasPattern.isInstanceOf(t) { + CanvasPattern(toCanvasPattern(t)) + } else { + String(toString(t)) + } +} diff --git a/packages/Canvas/src/Global.res b/packages/Canvas/src/Global.res new file mode 100644 index 00000000..fe925d53 --- /dev/null +++ b/packages/Canvas/src/Global.res @@ -0,0 +1,179 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap: ( + ~image: WebApiDOM.Types.htmlImageElement, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap2: ( + ~image: WebApiDOM.Types.svgImageElement, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap3: ( + ~image: WebApiDOM.Types.htmlVideoElement, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap4: ( + ~image: WebApiDOM.Types.htmlCanvasElement, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap5: ( + ~image: Types.imageBitmap, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap6: ( + ~image: Types.offscreenCanvas, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap7: ( + ~image: WebApiDOM.Types.videoFrame, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap8: ( + ~image: WebApiFile.Types.blob, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap9: ( + ~image: WebApiDOM.Types.imageData, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap10: ( + ~image: WebApiDOM.Types.htmlImageElement, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap11: ( + ~image: WebApiDOM.Types.svgImageElement, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap12: ( + ~image: WebApiDOM.Types.htmlVideoElement, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap13: ( + ~image: WebApiDOM.Types.htmlCanvasElement, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap14: ( + ~image: Types.imageBitmap, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap15: ( + ~image: Types.offscreenCanvas, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap16: ( + ~image: WebApiDOM.Types.videoFrame, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap17: ( + ~image: WebApiFile.Types.blob, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/createImageBitmap) +*/ +external createImageBitmap18: ( + ~image: WebApiDOM.Types.imageData, + ~sx: int, + ~sy: int, + ~sw: int, + ~sh: int, + ~options: WebApiDOM.Types.imageBitmapOptions=?, +) => promise = "createImageBitmap" diff --git a/src/DOMAPI/HTMLCanvasElement.res b/packages/Canvas/src/HTMLCanvasElement.res similarity index 75% rename from src/DOMAPI/HTMLCanvasElement.res rename to packages/Canvas/src/HTMLCanvasElement.res index d7d7121f..0b7d6cd7 100644 --- a/src/DOMAPI/HTMLCanvasElement.res +++ b/packages/Canvas/src/HTMLCanvasElement.res @@ -1,8 +1,4 @@ -open DOMAPI -open CanvasAPI -open MediaCaptureAndStreamsAPI - -include HTMLElement.Impl({type t = htmlCanvasElement}) +include WebApiDOM.HTMLElement.Impl({type t = WebApiDOM.Types.htmlCanvasElement}) /** Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. @@ -12,10 +8,10 @@ Creates a CanvasRenderingContext2D object representing a two-dimensional renderi */ @send external getContext2D: ( - htmlCanvasElement, + WebApiDOM.Types.htmlCanvasElement, @as("2d") _, - ~options: canvasRenderingContext2DSettings=?, -) => canvasRenderingContext2D = "getContext" + ~options: Types.canvasRenderingContext2DSettings=?, +) => WebApiDOM.Types.canvasRenderingContext2D = "getContext" /** Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. @@ -24,10 +20,10 @@ Returns an object that provides methods and properties for drawing and manipulat */ @send external getContextWebGL: ( - htmlCanvasElement, + WebApiDOM.Types.htmlCanvasElement, @as("webgl") _, - ~options: webGLContextAttributes=?, -) => webGLRenderingContext = "getContext" + ~options: Types.webGLContextAttributes=?, +) => Types.webGLRenderingContext = "getContext" /** Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. @@ -36,10 +32,10 @@ Returns an object that provides methods and properties for drawing and manipulat */ @send external getContextWebGL2: ( - htmlCanvasElement, + WebApiDOM.Types.htmlCanvasElement, @as("webgl2") _, - ~options: webGLContextAttributes=?, -) => webGL2RenderingContext = "getContext" + ~options: Types.webGLContextAttributes=?, +) => Types.webGL2RenderingContext = "getContext" /** Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. @@ -48,10 +44,10 @@ Returns an object that provides methods and properties for drawing and manipulat */ @send external getContextBitmapRenderer: ( - htmlCanvasElement, + WebApiDOM.Types.htmlCanvasElement, @as("bitmaprenderer") _, - ~options: imageBitmapRenderingContextSettings=?, -) => imageBitmapRenderingContext = "getContext" + ~options: Types.imageBitmapRenderingContextSettings=?, +) => Types.imageBitmapRenderingContext = "getContext" /** Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. @@ -59,16 +55,19 @@ Returns the content of the current canvas as an image that you can use as a sour [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/toDataURL) */ @send -external toDataURL: (htmlCanvasElement, ~type_: string=?, ~quality: JSON.t=?) => string = - "toDataURL" +external toDataURL: ( + WebApiDOM.Types.htmlCanvasElement, + ~type_: string=?, + ~quality: JSON.t=?, +) => string = "toDataURL" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/toBlob) */ @send external toBlob: ( - htmlCanvasElement, - ~callback: blobCallback, + WebApiDOM.Types.htmlCanvasElement, + ~callback: WebApiFile.Types.blob => unit, ~type_: string=?, ~quality: JSON.t=?, ) => unit = "toBlob" @@ -77,12 +76,14 @@ external toBlob: ( [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen) */ @send -external transferControlToOffscreen: htmlCanvasElement => offscreenCanvas = +external transferControlToOffscreen: WebApiDOM.Types.htmlCanvasElement => Types.offscreenCanvas = "transferControlToOffscreen" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/captureStream) */ @send -external captureStream: (htmlCanvasElement, ~frameRequestRate: float=?) => mediaStream = - "captureStream" +external captureStream: ( + WebApiDOM.Types.htmlCanvasElement, + ~frameRequestRate: float=?, +) => WebApiMediaCaptureAndStreams.Types.mediaStream = "captureStream" diff --git a/packages/Canvas/src/ImageBitmap.res b/packages/Canvas/src/ImageBitmap.res new file mode 100644 index 00000000..087279dc --- /dev/null +++ b/packages/Canvas/src/ImageBitmap.res @@ -0,0 +1,6 @@ +/** +Releases imageBitmap's underlying bitmap data. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmap/close) +*/ +@send +external close: Types.imageBitmap => unit = "close" diff --git a/packages/Canvas/src/ImageBitmapRenderingContext.res b/packages/Canvas/src/ImageBitmapRenderingContext.res new file mode 100644 index 00000000..85c85f10 --- /dev/null +++ b/packages/Canvas/src/ImageBitmapRenderingContext.res @@ -0,0 +1,7 @@ +/** +Transfers the underlying bitmap data from imageBitmap to context, and the bitmap becomes the contents of the canvas element to which context is bound. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmapRenderingContext/transferFromImageBitmap) +*/ +@send +external transferFromImageBitmap: (Types.imageBitmapRenderingContext, Types.imageBitmap) => unit = + "transferFromImageBitmap" diff --git a/src/CanvasAPI/OffscreenCanvas.res b/packages/Canvas/src/OffscreenCanvas.res similarity index 82% rename from src/CanvasAPI/OffscreenCanvas.res rename to packages/Canvas/src/OffscreenCanvas.res index 83b68802..e7401514 100644 --- a/src/CanvasAPI/OffscreenCanvas.res +++ b/packages/Canvas/src/OffscreenCanvas.res @@ -1,13 +1,10 @@ -open CanvasAPI -open FileAPI - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas) */ @new -external make: (~width: int, ~height: int) => offscreenCanvas = "OffscreenCanvas" +external make: (~width: int, ~height: int) => Types.offscreenCanvas = "OffscreenCanvas" -include EventTarget.Impl({type t = offscreenCanvas}) +include WebApiEvent.EventTarget.Impl({type t = Types.offscreenCanvas}) /** Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. @@ -19,10 +16,10 @@ Returns null if the canvas has already been initialized with another context typ */ @send external getContext2D: ( - offscreenCanvas, + Types.offscreenCanvas, @as("2d") _, ~options: JSON.t=?, -) => offscreenCanvasRenderingContext2D = "getContext" +) => Types.offscreenCanvasRenderingContext2D = "getContext" /** Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. @@ -34,10 +31,10 @@ Returns null if the canvas has already been initialized with another context typ */ @send external getContextWebGL: ( - offscreenCanvas, + Types.offscreenCanvas, @as("webgl") _, - ~options: webGLContextAttributes=?, -) => webGLRenderingContext = "getContext" + ~options: Types.webGLContextAttributes=?, +) => Types.webGLRenderingContext = "getContext" /** Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. @@ -49,10 +46,10 @@ Returns null if the canvas has already been initialized with another context typ */ @send external getContextWebGL2: ( - offscreenCanvas, + Types.offscreenCanvas, @as("webgl2") _, - ~options: webGLContextAttributes=?, -) => webGL2RenderingContext = "getContext" + ~options: Types.webGLContextAttributes=?, +) => Types.webGL2RenderingContext = "getContext" /** Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. @@ -64,17 +61,17 @@ Returns null if the canvas has already been initialized with another context typ */ @send external getContextBitmapRenderer: ( - offscreenCanvas, + Types.offscreenCanvas, @as("bitmaprenderer") _, - ~options: imageBitmapRenderingContextSettings=?, -) => imageBitmapRenderingContext = "getContext" + ~options: Types.imageBitmapRenderingContextSettings=?, +) => Types.imageBitmapRenderingContext = "getContext" /** Returns a newly created ImageBitmap object with the image in the OffscreenCanvas object. The image in the OffscreenCanvas object is replaced with a new blank image. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/transferToImageBitmap) */ @send -external transferToImageBitmap: offscreenCanvas => imageBitmap = "transferToImageBitmap" +external transferToImageBitmap: Types.offscreenCanvas => Types.imageBitmap = "transferToImageBitmap" /** Returns a promise that will fulfill with a new Blob object representing a file containing the image in the OffscreenCanvas object. @@ -83,5 +80,7 @@ The argument, if provided, is a dictionary that controls the encoding options of [Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/convertToBlob) */ @send -external convertToBlob: (offscreenCanvas, ~options: imageEncodeOptions=?) => promise = - "convertToBlob" +external convertToBlob: ( + Types.offscreenCanvas, + ~options: Types.imageEncodeOptions=?, +) => promise = "convertToBlob" diff --git a/packages/Canvas/src/Path2D.res b/packages/Canvas/src/Path2D.res new file mode 100644 index 00000000..663b2453 --- /dev/null +++ b/packages/Canvas/src/Path2D.res @@ -0,0 +1,148 @@ +type domMatrix2DInit = WebApiDOM.Types.domMatrix2DInit + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Path2D) +*/ +@new +external make: (~path: Types.path2D=?) => Types.path2D = "Path2D" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Path2D) +*/ +@new +external make2: (~path: string=?) => Types.path2D = "Path2D" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/closePath) +*/ +@send +external closePath: Types.path2D => unit = "closePath" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/moveTo) +*/ +@send +external moveTo: (Types.path2D, ~x: float, ~y: float) => unit = "moveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineTo) +*/ +@send +external lineTo: (Types.path2D, ~x: float, ~y: float) => unit = "lineTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/quadraticCurveTo) +*/ +@send +external quadraticCurveTo: (Types.path2D, ~cpx: float, ~cpy: float, ~x: float, ~y: float) => unit = + "quadraticCurveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/bezierCurveTo) +*/ +@send +external bezierCurveTo: ( + Types.path2D, + ~cp1x: float, + ~cp1y: float, + ~cp2x: float, + ~cp2y: float, + ~x: float, + ~y: float, +) => unit = "bezierCurveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arcTo) +*/ +@send +external arcTo: ( + Types.path2D, + ~x1: float, + ~y1: float, + ~x2: float, + ~y2: float, + ~radius: float, +) => unit = "arcTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/rect) +*/ +@send +external rect: (Types.path2D, ~x: float, ~y: float, ~w: float, ~h: float) => unit = "rect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect: ( + Types.path2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect2: ( + Types.path2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/roundRect) +*/ +@send +external roundRect3: ( + Types.path2D, + ~x: float, + ~y: float, + ~w: float, + ~h: float, + ~radii_: array=?, +) => unit = "roundRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/arc) +*/ +@send +external arc: ( + Types.path2D, + ~x: float, + ~y: float, + ~radius: float, + ~startAngle: float, + ~endAngle: float, + ~counterclockwise: bool=?, +) => unit = "arc" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/ellipse) +*/ +@send +external ellipse: ( + Types.path2D, + ~x: float, + ~y: float, + ~radiusX: float, + ~radiusY: float, + ~rotation: float, + ~startAngle: float, + ~endAngle: float, + ~counterclockwise: bool=?, +) => unit = "ellipse" + +/** +Adds to the path the path given by the argument. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Path2D/addPath) +*/ +@send +external addPath: (Types.path2D, ~path: Types.path2D, ~transform: domMatrix2DInit=?) => unit = + "addPath" diff --git a/packages/Canvas/src/Types.res b/packages/Canvas/src/Types.res new file mode 100644 index 00000000..005d30ad --- /dev/null +++ b/packages/Canvas/src/Types.res @@ -0,0 +1,452 @@ +@@warning("-30") + +type offscreenRenderingContextId = + | @as("2d") V2d + | @as("bitmaprenderer") Bitmaprenderer + | @as("webgl") Webgl + | @as("webgl2") Webgl2 + | @as("webgpu") Webgpu + +type globalCompositeOperation = + | @as("color") Color + | @as("color-burn") ColorBurn + | @as("color-dodge") ColorDodge + | @as("copy") Copy + | @as("darken") Darken + | @as("destination-atop") DestinationAtop + | @as("destination-in") DestinationIn + | @as("destination-out") DestinationOut + | @as("destination-over") DestinationOver + | @as("difference") Difference + | @as("exclusion") Exclusion + | @as("hard-light") HardLight + | @as("hue") Hue + | @as("lighten") Lighten + | @as("lighter") Lighter + | @as("luminosity") Luminosity + | @as("multiply") Multiply + | @as("overlay") Overlay + | @as("saturation") Saturation + | @as("screen") Screen + | @as("soft-light") SoftLight + | @as("source-atop") SourceAtop + | @as("source-in") SourceIn + | @as("source-out") SourceOut + | @as("source-over") SourceOver + | @as("xor") Xor + +type imageSmoothingQuality = + | @as("high") High + | @as("low") Low + | @as("medium") Medium + +type canvasLineCap = + | @as("butt") Butt + | @as("round") Round + | @as("square") Square + +type canvasLineJoin = + | @as("bevel") Bevel + | @as("miter") Miter + | @as("round") Round + +type canvasTextAlign = + | @as("center") Center + | @as("end") End + | @as("left") Left + | @as("right") Right + | @as("start") Start + +type canvasTextBaseline = + | @as("alphabetic") Alphabetic + | @as("bottom") Bottom + | @as("hanging") Hanging + | @as("ideographic") Ideographic + | @as("middle") Middle + | @as("top") Top + +type canvasDirection = + | @as("inherit") Inherit + | @as("ltr") Ltr + | @as("rtl") Rtl + +type canvasFontKerning = + | @as("auto") Auto + | @as("none") None + | @as("normal") Normal + +type canvasFontStretch = + | @as("condensed") Condensed + | @as("expanded") Expanded + | @as("extra-condensed") ExtraCondensed + | @as("extra-expanded") ExtraExpanded + | @as("normal") Normal + | @as("semi-condensed") SemiCondensed + | @as("semi-expanded") SemiExpanded + | @as("ultra-condensed") UltraCondensed + | @as("ultra-expanded") UltraExpanded + +type canvasFontVariantCaps = + | @as("all-petite-caps") AllPetiteCaps + | @as("all-small-caps") AllSmallCaps + | @as("normal") Normal + | @as("petite-caps") PetiteCaps + | @as("small-caps") SmallCaps + | @as("titling-caps") TitlingCaps + | @as("unicase") Unicase + +type canvasTextRendering = + | @as("auto") Auto + | @as("geometricPrecision") GeometricPrecision + | @as("optimizeLegibility") OptimizeLegibility + | @as("optimizeSpeed") OptimizeSpeed + +type predefinedColorSpace = + | @as("display-p3") DisplayP3 + | @as("srgb") Srgb + +type canvasFillRule = + | @as("evenodd") Evenodd + | @as("nonzero") Nonzero + +type webGLPowerPreference = + | @as("default") Default + | @as("high-performance") HighPerformance + | @as("low-power") LowPower + +@editor.completeFrom(FillStyle) type fillStyle + +/** +[See OffscreenCanvas on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(OffscreenCanvas) +type offscreenCanvas = { + ...WebApiEvent.Types.eventTarget, + /** + These attributes return the dimensions of the OffscreenCanvas object's bitmap. + +They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/width) + */ + mutable width: int, + /** + These attributes return the dimensions of the OffscreenCanvas object's bitmap. + +They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas/height) + */ + mutable height: int, +} + +/** +[See ImageBitmap on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmap) +*/ +@editor.completeFrom(ImageBitmap) +type imageBitmap = private { + /** + Returns the intrinsic width of the image, in CSS pixels. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmap/width) + */ + width: int, + /** + Returns the intrinsic height of the image, in CSS pixels. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmap/height) + */ + height: int, +} + +/** +[See OffscreenCanvasRenderingContext2D on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvasRenderingContext2D) +*/ +type offscreenCanvasRenderingContext2D = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/canvas) + */ + canvas: offscreenCanvas, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalAlpha) + */ + mutable globalAlpha: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation) + */ + mutable globalCompositeOperation: globalCompositeOperation, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled) + */ + mutable imageSmoothingEnabled: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality) + */ + mutable imageSmoothingQuality: imageSmoothingQuality, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeStyle) + */ + mutable strokeStyle: fillStyle, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillStyle) + */ + mutable fillStyle: fillStyle, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX) + */ + mutable shadowOffsetX: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY) + */ + mutable shadowOffsetY: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowBlur) + */ + mutable shadowBlur: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowColor) + */ + mutable shadowColor: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/filter) + */ + mutable filter: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineWidth) + */ + mutable lineWidth: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineCap) + */ + mutable lineCap: canvasLineCap, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineJoin) + */ + mutable lineJoin: canvasLineJoin, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/miterLimit) + */ + mutable miterLimit: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineDashOffset) + */ + mutable lineDashOffset: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/font) + */ + mutable font: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textAlign) + */ + mutable textAlign: canvasTextAlign, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textBaseline) + */ + mutable textBaseline: canvasTextBaseline, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/direction) + */ + mutable direction: canvasDirection, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/letterSpacing) + */ + mutable letterSpacing: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontKerning) + */ + mutable fontKerning: canvasFontKerning, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontStretch) + */ + mutable fontStretch: canvasFontStretch, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontVariantCaps) + */ + mutable fontVariantCaps: canvasFontVariantCaps, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textRendering) + */ + mutable textRendering: canvasTextRendering, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/wordSpacing) + */ + mutable wordSpacing: string, +} + +/** +[See ImageBitmapRenderingContext on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmapRenderingContext) +*/ +@editor.completeFrom(ImageBitmapRenderingContext) +type imageBitmapRenderingContext = private { + /** + Returns the canvas element that the context is bound to. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageBitmapRenderingContext/canvas) + */ + canvas: unknown, +} + +/** +Provides an interface to the OpenGL ES 2.0 graphics rendering context for the drawing surface of an HTML element. +[See WebGLRenderingContext on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext) +*/ +type webGLRenderingContext = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/canvas) + */ + canvas: unknown, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferWidth) + */ + drawingBufferWidth: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferHeight) + */ + drawingBufferHeight: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferColorSpace) + */ + mutable drawingBufferColorSpace: predefinedColorSpace, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/unpackColorSpace) + */ + mutable unpackColorSpace: predefinedColorSpace, +} + +/** +[See WebGL2RenderingContext on MDN](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext) +*/ +type webGL2RenderingContext = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/canvas) + */ + canvas: unknown, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferWidth) + */ + drawingBufferWidth: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferHeight) + */ + drawingBufferHeight: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGLRenderingContext/drawingBufferColorSpace) + */ + mutable drawingBufferColorSpace: predefinedColorSpace, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/unpackColorSpace) + */ + mutable unpackColorSpace: predefinedColorSpace, +} + +/** +An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). +[See CanvasGradient on MDN](https://developer.mozilla.org/docs/Web/API/CanvasGradient) +*/ +@editor.completeFrom(CanvasGradient) +type canvasGradient = private {} + +/** +An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. +[See CanvasPattern on MDN](https://developer.mozilla.org/docs/Web/API/CanvasPattern) +*/ +@editor.completeFrom(CanvasPattern) +type canvasPattern = private {} + +/** +This WebApiCanvas 2D API interface is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. +[See Path2D on MDN](https://developer.mozilla.org/docs/Web/API/Path2D) +*/ +@editor.completeFrom(Path2D) +type path2D = private {} + +/** +The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. +[See TextMetrics on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics) +*/ +type textMetrics = { + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/width) + */ + width: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/actualBoundingBoxLeft) + */ + actualBoundingBoxLeft: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/actualBoundingBoxRight) + */ + actualBoundingBoxRight: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/fontBoundingBoxAscent) + */ + fontBoundingBoxAscent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/fontBoundingBoxDescent) + */ + fontBoundingBoxDescent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/actualBoundingBoxAscent) + */ + actualBoundingBoxAscent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/actualBoundingBoxDescent) + */ + actualBoundingBoxDescent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/emHeightAscent) + */ + emHeightAscent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/emHeightDescent) + */ + emHeightDescent: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/hangingBaseline) + */ + hangingBaseline: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/alphabeticBaseline) + */ + alphabeticBaseline: float, + /** + Returns the measurement described below. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextMetrics/ideographicBaseline) + */ + ideographicBaseline: float, +} + +type offscreenRenderingContext = unknown + +type imageEncodeOptions = { + @as("type") mutable type_?: string, + mutable quality?: float, +} + +type canvasRenderingContext2DSettings = { + mutable alpha?: bool, + mutable desynchronized?: bool, + mutable colorSpace?: predefinedColorSpace, + mutable willReadFrequently?: bool, +} + +type webGLContextAttributes = { + mutable alpha?: bool, + mutable depth?: bool, + mutable stencil?: bool, + mutable antialias?: bool, + mutable premultipliedAlpha?: bool, + mutable preserveDrawingBuffer?: bool, + mutable powerPreference?: webGLPowerPreference, + mutable failIfMajorPerformanceCaveat?: bool, + mutable desynchronized?: bool, +} + +type imageBitmapRenderingContextSettings = {mutable alpha?: bool} diff --git a/packages/Canvas/src/VideoFrame.res b/packages/Canvas/src/VideoFrame.res new file mode 100644 index 00000000..fdb56410 --- /dev/null +++ b/packages/Canvas/src/VideoFrame.res @@ -0,0 +1,140 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make: ( + ~image: WebApiDOM.Types.htmlImageElement, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make2: ( + ~image: WebApiDOM.Types.svgImageElement, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make3: ( + ~image: WebApiDOM.Types.htmlVideoElement, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make4: ( + ~image: WebApiDOM.Types.htmlCanvasElement, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make5: ( + ~image: Types.imageBitmap, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make6: ( + ~image: Types.offscreenCanvas, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make7: ( + ~image: WebApiDOM.Types.videoFrame, + ~init: WebApiDOM.Types.videoFrameInit=?, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make8: ( + ~data: ArrayBuffer.t, + ~init: WebApiDOM.Types.videoFrameBufferInit, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make9: ( + ~data: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + ~init: WebApiDOM.Types.videoFrameBufferInit, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame) +*/ +@new +external make10: ( + ~data: DataView.t, + ~init: WebApiDOM.Types.videoFrameBufferInit, +) => WebApiDOM.Types.videoFrame = "VideoFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/allocationSize) +*/ +@send +external allocationSize: ( + WebApiDOM.Types.videoFrame, + ~options: WebApiDOM.Types.videoFrameCopyToOptions=?, +) => int = "allocationSize" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/copyTo) +*/ +@send +external copyTo: ( + WebApiDOM.Types.videoFrame, + ~destination: ArrayBuffer.t, + ~options: WebApiDOM.Types.videoFrameCopyToOptions=?, +) => promise> = "copyTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/copyTo) +*/ +@send +external copyTo2: ( + WebApiDOM.Types.videoFrame, + ~destination: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + ~options: WebApiDOM.Types.videoFrameCopyToOptions=?, +) => promise> = "copyTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/copyTo) +*/ +@send +external copyTo3: ( + WebApiDOM.Types.videoFrame, + ~destination: DataView.t, + ~options: WebApiDOM.Types.videoFrameCopyToOptions=?, +) => promise> = "copyTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/clone) +*/ +@send +external clone: WebApiDOM.Types.videoFrame => WebApiDOM.Types.videoFrame = "clone" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/VideoFrame/close) +*/ +@send +external close: WebApiDOM.Types.videoFrame => unit = "close" diff --git a/packages/ChannelMessaging/package.json b/packages/ChannelMessaging/package.json new file mode 100644 index 00000000..f93a5651 --- /dev/null +++ b/packages/ChannelMessaging/package.json @@ -0,0 +1,23 @@ +{ + "name": "@rescript/webapi-channel-messaging", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@rescript/webapi-event": "0.1.0" + } +} diff --git a/packages/ChannelMessaging/rescript.json b/packages/ChannelMessaging/rescript.json new file mode 100644 index 00000000..90901df6 --- /dev/null +++ b/packages/ChannelMessaging/rescript.json @@ -0,0 +1,18 @@ +{ + "name": "@rescript/webapi-channel-messaging", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-event" + ], + "namespace": "WebApiChannelMessaging" +} diff --git a/packages/ChannelMessaging/src/MessagePort.res b/packages/ChannelMessaging/src/MessagePort.res new file mode 100644 index 00000000..1cb29f56 --- /dev/null +++ b/packages/ChannelMessaging/src/MessagePort.res @@ -0,0 +1,38 @@ +type t = Types.messagePort = private {...Types.messagePort} +type structuredSerializeOptions = Types.structuredSerializeOptions + +include WebApiEvent.EventTarget.Impl({type t = t}) + +/** +Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side. + +Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage) +*/ +@send +external postMessage: (t, ~message: JSON.t, ~transfer: array>) => unit = + "postMessage" + +/** +Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side. + +Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage) +*/ +@send +external postMessage2: (t, ~message: JSON.t, ~options: structuredSerializeOptions=?) => unit = + "postMessage" + +/** +Begins dispatching messages received on the port. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/start) +*/ +@send +external start: t => unit = "start" + +/** +Disconnects the port, so that it is no longer active. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort/close) +*/ +@send +external close: t => unit = "close" diff --git a/packages/ChannelMessaging/src/Types.res b/packages/ChannelMessaging/src/Types.res new file mode 100644 index 00000000..4533ba60 --- /dev/null +++ b/packages/ChannelMessaging/src/Types.res @@ -0,0 +1,12 @@ +@@warning("-30") + +/** +This Channel Messaging API interface represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other. +[See MessagePort on MDN](https://developer.mozilla.org/docs/Web/API/MessagePort) +*/ +@editor.completeFrom(MessagePort) +type messagePort = private { + ...WebApiEvent.Types.eventTarget, +} + +type structuredSerializeOptions = {mutable transfer?: array>} diff --git a/packages/Clipboard/package.json b/packages/Clipboard/package.json new file mode 100644 index 00000000..66f89bd4 --- /dev/null +++ b/packages/Clipboard/package.json @@ -0,0 +1,24 @@ +{ + "name": "@rescript/webapi-clipboard", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-file": "0.1.0" + } +} diff --git a/packages/Clipboard/rescript.json b/packages/Clipboard/rescript.json new file mode 100644 index 00000000..305cf73b --- /dev/null +++ b/packages/Clipboard/rescript.json @@ -0,0 +1,19 @@ +{ + "name": "@rescript/webapi-clipboard", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-event", + "@rescript/webapi-file" + ], + "namespace": "WebApiClipboard" +} diff --git a/packages/Clipboard/src/Clipboard.res b/packages/Clipboard/src/Clipboard.res new file mode 100644 index 00000000..98cdc932 --- /dev/null +++ b/packages/Clipboard/src/Clipboard.res @@ -0,0 +1,25 @@ +include WebApiEvent.EventTarget.Impl({type t = Types.clipboard}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebApiClipboard/read) +*/ +@send +external read: Types.clipboard => promise> = "read" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebApiClipboard/readText) +*/ +@send +external readText: Types.clipboard => promise = "readText" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebApiClipboard/write) +*/ +@send +external write: (Types.clipboard, array) => promise = "write" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/WebApiClipboard/writeText) +*/ +@send +external writeText: (Types.clipboard, string) => promise = "writeText" diff --git a/packages/Clipboard/src/ClipboardItem.res b/packages/Clipboard/src/ClipboardItem.res new file mode 100644 index 00000000..d67b4da6 --- /dev/null +++ b/packages/Clipboard/src/ClipboardItem.res @@ -0,0 +1,18 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem) +*/ +@new +external make: (~items: unknown, ~options: Types.clipboardItemOptions=?) => Types.clipboardItem = + "ClipboardItem" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem/getType) +*/ +@send +external getType: (Types.clipboardItem, string) => promise = "getType" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem/supports_static) +*/ +@scope("ClipboardItem") +external supports: string => bool = "supports" diff --git a/packages/Clipboard/src/Types.res b/packages/Clipboard/src/Types.res new file mode 100644 index 00000000..987d2e48 --- /dev/null +++ b/packages/Clipboard/src/Types.res @@ -0,0 +1,31 @@ +@@warning("-30") + +type presentationStyle = + | @as("attachment") Attachment + | @as("inline") Inline + | @as("unspecified") Unspecified + +/** +[See ClipboardItem on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem) +*/ +@editor.completeFrom(ClipboardItem) +type clipboardItem = private { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem/presentationStyle) + */ + presentationStyle: presentationStyle, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ClipboardItem/types) + */ + types: array, +} + +/** +[See WebApiClipboard on MDN](https://developer.mozilla.org/docs/Web/API/WebApiClipboard) +*/ +@editor.completeFrom(WebApiClipboard) +type clipboard = private { + ...WebApiEvent.Types.eventTarget, +} + +type clipboardItemOptions = {mutable presentationStyle?: presentationStyle} diff --git a/packages/CredentialManagement/package.json b/packages/CredentialManagement/package.json new file mode 100644 index 00000000..3320b9fd --- /dev/null +++ b/packages/CredentialManagement/package.json @@ -0,0 +1,24 @@ +{ + "name": "@rescript/webapi-credential-management", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@rescript/webapi-event": "0.1.0", + "@rescript/webapi-prelude": "0.1.0" + } +} diff --git a/packages/CredentialManagement/rescript.json b/packages/CredentialManagement/rescript.json new file mode 100644 index 00000000..a07ff4ae --- /dev/null +++ b/packages/CredentialManagement/rescript.json @@ -0,0 +1,19 @@ +{ + "name": "@rescript/webapi-credential-management", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-event", + "@rescript/webapi-prelude" + ], + "namespace": "WebApiCredentialManagement" +} diff --git a/packages/CredentialManagement/src/CredentialsContainer.res b/packages/CredentialManagement/src/CredentialsContainer.res new file mode 100644 index 00000000..fb8df6e1 --- /dev/null +++ b/packages/CredentialManagement/src/CredentialsContainer.res @@ -0,0 +1,29 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get) +*/ +@send +external get: ( + Types.credentialsContainer, + ~options: Types.credentialRequestOptions=?, +) => promise = "get" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store) +*/ +@send +external store: (Types.credentialsContainer, Types.credential) => promise = "store" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/create) +*/ +@send +external create: ( + Types.credentialsContainer, + ~options: Types.credentialCreationOptions=?, +) => promise = "create" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/preventSilentAccess) +*/ +@send +external preventSilentAccess: Types.credentialsContainer => promise = "preventSilentAccess" diff --git a/packages/CredentialManagement/src/Types.res b/packages/CredentialManagement/src/Types.res new file mode 100644 index 00000000..3eccaa69 --- /dev/null +++ b/packages/CredentialManagement/src/Types.res @@ -0,0 +1,138 @@ +@@warning("-30") + +type authenticatorTransport = + | @as("ble") Ble + | @as("hybrid") Hybrid + | @as("internal") Internal + | @as("nfc") Nfc + | @as("usb") Usb + +type credentialMediationRequirement = + | @as("conditional") Conditional + | @as("optional") Optional + | @as("required") Required + | @as("silent") Silent + +type publicKeyCredentialType = | @as("public-key") PublicKey + +type userVerificationRequirement = + | @as("discouraged") Discouraged + | @as("preferred") Preferred + | @as("required") Required + +type authenticatorAttachment = + | @as("cross-platform") CrossPlatform + | @as("platform") Platform + +type residentKeyRequirement = + | @as("discouraged") Discouraged + | @as("preferred") Preferred + | @as("required") Required + +type attestationConveyancePreference = + | @as("direct") Direct + | @as("enterprise") Enterprise + | @as("indirect") Indirect + | @as("none") None + +/** +[See CredentialsContainer on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer) +*/ +@editor.completeFrom(CredentialsContainer) +type credentialsContainer = private {} + +/** +[See Credential on MDN](https://developer.mozilla.org/docs/Web/API/Credential) +*/ +type credential = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Credential/id) + */ + id: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Credential/type) + */ + @as("type") + type_: string, +} + +type publicKeyCredentialDescriptor = { + @as("type") mutable type_: publicKeyCredentialType, + mutable id: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + mutable transports?: array, +} + +type authenticationExtensionsPRFValues = { + mutable first: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + mutable second?: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, +} + +type authenticationExtensionsPRFInputs = { + mutable eval?: authenticationExtensionsPRFValues, + mutable evalByCredential?: unknown, +} + +type authenticationExtensionsClientInputs = { + mutable minPinLength?: bool, + mutable hmacCreateSecret?: bool, + mutable appid?: string, + mutable credProps?: bool, + mutable prf?: authenticationExtensionsPRFInputs, +} + +type publicKeyCredentialRequestOptions = { + mutable challenge: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + mutable timeout?: int, + mutable rpId?: string, + mutable allowCredentials?: array, + mutable userVerification?: userVerificationRequirement, + mutable extensions?: authenticationExtensionsClientInputs, +} + +type credentialRequestOptions = { + mutable mediation?: credentialMediationRequirement, + mutable signal?: WebApiEvent.Types.abortSignal, + mutable publicKey?: publicKeyCredentialRequestOptions, +} + +type publicKeyCredentialEntity = {mutable name: string} + +type publicKeyCredentialRpEntity = { + ...publicKeyCredentialEntity, + mutable id?: string, +} + +type publicKeyCredentialUserEntity = { + ...publicKeyCredentialEntity, + mutable id: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + mutable displayName: string, +} + +type publicKeyCredentialParameters = { + @as("type") mutable type_: publicKeyCredentialType, + mutable alg: int, +} + +type authenticatorSelectionCriteria = { + mutable authenticatorAttachment?: authenticatorAttachment, + mutable residentKey?: residentKeyRequirement, + mutable requireResidentKey?: bool, + mutable userVerification?: userVerificationRequirement, +} + +type publicKeyCredentialCreationOptions = { + mutable rp: publicKeyCredentialRpEntity, + mutable user: publicKeyCredentialUserEntity, + mutable challenge: WebApiPrelude.Types.ArrayBufferTypedArrayOrDataView.t, + mutable pubKeyCredParams: array, + mutable timeout?: int, + mutable excludeCredentials?: array, + mutable authenticatorSelection?: authenticatorSelectionCriteria, + mutable attestation?: attestationConveyancePreference, + mutable extensions?: authenticationExtensionsClientInputs, +} + +type credentialCreationOptions = { + mutable signal?: WebApiEvent.Types.abortSignal, + mutable publicKey?: publicKeyCredentialCreationOptions, +} diff --git a/packages/DOM/package.json b/packages/DOM/package.json new file mode 100644 index 00000000..acaa4c4e --- /dev/null +++ b/packages/DOM/package.json @@ -0,0 +1,55 @@ +{ + "name": "@rescript/webapi-dom", + "version": "0.1.0", + "license": "MIT", + "type": "module", + "files": [ + "rescript.json", + "src/**/*.res" + ], + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "rescript" + }, + "peerDependencies": { + "rescript": ">=12.0.0 <13" + }, + "dependencies": { + "@rescript/webapi-css-font-loading": "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-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-prelude": "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" + } +} diff --git a/packages/DOM/rescript.json b/packages/DOM/rescript.json new file mode 100644 index 00000000..0c1b0b9f --- /dev/null +++ b/packages/DOM/rescript.json @@ -0,0 +1,50 @@ +{ + "name": "@rescript/webapi-dom", + "sources": [ + { + "dir": "src", + "subdirs": true + } + ], + "package-specs": { + "module": "esmodule", + "in-source": true + }, + "suffix": ".js", + "dependencies": [ + "@rescript/webapi-css-font-loading", + "@rescript/webapi-channel-messaging", + "@rescript/webapi-clipboard", + "@rescript/webapi-credential-management", + "@rescript/webapi-event", + "@rescript/webapi-fetch", + "@rescript/webapi-file", + "@rescript/webapi-file-and-directory-entries", + "@rescript/webapi-gamepad", + "@rescript/webapi-geolocation", + "@rescript/webapi-history", + "@rescript/webapi-indexed-db", + "@rescript/webapi-media-capabilities", + "@rescript/webapi-media-capture-and-streams", + "@rescript/webapi-media-session", + "@rescript/webapi-performance", + "@rescript/webapi-permissions", + "@rescript/webapi-picture-in-picture", + "@rescript/webapi-prelude", + "@rescript/webapi-remote-playback", + "@rescript/webapi-screen-wake-lock", + "@rescript/webapi-service-worker", + "@rescript/webapi-storage", + "@rescript/webapi-url", + "@rescript/webapi-view-transitions", + "@rescript/webapi-visual-viewport", + "@rescript/webapi-web-crypto", + "@rescript/webapi-web-locks", + "@rescript/webapi-web-midi", + "@rescript/webapi-web-speech", + "@rescript/webapi-web-storage", + "@rescript/webapi-web-vtt", + "@rescript/webapi-web-workers" + ], + "namespace": "WebApiDOM" +} diff --git a/packages/DOM/src/Animation.res b/packages/DOM/src/Animation.res new file mode 100644 index 00000000..fa1455be --- /dev/null +++ b/packages/DOM/src/Animation.res @@ -0,0 +1,58 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation) +*/ +@new +external make: ( + ~effect: Types.animationEffect=?, + ~timeline: Types.animationTimeline=?, +) => Types.animation = "Animation" + +include WebApiEvent.EventTarget.Impl({type t = Types.animation}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/cancel) +*/ +@send +external cancel: Types.animation => unit = "cancel" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/finish) +*/ +@send +external finish: Types.animation => unit = "finish" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/play) +*/ +@send +external play: Types.animation => unit = "play" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/pause) +*/ +@send +external pause: Types.animation => unit = "pause" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/updatePlaybackRate) +*/ +@send +external updatePlaybackRate: (Types.animation, float) => unit = "updatePlaybackRate" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/reverse) +*/ +@send +external reverse: Types.animation => unit = "reverse" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/persist) +*/ +@send +external persist: Types.animation => unit = "persist" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Animation/commitStyles) +*/ +@send +external commitStyles: Types.animation => unit = "commitStyles" diff --git a/packages/DOM/src/AnimationEffect.res b/packages/DOM/src/AnimationEffect.res new file mode 100644 index 00000000..7d8c9696 --- /dev/null +++ b/packages/DOM/src/AnimationEffect.res @@ -0,0 +1,19 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AnimationEffect/getTiming) +*/ +@send +external getTiming: Types.animationEffect => Types.effectTiming = "getTiming" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AnimationEffect/getComputedTiming) +*/ +@send +external getComputedTiming: Types.animationEffect => Types.computedEffectTiming = + "getComputedTiming" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AnimationEffect/updateTiming) +*/ +@send +external updateTiming: (Types.animationEffect, ~timing: Types.optionalEffectTiming=?) => unit = + "updateTiming" diff --git a/packages/DOM/src/CSSRuleList.res b/packages/DOM/src/CSSRuleList.res new file mode 100644 index 00000000..a1a326a4 --- /dev/null +++ b/packages/DOM/src/CSSRuleList.res @@ -0,0 +1,5 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSRuleList/item) +*/ +@send +external item: (Types.cssRuleList, int) => Types.cssRule = "item" diff --git a/packages/DOM/src/CSSStyleDeclaration.res b/packages/DOM/src/CSSStyleDeclaration.res new file mode 100644 index 00000000..4085a769 --- /dev/null +++ b/packages/DOM/src/CSSStyleDeclaration.res @@ -0,0 +1,34 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/item) +*/ +@send +external item: (Types.cssStyleDeclaration, int) => string = "item" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyValue) +*/ +@send +external getPropertyValue: (Types.cssStyleDeclaration, string) => string = "getPropertyValue" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyPriority) +*/ +@send +external getPropertyPriority: (Types.cssStyleDeclaration, string) => string = "getPropertyPriority" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/setProperty) +*/ +@send +external setProperty: ( + Types.cssStyleDeclaration, + ~property: string, + ~value: string, + ~priority: string=?, +) => unit = "setProperty" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/removeProperty) +*/ +@send +external removeProperty: (Types.cssStyleDeclaration, string) => string = "removeProperty" diff --git a/packages/DOM/src/CSSStyleSheet.res b/packages/DOM/src/CSSStyleSheet.res new file mode 100644 index 00000000..5d6cac8d --- /dev/null +++ b/packages/DOM/src/CSSStyleSheet.res @@ -0,0 +1,30 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet) +*/ +@new +external make: (~options: Types.cssStyleSheetInit=?) => Types.cssStyleSheet = "CSSStyleSheet" + +external asStyleSheet: Types.cssStyleSheet => Types.styleSheet = "%identity" +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule) +*/ +@send +external insertRule: (Types.cssStyleSheet, ~rule: string, ~index: int=?) => int = "insertRule" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/deleteRule) +*/ +@send +external deleteRule: (Types.cssStyleSheet, int) => unit = "deleteRule" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/replace) +*/ +@send +external replace: (Types.cssStyleSheet, string) => promise = "replace" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/replaceSync) +*/ +@send +external replaceSync: (Types.cssStyleSheet, string) => unit = "replaceSync" diff --git a/packages/DOM/src/CSSStyleValue.res b/packages/DOM/src/CSSStyleValue.res new file mode 100644 index 00000000..4377e411 --- /dev/null +++ b/packages/DOM/src/CSSStyleValue.res @@ -0,0 +1,11 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CSSStyleValue/parse_static) +*/ +@scope("CSSStyleValue") +external parse: (~property: string, ~cssText: string) => Types.cssStyleValue = "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" diff --git a/packages/DOM/src/CaretPosition.res b/packages/DOM/src/CaretPosition.res new file mode 100644 index 00000000..b8be2b90 --- /dev/null +++ b/packages/DOM/src/CaretPosition.res @@ -0,0 +1,2 @@ +@send +external getClientRect: Types.caretPosition => Types.domRect = "getClientRect" diff --git a/src/DOMAPI/CharacterData.res b/packages/DOM/src/CharacterData.res similarity index 91% rename from src/DOMAPI/CharacterData.res rename to packages/DOM/src/CharacterData.res index 8ebc3065..22fe29a6 100644 --- a/src/DOMAPI/CharacterData.res +++ b/packages/DOM/src/CharacterData.res @@ -1,5 +1,3 @@ -open DOMAPI - module Impl = ( T: { type t @@ -7,7 +5,7 @@ module Impl = ( ) => { include Node.Impl({type t = T.t}) - external asCharacterData: T.t => characterData = "%identity" + external asCharacterData: T.t => Types.characterData = "%identity" /** Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. @@ -16,7 +14,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/after) */ @send - external after: (T.t, node) => unit = "after" + external after: (T.t, Types.node) => unit = "after" /** Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. @@ -40,7 +38,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/before) */ @send - external before: (T.t, node) => unit = "before" + external before: (T.t, Types.node) => unit = "before" /** Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. @@ -83,7 +81,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceWith) */ @send - external replaceWith: (T.t, node) => unit = "replaceWith" + external replaceWith: (T.t, Types.node) => unit = "replaceWith" /** Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes. @@ -101,4 +99,4 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre external substringData: (T.t, ~offset: int, ~count: int) => string = "substringData" } -include Impl({type t = characterData}) +include Impl({type t = Types.characterData}) diff --git a/packages/DOM/src/Comment.res b/packages/DOM/src/Comment.res new file mode 100644 index 00000000..623d9652 --- /dev/null +++ b/packages/DOM/src/Comment.res @@ -0,0 +1,7 @@ +include CharacterData.Impl({type t = Types.comment}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Comment) +*/ +@new +external make: (~data: string=?) => Types.comment = "Comment" diff --git a/packages/DOM/src/CustomElementRegistry.res b/packages/DOM/src/CustomElementRegistry.res new file mode 100644 index 00000000..ca33736c --- /dev/null +++ b/packages/DOM/src/CustomElementRegistry.res @@ -0,0 +1,32 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/define) +*/ +@send +external define: ( + Types.customElementRegistry, + ~name: string, + ~constructor: Types.htmlElement, + ~options: Types.elementDefinitionOptions=?, +) => unit = "define" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/getName) +*/ +@send +external getName: (Types.customElementRegistry, Types.customElementConstructor) => string = + "getName" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/whenDefined) +*/ +@send +external whenDefined: ( + Types.customElementRegistry, + string, +) => promise = "whenDefined" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry/upgrade) +*/ +@send +external upgrade: (Types.customElementRegistry, Types.node) => unit = "upgrade" diff --git a/packages/DOM/src/DOMImplementation.res b/packages/DOM/src/DOMImplementation.res new file mode 100644 index 00000000..fc68eb6f --- /dev/null +++ b/packages/DOM/src/DOMImplementation.res @@ -0,0 +1,28 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createDocumentType) +*/ +@send +external createDocumentType: ( + Types.domImplementation, + ~qualifiedName: string, + ~publicId: string, + ~systemId: string, +) => Types.documentType = "createDocumentType" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createDocument) +*/ +@send +external createDocument: ( + Types.domImplementation, + ~namespace: string, + ~qualifiedName: string, + ~doctype: Types.documentType=?, +) => Types.xmlDocument = "createDocument" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument) +*/ +@send +external createHTMLDocument: (Types.domImplementation, ~title: string=?) => Types.document = + "createHTMLDocument" diff --git a/packages/DOM/src/DOMMatrix.res b/packages/DOM/src/DOMMatrix.res new file mode 100644 index 00000000..f9e85641 --- /dev/null +++ b/packages/DOM/src/DOMMatrix.res @@ -0,0 +1,184 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrix) +*/ +@new +external make: (~init: string=?) => Types.domMatrix = "DOMMatrix" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrix) +*/ +@new +external make2: (~init: array=?) => Types.domMatrix = "DOMMatrix" + +external asDOMMatrixReadOnly: Types.domMatrix => Types.domMatrixReadOnly = "%identity" +@scope("DOMMatrix") +external fromMatrix: (~other: Types.domMatrixInit=?) => Types.domMatrixReadOnly = "fromMatrix" + +@scope("DOMMatrix") +external fromFloat32Array: array => Types.domMatrixReadOnly = "fromFloat32Array" + +@scope("DOMMatrix") +external fromFloat64Array: Float64Array.t => Types.domMatrixReadOnly = "fromFloat64Array" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/translate) +*/ +@send +external translate: (Types.domMatrix, ~tx: float=?, ~ty: float=?, ~tz: float=?) => Types.domMatrix = + "translate" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale) +*/ +@send +external scale: ( + Types.domMatrix, + ~scaleX: float=?, + ~scaleY: float=?, + ~scaleZ: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scale" + +@send +external scale3d: ( + Types.domMatrix, + ~scale: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scale3d" + +@send +external rotate: ( + Types.domMatrix, + ~rotX: float=?, + ~rotY: float=?, + ~rotZ: float=?, +) => Types.domMatrix = "rotate" + +@send +external rotateFromVector: (Types.domMatrix, ~x: float=?, ~y: float=?) => Types.domMatrix = + "rotateFromVector" + +@send +external rotateAxisAngle: ( + Types.domMatrix, + ~x: float=?, + ~y: float=?, + ~z: float=?, + ~angle: float=?, +) => Types.domMatrix = "rotateAxisAngle" + +@send +external skewX: (Types.domMatrix, ~sx: float=?) => Types.domMatrix = "skewX" + +@send +external skewY: (Types.domMatrix, ~sy: float=?) => Types.domMatrix = "skewY" + +@send +external multiply: (Types.domMatrix, ~other: Types.domMatrixInit=?) => Types.domMatrix = "multiply" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipX) +*/ +@send +external flipX: Types.domMatrix => Types.domMatrix = "flipX" + +@send +external flipY: Types.domMatrix => Types.domMatrix = "flipY" + +@send +external inverse: Types.domMatrix => Types.domMatrix = "inverse" + +@send +external transformPoint: (Types.domMatrix, ~point: Types.domPointInit=?) => Types.domPoint = + "transformPoint" + +@send +external toFloat32Array: Types.domMatrix => array = "toFloat32Array" + +@send +external toFloat64Array: Types.domMatrix => Float64Array.t = "toFloat64Array" + +@send +external toJSON: Types.domMatrix => Dict.t = "toJSON" + +@scope("DOMMatrix") +external fromMatrixD: (~other: Types.domMatrixInit=?) => Types.domMatrix = "fromMatrix" + +@scope("DOMMatrix") +external fromFloat32ArrayD: array => Types.domMatrix = "fromFloat32Array" + +@scope("DOMMatrix") +external fromFloat64ArrayD: Float64Array.t => Types.domMatrix = "fromFloat64Array" + +@send +external multiplySelf: (Types.domMatrix, ~other: Types.domMatrixInit=?) => Types.domMatrix = + "multiplySelf" + +@send +external preMultiplySelf: (Types.domMatrix, ~other: Types.domMatrixInit=?) => Types.domMatrix = + "preMultiplySelf" + +@send +external translateSelf: ( + Types.domMatrix, + ~tx: float=?, + ~ty: float=?, + ~tz: float=?, +) => Types.domMatrix = "translateSelf" + +@send +external scaleSelf: ( + Types.domMatrix, + ~scaleX: float=?, + ~scaleY: float=?, + ~scaleZ: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scaleSelf" + +@send +external scale3dSelf: ( + Types.domMatrix, + ~scale: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scale3dSelf" + +@send +external rotateSelf: ( + Types.domMatrix, + ~rotX: float=?, + ~rotY: float=?, + ~rotZ: float=?, +) => Types.domMatrix = "rotateSelf" + +@send +external rotateFromVectorSelf: (Types.domMatrix, ~x: float=?, ~y: float=?) => Types.domMatrix = + "rotateFromVectorSelf" + +@send +external rotateAxisAngleSelf: ( + Types.domMatrix, + ~x: float=?, + ~y: float=?, + ~z: float=?, + ~angle: float=?, +) => Types.domMatrix = "rotateAxisAngleSelf" + +@send +external skewXSelf: (Types.domMatrix, ~sx: float=?) => Types.domMatrix = "skewXSelf" + +@send +external skewYSelf: (Types.domMatrix, ~sy: float=?) => Types.domMatrix = "skewYSelf" + +@send +external invertSelf: Types.domMatrix => Types.domMatrix = "invertSelf" + +@send +external setMatrixValue: (Types.domMatrix, string) => Types.domMatrix = "setMatrixValue" diff --git a/packages/DOM/src/DOMMatrixReadOnly.res b/packages/DOM/src/DOMMatrixReadOnly.res new file mode 100644 index 00000000..1c5cc270 --- /dev/null +++ b/packages/DOM/src/DOMMatrixReadOnly.res @@ -0,0 +1,110 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly) +*/ +@new +external make: (~init: string=?) => Types.domMatrixReadOnly = "DOMMatrixReadOnly" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly) +*/ +@new +external make2: (~init: array=?) => Types.domMatrixReadOnly = "DOMMatrixReadOnly" + +@scope("DOMMatrixReadOnly") +external fromMatrix: (~other: Types.domMatrixInit=?) => Types.domMatrixReadOnly = "fromMatrix" + +@scope("DOMMatrixReadOnly") +external fromFloat32Array: array => Types.domMatrixReadOnly = "fromFloat32Array" + +@scope("DOMMatrixReadOnly") +external fromFloat64Array: Float64Array.t => Types.domMatrixReadOnly = "fromFloat64Array" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/translate) +*/ +@send +external translate: ( + Types.domMatrixReadOnly, + ~tx: float=?, + ~ty: float=?, + ~tz: float=?, +) => Types.domMatrix = "translate" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/scale) +*/ +@send +external scale: ( + Types.domMatrixReadOnly, + ~scaleX: float=?, + ~scaleY: float=?, + ~scaleZ: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scale" + +@send +external scale3d: ( + Types.domMatrixReadOnly, + ~scale: float=?, + ~originX: float=?, + ~originY: float=?, + ~originZ: float=?, +) => Types.domMatrix = "scale3d" + +@send +external rotate: ( + Types.domMatrixReadOnly, + ~rotX: float=?, + ~rotY: float=?, + ~rotZ: float=?, +) => Types.domMatrix = "rotate" + +@send +external rotateFromVector: (Types.domMatrixReadOnly, ~x: float=?, ~y: float=?) => Types.domMatrix = + "rotateFromVector" + +@send +external rotateAxisAngle: ( + Types.domMatrixReadOnly, + ~x: float=?, + ~y: float=?, + ~z: float=?, + ~angle: float=?, +) => Types.domMatrix = "rotateAxisAngle" + +@send +external skewX: (Types.domMatrixReadOnly, ~sx: float=?) => Types.domMatrix = "skewX" + +@send +external skewY: (Types.domMatrixReadOnly, ~sy: float=?) => Types.domMatrix = "skewY" + +@send +external multiply: (Types.domMatrixReadOnly, ~other: Types.domMatrixInit=?) => Types.domMatrix = + "multiply" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMMatrixReadOnly/flipX) +*/ +@send +external flipX: Types.domMatrixReadOnly => Types.domMatrix = "flipX" + +@send +external flipY: Types.domMatrixReadOnly => Types.domMatrix = "flipY" + +@send +external inverse: Types.domMatrixReadOnly => Types.domMatrix = "inverse" + +@send +external transformPoint: (Types.domMatrixReadOnly, ~point: Types.domPointInit=?) => Types.domPoint = + "transformPoint" + +@send +external toFloat32Array: Types.domMatrixReadOnly => array = "toFloat32Array" + +@send +external toFloat64Array: Types.domMatrixReadOnly => Float64Array.t = "toFloat64Array" + +@send +external toJSON: Types.domMatrixReadOnly => Dict.t = "toJSON" diff --git a/packages/DOM/src/DOMPoint.res b/packages/DOM/src/DOMPoint.res new file mode 100644 index 00000000..7c2d45c6 --- /dev/null +++ b/packages/DOM/src/DOMPoint.res @@ -0,0 +1,28 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPoint) +*/ +@new +external make: (~x: float=?, ~y: float=?, ~z: float=?, ~w: float=?) => Types.domPoint = "DOMPoint" + +external asDOMPointReadOnly: Types.domPoint => Types.domPointReadOnly = "%identity" +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/fromPoint_static) +*/ +@scope("DOMPoint") +external fromPoint: (~other: Types.domPointInit=?) => Types.domPointReadOnly = "fromPoint" + +@send +external matrixTransform: (Types.domPoint, ~matrix: Types.domMatrixInit=?) => Types.domPoint = + "matrixTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/toJSON) +*/ +@send +external toJSON: Types.domPoint => Dict.t = "toJSON" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPoint/fromPoint_static) +*/ +@scope("DOMPoint") +external fromPointD: (~other: Types.domPointInit=?) => Types.domPoint = "fromPoint" diff --git a/packages/DOM/src/DOMPointReadOnly.res b/packages/DOM/src/DOMPointReadOnly.res new file mode 100644 index 00000000..47c8dd38 --- /dev/null +++ b/packages/DOM/src/DOMPointReadOnly.res @@ -0,0 +1,24 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly) +*/ +@new +external make: (~x: float=?, ~y: float=?, ~z: float=?, ~w: float=?) => Types.domPointReadOnly = + "DOMPointReadOnly" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/fromPoint_static) +*/ +@scope("DOMPointReadOnly") +external fromPoint: (~other: Types.domPointInit=?) => Types.domPointReadOnly = "fromPoint" + +@send +external matrixTransform: ( + Types.domPointReadOnly, + ~matrix: Types.domMatrixInit=?, +) => Types.domPoint = "matrixTransform" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMPointReadOnly/toJSON) +*/ +@send +external toJSON: Types.domPointReadOnly => Dict.t = "toJSON" diff --git a/packages/DOM/src/DOMRect.res b/packages/DOM/src/DOMRect.res new file mode 100644 index 00000000..cde1e96f --- /dev/null +++ b/packages/DOM/src/DOMRect.res @@ -0,0 +1,22 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRect) +*/ +@new +external make: (~x: float=?, ~y: float=?, ~width: float=?, ~height: float=?) => Types.domRect = + "DOMRect" + +external asDOMRectReadOnly: Types.domRect => Types.domRectReadOnly = "%identity" +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/fromRect_static) +*/ +@scope("DOMRect") +external fromRect: (~other: Types.domRectInit=?) => Types.domRectReadOnly = "fromRect" + +@send +external toJSON: Types.domRect => Dict.t = "toJSON" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRect/fromRect_static) +*/ +@scope("DOMRect") +external fromRectD: (~other: Types.domRectInit=?) => Types.domRect = "fromRect" diff --git a/packages/DOM/src/DOMRectList.res b/packages/DOM/src/DOMRectList.res new file mode 100644 index 00000000..8fd1645a --- /dev/null +++ b/packages/DOM/src/DOMRectList.res @@ -0,0 +1,2 @@ +@send +external item: (Types.domRectList, int) => Types.domRect = "item" diff --git a/packages/DOM/src/DOMRectReadOnly.res b/packages/DOM/src/DOMRectReadOnly.res new file mode 100644 index 00000000..03629e92 --- /dev/null +++ b/packages/DOM/src/DOMRectReadOnly.res @@ -0,0 +1,19 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly) +*/ +@new +external make: ( + ~x: float=?, + ~y: float=?, + ~width: float=?, + ~height: float=?, +) => Types.domRectReadOnly = "DOMRectReadOnly" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMRectReadOnly/fromRect_static) +*/ +@scope("DOMRectReadOnly") +external fromRect: (~other: Types.domRectInit=?) => Types.domRectReadOnly = "fromRect" + +@send +external toJSON: Types.domRectReadOnly => Dict.t = "toJSON" diff --git a/src/DOMAPI/DOMTokenList.res b/packages/DOM/src/DOMTokenList.res similarity index 80% rename from src/DOMAPI/DOMTokenList.res rename to packages/DOM/src/DOMTokenList.res index 47348f69..227c66ea 100644 --- a/src/DOMAPI/DOMTokenList.res +++ b/packages/DOM/src/DOMTokenList.res @@ -1,18 +1,16 @@ -open DOMAPI - /** Returns the token with index index. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/item) */ @send -external item: (domTokenList, int) => string = "item" +external item: (Types.domTokenList, int) => string = "item" /** Returns true if token is present, and false otherwise. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/contains) */ @send -external contains: (domTokenList, string) => bool = "contains" +external contains: (Types.domTokenList, string) => bool = "contains" /** Adds all arguments passed, except those already present. @@ -23,7 +21,7 @@ Throws an "InvalidCharacterError" DOMException if one of the arguments contains [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/add) */ @send -external add: (domTokenList, string) => unit = "add" +external add: (Types.domTokenList, string) => unit = "add" /** Removes arguments passed, if they are present. @@ -34,7 +32,7 @@ Throws an "InvalidCharacterError" DOMException if one of the arguments contains [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/remove) */ @send -external remove: (domTokenList, string) => unit = "remove" +external remove: (Types.domTokenList, string) => unit = "remove" /** If force is not given, "toggles" token, removing it if it's present and adding it if it's not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()). @@ -47,7 +45,7 @@ Throws an "InvalidCharacterError" DOMException if token contains any spaces. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/toggle) */ @send -external toggle: (domTokenList, ~token: string, ~force: bool=?) => bool = "toggle" +external toggle: (Types.domTokenList, ~token: string, ~force: bool=?) => bool = "toggle" /** Replaces token with newToken. @@ -60,7 +58,7 @@ Throws an "InvalidCharacterError" DOMException if one of the arguments contains [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/replace) */ @send -external replace: (domTokenList, ~token: string, ~newToken: string) => bool = "replace" +external replace: (Types.domTokenList, ~token: string, ~newToken: string) => bool = "replace" /** Returns true if token is in the associated attribute's supported tokens. Returns false otherwise. @@ -69,4 +67,4 @@ Throws a TypeError if the associated attribute has no supported tokens defined. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/supports) */ @send -external supports: (domTokenList, string) => bool = "supports" +external supports: (Types.domTokenList, string) => bool = "supports" diff --git a/packages/DOM/src/Document.res b/packages/DOM/src/Document.res new file mode 100644 index 00000000..bba844c6 --- /dev/null +++ b/packages/DOM/src/Document.res @@ -0,0 +1,463 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document) +*/ +@new +external make: unit => Types.document = "Document" + +include Node.Impl({type t = Types.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) +*/ +@send +external getElementById: (Types.document, string) => null = "getElementById" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getAnimations) +*/ +@send +external getAnimations: Types.document => array = "getAnimations" + +/** +Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/prepend) +*/ +@send +external prepend: (Types.document, Types.node) => unit = "prepend" + +/** +Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/prepend) +*/ +@send +external prepend2: (Types.document, string) => unit = "prepend" + +/** +Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/append) +*/ +@send +external append: (Types.document, Types.node) => unit = "append" + +/** +Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/append) +*/ +@send +external append2: (Types.document, string) => unit = "append" + +/** +Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/replaceChildren) +*/ +@send +external replaceChildren: (Types.document, Types.node) => unit = "replaceChildren" + +/** +Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. + +Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/replaceChildren) +*/ +@send +external replaceChildren2: (Types.document, string) => unit = "replaceChildren" + +/** +Returns the first element that is a descendant of node that matches selectors. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelector) +*/ +@send +external querySelector: (Types.document, string) => Null.t = "querySelector" + +/** +Returns all element descendants of node that match selectors. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelectorAll) +*/ +@send +external querySelectorAll: (Types.document, string) => Types.nodeList = + "querySelectorAll" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createExpression) +*/ +@send +external createExpression: ( + Types.document, + ~expression: string, + ~resolver: Types.xPathNSResolver=?, +) => Types.xPathExpression = "createExpression" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/evaluate) +*/ +@send +external evaluate: ( + Types.document, + ~expression: string, + ~contextNode: Types.node, + ~resolver: Types.xPathNSResolver=?, + ~type_: int=?, + ~result: Types.xPathResult=?, +) => Types.xPathResult = "evaluate" + +/** +Retrieves a collection of objects based on the specified element name. +@param name Specifies the name of an element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementsByTagName) +*/ +@send +external getElementsByTagName: (Types.document, string) => Types.htmlCollection = + "getElementsByTagName" + +/** +If namespace and localName are "*" returns a HTMLCollection of all descendant elements. + +If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName. + +If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. + +Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementsByTagNameNS) +*/ +@send +external getElementsByTagNameNS: ( + Types.document, + ~namespace: string, + ~localName: string, +) => Types.htmlCollection = "getElementsByTagNameNS" + +/** +Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementsByClassName) +*/ +@send +external getElementsByClassName: (Types.document, string) => Types.htmlCollection = + "getElementsByClassName" + +/** +Creates an instance of the element for the specified tag. +@param tagName The name of an element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createElement) +*/ +@send +external createElement: (Types.document, string, ~options: string=?) => Types.element = + "createElement" + +/** +Creates an instance of the element for the specified tag. +@param tagName The name of an element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createElement) +*/ +@send +external createElement2: ( + Types.document, + ~localName: string, + ~options: Types.elementCreationOptions=?, +) => Types.element = "createElement" + +/** +Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName. + +If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown. + +If one of the following conditions is true a "NamespaceError" DOMException will be thrown: + +localName does not match the QName production. +Namespace prefix is not null and namespace is the empty string. +Namespace prefix is "xml" and namespace is not the XML namespace. +qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. +namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns". + +When supplied, options's is can be used to create a customized built-in element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createElementNS) +*/ +@send +external createElementNS: ( + Types.document, + ~namespace: string, + ~qualifiedName: string, + ~options: string=?, +) => Types.element = "createElementNS" + +/** +Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName. + +If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown. + +If one of the following conditions is true a "NamespaceError" DOMException will be thrown: + +localName does not match the QName production. +Namespace prefix is not null and namespace is the empty string. +Namespace prefix is "xml" and namespace is not the XML namespace. +qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. +namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns". + +When supplied, options's is can be used to create a customized built-in element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createElementNS) +*/ +@send +external createElementNS2: ( + Types.document, + ~namespace: string, + ~qualifiedName: string, + ~options: Types.elementCreationOptions=?, +) => Types.element = "createElementNS" + +/** +Creates a new document. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createDocumentFragment) +*/ +@send +external createDocumentFragment: Types.document => Types.documentFragment = "createDocumentFragment" + +/** +Creates a text string from the specified value. +@param data String that specifies the nodeValue property of the text node. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createTextNode) +*/ +@send +external createTextNode: (Types.document, string) => Types.text = "createTextNode" + +/** +Returns a CDATASection node whose data is data. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createCDATASection) +*/ +@send +external createCDATASection: (Types.document, string) => Types.cdataSection = "createCDATASection" + +/** +Creates a comment object with the specified data. +@param data Sets the comment object's data. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createComment) +*/ +@send +external createComment: (Types.document, string) => Types.comment = "createComment" + +/** +Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction) +*/ +@send +external createProcessingInstruction: ( + Types.document, + ~target: string, + ~data: string, +) => Types.processingInstruction = "createProcessingInstruction" + +/** +Returns a copy of node. If deep is true, the copy also includes the node's descendants. + +If node is a document or a shadow root, throws a "NotSupportedError" DOMException. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/importNode) +*/ +@send +external importNode: (Types.document, 't, ~deep: bool=?) => 't = "importNode" + +/** +Moves node from another document and returns it. + +If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/adoptNode) +*/ +@send +external adoptNode: (Types.document, 't) => 't = "adoptNode" + +/** +Creates an attribute object with a specified name. +@param name String that sets the attribute object's name. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createAttribute) +*/ +@send +external createAttribute: (Types.document, string) => Types.attr = "createAttribute" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createAttributeNS) +*/ +@send +external createAttributeNS: ( + Types.document, + ~namespace: string, + ~qualifiedName: string, +) => Types.attr = "createAttributeNS" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createEvent) +*/ +@send +external createEvent: (Types.document, string) => WebApiEvent.Types.event = "createEvent" + +/** + Returns an empty range object that has both of its boundary points positioned at the beginning of the document. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createRange) +*/ +@send +external createRange: Types.document => Types.range = "createRange" + +/** +Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. +@param root The root element or node to start traversing on. +@param whatToShow The type of nodes or elements to appear in the node list +@param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createNodeIterator) +*/ +@send +external createNodeIterator: ( + Types.document, + ~root: Types.node, + ~whatToShow: int=?, + ~filter: Types.nodeFilter=?, +) => Types.nodeIterator = "createNodeIterator" + +/** +Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. +@param root The root element or node to start traversing on. +@param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. +@param filter A custom NodeFilter function to use. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/createTreeWalker) +*/ +@send +external createTreeWalker: ( + Types.document, + ~root: Types.node, + ~whatToShow: int=?, + ~filter: Types.nodeFilter=?, +) => Types.treeWalker = "createTreeWalker" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/startViewTransition) +*/ +@send +external startViewTransition: ( + Types.document, + ~callbackOptions: WebApiViewTransitions.Types.viewTransitionUpdateCallback=?, +) => WebApiViewTransitions.Types.viewTransition = "startViewTransition" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/caretPositionFromPoint) +*/ +@send +external caretPositionFromPoint: ( + Types.document, + ~x: float, + ~y: float, + ~options: Types.caretPositionFromPointOptions=?, +) => Types.caretPosition = "caretPositionFromPoint" + +/** +Stops document's fullscreen element from being displayed fullscreen and resolves promise when done. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/exitFullscreen) +*/ +@send +external exitFullscreen: Types.document => promise = "exitFullscreen" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/parseHTMLUnsafe_static) +*/ +@scope("Document") +external parseHTMLUnsafe: string => Types.document = "parseHTMLUnsafe" + +/** +Gets a collection of objects based on the value of the NAME or ID attribute. +@param elementName Gets a collection of objects based on the value of the NAME or ID attribute. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getElementsByName) +*/ +@send +external getElementsByName: (Types.document, string) => Types.nodeList = + "getElementsByName" + +/** +Opens a new window and loads a document specified by a given WebApiURL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. +@param url Specifies a MIME type for the document. +@param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. +@param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. +@param replace Specifies whether the existing entry for the document is replaced in the history list. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/open) +*/ +@send +external open_: (Types.document, ~unused1: string=?, ~unused2: string=?) => Types.document = "open" + +/** +Opens a new window and loads a document specified by a given WebApiURL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. +@param url Specifies a MIME type for the document. +@param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. +@param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. +@param replace Specifies whether the existing entry for the document is replaced in the history list. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/open) +*/ +@send +external open2: (Types.document, ~url: string, ~name: string, ~features: string) => Types.window = + "open" + +/** +Closes an output stream and forces the sent data to display. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/close) +*/ +@send +external close: Types.document => unit = "close" + +/** +Writes one or more HTML expressions to a document in the specified window. +@param content Specifies the text and HTML tags to write. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/write) +*/ +@send +external write: (Types.document, string) => unit = "write" + +/** +Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. +@param content The text and HTML tags to write. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/writeln) +*/ +@send +external writeln: (Types.document, string) => unit = "writeln" + +/** +Gets a value indicating whether the object currently has focus. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/hasFocus) +*/ +@send +external hasFocus: Types.document => bool = "hasFocus" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/exitPictureInPicture) +*/ +@send +external exitPictureInPicture: Types.document => promise = "exitPictureInPicture" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/exitPointerLock) +*/ +@send +external exitPointerLock: Types.document => unit = "exitPointerLock" + +/** +Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getSelection) +*/ +@send +external getSelection: Types.document => null = "getSelection" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/hasStorageAccess) +*/ +@send +external hasStorageAccess: Types.document => promise = "hasStorageAccess" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/requestStorageAccess) +*/ +@send +external requestStorageAccess: Types.document => promise = "requestStorageAccess" + +let isInstanceOf = (_: 't): bool => %raw(`param instanceof Document`) diff --git a/src/DOMAPI/DocumentFragment.res b/packages/DOM/src/DocumentFragment.res similarity index 81% rename from src/DOMAPI/DocumentFragment.res rename to packages/DOM/src/DocumentFragment.res index 297fc6fd..c210a4a4 100644 --- a/src/DOMAPI/DocumentFragment.res +++ b/packages/DOM/src/DocumentFragment.res @@ -1,10 +1,8 @@ -open DOMAPI - /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragmentFragment) */ @new -external make: unit => documentFragment = "DocumentFragment" +external make: unit => Types.documentFragment = "DocumentFragment" module Impl = ( T: { @@ -13,7 +11,7 @@ module Impl = ( ) => { include Node.Impl({type t = T.t}) - external asDocumentFragment: T.t => documentFragment = "%identity" + external asDocumentFragment: T.t => Types.documentFragment = "%identity" /** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. @@ -22,7 +20,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/append) */ @send - external append: (T.t, node) => unit = "append" + external append: (T.t, Types.node) => unit = "append" /** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. @@ -38,7 +36,7 @@ Returns the first element within node's descendants whose ID is elementId. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/getElementById) */ @send - external getElementById: (T.t, string) => null = "getElementById" + external getElementById: (T.t, string) => null = "getElementById" /** Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. @@ -47,7 +45,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/prepend) */ @send - external prepend: (T.t, node) => unit = "prepend" + external prepend: (T.t, Types.node) => unit = "prepend" /** Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. @@ -63,14 +61,14 @@ Returns the first element that is a descendant of node that matches selectors. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/querySelector) */ @send - external querySelector: (T.t, string) => Null.t = "querySelector" + external querySelector: (T.t, string) => Null.t = "querySelector" /** Returns all element descendants of node that match selectors. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/querySelectorAll) */ @send - external querySelectorAll: (T.t, string) => nodeList = "querySelectorAll" + external querySelectorAll: (T.t, string) => Types.nodeList = "querySelectorAll" /** Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. @@ -79,7 +77,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentFragment/replaceChildren) */ @send - external replaceChildren: (T.t, node) => unit = "replaceChildren" + external replaceChildren: (T.t, Types.node) => unit = "replaceChildren" /** Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. @@ -91,4 +89,4 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre external replaceChildren2: (T.t, string) => unit = "replaceChildren" } -include Impl({type t = documentFragment}) +include Impl({type t = Types.documentFragment}) diff --git a/packages/DOM/src/DocumentTimeline.res b/packages/DOM/src/DocumentTimeline.res new file mode 100644 index 00000000..441b1558 --- /dev/null +++ b/packages/DOM/src/DocumentTimeline.res @@ -0,0 +1,8 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DocumentTimeline) +*/ +@new +external make: (~options: Types.documentTimelineOptions=?) => Types.documentTimeline = + "DocumentTimeline" + +external asAnimationTimeline: Types.documentTimeline => Types.animationTimeline = "%identity" diff --git a/src/DOMAPI/Element.res b/packages/DOM/src/Element.res similarity index 82% rename from src/DOMAPI/Element.res rename to packages/DOM/src/Element.res index 179e6132..4e78e339 100644 --- a/src/DOMAPI/Element.res +++ b/packages/DOM/src/Element.res @@ -1,6 +1,3 @@ -open DOMAPI -open Prelude - module Impl = ( T: { type t @@ -8,7 +5,7 @@ module Impl = ( ) => { include Node.Impl({type t = T.t}) - external asElement: T.t => element = "%identity" + external asElement: T.t => Types.element = "%identity" /** Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. @@ -17,7 +14,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/after) */ @send - external after: (T.t, node) => unit = "after" + external after: (T.t, Types.node) => unit = "after" /** Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. @@ -32,14 +29,17 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/animate) */ @send - external animate: (T.t, ~keyframes: any, ~options: float=?) => animation = "animate" + external animate: (T.t, ~keyframes: unknown, ~options: float=?) => Types.animation = "animate" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/animate) */ @send - external animate2: (T.t, ~keyframes: any, ~options: keyframeAnimationOptions=?) => animation = - "animate" + external animate2: ( + T.t, + ~keyframes: unknown, + ~options: Types.keyframeAnimationOptions=?, + ) => Types.animation = "animate" /** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. @@ -48,7 +48,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/append) */ @send - external append: (T.t, node) => unit = "append" + external append: (T.t, Types.node) => unit = "append" /** Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. @@ -64,7 +64,7 @@ Creates a shadow root for element and returns it. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/attachShadow) */ @send - external attachShadow: (T.t, shadowRootInit) => shadowRoot = "attachShadow" + external attachShadow: (T.t, Types.shadowRootInit) => Types.shadowRoot = "attachShadow" /** Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. @@ -73,7 +73,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/before) */ @send - external before: (T.t, node) => unit = "before" + external before: (T.t, Types.node) => unit = "before" /** Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. @@ -88,7 +88,8 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/checkVisibility) */ @send - external checkVisibility: (T.t, ~options: checkVisibilityOptions=?) => bool = "checkVisibility" + external checkVisibility: (T.t, ~options: Types.checkVisibilityOptions=?) => bool = + "checkVisibility" /** Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. @@ -101,13 +102,13 @@ Returns the first (starting at element) inclusive ancestor that matches selector [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/computedStyleMap) */ @send - external computedStyleMap: T.t => stylePropertyMapReadOnly = "computedStyleMap" + external computedStyleMap: T.t => Types.stylePropertyMapReadOnly = "computedStyleMap" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getAnimations) */ @send - external getAnimations: (T.t, ~options: getAnimationsOptions=?) => array = + external getAnimations: (T.t, ~options: Types.getAnimationsOptions=?) => array = "getAnimations" /** @@ -128,13 +129,13 @@ Returns the qualified names of all element's attributes. Can contain duplicates. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNode) */ @send - external getAttributeNode: (T.t, string) => attr = "getAttributeNode" + external getAttributeNode: (T.t, string) => Types.attr = "getAttributeNode" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNodeNS) */ @send - external getAttributeNodeNS: (T.t, ~namespace: string, ~localName: string) => attr = + external getAttributeNodeNS: (T.t, ~namespace: string, ~localName: string) => Types.attr = "getAttributeNodeNS" /** @@ -149,43 +150,44 @@ Returns element's attribute whose namespace is namespace and local name is local [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect) */ @send - external getBoundingClientRect: T.t => domRect = "getBoundingClientRect" + external getBoundingClientRect: T.t => Types.domRect = "getBoundingClientRect" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getClientRects) */ @send - external getClientRects: T.t => domRectList = "getClientRects" + external getClientRects: T.t => Types.domRectList = "getClientRects" /** Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getElementsByClassName) */ @send - external getElementsByClassName: (T.t, string) => htmlCollection = + external getElementsByClassName: (T.t, string) => Types.htmlCollection = "getElementsByClassName" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagName) */ @send - external getElementsByTagName: (T.t, string) => htmlCollection = "getElementsByTagName" + external getElementsByTagName: (T.t, string) => Types.htmlCollection = + "getElementsByTagName" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS) */ @send external getElementsByTagNameNS: ( - element, + Types.element, ~namespace: string, ~localName: string, - ) => htmlCollection = "getElementsByTagNameNS" + ) => Types.htmlCollection = "getElementsByTagNameNS" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getHTML) */ @send - external getHTML: (T.t, ~options: getHTMLOptions=?) => string = "getHTML" + external getHTML: (T.t, ~options: Types.getHTMLOptions=?) => string = "getHTML" /** Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. @@ -218,21 +220,24 @@ Returns true if element has attributes, and false otherwise. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentElement) */ @send - external insertAdjacentElement: (T.t, ~where: insertPosition, ~element: element) => element = - "insertAdjacentElement" + external insertAdjacentElement: ( + T.t, + ~where: Types.insertPosition, + ~element: Types.element, + ) => Types.element = "insertAdjacentElement" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentHTML) */ @send - external insertAdjacentHTML: (T.t, ~position: insertPosition, ~string: string) => unit = + external insertAdjacentHTML: (T.t, ~position: Types.insertPosition, ~string: string) => unit = "insertAdjacentHTML" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/insertAdjacentText) */ @send - external insertAdjacentText: (T.t, ~where: insertPosition, ~data: string) => unit = + external insertAdjacentText: (T.t, ~where: Types.insertPosition, ~data: string) => unit = "insertAdjacentText" /** @@ -249,7 +254,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/prepend) */ @send - external prepend: (T.t, node) => unit = "prepend" + external prepend: (T.t, Types.node) => unit = "prepend" /** Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. @@ -265,14 +270,14 @@ Returns the first element that is a descendant of node that matches selectors. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelector) */ @send - external querySelector: (T.t, string) => Null.t = "querySelector" + external querySelector: (T.t, string) => Null.t = "querySelector" /** Returns all element descendants of node that match selectors. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/querySelectorAll) */ @send - external querySelectorAll: (T.t, string) => nodeList = "querySelectorAll" + external querySelectorAll: (T.t, string) => Types.nodeList = "querySelectorAll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/releasePointerCapture) @@ -298,7 +303,7 @@ Removes element's first attribute whose qualified name is qualifiedName. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNode) */ @send - external removeAttributeNode: (T.t, attr) => attr = "removeAttributeNode" + external removeAttributeNode: (T.t, Types.attr) => Types.attr = "removeAttributeNode" /** Removes element's attribute whose namespace is namespace and local name is localName. @@ -315,7 +320,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/replaceChildren) */ @send - external replaceChildren: (T.t, node) => unit = "replaceChildren" + external replaceChildren: (T.t, Types.node) => unit = "replaceChildren" /** Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes. @@ -333,7 +338,7 @@ Throws a "HierarchyRequestError" DOMException if the constraints of the node tre [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceWith) */ @send - external replaceWith: (T.t, node) => unit = "replaceWith" + external replaceWith: (T.t, Types.node) => unit = "replaceWith" /** Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes. @@ -351,21 +356,21 @@ When supplied, options's navigationUI member indicates whether showing navigatio [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/requestFullscreen) */ @send - external requestFullscreen: (T.t, ~options: fullscreenOptions=?) => promise = + external requestFullscreen: (T.t, ~options: Types.fullscreenOptions=?) => promise = "requestFullscreen" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/requestPointerLock) */ @send - external requestPointerLock: (T.t, ~options: pointerLockOptions=?) => promise = + external requestPointerLock: (T.t, ~options: Types.pointerLockOptions=?) => promise = "requestPointerLock" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scroll) */ @send - external scroll: (T.t, ~options: scrollToOptions=?) => unit = "scroll" + external scroll: (T.t, ~options: Types.scrollToOptions=?) => unit = "scroll" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scroll) @@ -377,7 +382,7 @@ When supplied, options's navigationUI member indicates whether showing navigatio [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollBy) */ @send - external scrollBy: (T.t, ~options: scrollToOptions=?) => unit = "scrollBy" + external scrollBy: (T.t, ~options: Types.scrollToOptions=?) => unit = "scrollBy" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollBy) @@ -425,13 +430,13 @@ element->Element.scrollIntoViewWithOptions({ behavior: DOMAPI.Smooth }) [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollIntoView) */ @send - external scrollIntoViewWithOptions: (T.t, scrollIntoViewOptions) => unit = "scrollIntoView" + external scrollIntoViewWithOptions: (T.t, Types.scrollIntoViewOptions) => unit = "scrollIntoView" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollTo) */ @send - external scrollTo: (T.t, ~options: scrollToOptions=?) => unit = "scrollTo" + external scrollTo: (T.t, ~options: Types.scrollToOptions=?) => unit = "scrollTo" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/scrollTo) @@ -450,13 +455,13 @@ Sets the value of element's first attribute whose qualified name is qualifiedNam [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNode) */ @send - external setAttributeNode: (T.t, attr) => attr = "setAttributeNode" + external setAttributeNode: (T.t, Types.attr) => Types.attr = "setAttributeNode" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNodeNS) */ @send - external setAttributeNodeNS: (T.t, attr) => attr = "setAttributeNodeNS" + external setAttributeNodeNS: (T.t, Types.attr) => Types.attr = "setAttributeNodeNS" /** Sets the value of element's attribute whose namespace is namespace and local name is localName to value. @@ -464,7 +469,7 @@ Sets the value of element's attribute whose namespace is namespace and local nam */ @send external setAttributeNS: ( - element, + Types.element, ~namespace: string, ~qualifiedName: string, ~value: string, @@ -493,6 +498,6 @@ Returns true if qualifiedName is now present, and false otherwise. "toggleAttribute" } -include Impl({type t = element}) +include Impl({type t = Types.element}) let isInstanceOf = (_: 't): bool => %raw(`param instanceof Element`) diff --git a/src/DOMAPI/ElementInternals.res b/packages/DOM/src/ElementInternals.res similarity index 80% rename from src/DOMAPI/ElementInternals.res rename to packages/DOM/src/ElementInternals.res index f873a2e7..d5dfbcd7 100644 --- a/src/DOMAPI/ElementInternals.res +++ b/packages/DOM/src/ElementInternals.res @@ -1,5 +1,3 @@ -open DOMAPI - /** Sets both the state and submission value of internals's target element to value. @@ -7,7 +5,7 @@ If value is null, the element won't participate in form submission. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ElementInternals/setFormValue) */ @send -external setFormValue: (elementInternals, ~value: unknown, ~state: unknown=?) => unit = +external setFormValue: (Types.elementInternals, ~value: unknown, ~state: unknown=?) => unit = "setFormValue" /** @@ -16,10 +14,10 @@ Marks internals's target element as suffering from the constraints indicated by */ @send external setValidity: ( - elementInternals, - ~flags: validityStateFlags=?, + Types.elementInternals, + ~flags: Types.validityStateFlags=?, ~message: string=?, - ~anchor: htmlElement=?, + ~anchor: Types.htmlElement=?, ) => unit = "setValidity" /** @@ -27,11 +25,11 @@ Returns true if internals's target element has no validity problems; false other [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ElementInternals/checkValidity) */ @send -external checkValidity: elementInternals => bool = "checkValidity" +external checkValidity: Types.elementInternals => bool = "checkValidity" /** Returns true if internals's target element has no validity problems; otherwise, returns false, fires an invalid event at the element, and (if the event isn't canceled) reports the problem to the user. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/ElementInternals/reportValidity) */ @send -external reportValidity: elementInternals => bool = "reportValidity" +external reportValidity: Types.elementInternals => bool = "reportValidity" diff --git a/packages/DOM/src/FileList.res b/packages/DOM/src/FileList.res new file mode 100644 index 00000000..726e3534 --- /dev/null +++ b/packages/DOM/src/FileList.res @@ -0,0 +1,16 @@ +/** +Returns the `WebApiFile` at the specified index. + +`FileList` is not an array, so you need to iterate manually using `length` and `item`: + +```rescript +let files = [] +for i in 0 to fileList.length - 1 { + files->Array.push(fileList->FileList.item(i)) +} +``` + +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FileList/item) +*/ +@send +external item: (Types.fileList, int) => WebApiFile.Types.file = "item" diff --git a/packages/DOM/src/Global.res b/packages/DOM/src/Global.res new file mode 100644 index 00000000..f66154f6 --- /dev/null +++ b/packages/DOM/src/Global.res @@ -0,0 +1,526 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/window) +*/ +external window: Types.window = "window" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/self) +*/ +external self: Types.window = "self" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/document) +*/ +external document: Types.document = "document" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/name) +*/ +external name: string = "name" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/location) +*/ +external location: Types.location = "location" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/history) +*/ +external history: WebApiHistory.Types.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: Types.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) +*/ +external locationbar: Types.barProp = "locationbar" + +/** +Returns true if the menu bar is visible; otherwise, returns false. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/menubar) +*/ +external menubar: Types.barProp = "menubar" + +/** +Returns true if the personal bar is visible; otherwise, returns false. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/personalbar) +*/ +external personalbar: Types.barProp = "personalbar" + +/** +Returns true if the scrollbars are visible; otherwise, returns false. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollbars) +*/ +external scrollbars: Types.barProp = "scrollbars" + +/** +Returns true if the status bar is visible; otherwise, returns false. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/statusbar) +*/ +external statusbar: Types.barProp = "statusbar" + +/** +Returns true if the toolbar is visible; otherwise, returns false. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/toolbar) +*/ +external toolbar: Types.barProp = "toolbar" + +/** +Returns true if the window has been closed, false otherwise. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/closed) +*/ +external closed: bool = "closed" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/frames) +*/ +external frames: Types.window = "frames" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/length) +*/ +external length: int = "length" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/top) +*/ +external top: Types.window = "top" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/opener) +*/ +external opener: JSON.t = "opener" + +/** +Refers to either the parent WindowProxy, or itself. + +It can rarely be null e.g. for contentWindow of an iframe that is already removed from the parent. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/parent) +*/ +external parent: Types.window = "parent" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/frameElement) +*/ +external frameElement: Types.element = "frameElement" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/navigator) +*/ +external navigator: Types.navigator = "navigator" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screen) +*/ +external screen: Types.screen = "screen" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/visualViewport) +*/ +external visualViewport: WebApiVisualViewport.Types.visualViewport = "visualViewport" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/innerWidth) +*/ +external innerWidth: int = "innerWidth" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/innerHeight) +*/ +external innerHeight: int = "innerHeight" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollX) +*/ +external scrollX: float = "scrollX" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollY) +*/ +external scrollY: float = "scrollY" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screenX) +*/ +external screenX: int = "screenX" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screenLeft) +*/ +external screenLeft: int = "screenLeft" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screenY) +*/ +external screenY: int = "screenY" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/screenTop) +*/ +external screenTop: int = "screenTop" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/outerWidth) +*/ +external outerWidth: int = "outerWidth" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/outerHeight) +*/ +external outerHeight: int = "outerHeight" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/devicePixelRatio) +*/ +external devicePixelRatio: float = "devicePixelRatio" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/speechSynthesis) +*/ +external speechSynthesis: WebApiWebSpeech.Types.speechSynthesis = "speechSynthesis" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/origin) +*/ +external origin: string = "origin" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/isSecureContext) +*/ +external isSecureContext: bool = "isSecureContext" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/crossOriginIsolated) +*/ +external crossOriginIsolated: bool = "crossOriginIsolated" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/indexedDB) +*/ +external indexedDB: WebApiIndexedDB.Types.idbFactory = "indexedDB" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/crypto) +*/ +external crypto: WebApiWebCrypto.Types.crypto = "crypto" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/performance) +*/ +external performance: WebApiPerformance.Types.performance = "performance" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/caches) +*/ +external caches: WebApiWebWorkers.Types.cacheStorage = "caches" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/sessionStorage) +*/ +external sessionStorage: WebApiWebStorage.Types.storage = "sessionStorage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/localStorage) +*/ +external localStorage: WebApiWebStorage.Types.storage = "localStorage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/reportError) +*/ +external reportError: JSON.t => unit = "reportError" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/btoa) +*/ +external btoa: string => string = "btoa" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/atob) +*/ +external atob: string => string = "atob" + +/** +Executes a function after a delay given in milliseconds expires. + +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) +*/ +external setTimeout: (~handler: unit => unit, ~timeout: int=?) => Types.timeoutId = "setTimeout" + +/** +Cancels the execution of a timeout created with setTimeout. + +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) +*/ +external clearTimeout: Types.timeoutId => unit = "clearTimeout" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setInterval) +*/ +external setInterval: (~handler: string, ~timeout: int=?) => int = "setInterval" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setInterval) +*/ +external setInterval2: (~handler: unit => unit, ~timeout: int=?) => int = "setInterval" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) +*/ +external clearInterval: int => unit = "clearInterval" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) +*/ +external queueMicrotask: unit => unit => unit = "queueMicrotask" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) +*/ +external structuredClone: ( + 't, + ~options: WebApiChannelMessaging.Types.structuredSerializeOptions=?, +) => 't = "structuredClone" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame) +*/ +external requestAnimationFrame: (float => unit) => int = "requestAnimationFrame" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/cancelAnimationFrame) +*/ +external cancelAnimationFrame: int => unit = "cancelAnimationFrame" + +/** +Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. + +The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. + +When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. + +When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. + +When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. + +If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted. + +The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) +*/ +external addEventListener: ( + WebApiEvent.Types.eventType, + WebApiEvent.Types.eventListener<'event>, + ~options: WebApiEvent.Types.addEventListenerOptions=?, +) => unit = "addEventListener" + +/** +Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. + +The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. + +When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. + +When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. + +When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. + +If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted. + +The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) +*/ +external addEventListenerWithCapture: ( + WebApiEvent.Types.eventType, + WebApiEvent.Types.eventListener<'event>, + @as(json`true`) _, +) => unit = "addEventListener" + +/** +Removes the event listener in target's event listener list with the same type, callback, and options. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) +*/ +external removeEventListener: ( + WebApiEvent.Types.eventType, + WebApiEvent.Types.eventListener<'event>, + ~options: WebApiEvent.Types.eventListenerOptions=?, +) => unit = "removeEventListener" + +/** +Removes the event listener in target's event listener list with the same type, callback, and options. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) +*/ +external removeEventListenerUseCapture: ( + WebApiEvent.Types.eventType, + WebApiEvent.Types.eventListener<'event>, + @as(json`true`) _, +) => unit = "removeEventListener" + +/** +Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) +*/ +external dispatchEvent: WebApiEvent.Types.event => bool = "dispatchEvent" + +/** +Closes the window. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/close) +*/ +external close: unit => unit = "close" + +/** +Cancels the document load. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/stop) +*/ +external stop: unit => unit = "stop" + +/** +Moves the focus to the window's browsing context, if any. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/focus) +*/ +external focus: unit => unit = "focus" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/open) +*/ +external open_: (~url: string=?, ~target: string=?, ~features: string=?) => Types.window = "open" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/alert) +*/ +external alert: (~message: string=?) => unit = "alert" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/confirm) +*/ +external confirm: (~message: string=?) => bool = "confirm" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/prompt) +*/ +external prompt: (~message: string=?, ~default: string=?) => string = "prompt" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/print) +*/ +external print: unit => unit = "print" + +/** +Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as WebApiFile Blob, FileList, and ArrayBuffer objects. + +Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side. + +A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only. + +If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*". + +Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/postMessage) +*/ +external postMessage: ( + ~message: JSON.t, + ~targetOrigin: string, + ~transfer: array>=?, +) => unit = "postMessage" + +/** +Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as WebApiFile Blob, FileList, and ArrayBuffer objects. + +Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side. + +A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only. + +If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*". + +Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/postMessage) +*/ +external postMessageWithOptions: ( + ~message: JSON.t, + ~options: Types.windowPostMessageOptions=?, +) => unit = "postMessage" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/matchMedia) +*/ +external matchMedia: string => Types.mediaQueryList = "matchMedia" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/moveTo) +*/ +external moveTo: (~x: int, ~y: int) => unit = "moveTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/moveBy) +*/ +external moveBy: (~x: int, ~y: int) => unit = "moveBy" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/resizeTo) +*/ +external resizeTo: (~width: int, ~height: int) => unit = "resizeTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/resizeBy) +*/ +external resizeBy: (~x: int, ~y: int) => unit = "resizeBy" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scroll) +*/ +external scroll: (~options: Types.scrollToOptions=?) => unit = "scroll" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scroll) +*/ +external scroll2: (~x: float, ~y: float) => unit = "scroll" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollTo) +*/ +external scrollTo: (~options: Types.scrollToOptions=?) => unit = "scrollTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollTo) +*/ +external scrollTo2: (~x: float, ~y: float) => unit = "scrollTo" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollBy) +*/ +external scrollBy: (~options: Types.scrollToOptions=?) => unit = "scrollBy" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/scrollBy) +*/ +external scrollBy2: (~x: float, ~y: float) => unit = "scrollBy" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/getComputedStyle) +*/ +external getComputedStyle: ( + ~elt: Types.element, + ~pseudoElt: string=?, +) => Types.cssStyleDeclaration = "getComputedStyle" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/requestIdleCallback) +*/ +external requestIdleCallback: ( + ~callback: Types.idleDeadline => unit, + ~options: Types.idleRequestOptions=?, +) => int = "requestIdleCallback" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/cancelIdleCallback) +*/ +external cancelIdleCallback: int => unit = "cancelIdleCallback" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/getSelection) +*/ +external getSelection: unit => null = "getSelection" diff --git a/packages/DOM/src/HTMLAnchorElement.res b/packages/DOM/src/HTMLAnchorElement.res new file mode 100644 index 00000000..5894994d --- /dev/null +++ b/packages/DOM/src/HTMLAnchorElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlAnchorElement}) diff --git a/packages/DOM/src/HTMLAreaElement.res b/packages/DOM/src/HTMLAreaElement.res new file mode 100644 index 00000000..eefec7c9 --- /dev/null +++ b/packages/DOM/src/HTMLAreaElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlAreaElement}) diff --git a/packages/DOM/src/HTMLAudioElement.res b/packages/DOM/src/HTMLAudioElement.res new file mode 100644 index 00000000..e3774f94 --- /dev/null +++ b/packages/DOM/src/HTMLAudioElement.res @@ -0,0 +1 @@ +include HTMLMediaElement.Impl({type t = Types.htmlAudioElement}) diff --git a/packages/DOM/src/HTMLBRElement.res b/packages/DOM/src/HTMLBRElement.res new file mode 100644 index 00000000..42c5d78a --- /dev/null +++ b/packages/DOM/src/HTMLBRElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlbrElement}) diff --git a/packages/DOM/src/HTMLBaseElement.res b/packages/DOM/src/HTMLBaseElement.res new file mode 100644 index 00000000..5d7a9f07 --- /dev/null +++ b/packages/DOM/src/HTMLBaseElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlBaseElement}) diff --git a/packages/DOM/src/HTMLBodyElement.res b/packages/DOM/src/HTMLBodyElement.res new file mode 100644 index 00000000..953df584 --- /dev/null +++ b/packages/DOM/src/HTMLBodyElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlBodyElement}) diff --git a/packages/DOM/src/HTMLButtonElement.res b/packages/DOM/src/HTMLButtonElement.res new file mode 100644 index 00000000..c7f23ce1 --- /dev/null +++ b/packages/DOM/src/HTMLButtonElement.res @@ -0,0 +1,22 @@ +include HTMLElement.Impl({type t = Types.htmlButtonElement}) + +/** +Returns whether a form will validate when it is submitted, without having to submit it. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLButtonElement/checkValidity) +*/ +@send +external checkValidity: Types.htmlButtonElement => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLButtonElement/reportValidity) +*/ +@send +external reportValidity: Types.htmlButtonElement => bool = "reportValidity" + +/** +Sets a custom error message that is displayed when a form is submitted. +@param error Sets a custom error message that is displayed when a form is submitted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLButtonElement/setCustomValidity) +*/ +@send +external setCustomValidity: (Types.htmlButtonElement, string) => unit = "setCustomValidity" diff --git a/packages/DOM/src/HTMLCollection.res b/packages/DOM/src/HTMLCollection.res new file mode 100644 index 00000000..e85dba03 --- /dev/null +++ b/packages/DOM/src/HTMLCollection.res @@ -0,0 +1,13 @@ +/** +Retrieves an object from various collections. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCollection/item) +*/ +@send +external item: (Types.htmlCollection<'t>, int) => 't = "item" + +/** +Retrieves a select object or an object from an options collection. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem) +*/ +@send +external namedItem: (Types.htmlCollection<'t>, string) => 't = "namedItem" diff --git a/packages/DOM/src/HTMLDListElement.res b/packages/DOM/src/HTMLDListElement.res new file mode 100644 index 00000000..d3fb938e --- /dev/null +++ b/packages/DOM/src/HTMLDListElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmldListElement}) diff --git a/packages/DOM/src/HTMLDataElement.res b/packages/DOM/src/HTMLDataElement.res new file mode 100644 index 00000000..21689c4a --- /dev/null +++ b/packages/DOM/src/HTMLDataElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlDataElement}) diff --git a/packages/DOM/src/HTMLDataListElement.res b/packages/DOM/src/HTMLDataListElement.res new file mode 100644 index 00000000..eab8f211 --- /dev/null +++ b/packages/DOM/src/HTMLDataListElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlDataListElement}) diff --git a/packages/DOM/src/HTMLDialogElement.res b/packages/DOM/src/HTMLDialogElement.res new file mode 100644 index 00000000..53238793 --- /dev/null +++ b/packages/DOM/src/HTMLDialogElement.res @@ -0,0 +1,23 @@ +include HTMLElement.Impl({type t = Types.htmlDialogElement}) + +/** +Displays the dialog element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/show) +*/ +@send +external show: Types.htmlDialogElement => unit = "show" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/showModal) +*/ +@send +external showModal: Types.htmlDialogElement => unit = "showModal" + +/** +Closes the dialog element. + +The argument, if provided, provides a return value. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLDialogElement/close) +*/ +@send +external close: (Types.htmlDialogElement, ~returnValue: string=?) => unit = "close" diff --git a/packages/DOM/src/HTMLDivElement.res b/packages/DOM/src/HTMLDivElement.res new file mode 100644 index 00000000..77f61667 --- /dev/null +++ b/packages/DOM/src/HTMLDivElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlDivElement}) diff --git a/src/DOMAPI/HTMLElement.res b/packages/DOM/src/HTMLElement.res similarity index 80% rename from src/DOMAPI/HTMLElement.res rename to packages/DOM/src/HTMLElement.res index 08c18904..2a4a1e96 100644 --- a/src/DOMAPI/HTMLElement.res +++ b/packages/DOM/src/HTMLElement.res @@ -1,4 +1,4 @@ -open DOMAPI +type t = Types.htmlElement module Impl = ( T: { @@ -7,13 +7,13 @@ module Impl = ( ) => { include Element.Impl({type t = T.t}) - external asHTMLElement: T.t => htmlElement = "%identity" + external asHTMLElement: T.t => t = "%identity" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/attachInternals) */ @send - external attachInternals: T.t => elementInternals = "attachInternals" + external attachInternals: T.t => Types.elementInternals = "attachInternals" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/blur) @@ -31,7 +31,7 @@ module Impl = ( [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/focus) */ @send - external focus: (T.t, ~options: focusOptions=?) => unit = "focus" + external focus: (T.t, ~options: Types.focusOptions=?) => unit = "focus" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLElement/hidePopover) @@ -52,4 +52,4 @@ module Impl = ( external togglePopover: (T.t, ~force: bool=?) => bool = "togglePopover" } -include Impl({type t = htmlElement}) +include Impl({type t = t}) diff --git a/packages/DOM/src/HTMLEmbedElement.res b/packages/DOM/src/HTMLEmbedElement.res new file mode 100644 index 00000000..7c269908 --- /dev/null +++ b/packages/DOM/src/HTMLEmbedElement.res @@ -0,0 +1,4 @@ +include HTMLElement.Impl({type t = Types.htmlEmbedElement}) + +@send +external getSVGDocument: Types.htmlEmbedElement => Types.document = "getSVGDocument" diff --git a/packages/DOM/src/HTMLFieldSetElement.res b/packages/DOM/src/HTMLFieldSetElement.res new file mode 100644 index 00000000..c9e34dde --- /dev/null +++ b/packages/DOM/src/HTMLFieldSetElement.res @@ -0,0 +1,22 @@ +include HTMLElement.Impl({type t = Types.htmlFieldSetElement}) + +/** +Returns whether a form will validate when it is submitted, without having to submit it. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFieldSetElement/checkValidity) +*/ +@send +external checkValidity: Types.htmlFieldSetElement => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFieldSetElement/reportValidity) +*/ +@send +external reportValidity: Types.htmlFieldSetElement => bool = "reportValidity" + +/** +Sets a custom error message that is displayed when a form is submitted. +@param error Sets a custom error message that is displayed when a form is submitted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFieldSetElement/setCustomValidity) +*/ +@send +external setCustomValidity: (Types.htmlFieldSetElement, string) => unit = "setCustomValidity" diff --git a/packages/DOM/src/HTMLFormControlsCollection.res b/packages/DOM/src/HTMLFormControlsCollection.res new file mode 100644 index 00000000..f347bc51 --- /dev/null +++ b/packages/DOM/src/HTMLFormControlsCollection.res @@ -0,0 +1,15 @@ +external asHTMLCollection: Types.htmlFormControlsCollection => Types.htmlCollection = + "%identity" +/** +Retrieves an object from various collections. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCollection/item) +*/ +@send +external item: (Types.htmlFormControlsCollection, int) => Types.element = "item" + +/** +Retrieves a select object or an object from an options collection. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCollection/namedItem) +*/ +@send +external namedItem: (Types.htmlFormControlsCollection, string) => Types.element = "namedItem" diff --git a/packages/DOM/src/HTMLFormElement.res b/packages/DOM/src/HTMLFormElement.res new file mode 100644 index 00000000..1219aceb --- /dev/null +++ b/packages/DOM/src/HTMLFormElement.res @@ -0,0 +1,36 @@ +type t = Types.htmlFormElement + +include HTMLElement.Impl({type t = t}) + +/** +Fires when a FORM is about to be submitted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/submit) +*/ +@send +external submit: t => unit = "submit" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/requestSubmit) +*/ +@send +external requestSubmit: (t, ~submitter: WebApiDOM.HTMLElement.t=?) => unit = "requestSubmit" + +/** +Fires when the user resets a form. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reset) +*/ +@send +external reset: t => unit = "reset" + +/** +Returns whether a form will validate when it is submitted, without having to submit it. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/checkValidity) +*/ +@send +external checkValidity: t => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/reportValidity) +*/ +@send +external reportValidity: t => bool = "reportValidity" diff --git a/packages/DOM/src/HTMLFrameSetElement.res b/packages/DOM/src/HTMLFrameSetElement.res new file mode 100644 index 00000000..aed6c7e7 --- /dev/null +++ b/packages/DOM/src/HTMLFrameSetElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlFrameSetElement}) diff --git a/packages/DOM/src/HTMLHRElement.res b/packages/DOM/src/HTMLHRElement.res new file mode 100644 index 00000000..856fcc3c --- /dev/null +++ b/packages/DOM/src/HTMLHRElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlhrElement}) diff --git a/packages/DOM/src/HTMLHeadElement.res b/packages/DOM/src/HTMLHeadElement.res new file mode 100644 index 00000000..45124481 --- /dev/null +++ b/packages/DOM/src/HTMLHeadElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlHeadElement}) diff --git a/packages/DOM/src/HTMLHeadingElement.res b/packages/DOM/src/HTMLHeadingElement.res new file mode 100644 index 00000000..7f896e63 --- /dev/null +++ b/packages/DOM/src/HTMLHeadingElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlHeadingElement}) diff --git a/packages/DOM/src/HTMLHtmlElement.res b/packages/DOM/src/HTMLHtmlElement.res new file mode 100644 index 00000000..0e760954 --- /dev/null +++ b/packages/DOM/src/HTMLHtmlElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlHtmlElement}) diff --git a/packages/DOM/src/HTMLIFrameElement.res b/packages/DOM/src/HTMLIFrameElement.res new file mode 100644 index 00000000..637d2bd9 --- /dev/null +++ b/packages/DOM/src/HTMLIFrameElement.res @@ -0,0 +1,4 @@ +include HTMLElement.Impl({type t = Types.htmliFrameElement}) + +@send +external getSVGDocument: Types.htmliFrameElement => Types.document = "getSVGDocument" diff --git a/packages/DOM/src/HTMLImageElement.res b/packages/DOM/src/HTMLImageElement.res new file mode 100644 index 00000000..64979a5d --- /dev/null +++ b/packages/DOM/src/HTMLImageElement.res @@ -0,0 +1,7 @@ +include HTMLElement.Impl({type t = Types.htmlImageElement}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLImageElement/decode) +*/ +@send +external decode: Types.htmlImageElement => promise = "decode" diff --git a/src/DOMAPI/HTMLInputElement.res b/packages/DOM/src/HTMLInputElement.res similarity index 75% rename from src/DOMAPI/HTMLInputElement.res rename to packages/DOM/src/HTMLInputElement.res index c538847a..13d16fab 100644 --- a/src/DOMAPI/HTMLInputElement.res +++ b/packages/DOM/src/HTMLInputElement.res @@ -1,6 +1,4 @@ -open DOMAPI - -include HTMLElement.Impl({type t = htmlInputElement}) +include HTMLElement.Impl({type t = Types.htmlInputElement}) /** Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. @@ -8,7 +6,7 @@ Increments a range input control's value by the value given by the Step attribut [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/stepUp) */ @send -external stepUp: (htmlInputElement, ~n: int=?) => unit = "stepUp" +external stepUp: (Types.htmlInputElement, ~n: int=?) => unit = "stepUp" /** Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. @@ -16,20 +14,20 @@ Decrements a range input control's value by the value given by the Step attribut [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/stepDown) */ @send -external stepDown: (htmlInputElement, ~n: int=?) => unit = "stepDown" +external stepDown: (Types.htmlInputElement, ~n: int=?) => unit = "stepDown" /** Returns whether a form will validate when it is submitted, without having to submit it. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/checkValidity) */ @send -external checkValidity: htmlInputElement => bool = "checkValidity" +external checkValidity: Types.htmlInputElement => bool = "checkValidity" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/reportValidity) */ @send -external reportValidity: htmlInputElement => bool = "reportValidity" +external reportValidity: Types.htmlInputElement => bool = "reportValidity" /** Sets a custom error message that is displayed when a form is submitted. @@ -37,31 +35,31 @@ Sets a custom error message that is displayed when a form is submitted. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setCustomValidity) */ @send -external setCustomValidity: (htmlInputElement, string) => unit = "setCustomValidity" +external setCustomValidity: (Types.htmlInputElement, string) => unit = "setCustomValidity" /** Makes the selection equal to the current object. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/select) */ @send -external select: htmlInputElement => unit = "select" +external select: Types.htmlInputElement => unit = "select" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setRangeText) */ @send -external setRangeText: (htmlInputElement, string) => unit = "setRangeText" +external setRangeText: (Types.htmlInputElement, string) => unit = "setRangeText" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setRangeText) */ @send external setRangeText2: ( - htmlInputElement, + Types.htmlInputElement, ~replacement: string, ~start: int, ~end: int, - ~selectionMode: selectionMode=?, + ~selectionMode: Types.selectionMode=?, ) => unit = "setRangeText" /** @@ -73,7 +71,7 @@ Sets the start and end positions of a selection in a text field. */ @send external setSelectionRange: ( - htmlInputElement, + Types.htmlInputElement, ~start: int, ~end: int, ~direction: string=?, @@ -83,4 +81,4 @@ external setSelectionRange: ( [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/showPicker) */ @send -external showPicker: htmlInputElement => unit = "showPicker" +external showPicker: Types.htmlInputElement => unit = "showPicker" diff --git a/packages/DOM/src/HTMLLIElement.res b/packages/DOM/src/HTMLLIElement.res new file mode 100644 index 00000000..cbf76f46 --- /dev/null +++ b/packages/DOM/src/HTMLLIElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlliElement}) diff --git a/packages/DOM/src/HTMLLabelElement.res b/packages/DOM/src/HTMLLabelElement.res new file mode 100644 index 00000000..9b02a020 --- /dev/null +++ b/packages/DOM/src/HTMLLabelElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlLabelElement}) diff --git a/packages/DOM/src/HTMLLegendElement.res b/packages/DOM/src/HTMLLegendElement.res new file mode 100644 index 00000000..aa727c73 --- /dev/null +++ b/packages/DOM/src/HTMLLegendElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlLegendElement}) diff --git a/packages/DOM/src/HTMLLinkElement.res b/packages/DOM/src/HTMLLinkElement.res new file mode 100644 index 00000000..6ed981b7 --- /dev/null +++ b/packages/DOM/src/HTMLLinkElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlLinkElement}) diff --git a/packages/DOM/src/HTMLMapElement.res b/packages/DOM/src/HTMLMapElement.res new file mode 100644 index 00000000..ec7c9f7c --- /dev/null +++ b/packages/DOM/src/HTMLMapElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlMapElement}) diff --git a/packages/DOM/src/HTMLMediaElement.res b/packages/DOM/src/HTMLMediaElement.res new file mode 100644 index 00000000..4cbb56ad --- /dev/null +++ b/packages/DOM/src/HTMLMediaElement.res @@ -0,0 +1,62 @@ +module Impl = ( + T: { + type t + }, +) => { + include HTMLElement.Impl({type t = Types.htmlMediaElement}) + + external asHTMLMediaElement: T.t => Types.htmlMediaElement = "%identity" + + /** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/addTextTrack) +*/ + @send + external addTextTrack: ( + T.t, + ~kind: WebApiWebVTT.Types.textTrackKind, + ~label: string=?, + ~language: string=?, + ) => WebApiWebVTT.Types.textTrack = "addTextTrack" + + /** +Returns a string that specifies whether the client can play a given media resource type. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/canPlayType) +*/ + @send + external canPlayType: (T.t, string) => Types.canPlayTypeResult = "canPlayType" + + /** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/fastSeek) +*/ + @send + external fastSeek: (T.t, float) => unit = "fastSeek" + + /** +Resets the audio or video object and loads a new media resource. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/load) +*/ + @send + external load: T.t => unit = "load" + + /** +Pauses the current playback and sets paused to TRUE. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/pause) +*/ + @send + external pause: T.t => unit = "pause" + + /** +Loads and starts playback of a media resource. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/play) +*/ + @send + external play: T.t => promise = "play" + + /** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/setSinkId) +*/ + @send + external setSinkId: (T.t, string) => promise = "setSinkId" +} + +include Impl({type t = Types.htmlMediaElement}) diff --git a/packages/DOM/src/HTMLMenuElement.res b/packages/DOM/src/HTMLMenuElement.res new file mode 100644 index 00000000..1015ce32 --- /dev/null +++ b/packages/DOM/src/HTMLMenuElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlMenuElement}) diff --git a/packages/DOM/src/HTMLMetaElement.res b/packages/DOM/src/HTMLMetaElement.res new file mode 100644 index 00000000..883342d3 --- /dev/null +++ b/packages/DOM/src/HTMLMetaElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlMetaElement}) diff --git a/packages/DOM/src/HTMLMeterElement.res b/packages/DOM/src/HTMLMeterElement.res new file mode 100644 index 00000000..8d3ba7b9 --- /dev/null +++ b/packages/DOM/src/HTMLMeterElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlMeterElement}) diff --git a/packages/DOM/src/HTMLModElement.res b/packages/DOM/src/HTMLModElement.res new file mode 100644 index 00000000..a337135a --- /dev/null +++ b/packages/DOM/src/HTMLModElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlModElement}) diff --git a/packages/DOM/src/HTMLOListElement.res b/packages/DOM/src/HTMLOListElement.res new file mode 100644 index 00000000..4aeac356 --- /dev/null +++ b/packages/DOM/src/HTMLOListElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmloListElement}) diff --git a/packages/DOM/src/HTMLObjectElement.res b/packages/DOM/src/HTMLObjectElement.res new file mode 100644 index 00000000..80f121e9 --- /dev/null +++ b/packages/DOM/src/HTMLObjectElement.res @@ -0,0 +1,25 @@ +include HTMLElement.Impl({type t = Types.htmlObjectElement}) + +@send +external getSVGDocument: Types.htmlObjectElement => Types.document = "getSVGDocument" + +/** +Returns whether a form will validate when it is submitted, without having to submit it. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLObjectElement/checkValidity) +*/ +@send +external checkValidity: Types.htmlObjectElement => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLObjectElement/reportValidity) +*/ +@send +external reportValidity: Types.htmlObjectElement => bool = "reportValidity" + +/** +Sets a custom error message that is displayed when a form is submitted. +@param error Sets a custom error message that is displayed when a form is submitted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLObjectElement/setCustomValidity) +*/ +@send +external setCustomValidity: (Types.htmlObjectElement, string) => unit = "setCustomValidity" diff --git a/packages/DOM/src/HTMLOptGroupElement.res b/packages/DOM/src/HTMLOptGroupElement.res new file mode 100644 index 00000000..3b2b9f20 --- /dev/null +++ b/packages/DOM/src/HTMLOptGroupElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlOptGroupElement}) diff --git a/packages/DOM/src/HTMLOptionElement.res b/packages/DOM/src/HTMLOptionElement.res new file mode 100644 index 00000000..11e2b30f --- /dev/null +++ b/packages/DOM/src/HTMLOptionElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlOptionElement}) diff --git a/src/DOMAPI/HTMLOptionsCollection.res b/packages/DOM/src/HTMLOptionsCollection.res similarity index 75% rename from src/DOMAPI/HTMLOptionsCollection.res rename to packages/DOM/src/HTMLOptionsCollection.res index b4390c9e..ee75d58b 100644 --- a/src/DOMAPI/HTMLOptionsCollection.res +++ b/packages/DOM/src/HTMLOptionsCollection.res @@ -1,7 +1,5 @@ -open DOMAPI - /** -Inserts element before the node given by before. +Inserts element before the Types.node given by before. The before argument can be a number, in which case element is inserted before the item with that number, or an element from the collection, in which case element is inserted before that element. @@ -11,11 +9,11 @@ This method will throw a "HierarchyRequestError" DOMException if element is an a [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/add) */ @send -external add: (htmlOptionsCollection, ~element: unknown, ~before: unknown=?) => unit = "add" +external add: (Types.htmlOptionsCollection, ~element: unknown, ~before: unknown=?) => unit = "add" /** Removes the item with index index from the collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLOptionsCollection/remove) */ @send -external remove: (htmlOptionsCollection, int) => unit = "remove" +external remove: (Types.htmlOptionsCollection, int) => unit = "remove" diff --git a/packages/DOM/src/HTMLOutputElement.res b/packages/DOM/src/HTMLOutputElement.res new file mode 100644 index 00000000..16aa2d59 --- /dev/null +++ b/packages/DOM/src/HTMLOutputElement.res @@ -0,0 +1,19 @@ +include HTMLElement.Impl({type t = Types.htmlOutputElement}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLOutputElement/checkValidity) +*/ +@send +external checkValidity: Types.htmlOutputElement => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLOutputElement/reportValidity) +*/ +@send +external reportValidity: Types.htmlOutputElement => bool = "reportValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLOutputElement/setCustomValidity) +*/ +@send +external setCustomValidity: (Types.htmlOutputElement, string) => unit = "setCustomValidity" diff --git a/packages/DOM/src/HTMLParagraphElement.res b/packages/DOM/src/HTMLParagraphElement.res new file mode 100644 index 00000000..e22f47a5 --- /dev/null +++ b/packages/DOM/src/HTMLParagraphElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlParagraphElement}) diff --git a/packages/DOM/src/HTMLPictureElement.res b/packages/DOM/src/HTMLPictureElement.res new file mode 100644 index 00000000..2d245073 --- /dev/null +++ b/packages/DOM/src/HTMLPictureElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlPictureElement}) diff --git a/packages/DOM/src/HTMLPreElement.res b/packages/DOM/src/HTMLPreElement.res new file mode 100644 index 00000000..13ca9cba --- /dev/null +++ b/packages/DOM/src/HTMLPreElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlPreElement}) diff --git a/packages/DOM/src/HTMLProgressElement.res b/packages/DOM/src/HTMLProgressElement.res new file mode 100644 index 00000000..d434c5f4 --- /dev/null +++ b/packages/DOM/src/HTMLProgressElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlProgressElement}) diff --git a/packages/DOM/src/HTMLQuoteElement.res b/packages/DOM/src/HTMLQuoteElement.res new file mode 100644 index 00000000..5a66af0a --- /dev/null +++ b/packages/DOM/src/HTMLQuoteElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlQuoteElement}) diff --git a/packages/DOM/src/HTMLScriptElement.res b/packages/DOM/src/HTMLScriptElement.res new file mode 100644 index 00000000..e71cb1f4 --- /dev/null +++ b/packages/DOM/src/HTMLScriptElement.res @@ -0,0 +1,7 @@ +include HTMLElement.Impl({type t = Types.htmlScriptElement}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLScriptElement/supports_static) +*/ +@scope("HTMLScriptElement") +external supports: string => bool = "supports" diff --git a/src/DOMAPI/HTMLSelectElement.res b/packages/DOM/src/HTMLSelectElement.res similarity index 77% rename from src/DOMAPI/HTMLSelectElement.res rename to packages/DOM/src/HTMLSelectElement.res index 8e05f4be..58f39d49 100644 --- a/src/DOMAPI/HTMLSelectElement.res +++ b/packages/DOM/src/HTMLSelectElement.res @@ -1,5 +1,3 @@ -open DOMAPI - /** Retrieves a select object or an object from an options collection. @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. @@ -7,7 +5,7 @@ Retrieves a select object or an object from an options collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/item) */ @send -external item: (htmlSelectElement, int) => htmlOptionElement = "item" +external item: (Types.htmlSelectElement, int) => Types.htmlOptionElement = "item" /** Retrieves a select object or an object from an options collection. @@ -15,7 +13,7 @@ Retrieves a select object or an object from an options collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/namedItem) */ @send -external namedItem: (htmlSelectElement, string) => htmlOptionElement = "namedItem" +external namedItem: (Types.htmlSelectElement, string) => Types.htmlOptionElement = "namedItem" /** Adds an element to the areas, controlRange, or options collection. @@ -24,7 +22,7 @@ Adds an element to the areas, controlRange, or options collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/add) */ @send -external add: (htmlSelectElement, ~element: unknown, ~before: unknown=?) => unit = "add" +external add: (Types.htmlSelectElement, ~element: unknown, ~before: unknown=?) => unit = "add" /** Removes an element from the collection. @@ -32,7 +30,7 @@ Removes an element from the collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/remove) */ @send -external removeH: htmlSelectElement => unit = "remove" +external removeH: Types.htmlSelectElement => unit = "remove" /** Removes an element from the collection. @@ -40,20 +38,20 @@ Removes an element from the collection. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/remove) */ @send -external removeH2: (htmlSelectElement, int) => unit = "remove" +external removeH2: (Types.htmlSelectElement, int) => unit = "remove" /** Returns whether a form will validate when it is submitted, without having to submit it. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/checkValidity) */ @send -external checkValidity: htmlSelectElement => bool = "checkValidity" +external checkValidity: Types.htmlSelectElement => bool = "checkValidity" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/reportValidity) */ @send -external reportValidity: htmlSelectElement => bool = "reportValidity" +external reportValidity: Types.htmlSelectElement => bool = "reportValidity" /** Sets a custom error message that is displayed when a form is submitted. @@ -61,12 +59,12 @@ Sets a custom error message that is displayed when a form is submitted. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/setCustomValidity) */ @send -external setCustomValidity: (htmlSelectElement, string) => unit = "setCustomValidity" +external setCustomValidity: (Types.htmlSelectElement, string) => unit = "setCustomValidity" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/showPicker) */ @send -external showPicker: htmlSelectElement => unit = "showPicker" +external showPicker: Types.htmlSelectElement => unit = "showPicker" -include HTMLElement.Impl({type t = htmlSelectElement}) +include HTMLElement.Impl({type t = Types.htmlSelectElement}) diff --git a/packages/DOM/src/HTMLSlotElement.res b/packages/DOM/src/HTMLSlotElement.res new file mode 100644 index 00000000..76083a6a --- /dev/null +++ b/packages/DOM/src/HTMLSlotElement.res @@ -0,0 +1,31 @@ +include HTMLElement.Impl({type t = Types.htmlSlotElement}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/assignedNodes) +*/ +@send +external assignedNodes: ( + Types.htmlSlotElement, + ~options: Types.assignedNodesOptions=?, +) => array = "assignedNodes" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/assignedElements) +*/ +@send +external assignedElements: ( + Types.htmlSlotElement, + ~options: Types.assignedNodesOptions=?, +) => array = "assignedElements" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/assign) +*/ +@send +external assign: (Types.htmlSlotElement, Types.element) => unit = "assign" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLSlotElement/assign) +*/ +@send +external assign2: (Types.htmlSlotElement, Types.text) => unit = "assign" diff --git a/packages/DOM/src/HTMLSourceElement.res b/packages/DOM/src/HTMLSourceElement.res new file mode 100644 index 00000000..fba7a318 --- /dev/null +++ b/packages/DOM/src/HTMLSourceElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlSourceElement}) diff --git a/packages/DOM/src/HTMLSpanElement.res b/packages/DOM/src/HTMLSpanElement.res new file mode 100644 index 00000000..6653b8ba --- /dev/null +++ b/packages/DOM/src/HTMLSpanElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlSpanElement}) diff --git a/packages/DOM/src/HTMLStyleElement.res b/packages/DOM/src/HTMLStyleElement.res new file mode 100644 index 00000000..71021b40 --- /dev/null +++ b/packages/DOM/src/HTMLStyleElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlStyleElement}) diff --git a/packages/DOM/src/HTMLTableCaptionElement.res b/packages/DOM/src/HTMLTableCaptionElement.res new file mode 100644 index 00000000..a315b6ff --- /dev/null +++ b/packages/DOM/src/HTMLTableCaptionElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTableCaptionElement}) diff --git a/packages/DOM/src/HTMLTableCellElement.res b/packages/DOM/src/HTMLTableCellElement.res new file mode 100644 index 00000000..404cb6e2 --- /dev/null +++ b/packages/DOM/src/HTMLTableCellElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTableCellElement}) diff --git a/packages/DOM/src/HTMLTableElement.res b/packages/DOM/src/HTMLTableElement.res new file mode 100644 index 00000000..9da0d9d3 --- /dev/null +++ b/packages/DOM/src/HTMLTableElement.res @@ -0,0 +1,67 @@ +include HTMLElement.Impl({type t = Types.htmlTableElement}) + +/** +Creates an empty caption element in the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/createCaption) +*/ +@send +external createCaption: Types.htmlTableElement => Types.htmlTableCaptionElement = "createCaption" + +/** +Deletes the caption element and its contents from the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/deleteCaption) +*/ +@send +external deleteCaption: Types.htmlTableElement => unit = "deleteCaption" + +/** +Returns the tHead element object if successful, or null otherwise. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/createTHead) +*/ +@send +external createTHead: Types.htmlTableElement => Types.htmlTableSectionElement = "createTHead" + +/** +Deletes the tHead element and its contents from the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/deleteTHead) +*/ +@send +external deleteTHead: Types.htmlTableElement => unit = "deleteTHead" + +/** +Creates an empty tFoot element in the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/createTFoot) +*/ +@send +external createTFoot: Types.htmlTableElement => Types.htmlTableSectionElement = "createTFoot" + +/** +Deletes the tFoot element and its contents from the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/deleteTFoot) +*/ +@send +external deleteTFoot: Types.htmlTableElement => unit = "deleteTFoot" + +/** +Creates an empty tBody element in the table. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/createTBody) +*/ +@send +external createTBody: Types.htmlTableElement => Types.htmlTableSectionElement = "createTBody" + +/** +Creates a new row (tr) in the table, and adds the row to the rows collection. +@param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/insertRow) +*/ +@send +external insertRow: (Types.htmlTableElement, ~index: int=?) => Types.htmlTableRowElement = + "insertRow" + +/** +Removes the specified row (tr) from the element and from the rows collection. +@param index Number that specifies the zero-based position in the rows collection of the row to remove. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableElement/deleteRow) +*/ +@send +external deleteRow: (Types.htmlTableElement, int) => unit = "deleteRow" diff --git a/packages/DOM/src/HTMLTableRowElement.res b/packages/DOM/src/HTMLTableRowElement.res new file mode 100644 index 00000000..deb5e88c --- /dev/null +++ b/packages/DOM/src/HTMLTableRowElement.res @@ -0,0 +1,18 @@ +include HTMLElement.Impl({type t = Types.htmlTableRowElement}) + +/** +Creates a new cell in the table row, and adds the cell to the cells collection. +@param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableRowElement/insertCell) +*/ +@send +external insertCell: (Types.htmlTableRowElement, ~index: int=?) => Types.htmlTableCellElement = + "insertCell" + +/** +Removes the specified cell from the table row, as well as from the cells collection. +@param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableRowElement/deleteCell) +*/ +@send +external deleteCell: (Types.htmlTableRowElement, int) => unit = "deleteCell" diff --git a/packages/DOM/src/HTMLTableSectionElement.res b/packages/DOM/src/HTMLTableSectionElement.res new file mode 100644 index 00000000..67041ac5 --- /dev/null +++ b/packages/DOM/src/HTMLTableSectionElement.res @@ -0,0 +1,18 @@ +include HTMLElement.Impl({type t = Types.htmlTableSectionElement}) + +/** +Creates a new row (tr) in the table, and adds the row to the rows collection. +@param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableSectionElement/insertRow) +*/ +@send +external insertRow: (Types.htmlTableSectionElement, ~index: int=?) => Types.htmlTableRowElement = + "insertRow" + +/** +Removes the specified row (tr) from the element and from the rows collection. +@param index Number that specifies the zero-based position in the rows collection of the row to remove. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTableSectionElement/deleteRow) +*/ +@send +external deleteRow: (Types.htmlTableSectionElement, int) => unit = "deleteRow" diff --git a/packages/DOM/src/HTMLTemplateElement.res b/packages/DOM/src/HTMLTemplateElement.res new file mode 100644 index 00000000..e62437c7 --- /dev/null +++ b/packages/DOM/src/HTMLTemplateElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTemplateElement}) diff --git a/packages/DOM/src/HTMLTextAreaElement.res b/packages/DOM/src/HTMLTextAreaElement.res new file mode 100644 index 00000000..06f0ff43 --- /dev/null +++ b/packages/DOM/src/HTMLTextAreaElement.res @@ -0,0 +1,62 @@ +include HTMLElement.Impl({type t = Types.htmlTextAreaElement}) + +/** +Returns whether a form will validate when it is submitted, without having to submit it. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/checkValidity) +*/ +@send +external checkValidity: Types.htmlTextAreaElement => bool = "checkValidity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/reportValidity) +*/ +@send +external reportValidity: Types.htmlTextAreaElement => bool = "reportValidity" + +/** +Sets a custom error message that is displayed when a form is submitted. +@param error Sets a custom error message that is displayed when a form is submitted. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/setCustomValidity) +*/ +@send +external setCustomValidity: (Types.htmlTextAreaElement, string) => unit = "setCustomValidity" + +/** +Highlights the input area of a form element. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/select) +*/ +@send +external select: Types.htmlTextAreaElement => unit = "select" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/setRangeText) +*/ +@send +external setRangeText: (Types.htmlTextAreaElement, string) => unit = "setRangeText" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/setRangeText) +*/ +@send +external setRangeText2: ( + Types.htmlTextAreaElement, + ~replacement: string, + ~start: int, + ~end: int, + ~selectionMode: Types.selectionMode=?, +) => unit = "setRangeText" + +/** +Sets the start and end positions of a selection in a text field. +@param start The offset into the text field for the start of the selection. +@param end The offset into the text field for the end of the selection. +@param direction The direction in which the selection is performed. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/setSelectionRange) +*/ +@send +external setSelectionRange: ( + Types.htmlTextAreaElement, + ~start: int, + ~end: int, + ~direction: string=?, +) => unit = "setSelectionRange" diff --git a/packages/DOM/src/HTMLTimeElement.res b/packages/DOM/src/HTMLTimeElement.res new file mode 100644 index 00000000..a7d18248 --- /dev/null +++ b/packages/DOM/src/HTMLTimeElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTimeElement}) diff --git a/packages/DOM/src/HTMLTitleElement.res b/packages/DOM/src/HTMLTitleElement.res new file mode 100644 index 00000000..56ae8e75 --- /dev/null +++ b/packages/DOM/src/HTMLTitleElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTitleElement}) diff --git a/packages/DOM/src/HTMLTrackElement.res b/packages/DOM/src/HTMLTrackElement.res new file mode 100644 index 00000000..eb52ee4f --- /dev/null +++ b/packages/DOM/src/HTMLTrackElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmlTrackElement}) diff --git a/packages/DOM/src/HTMLUListElement.res b/packages/DOM/src/HTMLUListElement.res new file mode 100644 index 00000000..1983a1c7 --- /dev/null +++ b/packages/DOM/src/HTMLUListElement.res @@ -0,0 +1 @@ +include HTMLElement.Impl({type t = Types.htmluListElement}) diff --git a/packages/DOM/src/HTMLVideoElement.res b/packages/DOM/src/HTMLVideoElement.res new file mode 100644 index 00000000..291d0d91 --- /dev/null +++ b/packages/DOM/src/HTMLVideoElement.res @@ -0,0 +1,32 @@ +include HTMLMediaElement.Impl({type t = Types.htmlVideoElement}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/getVideoPlaybackQuality) +*/ +@send +external getVideoPlaybackQuality: Types.htmlVideoElement => Types.videoPlaybackQuality = + "getVideoPlaybackQuality" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/requestPictureInPicture) +*/ +@send +external requestPictureInPicture: Types.htmlVideoElement => promise< + WebApiPictureInPicture.Types.pictureInPictureWindow, +> = "requestPictureInPicture" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/requestVideoFrameCallback) +*/ +@send +external requestVideoFrameCallback: ( + Types.htmlVideoElement, + (float, Types.videoFrameCallbackMetadata) => unit, +) => int = "requestVideoFrameCallback" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement/cancelVideoFrameCallback) +*/ +@send +external cancelVideoFrameCallback: (Types.htmlVideoElement, int) => unit = + "cancelVideoFrameCallback" diff --git a/packages/DOM/src/IdleDeadline.res b/packages/DOM/src/IdleDeadline.res new file mode 100644 index 00000000..fb5f513a --- /dev/null +++ b/packages/DOM/src/IdleDeadline.res @@ -0,0 +1,5 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IdleDeadline/timeRemaining) +*/ +@send +external timeRemaining: Types.idleDeadline => float = "timeRemaining" diff --git a/packages/DOM/src/ImageData.res b/packages/DOM/src/ImageData.res new file mode 100644 index 00000000..192b002e --- /dev/null +++ b/packages/DOM/src/ImageData.res @@ -0,0 +1,17 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageData) +*/ +@new +external make: (~sw: int, ~sh: int, ~settings: Types.imageDataSettings=?) => Types.imageData = + "ImageData" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ImageData) +*/ +@new +external makeWithData: ( + ~data: Uint8ClampedArray.t, + ~sw: int, + ~sh: int=?, + ~settings: Types.imageDataSettings=?, +) => Types.imageData = "ImageData" diff --git a/packages/DOM/src/Location.res b/packages/DOM/src/Location.res new file mode 100644 index 00000000..7ad9c04b --- /dev/null +++ b/packages/DOM/src/Location.res @@ -0,0 +1,20 @@ +/** +Navigates to the given WebApiURL. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/assign) +*/ +@send +external assign: (Types.location, string) => unit = "assign" + +/** +Removes the current page from the session history and navigates to the given WebApiURL. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/replace) +*/ +@send +external replace: (Types.location, string) => unit = "replace" + +/** +Reloads the current page. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Location/reload) +*/ +@send +external reload: Types.location => unit = "reload" diff --git a/packages/DOM/src/MediaList.res b/packages/DOM/src/MediaList.res new file mode 100644 index 00000000..93b88377 --- /dev/null +++ b/packages/DOM/src/MediaList.res @@ -0,0 +1,17 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaList/item) +*/ +@send +external item: (Types.mediaList, int) => string = "item" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaList/appendMedium) +*/ +@send +external appendMedium: (Types.mediaList, string) => unit = "appendMedium" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaList/deleteMedium) +*/ +@send +external deleteMedium: (Types.mediaList, string) => unit = "deleteMedium" diff --git a/packages/DOM/src/MediaQueryList.res b/packages/DOM/src/MediaQueryList.res new file mode 100644 index 00000000..cdea6dc7 --- /dev/null +++ b/packages/DOM/src/MediaQueryList.res @@ -0,0 +1 @@ +include WebApiEvent.EventTarget.Impl({type t = Types.mediaQueryList}) diff --git a/packages/DOM/src/NamedNodeMap.res b/packages/DOM/src/NamedNodeMap.res new file mode 100644 index 00000000..2ac7b6dd --- /dev/null +++ b/packages/DOM/src/NamedNodeMap.res @@ -0,0 +1,49 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/item) +*/ +@send +external item: (Types.namedNodeMap, int) => Types.attr = "item" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/getNamedItem) +*/ +@send +external getNamedItem: (Types.namedNodeMap, string) => Types.attr = "getNamedItem" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/getNamedItemNS) +*/ +@send +external getNamedItemNS: ( + Types.namedNodeMap, + ~namespace: string, + ~localName: string, +) => Types.attr = "getNamedItemNS" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/setNamedItem) +*/ +@send +external setNamedItem: (Types.namedNodeMap, Types.attr) => Types.attr = "setNamedItem" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/setNamedItemNS) +*/ +@send +external setNamedItemNS: (Types.namedNodeMap, Types.attr) => Types.attr = "setNamedItemNS" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/removeNamedItem) +*/ +@send +external removeNamedItem: (Types.namedNodeMap, string) => Types.attr = "removeNamedItem" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/removeNamedItemNS) +*/ +@send +external removeNamedItemNS: ( + Types.namedNodeMap, + ~namespace: string, + ~localName: string, +) => Types.attr = "removeNamedItemNS" diff --git a/packages/DOM/src/Navigator.res b/packages/DOM/src/Navigator.res new file mode 100644 index 00000000..cfabb9d0 --- /dev/null +++ b/packages/DOM/src/Navigator.res @@ -0,0 +1,169 @@ +type t = Types.navigator + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/clipboard) + */ +@get external clipboard: t => WebApiClipboard.Types.clipboard = "clipboard" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/credentials) + */ +@get external credentials: t => WebApiCredentialManagement.Types.credentialsContainer = + "credentials" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/geolocation) + */ +@get external geolocation: t => WebApiGeolocation.Types.geolocation = "geolocation" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/userActivation) + */ +@get external userActivation: t => Types.userActivation = "userActivation" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaCapabilities) + */ +@get external mediaCapabilities: t => WebApiMediaCapabilities.Types.mediaCapabilities = + "mediaCapabilities" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaDevices) + */ +@get external mediaDevices: t => WebApiMediaCaptureAndStreams.Types.mediaDevices = "mediaDevices" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/mediaSession) + */ +@get external mediaSession: t => WebApiMediaSession.Types.mediaSession = "mediaSession" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/permissions) + */ +@get external permissions: t => WebApiPermissions.Types.permissions = "permissions" + +/** + [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 => WebApiScreenWakeLock.Types.wakeLock = "wakeLock" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/serviceWorker) + */ +@get external serviceWorker: t => WebApiServiceWorker.Types.serviceWorkerContainer = "serviceWorker" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/userAgent) + */ +@get external userAgent: t => string = "userAgent" + +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/language) + */ +@get external language: t => string = "language" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/languages) + */ +@get external languages: t => array = "languages" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/onLine) + */ +@get external onLine: t => bool = "onLine" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/cookieEnabled) + */ +@get external cookieEnabled: t => bool = "cookieEnabled" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/pdfViewerEnabled) + */ +@get external pdfViewerEnabled: t => 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 => WebApiStorage.Types.storageManager = "storage" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/locks) + */ +@get external locks: t => WebApiWebLocks.Types.lockManager = "locks" +/** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/webdriver) + */ +@get external webdriver: t => bool = "webdriver" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) +*/ +@send +external sendBeacon: (t, ~url: string, ~data: WebApiFile.Types.readableStream=?) => bool = + "sendBeacon" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) +*/ +@send +external sendBeacon2: (t, ~url: string, ~data: WebApiFile.Types.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" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) +*/ +@send +external sendBeacon4: (t, ~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: WebApiFetch.Types.formData=?) => bool = "sendBeacon" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) +*/ +@send +external sendBeacon6: (t, ~url: string, ~data: WebApiURL.Types.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" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/getGamepads) +*/ +@send +external getGamepads: t => array = "getGamepads" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/requestMediaKeySystemAccess) +*/ +@send +external requestMediaKeySystemAccess: ( + t, + ~keySystem: string, + ~supportedConfigurations: array, +) => promise<'mediaKeySystemAccess> = "requestMediaKeySystemAccess" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Navigator/requestMIDIAccess) +*/ +@send +external requestMIDIAccess: ( + t, + ~options: WebApiWebMIDI.Types.midiOptions=?, +) => promise = "requestMIDIAccess" diff --git a/src/DOMAPI/Node.res b/packages/DOM/src/Node.res similarity index 78% rename from src/DOMAPI/Node.res rename to packages/DOM/src/Node.res index db1019b0..2b58567a 100644 --- a/src/DOMAPI/Node.res +++ b/packages/DOM/src/Node.res @@ -1,20 +1,18 @@ -open DOMAPI - module Impl = ( T: { type t }, ) => { - include EventTarget.Impl({type t = T.t}) + include WebApiEvent.EventTarget.Impl({type t = T.t}) - external asNode: T.t => node = "%identity" + external asNode: T.t => Types.node = "%identity" /** Returns node's root. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/getRootNode) */ @send - external getRootNode: (T.t, ~options: getRootNodeOptions=?) => node = "getRootNode" + external getRootNode: (T.t, ~options: Types.getRootNodeOptions=?) => Types.node = "getRootNode" /** Returns whether node has children. @@ -42,27 +40,27 @@ Returns whether node and otherNode have the same properties. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isEqualNode) */ @send - external isEqualNode: (T.t, node) => bool = "isEqualNode" + external isEqualNode: (T.t, Types.node) => bool = "isEqualNode" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/isSameNode) */ @send - external isSameNode: (T.t, node) => bool = "isSameNode" + external isSameNode: (T.t, Types.node) => bool = "isSameNode" /** Returns a bitmask indicating the position of other relative to node. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition) */ @send - external compareDocumentPosition: (T.t, node) => int = "compareDocumentPosition" + external compareDocumentPosition: (T.t, Types.node) => int = "compareDocumentPosition" /** Returns true if other is an inclusive descendant of node, and false otherwise. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/contains) */ @send - external contains: (T.t, node) => bool = "contains" + external contains: (T.t, Types.node) => bool = "contains" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix) @@ -86,7 +84,7 @@ Returns true if other is an inclusive descendant of node, and false otherwise. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/insertBefore) */ @send - external insertBefore: (T.t, 't, ~child: node) => 't = "insertBefore" + external insertBefore: (T.t, 't, ~child: Types.node) => 't = "insertBefore" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/appendChild) @@ -98,7 +96,7 @@ Returns true if other is an inclusive descendant of node, and false otherwise. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/replaceChild) */ @send - external replaceChild: (T.t, ~node: node, 't) => 't = "replaceChild" + external replaceChild: (T.t, ~node: Types.node, 't) => 't = "replaceChild" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Node/removeChild) @@ -107,4 +105,4 @@ Returns true if other is an inclusive descendant of node, and false otherwise. external removeChild: (T.t, 't) => 't = "removeChild" } -include Impl({type t = node}) +include Impl({type t = Types.node}) diff --git a/packages/DOM/src/NodeFilter.res b/packages/DOM/src/NodeFilter.res new file mode 100644 index 00000000..fdadeb82 --- /dev/null +++ b/packages/DOM/src/NodeFilter.res @@ -0,0 +1,2 @@ +@send +external acceptNode: (Types.nodeFilter, Types.node) => int = "acceptNode" diff --git a/packages/DOM/src/NodeIterator.res b/packages/DOM/src/NodeIterator.res new file mode 100644 index 00000000..44073747 --- /dev/null +++ b/packages/DOM/src/NodeIterator.res @@ -0,0 +1,11 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NodeIterator/nextNode) +*/ +@send +external nextNode: Types.nodeIterator => Types.node = "nextNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NodeIterator/previousNode) +*/ +@send +external previousNode: Types.nodeIterator => Types.node = "previousNode" diff --git a/packages/DOM/src/NodeList.res b/packages/DOM/src/NodeList.res new file mode 100644 index 00000000..1f8ea784 --- /dev/null +++ b/packages/DOM/src/NodeList.res @@ -0,0 +1,6 @@ +/** +Returns the node with index index from the collection. The nodes are sorted in tree order. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/NodeList/item) +*/ +@send +external item: (Types.nodeList<'tNode>, int) => 'tNode = "item" diff --git a/packages/DOM/src/Range.res b/packages/DOM/src/Range.res new file mode 100644 index 00000000..83f8c088 --- /dev/null +++ b/packages/DOM/src/Range.res @@ -0,0 +1,148 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range) +*/ +@new +external make: unit => Types.range = "Range" + +external asAbstractRange: Types.range => Types.abstractRange = "%identity" +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setStart) +*/ +@send +external setStart: (Types.range, ~node: Types.node, ~offset: int) => unit = "setStart" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setEnd) +*/ +@send +external setEnd: (Types.range, ~node: Types.node, ~offset: int) => unit = "setEnd" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setStartBefore) +*/ +@send +external setStartBefore: (Types.range, Types.node) => unit = "setStartBefore" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setStartAfter) +*/ +@send +external setStartAfter: (Types.range, Types.node) => unit = "setStartAfter" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setEndBefore) +*/ +@send +external setEndBefore: (Types.range, Types.node) => unit = "setEndBefore" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/setEndAfter) +*/ +@send +external setEndAfter: (Types.range, Types.node) => unit = "setEndAfter" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/collapse) +*/ +@send +external collapse: (Types.range, ~toStart: bool=?) => unit = "collapse" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/selectNode) +*/ +@send +external selectNode: (Types.range, Types.node) => unit = "selectNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/selectNodeContents) +*/ +@send +external selectNodeContents: (Types.range, Types.node) => unit = "selectNodeContents" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/compareBoundaryPoints) +*/ +@send +external compareBoundaryPoints: (Types.range, ~how: int, ~sourceRange: Types.range) => int = + "compareBoundaryPoints" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/deleteContents) +*/ +@send +external deleteContents: Types.range => unit = "deleteContents" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/extractContents) +*/ +@send +external extractContents: Types.range => Types.documentFragment = "extractContents" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/cloneContents) +*/ +@send +external cloneContents: Types.range => Types.documentFragment = "cloneContents" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/insertNode) +*/ +@send +external insertNode: (Types.range, Types.node) => unit = "insertNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/surroundContents) +*/ +@send +external surroundContents: (Types.range, Types.node) => unit = "surroundContents" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/cloneRange) +*/ +@send +external cloneRange: Types.range => Types.range = "cloneRange" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/detach) +*/ +@send +external detach: Types.range => unit = "detach" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/isPointInRange) +*/ +@send +external isPointInRange: (Types.range, ~node: Types.node, ~offset: int) => bool = "isPointInRange" + +/** +Returns −1 if the point is before the range, 0 if the point is in the range, and 1 if the point is after the range. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/comparePoint) +*/ +@send +external comparePoint: (Types.range, ~node: Types.node, ~offset: int) => int = "comparePoint" + +/** +Returns whether range intersects node. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/intersectsNode) +*/ +@send +external intersectsNode: (Types.range, Types.node) => bool = "intersectsNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/getClientRects) +*/ +@send +external getClientRects: Types.range => Types.domRectList = "getClientRects" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/getBoundingClientRect) +*/ +@send +external getBoundingClientRect: Types.range => Types.domRect = "getBoundingClientRect" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Range/createContextualFragment) +*/ +@send +external createContextualFragment: (Types.range, string) => Types.documentFragment = + "createContextualFragment" diff --git a/packages/DOM/src/SVGGraphicsElement.res b/packages/DOM/src/SVGGraphicsElement.res new file mode 100644 index 00000000..c70f0c93 --- /dev/null +++ b/packages/DOM/src/SVGGraphicsElement.res @@ -0,0 +1,18 @@ +include Element.Impl({type t = Types.svgGraphicsElement}) + +external asSVGElement: Types.svgGraphicsElement => Types.svgElement = "%identity" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/SVGGraphicsElement/getBBox) +*/ +@send +external getBBox: ( + Types.svgGraphicsElement, + ~options: Types.svgBoundingBoxOptions=?, +) => Types.domRect = "getBBox" + +@send +external getCTM: Types.svgGraphicsElement => Types.domMatrix = "getCTM" + +@send +external getScreenCTM: Types.svgGraphicsElement => Types.domMatrix = "getScreenCTM" diff --git a/packages/DOM/src/SVGLength.res b/packages/DOM/src/SVGLength.res new file mode 100644 index 00000000..41af6bc8 --- /dev/null +++ b/packages/DOM/src/SVGLength.res @@ -0,0 +1,9 @@ +@send +external newValueSpecifiedUnits: ( + Types.svgLength, + ~unitType: int, + ~valueInSpecifiedUnits: float, +) => unit = "newValueSpecifiedUnits" + +@send +external convertToSpecifiedUnits: (Types.svgLength, int) => unit = "convertToSpecifiedUnits" diff --git a/packages/DOM/src/ScreenOrientation.res b/packages/DOM/src/ScreenOrientation.res new file mode 100644 index 00000000..5297626f --- /dev/null +++ b/packages/DOM/src/ScreenOrientation.res @@ -0,0 +1,7 @@ +include WebApiEvent.EventTarget.Impl({type t = Types.screenOrientation}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/unlock) +*/ +@send +external unlock: Types.screenOrientation => unit = "unlock" diff --git a/packages/DOM/src/Selection.res b/packages/DOM/src/Selection.res new file mode 100644 index 00000000..fc537985 --- /dev/null +++ b/packages/DOM/src/Selection.res @@ -0,0 +1,104 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/getRangeAt) +*/ +@send +external getRangeAt: (Types.selection, int) => Types.range = "getRangeAt" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/addRange) +*/ +@send +external addRange: (Types.selection, Types.range) => unit = "addRange" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/removeRange) +*/ +@send +external removeRange: (Types.selection, Types.range) => unit = "removeRange" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/removeAllRanges) +*/ +@send +external removeAllRanges: Types.selection => unit = "removeAllRanges" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/removeAllRanges) +*/ +@send +external empty: Types.selection => unit = "empty" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/collapse) +*/ +@send +external collapse: (Types.selection, ~node: Types.node, ~offset: int=?) => unit = "collapse" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/collapse) +*/ +@send +external setPosition: (Types.selection, ~node: Types.node, ~offset: int=?) => unit = "setPosition" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/collapseToStart) +*/ +@send +external collapseToStart: Types.selection => unit = "collapseToStart" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/collapseToEnd) +*/ +@send +external collapseToEnd: Types.selection => unit = "collapseToEnd" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/extend) +*/ +@send +external extend: (Types.selection, ~node: Types.node, ~offset: int=?) => unit = "extend" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/setBaseAndExtent) +*/ +@send +external setBaseAndExtent: ( + Types.selection, + ~anchorNode: Types.node, + ~anchorOffset: int, + ~focusNode: Types.node, + ~focusOffset: int, +) => unit = "setBaseAndExtent" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/selectAllChildren) +*/ +@send +external selectAllChildren: (Types.selection, Types.node) => unit = "selectAllChildren" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/modify) +*/ +@send +external modify: ( + Types.selection, + ~alter: string=?, + ~direction: string=?, + ~granularity: string=?, +) => unit = "modify" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/deleteFromDocument) +*/ +@send +external deleteFromDocument: Types.selection => unit = "deleteFromDocument" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Selection/containsNode) +*/ +@send +external containsNode: ( + Types.selection, + ~node: Types.node, + ~allowPartialContainment: bool=?, +) => bool = "containsNode" diff --git a/packages/DOM/src/ShadowRoot.res b/packages/DOM/src/ShadowRoot.res new file mode 100644 index 00000000..576938ee --- /dev/null +++ b/packages/DOM/src/ShadowRoot.res @@ -0,0 +1,19 @@ +include DocumentFragment.Impl({type t = Types.shadowRoot}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Document/getAnimations) +*/ +@send +external getAnimations: Types.shadowRoot => array = "getAnimations" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ShadowRoot/setHTMLUnsafe) +*/ +@send +external setHTMLUnsafe: (Types.shadowRoot, string) => unit = "setHTMLUnsafe" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/ShadowRoot/getHTML) +*/ +@send +external getHTML: (Types.shadowRoot, ~options: Types.getHTMLOptions=?) => string = "getHTML" diff --git a/packages/DOM/src/StylePropertyMap.res b/packages/DOM/src/StylePropertyMap.res new file mode 100644 index 00000000..8e790a52 --- /dev/null +++ b/packages/DOM/src/StylePropertyMap.res @@ -0,0 +1,51 @@ +external asStylePropertyMapReadOnly: Types.stylePropertyMap => Types.stylePropertyMapReadOnly = + "%identity" +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/getAll) +*/ +@send +external getAll: (Types.stylePropertyMap, string) => array = "getAll" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/has) +*/ +@send +external has: (Types.stylePropertyMap, string) => bool = "has" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/set) +*/ +@send +external set: (Types.stylePropertyMap, ~property: string, ~values: Types.cssStyleValue) => unit = + "set" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/set) +*/ +@send +external set2: (Types.stylePropertyMap, ~property: string, ~values: string) => unit = "set" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/append) +*/ +@send +external append: (Types.stylePropertyMap, ~property: string, ~values: Types.cssStyleValue) => unit = + "append" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/append) +*/ +@send +external append2: (Types.stylePropertyMap, ~property: string, ~values: string) => unit = "append" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/delete) +*/ +@send +external delete: (Types.stylePropertyMap, string) => unit = "delete" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap/clear) +*/ +@send +external clear: Types.stylePropertyMap => unit = "clear" diff --git a/packages/DOM/src/StylePropertyMapReadOnly.res b/packages/DOM/src/StylePropertyMapReadOnly.res new file mode 100644 index 00000000..611edd27 --- /dev/null +++ b/packages/DOM/src/StylePropertyMapReadOnly.res @@ -0,0 +1,11 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/getAll) +*/ +@send +external getAll: (Types.stylePropertyMapReadOnly, string) => array = "getAll" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/has) +*/ +@send +external has: (Types.stylePropertyMapReadOnly, string) => bool = "has" diff --git a/packages/DOM/src/StyleSheetList.res b/packages/DOM/src/StyleSheetList.res new file mode 100644 index 00000000..9d684af0 --- /dev/null +++ b/packages/DOM/src/StyleSheetList.res @@ -0,0 +1,5 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/StyleSheetList/item) +*/ +@send +external item: (Types.styleSheetList, int) => Types.cssStyleSheet = "item" diff --git a/packages/DOM/src/Text.res b/packages/DOM/src/Text.res new file mode 100644 index 00000000..79f2ab8c --- /dev/null +++ b/packages/DOM/src/Text.res @@ -0,0 +1,14 @@ +include CharacterData.Impl({type t = Types.text}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Text) +*/ +@new +external make: (~data: string=?) => Types.text = "Text" + +/** +Splits data at the given offset and returns the remainder as Text node. +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Text/splitText) +*/ +@send +external splitText: (Types.text, int) => Types.text = "splitText" diff --git a/packages/DOM/src/TextTrackList.res b/packages/DOM/src/TextTrackList.res new file mode 100644 index 00000000..ef88d2b2 --- /dev/null +++ b/packages/DOM/src/TextTrackList.res @@ -0,0 +1,8 @@ +include WebApiEvent.EventTarget.Impl({type t = Types.textTrackList}) + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TextTrackList/getTrackById) +*/ +@send +external getTrackById: (Types.textTrackList, string) => WebApiWebVTT.Types.textTrack = + "getTrackById" diff --git a/src/DOMAPI/TimeRanges.res b/packages/DOM/src/TimeRanges.res similarity index 79% rename from src/DOMAPI/TimeRanges.res rename to packages/DOM/src/TimeRanges.res index d0dbf0b7..6f92754a 100644 --- a/src/DOMAPI/TimeRanges.res +++ b/packages/DOM/src/TimeRanges.res @@ -1,5 +1,3 @@ -open DOMAPI - /** Returns the time for the start of the range with the given index. @@ -7,7 +5,7 @@ Throws an "IndexSizeError" DOMException if the index is out of range. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TimeRanges/start) */ @send -external start: (timeRanges, int) => float = "start" +external start: (Types.timeRanges, int) => float = "start" /** Returns the time for the end of the range with the given index. @@ -16,4 +14,4 @@ Throws an "IndexSizeError" DOMException if the index is out of range. [Read more on MDN](https://developer.mozilla.org/docs/Web/API/TimeRanges/end) */ @send -external end: (timeRanges, int) => float = "end" +external end: (Types.timeRanges, int) => float = "end" diff --git a/packages/DOM/src/TreeWalker.res b/packages/DOM/src/TreeWalker.res new file mode 100644 index 00000000..9066b16b --- /dev/null +++ b/packages/DOM/src/TreeWalker.res @@ -0,0 +1,41 @@ +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/parentNode) +*/ +@send +external parentNode: Types.treeWalker => Types.node = "parentNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/firstChild) +*/ +@send +external firstChild: Types.treeWalker => Types.node = "firstChild" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/lastChild) +*/ +@send +external lastChild: Types.treeWalker => Types.node = "lastChild" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/previousSibling) +*/ +@send +external previousSibling: Types.treeWalker => Types.node = "previousSibling" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/nextSibling) +*/ +@send +external nextSibling: Types.treeWalker => Types.node = "nextSibling" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/previousNode) +*/ +@send +external previousNode: Types.treeWalker => Types.node = "previousNode" + +/** +[Read more on MDN](https://developer.mozilla.org/docs/Web/API/TreeWalker/nextNode) +*/ +@send +external nextNode: Types.treeWalker => Types.node = "nextNode" diff --git a/packages/DOM/src/Types.res b/packages/DOM/src/Types.res new file mode 100644 index 00000000..73b34046 --- /dev/null +++ b/packages/DOM/src/Types.res @@ -0,0 +1,2105 @@ +@@warning("-30") + +type domStringList = WebApiPrelude.Types.domStringList +type eventTarget = WebApiEvent.Types.eventTarget +type eventType = WebApiEvent.Types.eventType +type file = WebApiFile.Types.file +type blob = WebApiFile.Types.blob +type fileSystemEntry = WebApiFileAndDirectoryEntries.Types.fileSystemEntry +type remotePlayback = WebApiRemotePlayback.Types.remotePlayback +type fontFaceSet = WebApiCSSFontLoading.Types.fontFaceSet +type structuredSerializeOptions = WebApiChannelMessaging.Types.structuredSerializeOptions + +type htmlElement = WebApiPrelude.Types.htmlElement +type mediaError = WebApiPrelude.Types.mediaError +type timeRanges = WebApiPrelude.Types.timeRanges +type textTrackList = WebApiPrelude.Types.textTrackList +type htmlFormElement = WebApiPrelude.Types.htmlFormElement +type htmlCollection<'a> = WebApiPrelude.Types.htmlCollection<'a> +type element = WebApiPrelude.Types.element +type validityState = WebApiPrelude.Types.validityState +type document = WebApiPrelude.Types.document +type cssStyleSheet = WebApiPrelude.Types.cssStyleSheet +type nodeList<'a> = WebApiPrelude.Types.nodeList<'a> +type htmlLabelElement = WebApiPrelude.Types.htmlLabelElement +type documentFragment = WebApiPrelude.Types.documentFragment +type node = WebApiPrelude.Types.node +type cssStyleDeclaration = WebApiPrelude.Types.cssStyleDeclaration +type domRectReadOnly = WebApiPrelude.Types.domRectReadOnly +type shadowRoot = WebApiPrelude.Types.shadowRoot +type styleSheet = WebApiPrelude.Types.styleSheet +type mediaQueryList = WebApiPrelude.Types.mediaQueryList +type domRect = WebApiPrelude.Types.domRect +type range = WebApiPrelude.Types.range +type documentType = WebApiPrelude.Types.documentType +type cssStyleValue = WebApiPrelude.Types.cssStyleValue +type treeWalker = WebApiPrelude.Types.treeWalker +type selection = WebApiPrelude.Types.selection +type abstractRange = WebApiPrelude.Types.abstractRange +type htmlOptionsCollection = WebApiPrelude.Types.htmlOptionsCollection +type styleSheetList = WebApiPrelude.Types.styleSheetList +type elementInternals = WebApiPrelude.Types.elementInternals +type nodeFilter = WebApiPrelude.Types.nodeFilter +type fileList = WebApiPrelude.Types.fileList +type cssRule = WebApiPrelude.Types.cssRule +type attr = WebApiPrelude.Types.attr +type domRectList = WebApiPrelude.Types.domRectList +type htmlFormControlsCollection = WebApiPrelude.Types.htmlFormControlsCollection +type domImplementation = WebApiPrelude.Types.domImplementation +type nodeIterator = WebApiPrelude.Types.nodeIterator +type xmlDocument = WebApiPrelude.Types.xmlDocument +type characterData = WebApiPrelude.Types.characterData +type text = WebApiPrelude.Types.text +type cdataSection = WebApiPrelude.Types.cdataSection +type comment = WebApiPrelude.Types.comment +type processingInstruction = WebApiPrelude.Types.processingInstruction +type caretPosition = WebApiPrelude.Types.caretPosition +type htmlTableElement = WebApiPrelude.Types.htmlTableElement +type htmlOutputElement = WebApiPrelude.Types.htmlOutputElement +type htmlTableCellElement = WebApiPrelude.Types.htmlTableCellElement +type htmlHeadElement = WebApiPrelude.Types.htmlHeadElement +type htmlSelectElement = WebApiPrelude.Types.htmlSelectElement +type htmlButtonElement = WebApiPrelude.Types.htmlButtonElement +type htmlTableSectionElement = WebApiPrelude.Types.htmlTableSectionElement +type htmlOptionElement = WebApiPrelude.Types.htmlOptionElement +type htmlEmbedElement = WebApiPrelude.Types.htmlEmbedElement +type htmlTextAreaElement = WebApiPrelude.Types.htmlTextAreaElement +type htmlTableCaptionElement = WebApiPrelude.Types.htmlTableCaptionElement +type htmlSlotElement = WebApiPrelude.Types.htmlSlotElement +type htmlDataListElement = WebApiPrelude.Types.htmlDataListElement +type htmlInputElement = WebApiPrelude.Types.htmlInputElement +type htmlScriptElement = WebApiPrelude.Types.htmlScriptElement +type htmlAnchorElement = WebApiPrelude.Types.htmlAnchorElement +type htmlTableRowElement = WebApiPrelude.Types.htmlTableRowElement +type htmlImageElement = WebApiPrelude.Types.htmlImageElement +type htmlAreaElement = WebApiPrelude.Types.htmlAreaElement +type videoPlaybackQuality = WebApiPrelude.Types.videoPlaybackQuality +type idleDeadline = WebApiPrelude.Types.idleDeadline +type cssRuleList = WebApiPrelude.Types.cssRuleList +type mediaKeySystemConfiguration = WebApiPrelude.Types.mediaKeySystemConfiguration + +/** +A window containing a WebApiDOM document; the document property points to the WebApiDOM document loaded in that window. +[See Window on MDN](https://developer.mozilla.org/docs/Web/API/Window) +*/ +@editor.completeFrom(Window) type window = WebApiPrelude.Types.window + +type shadowRootMode = + | @as("closed") Closed + | @as("open") Open + +type slotAssignmentMode = + | @as("manual") Manual + | @as("named") Named + +type autoFillBase = + | @as("off") Off + | @as("on") On + +type documentReadyState = + | @as("complete") Complete + | @as("interactive") Interactive + | @as("loading") Loading + +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 insertPosition = + | @as("afterbegin") Afterbegin + | @as("afterend") Afterend + | @as("beforebegin") Beforebegin + | @as("beforeend") Beforeend + +type scrollBehavior = + | @as("auto") Auto + | @as("instant") Instant + | @as("smooth") Smooth + +type fullscreenNavigationUI = + | @as("auto") Auto + | @as("hide") Hide + | @as("show") Show + +type remotePlaybackState = + | @as("connected") Connected + | @as("connecting") Connecting + | @as("disconnected") Disconnected + +type referrerPolicy = + | @as("no-referrer") NoReferrer + | @as("no-referrer-when-downgrade") NoReferrerWhenDowngrade + | @as("origin") Origin + | @as("origin-when-cross-origin") OriginWhenCrossOrigin + | @as("same-origin") SameOrigin + | @as("strict-origin") StrictOrigin + | @as("strict-origin-when-cross-origin") StrictOriginWhenCrossOrigin + | @as("unsafe-url") UnsafeUrl + +type canPlayTypeResult = + | @as("maybe") Maybe + | @as("probably") Probably + +type animationPlayState = + | @as("finished") Finished + | @as("idle") Idle + | @as("paused") Paused + | @as("running") Running + +type animationReplaceState = + | @as("active") Active + | @as("persisted") Persisted + | @as("removed") Removed + +type fillMode = + | @as("auto") Auto + | @as("backwards") Backwards + | @as("both") Both + | @as("forwards") Forwards + | @as("none") None + +type playbackDirection = + | @as("alternate") Alternate + | @as("alternate-reverse") AlternateReverse + | @as("normal") Normal + | @as("reverse") Reverse + +type imageOrientation = + | @as("flipY") FlipY + | @as("from-image") FromImage + | @as("none") None + +type premultiplyAlpha = + | @as("default") Default + | @as("none") None + | @as("premultiply") Premultiply + +type colorSpaceConversion = + | @as("default") Default + | @as("none") None + +type resizeQuality = + | @as("high") High + | @as("low") Low + | @as("medium") Medium + | @as("pixelated") Pixelated + +type scrollLogicalPosition = + | @as("center") Center + | @as("end") End + | @as("nearest") Nearest + | @as("start") Start + +type selectionMode = + | @as("end") End + | @as("preserve") Preserve + | @as("select") Select + | @as("start") Start + +type compositeOperation = + | @as("accumulate") Accumulate + | @as("add") Add + | @as("replace") Replace + +type iterationCompositeOperation = + | @as("accumulate") Accumulate + | @as("replace") Replace + +type videoPixelFormat = + | BGRA + | BGRX + | I420 + | I420A + | I422 + | I444 + | NV12 + | RGBA + | RGBX + +type videoColorPrimaries = + | @as("bt470bg") Bt470bg + | @as("bt709") Bt709 + | @as("smpte170m") Smpte170m + +type videoTransferCharacteristics = + | @as("bt709") Bt709 + | @as("iec61966-2-1") Iec6196621 + | @as("smpte170m") Smpte170m + +type videoMatrixCoefficients = + | @as("bt470bg") Bt470bg + | @as("bt709") Bt709 + | @as("rgb") Rgb + | @as("smpte170m") Smpte170m + +type alphaOption = + | @as("discard") Discard + | @as("keep") Keep + +type predefinedColorSpace = + | @as("display-p3") DisplayP3 + | @as("srgb") Srgb + +type shareData = { + mutable files?: array, + mutable title?: string, + mutable text?: string, + mutable url?: string, +} + +/** +@editor.completeFrom(Window) 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) +*/ +@editor.completeFrom(Location) +type location = WebApiPrelude.Types.location = private {...WebApiPrelude.Types.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 = WebApiPrelude.Types.navigator + +// TODO: mark as private once mutating fields of private records is allowed +@editor.completeFrom(DOMTokenList) +type domTokenList = { + /** + Returns the number of tokens. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/length) + */ + length: int, + /** + Returns the associated set as string. + +Can be set, to change the associated attribute. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DOMTokenList/value) + */ + mutable value: string, +} + +/** +A collection of Attr objects. Objects inside a NamedNodeMap are not in any particular order, unlike NodeList, although they may be accessed by an index as in an array. +[See NamedNodeMap on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap) +*/ +@editor.completeFrom(NamedNodeMap) +type namedNodeMap = private { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/length) + */ + length: int, +} + +/** +[See FragmentDirective on MDN](https://developer.mozilla.org/docs/Web/API/FragmentDirective) +*/ +type fragmentDirective = {} + +/** +[See CustomElementRegistry on MDN](https://developer.mozilla.org/docs/Web/API/CustomElementRegistry) +*/ +@editor.completeFrom(CustomElementRegistry) +type customElementRegistry = private {} + +/** +[See BarProp on MDN](https://developer.mozilla.org/docs/Web/API/BarProp) +*/ +type barProp = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/BarProp/visible) + */ + visible: bool, +} + +/** +[See ScreenOrientation on MDN](https://developer.mozilla.org/docs/Web/API/ScreenOrientation) +*/ +@editor.completeFrom(ScreenOrientation) +type screenOrientation = private { + ...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, +} + +/** +A screen, usually the one on which the current window is being rendered, and is obtained using window.screen. +[See Screen on MDN](https://developer.mozilla.org/docs/Web/API/Screen) +*/ +type screen = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/availWidth) + */ + availWidth: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/availHeight) + */ + availHeight: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/width) + */ + width: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/height) + */ + height: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/colorDepth) + */ + colorDepth: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/pixelDepth) + */ + pixelDepth: int, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Screen/orientation) + */ + orientation: screenOrientation, +} + +@unboxed +type vibratePattern = + | Int(int) + | IntArray(array) + +type renderingContext = unknown + +type offscreenRenderingContext = unknown + +/** +[See AnimationTimeline on MDN](https://developer.mozilla.org/docs/Web/API/AnimationTimeline) +*/ +@editor.completeFrom(Animation) +type rec animationTimeline = private { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/AnimationTimeline/currentTime) + */ + currentTime: Null.t, +} + +/** +[See DocumentTimeline on MDN](https://developer.mozilla.org/docs/Web/API/DocumentTimeline) +*/ +@editor.completeFrom(DocumentTimeline) and documentTimeline = private { + // Base properties from AnimationTimeline + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/AnimationTimeline/currentTime) + */ + currentTime: Null.t, + // End base properties from AnimationTimeline +} + +/** +[See MediaList on MDN](https://developer.mozilla.org/docs/Web/API/MediaList) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(MediaList) +type mediaList = { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaList/mediaText) + */ + mutable mediaText: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/MediaList/length) + */ + length: int, +} + +/** +[See StylePropertyMapReadOnly on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly) +*/ +@editor.completeFrom(StylePropertyMapReadOnly) +type stylePropertyMapReadOnly = private { + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMapReadOnly/size) + */ + size: int, +} + +/** +[See StylePropertyMap on MDN](https://developer.mozilla.org/docs/Web/API/StylePropertyMap) +*/ +@editor.completeFrom(StylePropertyMap) +type stylePropertyMap = private { + ...stylePropertyMapReadOnly, +} + +/** +Used by the dataset HTML attribute to represent data for custom attributes added to elements. +[See DOMStringMap on MDN](https://developer.mozilla.org/docs/Web/API/DOMStringMap) +*/ +type domStringMap = {} + +type mediaProvider = unknown + +/** +Adds to HTMLElement the properties and methods needed to support basic media-related capabilities that are common to audio and video. +[See HTMLMediaElement on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement) +TODO: mark as private once mutating fields of private records is allowed +*/ +@editor.completeFrom(HTMLMediaElement) +type htmlMediaElement = { + ...htmlElement, + /** + Returns an object representing the current error state of the audio or video element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/error) + */ + error: Null.t, + /** + The address or WebApiURL of the a media resource that is to be considered. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/src) + */ + mutable src: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/srcObject) + */ + mutable srcObject: Null.t, + /** + Gets the address or WebApiURL of the current media resource that is selected by IHTMLMediaElement. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/currentSrc) + */ + currentSrc: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/crossOrigin) + */ + mutable crossOrigin: Null.t, + /** + Gets the current network activity for the element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/networkState) + */ + networkState: int, + /** + Gets or sets a value indicating what data should be preloaded, if any. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/preload) + */ + mutable preload: string, + /** + Gets a collection of buffered time ranges. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/buffered) + */ + buffered: timeRanges, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/readyState) + */ + readyState: int, + /** + Gets or sets the current playback position, in seconds. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/currentTime) + */ + mutable currentTime: float, + /** + Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/duration) + */ + duration: float, + /** + Gets a flag that specifies whether playback is paused. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/paused) + */ + paused: bool, + /** + Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/defaultPlaybackRate) + */ + mutable defaultPlaybackRate: float, + /** + Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/playbackRate) + */ + mutable playbackRate: float, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/preservesPitch) + */ + mutable preservesPitch: bool, + /** + Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/seekable) + */ + seekable: timeRanges, + /** + Gets information about whether the playback has ended or not. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/ended) + */ + ended: bool, + /** + Gets or sets a value that indicates whether to start playing the media automatically. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/autoplay) + */ + mutable autoplay: bool, + /** + Gets or sets a flag to specify whether playback should restart after it completes. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/loop) + */ + mutable loop: bool, + /** + Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/controls) + */ + mutable controls: bool, + /** + Gets or sets the volume level for audio portions of the media element. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/volume) + */ + mutable volume: float, + /** + Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/muted) + */ + mutable muted: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/defaultMuted) + */ + mutable defaultMuted: bool, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/textTracks) + */ + textTracks: textTrackList, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/sinkId) + */ + sinkId: string, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/remote) + */ + remote: remotePlayback, + /** + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLMediaElement/disableRemotePlayback) + */ + mutable disableRemotePlayback: bool, +} + +/** +Provides access to the properties of