|
3 | 3 | "19fe71f8af13886": { |
4 | 4 | "_id": "19fe71f8af13886", |
5 | 5 | "_name": "Worker", |
6 | | - "_schema": "Worker", |
7 | 6 | "_inherit": [ |
8 | 7 | "RuntimeComponent" |
9 | 8 | ], |
|
26 | 25 | "138a81fa1f16435": { |
27 | 26 | "_id": "138a81fa1f16435", |
28 | 27 | "_name": "RuntimeAdmin", |
29 | | - "_schema": "RuntimeAdmin", |
30 | 28 | "_inherit": [ |
31 | 29 | "RuntimeComponent" |
32 | 30 | ], |
|
46 | 44 | "135c71078810af2": { |
47 | 45 | "_id": "135c71078810af2", |
48 | 46 | "_name": "RuntimeChannel", |
49 | | - "_schema": "RuntimeChannel", |
50 | 47 | "_inherit": [ |
51 | 48 | "RuntimeComponent" |
52 | 49 | ], |
|
274 | 271 | "_id": "1c00c107e01c9b3", |
275 | 272 | "component": "RuntimeAdmin", |
276 | 273 | "state": "start", |
277 | | - "action": "function start(path) {\n var Worker = null,\n worker = null,\n workerPath = '',\n RuntimeChannel = null,\n runtimeChannel = 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') {\n \n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n this.require('worker-admin').worker().port.postMessage(message);\n });\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('metamodel').type(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('metamodel').schema(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('metamodel').type(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n $component.removeFromMemory(id);\n }, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n $db['RuntimeType'].remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component);\n }, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db['RuntimeBehavior'].insert(component);\n }, true);\n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n });\n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db['RuntimeBehavior'].remove({'_id': id}); \n }, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n this.loadSystem(JSON.parse(this.require('db').system()));\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.RuntimeMessage.insert(e.data);\n };\n \n console.info('runtime: admin is started');\n } else {\n console.info('runtime: admin is already started');\n }\n } else {\n console.info('runtime: the browser can not run admin features');\n }\n}", |
| 274 | + "action": "function start(path) {\n var Worker = null,\n worker = null,\n workerPath = '',\n RuntimeChannel = null,\n runtimeChannel = 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') {\n \n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n this.require('worker-admin').worker().port.postMessage(message);\n });\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('metamodel').type(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('metamodel').schema(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('metamodel').type(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n $component.removeFromMemory(id);\n }, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n $db['RuntimeType'].remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component);\n }, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db['RuntimeBehavior'].insert(component);\n }, true);\n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n });\n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db['RuntimeBehavior'].remove({'_id': id}); \n }, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n this.loadSystem(JSON.parse(this.require('db').system()));\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.RuntimeMessage.insert(e.data);\n };\n \n this.require('logger').info('admin is started');\n } else {\n this.require('logger').info('admin is already started');\n }\n } else {\n this.require('logger').warn('the browser can not run admin features');\n }\n}", |
278 | 275 | "useCoreAPI": true, |
279 | 276 | "core": true |
280 | 277 | }, |
281 | 278 | "1d7151dd2d1558f": { |
282 | 279 | "_id": "1d7151dd2d1558f", |
283 | 280 | "component": "RuntimeAdmin", |
284 | 281 | "state": "stop", |
285 | | - "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('runtime: admin is stopped');\n }\n}", |
| 282 | + "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 this.require('logger').info('admin is stopped');\n }\n}", |
286 | 283 | "useCoreAPI": true, |
287 | 284 | "core": true |
288 | | - }, |
289 | | - "1fc101c23918773": { |
290 | | - "component": "RuntimeComponent", |
291 | | - "state": "off", |
292 | | - "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(\"runtime: 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}", |
293 | | - "core": true, |
294 | | - "useCoreAPI": true |
295 | 285 | } |
296 | 286 | }, |
297 | 287 | "components": { |
|
0 commit comments