-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextension.js
57 lines (50 loc) · 2.1 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var pjson = require('./package.json'),
debug = require('debug')('openframe:example'),
extension = module.exports = {};
/**
* Extension initialization method.
*
* Called when the extension (and its dependencies) have been installed.
*
* @param {object} OF An interface provided to extensions giving limitted access to the frame environment
*/
extension.init = function(OF) {
// do your extension thing
debug('=======> Openframe-ExtensionExample initialized! <=======');
/**
* Extensions can add new artwork formats to the frame.
*
* Each format must have a unique name, which should correspond to the
* name of the npm package.
*/
OF.addFormat(
{
// the name should be the same as the package name
'name': pjson.name,
// displayed to the user, perhaps? Currently unused.
'display_name': 'Example Extension',
// does this type of artwork need to be downloaded to the frame?
'download': false,
// how do start this type of artwork? currently two token replacements, $filepath and $url
'start_command': 'echo "starting Example Extension..."',
// how do we stop this type of artwork?
'end_command': 'echo "stopping Example Extension..."'
}
);
/**
* The OF provides access to the current Frame model module. From this module you can access and modify
* the current frame state directly (frame.state, a serializable js object), persist it to the local disk or
* save it to the server, etc. Look at frame.js in the Openframe repo for details.
*/
extension.frame = OF.getFrame();
/**
* Extensions also have access to the global event system
*/
extension.pubsub = OF.getPubsub();
/**
* Extensions also have access to the Swagger REST client (https://github.com/swagger-api/swagger-js)
* See openframe.io/explorer for API docs, or openframe.io/explorer/swagger.json for the swagger definition
* which shows the available methods as 'operationId'
*/
extension.rest = OF.getRest();
};