GitXplorerGitXplorer
t

gwt-api-exporter

public
13 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
bab26960fe763295744b16245865f92a1a8d7979

2.0.0

ttargos committed 5 years ago
Unverified
795980a8e28c2d921eceeebb90418482a2ac892b

feat: add an option to extend the API before it is exported.

ttargos committed 5 years ago
Unverified
7af5eb1dd356c2bdb21e1a4f1190aed928d9f1a6

chore: update dependencies

ttargos committed 5 years ago
Unverified
8b6aad200ea91e30c8f5334278831a3602141446

chore: remove support for Node.js 4 and 6

ttargos committed 5 years ago
Unverified
b95b3c959614414308d63f8a0678bbe245079d71

1.2.1

ttargos committed 8 years ago
Unverified
26c7c4aad127b2949fe7aded81dcc360d578854b

fix: normalize detection of Window and Worker environments

ttargos committed 8 years ago

README

The README file for this repository.

gwt-api-exporter

NPM version build status npm download

Export a javascript API from GWT

Installation

npm i gwt-api-exporter

If you want to use the CLI, install globally:

npm i -g gwt-api-exporter

⚠️ This project uses Promise, which is only available since Node.js 0.12

What can be converted

The exporter is designed to work with files generated by the xsiframe linker, which is the default in GWT 2.7. It can handle both obfuscated and pretty files.
You will need to provide as input the file named XYZ.cache.js (name starting with MD5 hash).

To export the JS bindings, you need to use the JSInterop features available from GWT version 2.7.
Export all your names in the same object of $wnd and use the exports option to specify the name you chose.
Example: for the @JsNamespace("$wnd.example") annotation, exports would be example.
An simple example project made with Eclipse is available here: https://github.com/targos/gwt-js-example

Usage as a module

Only one method is exported and returns a Promise. If no output option is provided, the promise will resolve with the generated code. Otherwise it will write the output file and resolve with true.

var exporter = require('gwt-api-exporter');
exporter({
  input: 'xxx.cache.js',
  output: 'lib.js',
  exports: 'my.namespace',
  package: {
    name: 'my-lib',
    description: 'my awesome library',
    version: '1.0.0'
  },
  extendApi: 'function(exports) { export.extended = true }'
}).catch(function(e) {
  console.error(e);
});

package option can be the path to a package.json file or directly an object with the package data.

Usage as a CLI

gwt-api-exporter -i xxx.cache.js -e my.namespace

Options

  • -i, --input: Path to the file generated by GWT (supports only xsiframe linker)
  • -o, --output: Path for the output file (default: lib.js)
  • -e, --exports: Exported namespace of the API (without $wnd)
  • -p, --package: Path to a package.json file (default: null). If a valid file is provided, the generated lib will contain a header with some metadata like the name, description, version number...
  • -f, --no-fake: Do not use fakeWindow in browser. This is particularly useful if methods from the main window need to be called (for example $wnd.addEventListener). Care must be taken not to pollute the global object when this option is on.

License

MIT