{"id":15667661,"url":"https://github.com/treblereel/gwt3-processors","last_synced_at":"2025-04-30T08:22:52.471Z","repository":{"id":38658644,"uuid":"344924995","full_name":"treblereel/gwt3-processors","owner":"treblereel","description":"Set of goodies for J2CL apps","archived":false,"fork":false,"pushed_at":"2024-11-28T20:25:07.000Z","size":807,"stargazers_count":16,"open_issues_count":4,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T14:22:01.912Z","etag":null,"topics":["closure-compiler","closure-library","j2cl","java","javascript"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treblereel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-05T20:21:35.000Z","updated_at":"2024-12-09T20:44:20.000Z","dependencies_parsed_at":"2023-09-30T23:45:51.389Z","dependency_job_id":"7b102ad2-05b1-4fc8-9913-c713cc6b0136","html_url":"https://github.com/treblereel/gwt3-processors","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treblereel%2Fgwt3-processors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treblereel%2Fgwt3-processors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treblereel%2Fgwt3-processors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treblereel%2Fgwt3-processors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treblereel","download_url":"https://codeload.github.com/treblereel/gwt3-processors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666928,"owners_count":21624398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["closure-compiler","closure-library","j2cl","java","javascript"],"created_at":"2024-10-03T14:04:38.893Z","updated_at":"2025-04-30T08:22:52.440Z","avatar_url":"https://github.com/treblereel.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub license](https://img.shields.io/github/license/treblereel/gwt3-processors)](https://github.com/treblereel/gwt3-processors/blob/main/LICENSE)\n![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/org.treblereel.j2cl.processors/processors?server=https%3A%2F%2Foss.sonatype.org\u0026style=plastic)\n[![Join the chat at https://gitter.im/vertispan/j2cl](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/vertispan/j2cl?utm_source=badge)\n\n\n# gwt3-processors\n\n## What is it ?\n\nIt's a set of helper processors that can speed up J2CL development by generating boiler-plate code.\n\nThe latest version: https://search.maven.org/search?q=g:org.treblereel.j2cl.processors\n\nIt contains the following features:\n\n* *@GWT3EntryPoint* acts pretty much the same as *Gwt2 EntryPoint*, the annotated method will be called on application startup.\n  ```java\n  public class App {\n\n  @GWT3EntryPoint\n  public void init() {\n    HTMLButtonElement btn = (HTMLButtonElement) DomGlobal.document.createElement(\"button\");\n    btn.textContent = \"PRESS ME !\";\n    }\n  }\n  ```\n\n* *@ES6Module* allows us to use Es6 modules via JsInterop.\n  ```java\n  @ES6Module\n  @JsType(isNative = true, namespace = \"org.treblereel.j2cl.shim\")\n  public class ES6Test {\n    public String id;\n    public native boolean isTest();\n   }\n  ```\n  ```javascript\n   class ES6Test {\n    constructor() {\n      /** @type {string} */\n      this.id = \"#id\"\n    }\n    /**\n    * @return {boolean}\n    */\n    isTest() {\n      return true;\n    }\n   }\n  export { ES6Test };\n  ```\n  \n* *@GWT3Export* allows a resulted JavaScript file to be called from the pure JavaScript environment.\n  \n  ```java\n  public class ExportTestClass {\n  \n      @GWT3Export\n      public static String test(String s) {\n        return s;\n      }\n    \n      @GWT3Export\n      public Promise\u003cString\u003e promise() {\n        return Promise.resolve(\"Hello world!\");\n      }\n  }\n  ```\n  ```javascript\n    var test = new org.treblereel.j2cl.exports.ExportTestClass();\n\n    test.test('INSTANCE METHOD CALL');\n\n    test.promise().then(function(result) {\n       \n    });\n   ```\n\n* *@TranslationBundle* j2cl-maven-plugin 0.21 brings us support of Closure's `.xtb` translation bundles that are a very effective way to translate your application.\n    * Note: at the moment, `.xtb` support is only available for j2cl-maven-plugin 0.21 and above and works only in ADVANCED mode, otherwise default values will be used.\n\n  To use `@TranslationBundle`, you need to do the following steps:\n\n1. In the configuration section of j2cl-maven-plugin, enable `.xtb` auto discovery:\n\n  ```xml\n    \u003ctranslationsFile\u003e\n      \u003cauto\u003etrue\u003c/auto\u003e\n    \u003c/translationsFile\u003e\n  ```\n\n2. To a set locale for current compilation, you need to add the following line to your `pom.xml`\n    \n  ```xml\n    \u003cdefines\u003e\n      \u003cgoog.LOCALE\u003een\u003c/goog.LOCALE\u003e\n    \u003c/defines\u003e\n  ```\n\n3. Create an interface _MyBundle_ annotated with `@TranslationBundle`\n    \n  ```java\n    @TranslationBundle\n    public interface MyBundle {\n      ...\n    }\n  ```\n  The processor will generate the `MyBundleImpl.java` implementation in the same package where _MyBundle_ is.\n\n4. Create a translation property bundle for _MyBundle_ with a locale declared in the following format:\n\n    * `MyBundle_en.properties` or `MyBundle_en_US.properties` containing key value pairs like:\n    * `hello = Hello World!` or `hello = Hello {$arg}!`\n    \u003cbr/\u003e\u003cbr/\u003e\n    Note: `{$arg}` is a placeholder for a string argument.\n\n5. Declare corresponding methods in your _MyBundle_ interface.\n\n  ```java\n    @TranslationBundle\n    public interface MyBundle {\n    \n      @TranslationKey(defaultValue = \"Hello World!\")\n      String hello();\n    \n      @TranslationKey(defaultValue = \"Hello {$arg}!\")\n      String hello(String arg);\n    }\n  ```\n\n  Default value is used if no translation property value is found for a given locale and key.\n  If a value contains the `{$arg}` placeholder, it will be replaced with the argument provided to the method. Placeholder is surrounded with curly brackets and a corresponding method argument must be named the same; \n\n6. Values can be in HTML, in this case HTML will be escaped. To unescape it, set `unescapeHtmlEntities = true` in the `@TranslationKey` annotation.\n\n  ```java\n      @TranslationKey(defaultValue = \"\u003cdiv\u003eHELLO\u003c/div\u003e\", unescapeHtmlEntities = true)\n      String hello();\n  ```\n   \n7. Each method should have a corresponding key value pair in a translation property file. Otherwise, a default value will be used. A method name can be overridden in `@TranslationKey` annotation.\n\n  ```java\n      @TranslationKey(key = \"greetings\", defaultValue = \"Hello World!\")\n      String hello();\n  ```\n\n* *@GWT3Resource* is a lightweight port of GWT2 resources. Its main purpose is to embed various resources into the JavaScript bundle.\n\n  Here we declared a bundle of the resources that will be embedded into the JavaScript bundle:\n  ```java\n      @GWT3Resource\n      public interface CombinedClientBundle extends ClientBundle {\n\n          @Source(\"logo.png\")\n          ImageResource linuxLogo();\n\n          TextResource welcome();\n\n          @DataResource.MimeType(\"audio/mpeg\")\n          @Source(\"alarmloop.mp3\")\n          DataResource resourceMimeTypeAnnotationAudioOgg();\n     }\n  ```\n  Later,  we can use it like this:\n\n  ```java\n       CombinedClientBundle resources = CombinedClientBundleImpl.INSTANCE;\n\n        DomGlobal.document.body.appendChild(resources.linuxLogo().getImage());\n\n        HTMLDivElement container = (HTMLDivElement) DomGlobal.document.createElement(\"div\");\n        DomGlobal.document.body.appendChild(container);\n        container.textContent = resources.welcome().getText();\n\n        HTMLAudioElement audio = (HTMLAudioElement) DomGlobal.document.createElement(\"audio\");\n        DomGlobal.document.body.appendChild(audio);\n        audio.src = resources.resourceMimeTypeAnnotationAudioOgg().asString();\n        audio.controls = true;\n  ```  \n\nTake a look at tests for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblereel%2Fgwt3-processors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreblereel%2Fgwt3-processors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblereel%2Fgwt3-processors/lists"}