Skip to content

Commit 2a32fce

Browse files
committed
- remove '_schema' property
- clean code
1 parent a67d50d commit 2a32fce

File tree

15 files changed

+259
-343
lines changed

15 files changed

+259
-343
lines changed

addons/system-admin.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"19fe71f8af13886": {
44
"_id": "19fe71f8af13886",
55
"_name": "Worker",
6-
"_schema": "Worker",
76
"_inherit": [
87
"RuntimeComponent"
98
],
@@ -26,7 +25,6 @@
2625
"138a81fa1f16435": {
2726
"_id": "138a81fa1f16435",
2827
"_name": "RuntimeAdmin",
29-
"_schema": "RuntimeAdmin",
3028
"_inherit": [
3129
"RuntimeComponent"
3230
],
@@ -46,7 +44,6 @@
4644
"135c71078810af2": {
4745
"_id": "135c71078810af2",
4846
"_name": "RuntimeChannel",
49-
"_schema": "RuntimeChannel",
5047
"_inherit": [
5148
"RuntimeComponent"
5249
],
@@ -274,24 +271,17 @@
274271
"_id": "1c00c107e01c9b3",
275272
"component": "RuntimeAdmin",
276273
"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}",
278275
"useCoreAPI": true,
279276
"core": true
280277
},
281278
"1d7151dd2d1558f": {
282279
"_id": "1d7151dd2d1558f",
283280
"component": "RuntimeAdmin",
284281
"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}",
286283
"useCoreAPI": true,
287284
"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
295285
}
296286
},
297287
"components": {

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": "1.3.6",
3+
"version": "1.4.0",
44
"description": "Runtime, the System Runtime Environment",
55
"license": "MIT",
66
"homepage": "https://system-runtime.github.io",

0 commit comments

Comments
 (0)