BSB Developer Docs
Loading...
Searching...
No Matches
js_app.h File Reference

JavaScript application library. More...

#include "js_app_manifest.h"

Go to the source code of this file.

Data Structures

struct  JsAppIconPath
 Application icon path descriptor structure. More...
 
struct  JsAppPathInfo
 Application paths descriptor structure. More...
 
struct  JsAppInfo
 JsApp information structure. More...
 

Typedefs

typedef struct JsApp JsApp
 JsApp opaque type.
 

Functions

JsApp * js_app_alloc (void)
 Create a JsApp instance.
 
void js_app_free (JsApp *instance)
 Delete a JsApp instance.
 
bool js_app_load_from_directory (JsApp *instance, const char *dir_path)
 Load a JsApp instance from a special directory structure.
 
bool js_app_get_info (const JsApp *instance, JsAppInfo *info)
 Get the application information.
 

Detailed Description

JavaScript application library.

A JS application type contains the entirety of the information that is needed to properly display and run a JavaScript application.

The JS application is loaded from a directory with the following structure:

+ app_id
|
|-+ appmeta
| |- manifest.json
| |- config.json
| |- icon_front_8x8.png
| |- icon_back_11x11.png
|
|-+ scripts
| |- main.js
| |- module1.js
| |- module2.js
|
|-+ resources
|- smile.png
|- alert.snd
|- spinner.anim

The only two required files are:

  • appmeta/manifest.json - The application manifest.
  • scripts/main.js - The application entry point script.

Additionally, the top-level directory name MUST be the same as the id field in manifest.json.

All sub-folders besides appmeta and scripts are free-form and may or may not be present depending on the application.

See also
js_app_manifest.h for more info on JS application manifests.
JavaScript Applications for more info on JS applications.

Function Documentation

◆ js_app_alloc()

JsApp * js_app_alloc ( void )

Create a JsApp instance.

Returns
pointer to the created instance

◆ js_app_free()

void js_app_free ( JsApp * instance)

Delete a JsApp instance.

Warning
All JsAppInfo objects associated with the instance will become invalid after a call to this function.
Parameters
[in,out]instancepointer to the instance to be deleted

◆ js_app_get_info()

bool js_app_get_info ( const JsApp * instance,
JsAppInfo * info )

Get the application information.

Parameters
[in]instancepointer to the instance to be queried
[out]infopointer to the output structure to be filled out with info (must be allocated)
Returns
true if valid information was present, false otherwise

◆ js_app_load_from_directory()

bool js_app_load_from_directory ( JsApp * instance,
const char * dir_path )

Load a JsApp instance from a special directory structure.

Warning
All JsAppInfo objects associated with the instance will become invalid after a call to this function.
Parameters
[in,out]instancepointer to the instance to be loaded
[in]dir_pathzero-terminated string containing the path to the directory
Returns
true if the application was loaded successfully, false otherwise