diff --git a/docs/content/docs/index.mdx b/docs/content/docs/index.mdx index b1a05e1..826ac96 100644 --- a/docs/content/docs/index.mdx +++ b/docs/content/docs/index.mdx @@ -36,7 +36,7 @@ export const rescriptJson = ` "@rescript/webapi", ], "bsc-flags": [ - "-open Global" + "-open WebAPI.Global" ] } `; @@ -48,7 +48,7 @@ export const rescriptJson = ` After installing the package , you can use bindings for the various Web APIs as defined in [MDN](https://developer.mozilla.org/en-US/docs/Web/API). export const rescriptSample = ` -// Note that this only works when you added the \`-open Global\` bsc flag. +// Note that this only works when you added the \`-open WebAPI.Global\` bsc flag. let location = window.location // Access properties using \`.\` diff --git a/docs/content/docs/philosophy.mdx b/docs/content/docs/philosophy.mdx index 439f2f6..8e922bf 100644 --- a/docs/content/docs/philosophy.mdx +++ b/docs/content/docs/philosophy.mdx @@ -18,8 +18,8 @@ In other words, if you are searching for a specific JavaScript binding, begin yo 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. ```ReScript -open Global -open DOMAPI +open WebAPI.Global +open WebAPI.DOMAPI let myElement: element = document->Document.createElement( ~localName = "div") ``` @@ -43,6 +43,8 @@ JavaScript supports function overloads, where a function can have multiple signa In some cases, type conversion will be required. Subtypes can safely be cast to their base type using conversion helpers within their module. ```ReScript +open WebAPI + let element: element = document->Document.createElement( ~localName = "div") let node: node = element->Element.asNode ``` @@ -50,6 +52,8 @@ let node: node = element->Element.asNode Any other conversions can be performed using the `Prelude.unsafeConversation` helper. This should be done with caution, as it can lead to runtime errors. ```ReScript +open WebAPI + let element: element = document->Document.createElement( ~localName = "div") // This is potentially unsafe, as the type system cannot guarantee the conversion let divElement: htmlDivElement = element->Prelude.unsafeConversation diff --git a/rescript.json b/rescript.json index b32c7f6..fc89a01 100644 --- a/rescript.json +++ b/rescript.json @@ -1,6 +1,7 @@ { "version": "0.0.0", "name": "@rescript/webapi", + "namespace": "WebAPI", "sources": [ { "dir": "src",