Reputation: 1080
I'm trying to write a new library that would work in Scala.js. I have written some of the implementations of the classes and methods in Javascript. How do I set it up so that a user can code in Scala.js (Scala)?
I've looked at some Scala.js libraries on GitHub, but these do not show the Javascript code; they all appear to be .scala files.
So how does one actually create a new library for Scala.js?
Edit: The main code for the library must be written in Javascript since it takes advantage of the Javascript audio api.
Upvotes: 0
Views: 624
Reputation: 6025
Somewhat agreeing with the comment from @sjrd, it should be possible to write your JavaScript-targeted API directly within Scala.js (See Calling JavaScript from Scala.js ).
Alternatively, there may also be the possibility for 'importing' or converting your existing JavaScript code into Scala.js '.scala' files in a strongly-typed-Scala manner, so:
As TypeScript is a strongly-typed superset of JavaScript, changing the extension alone might be enough - otherwise, after running and failing step #2, you might need to refine you TypeScript'd library, this post, 'How to compile plain *.js (JavaScript) files with the TypeScript Compiler', should help with that.
The 'DefinitelyTyped' code repository @ Github contains a collection of JavaScript libraries updated to TypeScript, the webaudio API is one of them (so this could be converted and used within Scala.JS using some of the process outlined above).
I haven't [yet] personally tested this myself, in anger, I'd be interested in whether you get any mileage out of this tool set/process.
Here are some extra TypeScript resources:
http://en.wikipedia.org/wiki/TypeScript
http://www.sitepen.com/blog/2013/12/31/definitive-guide-to-typescript
Upvotes: 1