Create your applications

NextSurface provides an API for writing applications with JavaScript language. The API includes classes, functions, and objects, which together represent a programmable environment designed to makes easy writing interactive applications. NextSurface extends the JavaScript language with additional features which help creating reusable code. Developers can split the code into several files and import them into other scripts. Read the documentation about Classes and Objects to get started.

Classes

NextSurface API consists of classes which can be divided in categories such as values objects, stateful objects, built-in objects, and abstract objects. Value objects are immutable and safe to share. Stateful objects have mutable state and must be shared carefully (however JavaScript is single threaded so we don't need to worry about concurrency). Built-in objects are singleton and they can't be instantiated, but there is one global instance available. Abstract objects can't be instantiated directly, instead they are created using factory methods.

Objects

NextSurface provides several built-in implementations of Abstract objects. Each implementation extends the a base class adding properties and functions. Since JavaScript doesn't have the concept of subclass, the extension is implemented modifing a prototype object which is created from the base class. The majority of abstract objects are extension of Component class for building a rich user interface. Other abstract objects are extensions of LayoutManager and GestureRecognizer.

JavaScript extensions

NextSurface extends the JavaScript language with some features which help creating reusable code. NextSurface interprets a directive #include which allows to import the content of another script into current scripst's scope. The directive can be used with any absolute path or with expressions including built-in variables ${bundle-path} and ${workspace-path}. The bundle path represents the directory of application's bundle, usually located at /Applications/NextSurface.app. The workspace path represents the directory of workspace which is selected when launching the application. Files are imported in order of inclusion, therefore a file can override symbols declared in previous files. See examples below.

#include "${bundle-path}/Contents/Resources/scripts/libs/nextsurface.js";

#include ${workspace-path}/boot/launchpad.js;

#include /home/user/somescript.js;

console.log("Ready");
						

Examples

NextSurface is distributed with many examples. Examples are self-explanatory and quite easy to understand. In order to try the examples, launch the application in developer mode. Locate the workspace directory and open a script from the examples subdirectory in your preferred text editor. Use the Script menu to open the same file in NextSurface. See the output in the console if any. In case you created your workspace with an older version of NextSurface, you won't find any examples. Try creating a new workspace with the latest version and look for the examples there.


Follow NextSurface on Facebook