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

expose JavaScript API #15

Closed
wants to merge 5 commits into from
Closed

Conversation

cancerberoSgx
Copy link
Collaborator

@cancerberoSgx cancerberoSgx commented Jun 21, 2019

This is my current work (WIP) regarding Tw1ddle/geometrize-haxe-web#3. I just want to share it with you for review and discuss. WIP!

  • exposes classes Bitmap, ShapeJsonExporter, SvgExporter, ImageRunnerOptions, ImageRunner, ShapeType as you suggested
  • adds build-js-target.hxml (please review)
  • adds a simple browser example and build instructions. https://cancerberosgx.github.io/demos/geometrize-js-api-example/
  • adds simple node.js Command line tool example and build instructions
  • added method Bitmap.createFromRawBytes (since JavaScript users cannot access Bytes haxe standard library class which seems to be needed for building a Bitmap)

IMPORTANT: In order to not pollute this library with JavaScript stuff, maybe is better that this PR only contains changes related to exposing haxe classes and nothing else. Then, we can create an independent project geometrize-js which contains the library, examples and documentation. What do you think ?

TODO

  • reference shapes using ShapeTypes in example
  • documentation
  • render PNG example

Nice to have (but perhaps in another project?)

  • TypeScript type definitions
  • package.json and npm publish
  • tests

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 21, 2019

Very good! I've committed the @:exposes and ShapeType constants: 305b934

Perhaps you could create a separate repository that contains a submodule, like my web demo repo?

TypeScript definitions, this .d.ts generator might work though it's a WIP: https://github.com/nadako/hxtsdgen - the creator is really skilled and wants feedback.

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 21, 2019

Added function createFromByteArray to Bitmap.hx: b4b8924

For the .hxml, I think you could include the lib in one line like this: https://github.com/Tw1ddle/geometrize-haxe-web/blob/master/GeometrizeHaxeWeb.hxml#L7

@cancerberoSgx
Copy link
Collaborator Author

I think those changes are all I need :) I'm now creating the following node.js projects (tell me if that's fine):

  • geometrize-js :
    • zero-dependencies
    • contains a copy of geometrize.js file (output of haze compile), build-js.hxml, TypeScript typings api docs and build instructions.
    • contains tests that verify it exports classes/objects the typings declare
    • contains tests that verify happy path for exporters in node.js and in the browser (using puppeteer)
    • No implementation on my side, users will be calling the generated lib directly.
  • geometrize-js-cli: uses geometrize-js to provide a command line interface
  • geometrize-js-playground (private) a web demo using geometrize-js similar to geometrize-haxe-web testing the library in a real world app

I already have implemented geometrize-jswith tests and the playground as react application and is looking fine !!! :) In the typings I took the liberty of copy&paste your haxedocs.

I will update the status here right?

Please let me know if you agree or have any concerns.

Thanks! (it was really easy to do this, haxe was very friendly) :)

@Tw1ddle
Copy link
Owner

Tw1ddle commented Jun 21, 2019

Sounds like a good plan to me. Let me know if I can help at all. I'll link your work in the readme etc when you're ready 😄

One request, if you make a commercial app please don't use "geometrize" or "primitive" as the name for it, to avoid confusion. Also, include the MIT license text: https://github.com/raw/Tw1ddle/geometrize-haxe/master/LICENSE and, optionally, mention primitive and geometrize in the credits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants