https://github.com/google/elemental2
Type checked access to browser APIs for Java code.
https://github.com/google/elemental2
dom gwt indexeddb j2cl jsinterop promise svg web-storage webgl
Last synced: 5 months ago
JSON representation
Type checked access to browser APIs for Java code.
- Host: GitHub
- URL: https://github.com/google/elemental2
- Owner: google
- License: apache-2.0
- Created: 2017-05-17T22:39:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2026-01-07T21:43:02.000Z (5 months ago)
- Last Synced: 2026-01-10T20:16:39.829Z (5 months ago)
- Topics: dom, gwt, indexeddb, j2cl, jsinterop, promise, svg, web-storage, webgl
- Language: Java
- Homepage:
- Size: 464 KB
- Stars: 169
- Watchers: 25
- Forks: 37
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- gwt-boot-awesome-lili - elemental2
README
# Elemental2 ·  · [](https://github.com/google/elemental2/actions/workflows/ci.yaml)
Elemental2 provides type checked access to all browser APIs for Java code. This
is done by using [closure extern files](https://github.com/google/closure-compiler/tree/master/externs)
and generating JsTypes, which are part of the [new JsInterop specification](https://goo.gl/agme3T)
that is both implemented in GWT and J2CL.
Bazel dependencies
------------------
Using Bazel 8 or later, add to your \`MODULE.bazel\` file:
```starlark
bazel_dep(name = "elemental2", version = "")
```
Replace `RELEASE_VERSION` with an actual
[release version](https://github.com/google/elemental2/releases):
Now from you can add elemental2 targets as needed to your `j2cl_library` deps.
Following are the different elemental2 modules and their target names:
module | Bazel targets for J2CL
-----------| -----------------------
core | `@elemental2//:elemental2-core-j2cl`
dom | `@elemental2//:elemental2-dom-j2cl`
promise | `@elemental2//:elemental2-promise-j2cl`
indexeddb | `@elemental2//:elemental2-indexeddb-j2cl`
svg | `@elemental2//:elemental2-svg-j2cl`
webgl | `@elemental2//:elemental2-webgl-j2cl`
media | `@elemental2//:elemental2-media-j2cl`
webstorage | `@elemental2//:elemental2-webstorage-j2cl`
Maven dependencies
------------------
If your project uses [Maven](https://maven.apache.org), add the following maven
dependencies in your `pom.xml`. Replace `RELEASE_VERSION` with an actual
[release version](https://github.com/google/elemental2/releases):
com.google.elemental2
${artifact-id}
RELEASE_VERSION
module | artifact-id
------ | -----------
core | `elemental2-core`
dom | `elemental2-dom`
promise | `elemental2-promise`
indexeddb | `elemental2-indexeddb`
svg | `elemental2-svg`
webgl | `elemental2-webgl`
media | `elemental2-media`
webstorage | `elemental2-webstorage`
GWT
---
> Elemental2 v1.0.0+ requires GWT 2.9 or above.
If you use Elemental2 with [GWT](http://www.gwtproject.org/), you need to inherit the right gwt module in your `gwt.xml` file:
module | GWT module name
------ | ---------------
core | `elemental2.core.Core`
dom | `elemental2.dom.Dom`
promise | `elemental2.promise.Promise`
indexeddb | `elemental2.indexeddb.IndexedDb`
svg | `elemental2.svg.Svg`
webgl | `elemental2.webgl.WebGl`
media | `elemental2.media.Media`
webstorage | `elemental2.webstorage.WebStorage`
Build GWT compatible maven jar files
------------------------------------
If you want to modify and/or build the last version on your own, follow the instructions below:
- Install [Bazelisk](https://github.com/bazelbuild/bazelisk):
```shell
$ npm install -g @bazel/bazelisk
$ alias bazel=bazelisk
```
- Clone this git repository:
```shell
$ git clone https://github.com/google/elemental2.git
```
- Run the release script:
```shell
$ cd elemental2
$ ./maven/release_elemental.sh --version local --no-deploy
```
The script will output the directory containing the generated jar files that
can be used with maven.
Contributing
------------
Please refer to [the contributing document](CONTRIBUTING.md).
Licensing
---------
Please refer to [the license file](LICENSE).
Disclaimer
----------
This is not an official Google product.