Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshtynjala/openfl-custom-js-library-sample
A sample OpenFL project that calls a JavaScript library dependency with externs
https://github.com/joshtynjala/openfl-custom-js-library-sample
haxe openfl openfl-samples openfl-target-html5
Last synced: 16 days ago
JSON representation
A sample OpenFL project that calls a JavaScript library dependency with externs
- Host: GitHub
- URL: https://github.com/joshtynjala/openfl-custom-js-library-sample
- Owner: joshtynjala
- Created: 2023-06-09T21:23:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-16T22:15:37.000Z (12 months ago)
- Last Synced: 2024-10-16T20:23:42.465Z (29 days ago)
- Topics: haxe, openfl, openfl-samples, openfl-target-html5
- Language: Haxe
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# OpenFL custom JS library
The [OpenFL](https://openfl.org) library for Haxe contains a number of template files that are used when building a project. You can find them in the [_assets/templates_](https://github.com/openfl/openfl/tree/develop/assets/templates) directory. Using the `` element in _project.xml_, it's possible to provide additional template files to copy to the output directory, on a per-project basis, and without forking OpenFL.
This sample project contains a directory named [_custom-templates_](https://github.com/joshtynjala/openfl-custom-js-library-sample/tree/main/custom-templates). It is configured in [_project.xml_](https://github.com/joshtynjala/openfl-custom-js-library-sample/tree/main/project.xml) like this:
```xml
```
Inside [_custom-templates_](https://github.com/joshtynjala/openfl-custom-js-library-sample/tree/main/custom-templates), there's a file at [_html5/template/custom-library.js_](https://github.com/joshtynjala/openfl-custom-js-library-sample/tree/main/custom-templates/html5/template/custom-library.js). This is a custom JavaScript library that needs to be called from Haxe code.
To include an HTML `` tag in the _index.html_ for _custom-library.js_, configure it in [_project.xml_](https://github.com/joshtynjala/openfl-custom-js-library-sample/tree/main/project.xml) like this:
```xml
<dependency name="./custom-library.js" if="html5"/>
```There is also a file named _src/CustomLibrary.hx_ that defines [Haxe externs](https://haxe.org/manual/lf-externs.html) for the custom library. Visit [Haxe Manual: Using external JavaScript libraries](https://haxe.org/manual/target-javascript-external-libraries.html) for more details about custom JavaScript library externs.
To build and launch the project, run the following command:
```sh
openfl test html5
```Sample created by [Josh Tynjala](https://github.com/sponsors/joshtynjala), the author of [Feathers UI](https://feathersui.com/) and core contributor to [OpenFL](https://openfl.org/).