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.
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
File renamed without changes.
2 changes: 1 addition & 1 deletion src/CSSFontLoadingAPI.res → src/CSSFontLoading.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@warning("-30")

open EventAPI
open Event

type fontDisplay =
| @as("auto") Auto
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CSSFontLoadingAPI
open CSSFontLoading

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/FontFace)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CSSFontLoadingAPI
open CSSFontLoading

include EventTarget.Impl({type t = fontFaceSet})

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/CanvasAPI.res → src/Canvas.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@@warning("-30")

open Prelude
open EventAPI
open Event

type offscreenRenderingContextId =
| @as("2d") V2d
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CanvasAPI
open Canvas

/**
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.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open DOMAPI
open CanvasAPI
open DOM
open Canvas

/**
Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/CanvasAPI/FillStyle.res → src/Canvas/FillStyle.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Prelude
open CanvasAPI
open Canvas

external fromString: string => fillStyle = "%identity"
external fromCanvasGradient: canvasGradient => fillStyle = "%identity"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CanvasAPI
open Canvas

/**
Releases imageBitmap's underlying bitmap data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CanvasAPI
open Canvas

/**
Transfers the underlying bitmap data from imageBitmap to context, and the bitmap becomes the contents of the canvas element to which context is bound.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open CanvasAPI
open FileAPI
open Canvas
open File

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OffscreenCanvas)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/CanvasAPI/Path2D.res → src/Canvas/Path2D.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open CanvasAPI
open DOMAPI
open Canvas
open DOM

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Path2D)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ChannelMessagingAPI.res → src/ChannelMessaging.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@warning("-30")

open EventAPI
open Event

/**
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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open ChannelMessagingAPI
open ChannelMessaging

include EventTarget.Impl({type t = messagePort})

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open ClipboardAPI
include ClipboardTypes

include EventTarget.Impl({type t = clipboard})

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open FileAPI
open ClipboardAPI
open File
open Clipboard
open Prelude

/**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ClipboardAPI.res → src/ClipboardTypes.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@warning("-30")

open EventAPI
open Event

type presentationStyle =
| @as("attachment") Attachment
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@@warning("-30")

open Prelude
open EventAPI
open Event

type authenticatorTransport =
| @as("ble") Ble
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open CredentialManagementAPI
open CredentialManagement

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get)
Expand Down
File renamed without changes.
Loading
Loading