Skip to content

Internal API: underlying postMessage layer

Daniel Huigens edited this page Aug 30, 2014 · 1 revision

Intro

Our Internal API is implemented on top of window.postMessage().

"Upwards" messages

wm.*: From compat.js to laskyawm.js

Messages from compat.js to laskyawm.js are {messageID, action, args} objects.

messageID is an ID which is included by laskyawm.js in the response.

action is a string with the name of the function, such as 'wm.focus'.

args is an array of arguments to be passed to the function, not including callback-type functions.

fs.*: From compat.js to core.js

These messages are first sent to laskyawm.js, which forwards them to core.js and also forwards back the response. Otherwise they are the same as wm.* messages.

Note: for messages from compat.js to core.js, two messageIDs are used; one between compat.js and laskyawm.js, and one between laskyawm.js and core.js.

"Downwards" messages

Responses from core.js to laskyawm.js

These messages are {inReplyTo, result, [progress]} objects.

inReplyTo is the messageID this message is a response to.

result is an array with the arguments callback (or progress, or listener) was called with.

progress: If progress is true, the message represents a call to progress, not callback.

Requests from laskyawm.js to compat.js

laskyawm.js's openFile() also currently sends {action: 'openFile', args} messages, which you can listen for with airborn.addEventListener('openFileRequest', listener). Both of these will probably be deprecated in favor of Web Activities.

Forwarded messages from core.js to compat.js

core.js forwards messages directly sent from apps to core.js (window.top) to compat.js under the assumption they were meant to go there. This isn't perfect, though: many properties of the received message object, such as message.source, will be "wrong".