Cosmic Docs

Theme

Cosmic

Cosmic is a simple Javascript and WASM runtime for developing Desktop, Gaming, Backend, and Web applications. Our approach is to start with V8 (the fastest script engine) and design a rich API and tools around it. To get a gauge of what Cosmic can do now, check out the docs for each API module as well as the Tools section.

NOTE: Although the docs and public showcase present everything to be working, Cosmic is still considered experimental software since it's still in its infancy.

Native API

One of the goals of Cosmic is to provide a cross platform Js/Wasm API to do all the neat things your computer can do. This means having a window API, a 2D/3D graphics API, a multimedia API, a networking API, a file system API, and more. On top of these basic layers, Cosmic will also provide higher level constructs like a UI framework, an animation API, and more.

Supporting the Web/Node API is a non goal, but Cosmic will have similar features. For example, "fetch" is implemented as making http requests from the cs.http module. Once the Cosmic API is fleshed out more, it shouldn't be hard for one to create a Web polyfill in pure JS.

Conventions

If you've come from Web or Node development you might be wondering how different it is to code in Cosmic:

Cosmic is aiming to make coding accessible, unrestrictive, productive, fast, and fun! Like what you see? Join our community and voice your opinions!

Install

Download links can be found here: Downloads.

One liner cli install commands will make it here eventually.

Getting Started

Hello World

First make sure you have downloaded Cosmic for your platform. Open up your text editor and create hello.js:

const Color = cs.graphics.Color

puts('Hello World!')

const w = cs.window.create(1200, 720, 'Demo')
w.onUpdate(g => {
    g.fontSize(52)
    g.fillColor(Color.blue)
    g.text(400, 300, 'Hello World!')
})

Then run this in the terminal:

cosmic hello.js

Try out more examples:

git clone https://github.com/fubark/cosmic.git
cosmic cosmic/examples/paddleball.js
cosmic cosmic/examples/demo.js

You can find more examples here!

Tools

One of the goals for Cosmic is to provide useful tools to help you develop software.

cosmic run foo.js

This runs your script with the cosmic runtime. You can also run foo.js with "cosmic foo.js".

cosmic dev foo.js

This runs your script but also watches it for changes to do hot reloading. This feature is not implemented yet.

cosmic test foo.test.js

Runs tests in foo.test.js.

cosmic exe foo.js

Creates a single binary executable for your app at foo.js. This feature is not implemented yet.

You'll also be able to target the Web as a platform and it will generate the html/js bundle you'll need.

Eventually you'll be able to create an executable for a foreign target platform!

cosmic http ./public 8081

Starts hosting a HTTP web server over your static files in the public directory.

cosmic https ./public my.crt my.key 8081

Like `cosmic http` but secure. You'll need to supply your public and private keys.

cosmic shell

Starts a shell where you can perform quick calculations or experiment with the API before creating a script. Note: The window API does not work in the shell currently.

cosmic *more*

Do you think we're missing something? Voice your opinion on Discord or open an issue on Github!

Tutorials

Tutorials and learning material will be posted up when they are available.

Windowing
2D Graphics
UI and Widgets
3D Graphics
Input
Sound
Importing
Error handling
Async
Dev Mode
IntelliSense
Testing
WASM
Exporting

Community

Contributing

Head on over to the github repo to learn how to contribute!