W3C and WHATWG APIs
Tabris implements a subset of popular W3C/WHATWG standards. Besides providing web developers with familiar APIs, this also enables you to use libraries developed for a browser environment. All APIs reside in the global namespace and do not have to be imported.
global is the actual global object in Tabris.js. For example, the tabris object can be accessed either via
The Tabris console object implements a subset of the WHATWG Console standard. As in the browser, messages can be logged to the developer console with different methods indicating different log levels:
console.log("A log message"); console.warn("A warning message"); console.error("An error Message"); console.trace();
console.error will also cause a message to pop up (even if the developer console is closed), but it won’t interrupt script execution. If the application is loaded via
tabris serve the output is also shown on the developer machine.
Tabris supports the timer methods
clearInterval. Passing strings to
setInterval to evaluate is NOT supported.
Tabris supports the
fetch() function to make HTTP request and to read resources that are part of the application.
A blob represent raw data that may be created from various sources and can also be read into an
ArrayBuffer or converted to a string. Blobs work with fetch, XMLHttpRequest, FileSystem and WebSocket APIs. Tabris does not support the
slice() methods of
Tabris also supports
fetch() is recommended for convenience. Only asynchronous requests are supported in Tabris.js. Attempting a synchronous request will cause an error.
WebSockets are an advanced technology that makes it possible to open an interactive communication session between the user’s client and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
The tabris support for workers allows to send data to a running worker via the
worker.postMessage(data, transferList) method. The
transferList is ignored. The types supported in the data field are:
Only the following Tabris.js APIs can be used in a worker:
- App (Except:
- file system
Widget APIs are unavailable. Calling any unsupported APIs has no effect.
Tabris supports the global object
localStorage, which allows storing key-value pairs in a persistent store. Both keys and values are stored as strings.
Note that the “storage” event is not supported. For debugging purposes the contents of the localStorage can be inspected using
In addition to the
localStorage, Tabris.js adds support for a
secureStorage available in the global scope. This is a drop-in replacement for
localStorage that keeps data encrypted using the Keychain on iOS and the AndroidKeyStore on Android.
localStorageis only meant to store relatively short strings. To store larger amounts of data it is recommended to use the
The Canvas widget provides a “2D Context” object that implements a subset of the HTML5 canvas.
Random Source (Crypto)
crypto object provides an implementation of the
RandomSource interface that can be used to generate cryptographically secure random numbers.