Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Chrome APIs #120

Closed
wants to merge 1 commit into from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ jsinterop_generator(
name = "elemental2-indexeddb",
exports = ["//java/elemental2/indexeddb"],
)

# Chrome api
jsinterop_generator(
name = "elemental2-chrome",
exports = ["//java/elemental2/chrome"],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

top-level target for elemental2-chrome

)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Following are the different elemental2 modules and their target names:
webgl | `@com_google_elemental2//:elemental2-webgl-j2cl`
media | `@com_google_elemental2//:elemental2-media-j2cl`
webstorage | `@com_google_elemental2//:elemental2-webstorage-j2cl`
chrome | `@com_google_elemental2//:elemental2-chrome-j2cl`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard README updates


Maven dependencies
------------------
Expand All @@ -76,6 +77,7 @@ If your project use [Maven](https://maven.apache.org), add maven dependencies in
webgl | `elemental2-webgl`
media | `elemental2-media`
webstorage | `elemental2-webstorage`
chrome | `elemental2-chrome`

Download the jar files
----------------------
Expand All @@ -91,6 +93,7 @@ You can also download manually the jars files.
webgl | [elemental2-webgl.jar](https://oss.sonatype.org/content/repositories/releases/com/google/elemental2/elemental2-webgl/1.0.0-RC1/elemental2-webgl-1.0.0-RC1.jar)
media | [elemental2-media.jar](https://oss.sonatype.org/content/repositories/releases/com/google/elemental2/elemental2-media/1.0.0-RC1/elemental2-media-1.0.0-RC1.jar)
webstorage | [elemental2-webstorage.jar](https://oss.sonatype.org/content/repositories/releases/com/google/elemental2/elemental2-webstorage/1.0.0-RC1/elemental2-webstorage-1.0.0-RC1.jar)
chrome | [elemental2-chrome.jar](https://oss.sonatype.org/content/repositories/releases/com/google/elemental2/elemental2-webstorage/1.0.0-RC1/elemental2-chrome-1.0.0-RC1.jar)

GWT
---
Expand All @@ -106,6 +109,7 @@ If you use Elemental2 with [GWT](http://www.gwtproject.org/), you need to inheri
webgl | `elemental2.webgl.WebGl`
media | `elemental2.media.Media`
webstorage | `elemental2.webstorage.WebStorage`
chrome | `elemental2.chrome.Chrome`

Contributing
------------
Expand Down
39 changes: 39 additions & 0 deletions java/elemental2/chrome/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This package contains the build rule to build elemental2-chrome.

package(default_visibility = [
"//:__subpackages__",
])

# Apache2
licenses(["notice"])

load(
"@com_google_jsinterop_generator//:jsinterop_generator.bzl",
"jsinterop_generator",
)

load(
"//build_defs/internal_do_not_use:elemental_utils.bzl",
"patch_extern_file",
)

patch_extern_file(
name = "chrome_patched",
src = "//third_party:chrome.js",
patch_file = "chrome.js.diff",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple patch is applied via elemental2's patching defs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I'm working on elemental now in order to get rif of these patch files. This is a burden in term of extern maintenance and require a continuous sync between elemental2 and closure github repo.

)

filegroup(
name = "externs",
srcs = [":chrome_patched"],
)

jsinterop_generator(
name = "chrome",
srcs = [":externs"],
integer_entities_files = ["integer_entities.txt"],
name_mapping_files = ["name_mappings.txt"],
deps = [
"//java/elemental2/core",
"//java/elemental2/dom",
])
36 changes: 36 additions & 0 deletions java/elemental2/chrome/chrome.js.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
295c295
< * @extends {ChromeBaseEvent<function()>}
---
> * @extends {ChromeBaseEvent<!Function>}
303c303
< * @extends {ChromeBaseEvent<function(string)>}
---
> * @extends {ChromeBaseEvent<!Function>}
311c311
< * @extends {ChromeBaseEvent<function(boolean)>}
---
> * @extends {ChromeBaseEvent<!Function>}
319c319
< * @extends {ChromeBaseEvent<function(number)>}
---
> * @extends {ChromeBaseEvent<!Function>}
327c327
< * @extends {ChromeBaseEvent<function(!Object)>}
---
> * @extends {ChromeBaseEvent<!Function>}
335c335
< * @extends {ChromeBaseEvent<function(!Array<string>)>}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build was having issues with these signatures, so i've made them generic for now, until they can get better type visibility

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---
> * @extends {ChromeBaseEvent<!Function>}
343c343
< * @extends {ChromeBaseEvent<function(string, string)>}
---
> * @extends {ChromeBaseEvent<!Function>}
380,382c380,382
< USER: '',
< CAPTURE: '',
< EXTENSION: '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless diff

---
> USER: '',
> CAPTURE: '',
> EXTENSION: '',
7 changes: 7 additions & 0 deletions java/elemental2/chrome/integer_entities.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
elemental2.chrome.MessageSender.frameId
elemental2.chrome.Tab.id
elemental2.chrome.Tab.index
elemental2.chrome.Tab.windowId
elemental2.chrome.Tab.openerTabId
elemental2.chrome.Tab.width
elemental2.chrome.Tab.height
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are all the simple integer-seeming types i could find in the chrome extern namespace, at first glance

1 change: 1 addition & 0 deletions java/elemental2/chrome/name_mappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
elemental2.chrome.chrome.Runtime.SendMessageCallbackFn.onInvoke.p0=response
10 changes: 10 additions & 0 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,13 @@ alias(
name = "jsinterop-base-j2cl",
actual = "@com_google_jsinterop_base//:jsinterop-base-j2cl",
)

alias(
name = "chrome.js",
actual = "@com_google_closure_compiler//:contrib/externs/chrome.js",
)

alias(
name = "chrome_extensions.js",
actual = "@com_google_closure_compiler//:contrib/externs/chrome_extensions.js",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and, finally, update to third_party/BUILD to bring in the relevant extern files.

)