Skip to content

Commit 844c32a

Browse files
authored
docs(webapi): update alpha guides and fix broken links [Codex] (#398)
Updates installation and contributor guides for ReScript 13 alpha. Adds migration notes for #399 and a release guide. Fixes broken API links and adds automated checks for links within the built site. Replaces bundled fonts with system fonts because their source and licenses could not be verified. Builds on #399, after #397, and completes the documentation requirements for the issues below. npm Trusted Publishing still needs maintainer verification (#385). Closes #383, closes #387, closes #388, closes #390, closes #391, closes #392, closes #393, closes #394 and closes #395. Refs #385.
1 parent 115e1e7 commit 844c32a

37 files changed

Lines changed: 1551 additions & 533 deletions

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
- name: Build documentation
5353
run: npm run build:docs
5454

55+
- name: Check documentation links
56+
run: npm run check:docs-links
57+
5558
- name: Upload documentation
5659
uses: actions/upload-pages-artifact@v5
5760
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

‎.github/workflows/release.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ jobs:
6060
- name: Build documentation
6161
run: npm run build:docs
6262

63+
- name: Check documentation links
64+
run: npm run check:docs-links
65+
6366
- name: Validate alpha package metadata
6467
run: npm run check:release
6568

‎CHANGELOG.md‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Changelog
2+
3+
This file records user-visible changes. Alpha releases may contain breaking changes, and
4+
changes may occur between alpha versions. Version numbers and publication-channel instructions
5+
are maintained by the release workflow; see the [alpha release readiness tracker](https://github.com/rescript-lang/experimental-rescript-webapi/issues/382).
6+
7+
## 1.0.0-alpha.1 (candidate)
8+
9+
Planned first release in the `1.0.0-alpha.N` series. ReScript `13.0.0-alpha.5` is the tested
10+
compiler baseline. This alpha is not a stable API; review the migration notes below before
11+
upgrading from earlier prereleases. The release workflow is the source of truth for actual
12+
versioning and publication.
13+
14+
### Migration notes
15+
16+
- WebSocket sends and worker `Request` fetches now preserve their native receiver (`this`) rather
17+
than calling receiver-bound methods unbound.
18+
- `WebAPI.Request.bytes`, `WebAPI.Response.bytes`, `WebAPI.Blob.bytes`,
19+
`WebAPI.Blob.stream`, and `WebAPI.SafeFetch.bytes` expose
20+
native `Uint8Array.t` values or chunks instead of `array<int>`. Use the typed-array API
21+
directly; the bytes are not copied into a ReScript integer array. `SafeFetch.bytes` keeps its
22+
existing result and response wrapper; only the byte payload changes.
23+
- `BodyInit.fromReadableStream` and `Response.fromReadableStream` now require
24+
`ReadableStream.t<Uint8Array.t>` input. These HTTP-body adapters accept byte chunks, not arbitrary
25+
or string chunks; `ReadableStream` itself remains generic for other uses.
26+
- `ResizeObserver` callbacks now receive `(entries, observer)` as two arguments rather than a
27+
curried callback.
28+
- Web Audio analyser float buffers, `AudioBuffer` channel and copy APIs, and Biquad/IIR filter
29+
frequency-response buffers use `Float32Array.t`; analyser byte buffers use `Uint8Array.t`.
30+
`DOMMatrix` and `DOMMatrixReadOnly` Float32 conversions also use `Float32Array.t`. Use native
31+
typed-array values rather than ordinary ReScript arrays for these calls.
32+
- `Element.closest` returns `Null.t<DOMTree.element>` and is no longer polymorphic. Narrow the
33+
result with the relevant public classifier when a more specific HTML interface is required.
34+
- WebCrypto signatures now reflect native results: `sign` and `digest` return `ArrayBuffer.t`,
35+
`verify` returns `bool`, `deriveKey` returns `WebAPI.SubtleCrypto.cryptoKey`, and `deriveBits`
36+
and `wrapKey` return `ArrayBuffer.t`. Key and algorithm support types are available through
37+
`WebAPI.SubtleCrypto`. Use `algorithmString` for a native algorithm name and `algorithmObject`
38+
for parameter dictionaries such as AES-GCM's `iv` and `tagLength`; the object helper preserves
39+
typed-array values rather than copying them into a closed algorithm-name variant.
40+
- Generic `SubtleCrypto.generateKey` and `generateKey2` now return `unknown` because the result
41+
depends on the algorithm. Use `generateKeySymmetric` for HMAC keys
42+
(`SubtleCrypto.cryptoKey`) or `generateEcdsaKeyPair` for ECDSA pairs
43+
(`SubtleCrypto.cryptoKeyPair`). Generic `exportKey` also returns `unknown`; use
44+
`exportKeyBinary` for `Raw`, `Pkcs8`, or `Spki` formats (`ArrayBuffer.t`), and
45+
`exportKeyJwk` for `Jwk` format (`JSON.t`).
46+
- `DOMTree.element` no longer exposes a generic `className`. Specific HTML interfaces retain a
47+
string `className`; `SVGElement.t.className` is `SVGElement.svgAnimatedString` with
48+
`baseVal` and `animVal`.
49+
- `CustomElementRegistry.define` takes a `DOM.customElementConstructor`; it does not take an
50+
element instance.
51+
- Request destination, referrer-policy, and media `canPlayType` result types now include `Empty`
52+
for native empty-string values. `HTMLCanvasElement.toBlob` callbacks receive a
53+
`Null.t<WebAPI.Blob.t>` because the browser can return null (including for a zero-sized
54+
canvas). An `ifAvailable` Web Locks callback receives a nullable lock when the lock is
55+
unavailable. `IDBFactory.deleteDatabase` has an operation-specific `unit` result because the
56+
browser's successful result is `undefined`, not a database.
57+
- `WebAPI.Notification.t` no longer contains a static permission field. Read that value through
58+
`WebAPI.Notification.permission`.
59+
60+
For the intended installation, compiler range, runtime/browser checks, and known limitations,
61+
see the [project status](https://rescript-lang.github.io/experimental-rescript-webapi/project-status/)
62+
and [API surface guide](https://rescript-lang.github.io/experimental-rescript-webapi/api-surface/).

‎README.md‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,50 @@ Experimental successor to [rescript-webapi](https://github.com/TheSpyder/rescrip
66

77
## Getting started
88

9-
Install the package using your favorite package manager:
9+
ReScript `13.0.0-alpha.5` is the tested compiler baseline. Library alpha releases may contain
10+
breaking changes. See the [project status](https://rescript-lang.github.io/experimental-rescript-webapi/project-status/)
11+
for the accepted peer range and its testing limits.
12+
13+
Install the library and compiler in your application:
1014

1115
```shell
12-
npm i @rescript/webapi@alpha
16+
npm install @rescript/webapi@alpha
17+
npm install --save-dev rescript@13.0.0-alpha.5
1318
```
1419

15-
and add `@rescript/webapi` to your `rescript.json`:
20+
The `@alpha` command targets the published alpha dist-tag. The planned `1.0.0-alpha.1` candidate
21+
is not published yet; see [project status](https://rescript-lang.github.io/experimental-rescript-webapi/project-status/)
22+
for the current tag and note that candidate installation is verified from its packed tarball.
23+
24+
Add a source directory and the package dependency to `rescript.json`:
1625

1726
```json
1827
{
19-
"dependencies": [
20-
"@rescript/webapi"
21-
]
28+
"name": "webapi-consumer",
29+
"sources": [{ "dir": "src" }],
30+
"dependencies": ["@rescript/webapi"]
2231
}
2332
```
2433

25-
## Usage
34+
In `src/Main.res`:
2635

2736
```rescript
2837
let location = WebAPI.DOM.window->WebAPI.Window.location
2938
let href = location.href
3039
location->WebAPI.Location.reload
3140
```
3241

42+
Compile the consumer with:
43+
44+
```shell
45+
npx rescript build
46+
```
47+
48+
The namespace is flat under `WebAPI`; internal implementation modules are not public API.
49+
3350
## Documentation
3451

35-
More information can be found on https://rescript-lang.github.io/experimental-rescript-webapi/
52+
More information can be found on https://rescript-lang.github.io/experimental-rescript-webapi/.
53+
See the [alpha release checklist](https://github.com/rescript-lang/experimental-rescript-webapi/issues/382)
54+
and [migration notes](https://github.com/rescript-lang/experimental-rescript-webapi/blob/main/CHANGELOG.md)
55+
for known limitations and breaking changes.

‎astro.config.mjs‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { readFileSync } from "node:fs";
22
import { defineConfig } from "astro/config";
33
import starlight from "@astrojs/starlight";
44
import { apiModules } from "./docs/utils";
5+
import { docsBase, docsSite } from "./docs/siteConfig.js";
56

6-
const rescriptTM = JSON.parse(
7-
readFileSync("./docs/assets/rescript.tmLanguage.json", "utf-8"),
8-
);
7+
const rescriptTM = JSON.parse(readFileSync("./docs/assets/rescript.tmLanguage.json", "utf-8"));
98

109
const apiSidebarItems = apiModules.map(({ moduleName, link }) => ({
1110
label: moduleName,
@@ -15,8 +14,8 @@ const apiSidebarItems = apiModules.map(({ moduleName, link }) => ({
1514
export default defineConfig({
1615
srcDir: "docs",
1716
publicDir: "docs/public",
18-
site: "https://rescript-lang.github.io",
19-
base: "experimental-rescript-webapi",
17+
site: docsSite,
18+
base: docsBase,
2019
integrations: [
2120
starlight({
2221
title: "Experimental WebAPI",
@@ -31,8 +30,7 @@ export default defineConfig({
3130
},
3231
],
3332
editLink: {
34-
baseUrl:
35-
"https://github.com/rescript-lang/experimental-rescript-webapi/edit/main/",
33+
baseUrl: "https://github.com/rescript-lang/experimental-rescript-webapi/edit/main/",
3634
},
3735
sidebar: [
3836
{
@@ -44,6 +42,9 @@ export default defineConfig({
4442
{
4543
slug: "api-surface",
4644
},
45+
{
46+
slug: "font-attribution",
47+
},
4748
{
4849
label: "Examples",
4950
link: "examples",
@@ -75,7 +76,7 @@ export default defineConfig({
7576
},
7677
},
7778
],
78-
customCss: ["./docs/styles/fonts.css", "./docs/styles/theme.css"],
79+
customCss: ["./docs/styles/theme.css"],
7980
expressiveCode: {
8081
shiki: {
8182
langs: [rescriptTM],

‎docs/components/signatureItem.astro‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { createAPIModuleLink } from "../utils.js";
2+
import { apiModules, createAPIModuleLink, publicTypeTargets } from "../utils.js";
33
const { item, typesInOwnModule } = Astro.props;
44
55
let link;
@@ -9,8 +9,18 @@ if (typesInOwnModule && typesInOwnModule.has(item.path)) {
99
1010
if (item.path.startsWith("WebAPI.")) {
1111
const paths = item.path.split(".");
12-
if (paths.length === 3) {
13-
link = `${import.meta.env.BASE_URL}/${createAPIModuleLink(paths[1])}#${paths[2]}`;
12+
const moduleName = paths[1];
13+
if (
14+
paths.length === 3 &&
15+
moduleName &&
16+
apiModules.some((apiModule) => apiModule.moduleName === moduleName)
17+
) {
18+
link = `${import.meta.env.BASE_URL}/${createAPIModuleLink(moduleName)}#${paths[2]}`;
19+
} else if (paths.length === 3 && moduleName && paths[2]) {
20+
const publicType = publicTypeTargets.get(`${moduleName}.${paths[2]}`);
21+
if (publicType) {
22+
link = `${import.meta.env.BASE_URL}/${createAPIModuleLink(publicType.moduleName)}#${publicType.typeName}`;
23+
}
1424
}
1525
}
1626

‎docs/content/docs/api-surface.mdx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ description: A practical summary of how to use the public @rescript/webapi modul
44
slug: "api-surface"
55
---
66

7-
The package exposes browser APIs under the `WebAPI` namespace. In normal application code,
8-
add the package to `rescript.json`:
7+
The package exposes browser APIs under the `WebAPI` namespace. ReScript `13.0.0-alpha.5` is
8+
the tested compiler baseline, and alpha releases may contain breaking changes. See
9+
[project status](../project-status/) for the accepted peer range and its testing limits, and
10+
the [migration notes](https://github.com/rescript-lang/experimental-rescript-webapi/blob/main/CHANGELOG.md)
11+
for API changes.
12+
13+
Install `@rescript/webapi@alpha` and `rescript@13.0.0-alpha.5`, then add the package dependency.
14+
Feature bundles are optional when consumers need to restrict compiled modules:
915

1016
```json
1117
{
18+
"name": "webapi-consumer",
19+
"sources": [{ "dir": "src" }],
1220
"dependencies": ["@rescript/webapi"]
1321
}
1422
```
@@ -24,6 +32,9 @@ let href = location.href
2432
location->WebAPI.Location.reload
2533
```
2634

35+
For the compiler range, alpha compatibility contract, and breaking changes to byte, observer,
36+
DOM, and crypto types, read the [alpha migration notes](https://github.com/rescript-lang/experimental-rescript-webapi/blob/main/CHANGELOG.md).
37+
2738
## Public module shape
2839

2940
The public API is flat under `WebAPI`. Use owner modules directly rather than generated

0 commit comments

Comments
 (0)