Skip to content

Commit e625475

Browse files
Erwan CarriouErwan Carriou
authored andcommitted
- add system-admin addon
- .off() method remove all listeners from an object - schema are now merged when we create twice the same schema - remove SyrupChannelEvent schemas: now channel creation is easier, we use SyrupChannel schemas - update dev depedencies - add more unit tests
1 parent 4c7ef0d commit e625475

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1169
-555
lines changed

addons/system-admin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"schemas":{"Worker":{"_id":"Worker","_name":"Worker","_schema":"WorkerSchema","_inherit":["SyrupComponent"],"_core":true,"worker":{"type":"object","readOnly":false,"mandatory":false,"default":{}},"send":{"params":[{"name":"message","type":"object"}]}},"WorkerSchema":{"_id":"WorkerSchema","_name":"WorkerSchema","_inherit":["SyrupComponentSchema"],"_core":true,"worker":"property","send":"method"},"SyrupAdminSchema":{"_id":"SyrupAdminSchema","_name":"SyrupAdminSchema","_inherit":["SyrupComponentSchema"],"_core":true,"start":"method","stop":"method"},"SyrupAdmin":{"_id":"SyrupAdmin","_name":"SyrupAdmin","_schema":"SyrupAdminSchema","_inherit":["SyrupComponent"],"_core":true,"start":{"params":[{"name":"path","type":"string","mandatory":false,"default":""}]},"stop":{}},"SyrupChannelSchema":{"_id":"SyrupChannelSchema","_name":"SyrupChannelSchema","sync":"event","loadSystem":"event","updateBehavior":"event"},"SyrupChannel":{"_id":"SyrupChannel","_name":"SyrupChannel","_schema":"SyrupChannelSchema","_inherit":["SyrupComponent"],"sync":{},"loadSystem":{"params":[{"name":"system","type":"object"}]},"updateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]}}},"types":{},"behaviors":{"1c00c107e01c9b3":{"_id":"1c00c107e01c9b3","component":"SyrupAdmin","state":"start","action":"function start(path) {\n var Worker = null,\n worker = null,\n workerPath = '',\n SyrupChannel = null,\n syrupChannel = null;\n \n if (path) {\n workerPath = path + '/scripts/worker.js';\n workerPath = workerPath.replace(/\\/\\//g,'/');\n } else {\n workerPath = '/designer/scripts/worker.js';\n }\n \n if (typeof SharedWorker !== 'undefined' && !this.require('channel-admin')) {\n \n SyrupChannel = this.require('SyrupChannel');\n syrupChannel = new SyrupChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n syrupChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n });\n syrupChannel.on('sync', function sync() {\n this.loadSystem(JSON.parse(this.require('db').system()));\n });\n syrupChannel.on('send', function send(message) {\n this.require('worker-admin').worker().port.postMessage(message);\n });\n\n Worker = this.require('Worker');\n worker = new Worker({\n '_id': 'worker-admin',\n '_core': true,\n 'worker': new SharedWorker(workerPath),\n });\n \n worker.worker().port.onmessage = function (e) {\n $db.SyrupMessage.insert(e.data);\n };\n \n // notify System Designer\n syrupChannel.sync();\n \n console.info('syrup: admin is started');\n }\n}","useCoreAPI":true,"core":true},"1d7151dd2d1558f":{"_id":"1d7151dd2d1558f","component":"SyrupAdmin","state":"stop","action":"function stop() {\n var worker = null,\n channel = null;\n \n worker = this.require('worker-admin');\n if (worker && worker.worker()) {\n worker.worker().port.onmessage = function () {};\n worker.destroy();\n \n channel = this.require('channel-admin');\n if (channel) {\n channel.destroy();\n }\n \n console.info('syrup: admin is stopped');\n }\n}","useCoreAPI":false,"core":false},"1fc101c23918773":{"component":"SyrupComponent","state":"off","action":"function off(state, behaviorId) {\n var args = [],\n i = 0,\n length = 0;\n length = arguments.length;\n \n for (i = 0; i < length - 6; i++) {\n args.push(arguments[i]);\n }\n \n if ($workflow.checkParams({\n \"component\": this, \n \"methodName\": \"off\", \n \"args\": args\n })) {\n \n if (state || behaviorId) {\n if ($metamodel.isValidState(state, this.constructor.name)) {\n $behavior.remove({\n \"behaviorId\": behaviorId, \n \"componentId\": this.id(), \n \"state\": state\n });\n } else { \n console.warn(\"syrup: invoke \\'off\\' method of component '\" + this.id() + \"' with an invalid state '\" + state + \"'\"); \n }\n } else {\n $behavior.remove({\n \"componentId\": this.id()\n });\n }\n }\n}","core":true,"useCoreAPI":true}},"components":{"SyrupAdmin":{"admin":{"_id":"admin"}}},"name":"system-admin","version":"0.0.1","description":"SyrupJS administration component","_id":"18ed81de331252c","master":false,"subsystem":false}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "system-runtime",
3-
"version": "0.9.7",
3+
"version": "0.9.8",
44
"description": "SyrupJS, the System Runtime Platform",
55
"license": "MIT",
66
"homepage": "https://syrupjs.github.io",

0 commit comments

Comments
 (0)