Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 28 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:

permissions:
contents: read
pages: write
# pages: write
# Docs publishing is paused until the alpha docs/tag naming is settled.
id-token: write

jobs:
Expand Down Expand Up @@ -39,14 +40,16 @@ jobs:
- name: Run tests
run: npm test

- name: Build documentation
run: npm run build:docs

- name: Upload documentation
uses: actions/upload-pages-artifact@v4
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
with:
path: ./dist
# - name: Build documentation
# run: npm run build:docs
#
# - name: Upload documentation
# uses: actions/upload-pages-artifact@v4
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# with:
# path: ./dist
#
# Docs publishing is paused until the alpha docs/tag naming is settled.

- name: get-npm-version
id: package-version
Expand All @@ -57,7 +60,7 @@ jobs:
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Update version to -<commit-hash>
run: npm version --no-git-tag-version "${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }}"
run: npm version --no-git-tag-version "${{ steps.package-version.outputs.current-version }}-pre-alpha-${{ env.COMMIT_HASH }}"

- name: Package npm project
run: npm pack
Expand All @@ -72,16 +75,18 @@ jobs:
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

deploy-docs:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
run: npm publish --access public ./*.tgz --tag pre-alpha

# deploy-docs:
# needs: build
# runs-on: ubuntu-latest
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
# steps:
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v5
#
# Docs publishing is paused until the alpha docs/tag naming is settled.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dist/
tmp/
docs/public/llm.txt
*~
/packages/*/node_modules/
/packages/*/lib/
8 changes: 4 additions & 4 deletions docs/content/docs/contributing/api-modelling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ mutable fillStyle: fillStyle
}
`;

<Code code={fillStyleDef} title="DOMAPI.res" lang="ReScript"></Code>
<Code code={fillStyleDef} title="DOM.res" lang="ReScript"></Code>

When we wish to read and write the `fillStyle` property, we can use a helper module to lift the type to an actual ReScript variant:

export const fillStyleModule = `
open Prelude
open CanvasAPI
open DOMAPI
open Canvas
open DOM

external fromString: string => fillStyle = "%identity"
external fromCanvasGradient: canvasGradient => fillStyle = "%identity"
Expand All @@ -112,7 +112,7 @@ String(unsafeConversation(t))
}
`

<Code code={fillStyleModule} title="DOMAPI/FillStyle.res" lang="ReScript"></Code>
<Code code={fillStyleModule} title="DOM/FillStyle.res" lang="ReScript"></Code>

We can now use `FillStyle.decode` to get the actual value of the `fillStyle` property.
And use `FillStyle.fromString`, `FillStyle.fromCanvasGradient`, and `FillStyle.fromCanvasPattern` to set the value.
Expand Down
6 changes: 3 additions & 3 deletions docs/content/docs/contributing/api-module-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ slug: "02-api-module-structure"
import { Aside } from "@astrojs/starlight/components";
import { FileTree } from "@astrojs/starlight/components";

The bindings are organized by the Web API they represent. Each API has its interfaces and auxiliary types in a module named after the API, suffixed with `API` to prevent collisions with the type module.
The bindings are organized by the Web API they represent. Each API has its interfaces and auxiliary types in a module named after the API.

<FileTree>

- package.json
- src
- DOMAPI.res
- DOMAPI
- DOM.res
- DOM
- HTMLElement.res

</FileTree>
Expand Down
10 changes: 5 additions & 5 deletions docs/content/docs/contributing/module-type-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Under normal circumstances, the type module only contains `@send` bindings where

<FileTree>

- DOMAPI
- DOM
- HTMLButtonElement.res

</FileTree>
Expand All @@ -40,7 +40,7 @@ When an interface inherits from another interface, the base interface methods ca
All methods from [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement#instance_methods) should also be available on [HTMLButtonElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement#instance_methods).

export const htmlElementModule = `
open DOMAPI
open DOM

// A concrete type for \`T.t\` is passed later using the \`include\` keyword.
module Impl = (T: { type t }) => {
Expand All @@ -56,10 +56,10 @@ external focus: (T.t, ~options: focusOptions=?) => unit = "focus"
include Impl({ type t = htmlElement })
`;

<Code code={htmlElementModule} title="DOMAPI/HTMLElement.res" lang="ReScript"></Code>
<Code code={htmlElementModule} title="DOM/HTMLElement.res" lang="ReScript"></Code>

export const buttonModule = `
open DOMAPI
open DOM

// Include all the methods from HTMLElement
include HTMLElement.Impl({ type t = htmlButtonElement })
Expand All @@ -74,4 +74,4 @@ _/
external checkValidity: htmlButtonElement => bool = "checkValidity"
`;

<Code code={buttonModule} title="DOMAPI/HTMLButtonElement.res" lang="ReScript"></Code>
<Code code={buttonModule} title="DOM/HTMLButtonElement.res" lang="ReScript"></Code>
6 changes: 3 additions & 3 deletions docs/content/docs/contributing/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Create a new help in the `test` folder with the same name as the module you want
<FileTree>

- src
- DOMAPI.res
- DOMAPI
- DOM.res
- DOM
- HTMLCanvasElement.res
- tests
- DOMAPI
- DOM
- HTMLCanvasElement_test.res

</FileTree>
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/philosophy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ The bindings are generated from the [MDN Web API documentation](https://develope

In other words, if you are searching for a specific JavaScript binding, begin your journey at the [MDN Web API documentation](https://developer.mozilla.org/en-US/docs/Web/API) and determine which module contains your sample. Ensure that the module is available in the bindings by checking the specific API. Please [open an issue](https://github.com/rescript-lang/experimental-rescript-webapi/issues/new/choose) if you require an API that is not yet present.

Each API will have its interface and auxiliary types in a module named after the API, suffixed with `API` to prevent collisions with the type module.
Each API will have its interface and auxiliary types in a module named after the API.

```ReScript
open WebAPI.Global
open WebAPI.DOMAPI
open WebAPI.DOM

let myElement: element = document->Document.createElement( ~localName = "div")
```
Expand Down
Loading