Globally available window.cw
object carries most of externally available methods and objects. After CloudWall started, cw
global is frozen.
Members of window.cw
are different for debug and standard modes. Methods, marked with ✩
symbol, are available for apps and console only in debug mode.
If in debug mode, prints argument to console.
Exports public methods of cryptosafe closure, the only runtime context, knowing DB passwords and keys from user’s profile doc.
Returns bucket object, which is basically augmented and extended PouchDB instance. Bucket object provides large set of props and methods, though its full API description moved to a separate doc.
Returns list of db names and titles, which is array of objects like{"cw":"System DB", "manual":"Manual", ...}
.
Boolean property, debug state; true
if debug mode is on. Read-only.
Global event feed pub/sub. If argument is a string , all global listeners of the "progress"
event receive this string. If argument is a function, it becomes a listener of global "progress"
events feed.
If no argument provided, returns EventEmitter
object.
There are several system emitted "progress"
events. They generally just notifies subscribers, that system state changed, without pointing reason or event source — it’s an agreement for broadcasted events.
Events, broadcasted by system, are:
"slot open"
Some app just started"slot close"
Some app just closed"db replication started"
Tried to start replication"db replication failed"
Replication just closed or couldn’t start"settings update"
Received doc with profile settings update"app manifest update"
System received and mounted app manifest updateReturns form (named manifest) with all sub-manifests mounted, or null. If dbid provided and system appcache lookup failed, form is searched in appcache of dbid DB.
All manifests from all DBs are cached in RAM. All apps and components — their source manifests unfolded — are loaded into RAM on system start and kept up to date. System just read docs by keyrange cw-
to cw.
on start-up and caches these docs every time they are updated in DB.
When you create an app or component manifest, you give it a name. Names are like Appname
or Namespace.Appname.ComponentName
or whatever, but Capitalized and in Dot.Notation.
App may consist of many components, and each of them is mounted on app manifest to position, that is component name.
So you can create manifest of name Demo.ToDo.Wow
— and ToDo app will see it at runtime as object this.Wow
from any init
, bind
or other function of the app.
Capitals are used to guarantee no interferention with manifest properties, occupied by system. They all are not Capitalized — like ui
or init
or style
, which are taken from source manifest, and _db
or _id
, that are mounted by system.
Each DB has own cache — so you can have different versions of an app in sibling DBs.
System DB appcache is special — it is merged over every other DB’s appcache. It ensures that all system apps are visible in all DBs. Also it ensures that all DB-local apps can use system components.
Also it means you can not overlay system apps with your own in one particular DB.
System appcache consists not only of components loaded from DB. It also holds several dozens of system apps and components, loaded from cloudwall.me during system start. Each system manifest is of namespace cw.Sys
.
Layout UI, recalcs width and so on. Arg is slot id. If no arg provided, active slot gets re-layout. Slot receives layout
notification.
Locks/unlocks system. If no arg provided, returns longpoll promise. Lock state pauses all queues and disables slot switch.
Method is available only in debug mode.
Returns system lock state.
Writes serialized arguments to system log. If no arguments provided, returns array of several last log records. If only one argument passed and it‘s a number — returns an array with arg1
last log records. Each log record is normally a string of JSON format.
Log persists in localStorage and survives on any DB or profile removal.
Not equal to cw.crypto.me(). If no prop
passed, returns user name. If prop
is a string, returns property of user’s profile.
Popups non-blocking note in the right top corner of a screen. style
can be string ok
, error
, warning
or none.
Returns Promise, resolved with user profile doc. If profile is stored encrypted, it is returned ‘as is’, also encrypted.
Returns reference to the doc in cache or null. This method is available in debug mode only (restriction not yet implemented).
Registers manifest (app or component) into DB appcache.
Value is a string of CloudWall root URL, generally location.origin + '/'
.
Slot manager object. Used for running and switching apps.
Returns 20-char doc _id. First 12 numbers is a stamp with 10ms granularity, second — random 8-char string.
Returns true
if id might be doc _id, generated by uuid().