When building applications with the Saito-Lite-Rust software, Javapscript must first be compiled before it can ran on a core-client or served to lite-clients (like browsers).
The core-client is a full node, more specifically, an application node and is responsible for compiling and serving compiled applications to lite-clients.
Your application won't be compiled until the compile configuration lists it.
Open the file /saito-lite-rust/config/modules.config.js
.
Add myApp/myApp.js
to core
, lite
or both.
core [
'myApp/myApp.js',
...
lite: [
'myApp/myApp.js',
...
Then navigate to /saito-lite-rust
and compile the javascript bundle:
> npm run nuke
If this is not your first time compiling the software you can run npm run compile
instead. Once compilation finishes, start Saito by running:
> npm start
Saito uses two main configuration files. The first is config/options
which specifies network configuration options like the IP address on which the server runs and the ports it should open and the peers to which it should connect. A second config/modules.config.js
file specifies which modules should run on the server and any browsers that connect to it.
Running npm run nuke
will create fresh versions of these configuration files from template files that are stored in the config
directory. It will also compiles a compressed version of Saito from the modules.config.js
that will be fed out to browsers which connect to the server and request the default javascript.
You can always reset your client by running the "nuke" command, but if you wish to change the applications supported on your server without resetting the blockchain, you can run the following instruction instead:
npm run compile
compile
ScriptThe compile
script supports additional logging options, which can be specified using the --loglevel
or -l
flags. This feature allows you to set the desired log level for the compilation process.
To set a specific log level, use one of the following commands:
npm run compile -- --loglevel=<level>
or
npm run compile -- -l <level>
Where level can be one of the following:
npm run compile -- --loglevel=warn
or
npm run compile -- -l warn
Both the compile
and nuke
scripts can be run with a dev
flag:
npm run compile dev
npm run nuke dev
When this flag is used:
JavaScript is not minimized and source maps are shipped with the code
The payload is 2 to 3 times larger than otherwise but makes in-browser
debugging possible.
CSS files are linked (@include()
CSS source files, rather than
being a concatentation of the source CSS). This makes CSS development
slightly easier.
The result is that many more files are downloaded by the client, but in-browser debugging is much easier
Dynamic Module Compilation can be used to compile modules into standalone bundles users can drag-and-drop to install into their browser. The following section shows how to compile applications into this format.
Make sure your local Saito node is compiled with both CORE and LITE support of the devtools
module, and then start your server and visit /devtools
in your browser. You will see a drag-and-drop target.
Provide ZIP file of your module directory and a popup will appear confirming the details of the application. If there is an issue reading the .zip file you likely have a problem with the application -- make sure it compiles and runs locally before you attempt to compile for remote installation. Otherwise click the button to generate the application.
Once you click the button, it may take a short while, but your machine will compile your module into a standalone file and download it to your machine. Find that file - this is the application-file that browsers will be able to install.
To install these standalone application packages, click on the top-right menu in any Saito application and click on the Account button below your wallet balance. On the overlay that appears, look for the "+" button that shows up on the top-right of your installed modules.
Click on the add button and you'll get another drag-and-drop target. Drag the application package that you previously compiled into this window.
A popup will appear to confirm installation. Confirm that you want to install this application and click "Install" if so.
Your browser will unpack the application, save it in your wallet and refresh. Once your browser reloads it will load the application you have just installed along with all other modules. You can now toggle it on-or-off like any other module.