It's built one very flexible and powerful web framework so far but has all of the building blocks for any custom environment.
The download size can be reduced a lot by splitting up some of the existing framework layers so that it's only included if you use those features.
This assumes you've installed the scc command in getting started.
First install the coreFramework bundle of layers in the bundles directory. From this directory:
(cd bundles; git clone https://github.com/stratacode/coreFramework)
Put the StrataCode/bin directory in your path. Create the file:
Put ordinary Java files in the myLayer directory, add a main with @sc.obj.MainSettings like this
From this directory run:
scc -v -a myLayerGroup.myLayer
it should open the browser to an index page and the JS console will contain the "System.out.println" calls made in the code.
The 'main' class is added as an entry point during the build process and all referenced code is included in the "main.js" file, unless it's put into a module.
Look in bundles/coreFramework/js for the layers that control the Java to JS conversion.
TODO: The js.core layer could be split up to separate out the webFramework more cleanly to reduce the download size for java to js applications that don't use it.
Read the intro article
See the javadoc
Read more about customizing the generation in the framework documentation
Mapping Java classes to JS files
If you do not assign a JSSettings(jsModuleFile) annotation, only code which is accessible via an entryPoint class is included in the JS file for the entry point. This is a nice way to selectively drag in only the code used and build up one big JS file with all of that code.
When you set jsLibraryFile on the JSSettings annotation, it is not converted, but instead the library file is expected to include a native implementation of the Java class (i.e. authored in JS).
There's a way to replace method and field names if there are any naming conflicts. If a class has a field and method with the same name, that's automatically handled by adding an _ to the field name.
- js/jvsys.js - generated Java java.sys, java.util classes from Apache 8 Java classes in coreFramework/js/sys - Note these files are named '.scj' only for the IntelliJ plugin so they are mapped as StrataCode files, not the native Java engine.
- js/javasys.js - natively written Java classes java.sys, java.util classes (copied from coreFramework/js/core/js)
js/sccore.js - core functions used in the generated JS templates (also from coreFramework/js/core/js)
js/tags.js, - not used in this sample - the SC web framework. TODO: create a base-layer which does not include this and other SC framework JS files so the converter is usable without this dependency
/home/myProj/bundles/coreFramework/js/sys - the layer that contains the Java system files, used to build js/jvsys.js