Skip to content

Commit d8616a3

Browse files
committed
- improve MonocoChannel concept
1 parent d8f3d72 commit d8616a3

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

+1524
-511
lines changed

build/monoco-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/monoco.js

Lines changed: 198 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/monoco.json

Lines changed: 48 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -144,37 +144,6 @@
144144
"result": "boolean"
145145
}
146146
},
147-
"MonocoChannelEvent": {
148-
"_id": "MonocoChannelEvent",
149-
"_name": "MonocoChannelEvent",
150-
"_schema": "MonocoChannelEventSchema",
151-
"_inherit": [
152-
"MonocoComponent"
153-
],
154-
"_core": true,
155-
"name": {
156-
"type": "string",
157-
"readOnly": false,
158-
"mandatory": true,
159-
"default": ""
160-
},
161-
"type": {
162-
"type": "string",
163-
"readOnly": false,
164-
"mandatory": true,
165-
"default": ""
166-
}
167-
},
168-
"MonocoChannelEventSchema": {
169-
"_id": "MonocoChannelEventSchema",
170-
"_name": "MonocoChannelEventSchema",
171-
"_inherit": [
172-
"MonocoComponentSchema"
173-
],
174-
"_core": true,
175-
"name": "property",
176-
"type": "property"
177-
},
178147
"MonocoChannelSchema": {
179148
"_id": "MonocoChannelSchema",
180149
"_name": "MonocoChannelSchema",
@@ -679,7 +648,7 @@
679648
},
680649
"from": {
681650
"type": "string",
682-
"mandatory": true
651+
"mandatory": false
683652
},
684653
"data": {
685654
"type": "object",
@@ -768,167 +737,167 @@
768737
"action": "function ready() { var systems = [], system = null, i = 0, length = 0; if (typeof document !== 'undefined') { systems = document.querySelectorAll('link[rel=system]'); length = systems.length; for (i = 0; i < length; i++) { system = systems[i]; this.load(system.href, false); } } }",
769738
"core": true
770739
},
771-
"17191121311a9a3": {
772-
"_id": "17191121311a9a3",
740+
"1c7ed181d8143d6": {
741+
"_id": "1c7ed181d8143d6",
773742
"component": "Monoco",
774743
"state": "error",
775744
"action": "function error(data) { console.error('monoco: ' + data.message, data.error); }",
776745
"core": true
777746
},
778-
"12ee01122f1000f": {
779-
"_id": "12ee01122f1000f",
747+
"151b21611113189": {
748+
"_id": "151b21611113189",
780749
"component": "Monoco",
781750
"state": "find",
782751
"action": "function find(Class, query) { return $component.find(Class, query);}",
783752
"core": true,
784753
"useCoreAPI": true
785754
},
786-
"1c8af1afa310ea9": {
787-
"_id": "1c8af1afa310ea9",
755+
"13e60108ce18975": {
756+
"_id": "13e60108ce18975",
788757
"component": "Monoco",
789758
"state": "system",
790759
"action": "function system(name) { var System = null, system = {}, result = [], conf = {}; if (name) { conf.master = true; conf.name = name; System = monoco.require('MonocoSystem'); system = new System(conf); } else { result = monoco.find('MonocoSystem', {'master': true}); if (result.length) { system = result[0]; } } return system; }",
791760
"core": true
792761
},
793-
"192581bed6169eb": {
794-
"_id": "192581bed6169eb",
762+
"134a9123381129a": {
763+
"_id": "134a9123381129a",
795764
"component": "Monoco",
796765
"state": "warning",
797766
"action": "function warning(message) { console.warn('monoco: ' + message); }",
798767
"core": true
799768
},
800-
"13897187c4115ab": {
801-
"_id": "13897187c4115ab",
769+
"1d25a184391f0ce": {
770+
"_id": "1d25a184391f0ce",
802771
"component": "MonocoChannel",
803772
"state": "listen",
804-
"action": "function listen(event, action) { $behavior.add('db', 'insert', function channel_insert(collectionName, document) { if (collectionName === 'MonocoMessage') { if (document.event === event) { action(document); } } }, true, true); }",
773+
"action": "function listen(event, action) { $channel.listen(event, action); }",
805774
"core": true,
806775
"useCoreAPI": true
807776
},
808-
"139e610dbf1d372": {
809-
"_id": "139e610dbf1d372",
777+
"14803180b012cf2": {
778+
"_id": "14803180b012cf2",
810779
"component": "MonocoChannel",
811780
"state": "send",
812-
"action": "function send(message) {var messages = [], events = [], result = true; events = $db.MonocoChannelEvent.find({'name': message.event}); if (events.length && $metamodel.isValidType(message.data, events[0].type)) { messages = $db.MonocoMessage.insert({'from': message.from, 'event': message.event, 'data': message.data}); if (!messages.length) { result = false; } } else { result = false; $log.invalidChannelEvent(message.data, message.event, events[0].type); } return result;}",
781+
"action": "function send(message) { return $channel.send(message); }",
813782
"core": true,
814783
"useCoreAPI": true
815784
},
816-
"1dc581addc1dd83": {
817-
"_id": "1dc581addc1dd83",
785+
"1a8fb16c5912eec": {
786+
"_id": "1a8fb16c5912eec",
818787
"component": "MonocoClassInfo",
819788
"state": "event",
820789
"action": "function event(name) { var result = {}; if (this.metamodel()[name] === 'event') { result = this.model()[name]; } return result; }",
821790
"core": true
822791
},
823-
"1ddfc1846b161e7": {
824-
"_id": "1ddfc1846b161e7",
792+
"147cc1bf3f13c84": {
793+
"_id": "147cc1bf3f13c84",
825794
"component": "MonocoClassInfo",
826795
"state": "events",
827796
"action": "function events() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'event') { result.push(item); } } return result; }",
828797
"core": true
829798
},
830-
"1c7141a36f1ccf6": {
831-
"_id": "1c7141a36f1ccf6",
799+
"1fb0f1b2921db7b": {
800+
"_id": "1fb0f1b2921db7b",
832801
"component": "MonocoClassInfo",
833802
"state": "method",
834803
"action": "function method(name) { var result = {}; if (this.metamodel()[name] === 'method') { result = this.model()[name]; } return result; }",
835804
"core": true
836805
},
837-
"12d1a1687b1b5b8": {
838-
"_id": "12d1a1687b1b5b8",
806+
"105f619be61bd34": {
807+
"_id": "105f619be61bd34",
839808
"component": "MonocoClassInfo",
840809
"state": "methods",
841810
"action": "function methods() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'method') { result.push(item); } } return result; }",
842811
"core": true
843812
},
844-
"1df401828d10f7a": {
845-
"_id": "1df401828d10f7a",
813+
"1b655199ad147cb": {
814+
"_id": "1b655199ad147cb",
846815
"component": "MonocoClassInfo",
847816
"state": "properties",
848817
"action": "function properties() { var keys = Object.keys(this.metamodel()), item = '', result = [], i = 0, length = 0; length = keys.length; for (i = 0; i < length; i++) { item = keys[i]; if (this.metamodel()[item] === 'property') { result.push(item); } } return result; }",
849818
"core": true
850819
},
851-
"113561d8b01481a": {
852-
"_id": "113561d8b01481a",
820+
"1a77b1860619237": {
821+
"_id": "1a77b1860619237",
853822
"component": "MonocoClassInfo",
854823
"state": "property",
855824
"action": "function property(name) { var result = {}; if (this.metamodel()[name] === 'property') { result = this.model()[name]; } return result; }",
856825
"core": true
857826
},
858-
"1e3ad199d617b96": {
859-
"_id": "1e3ad199d617b96",
827+
"1e2261cd081fc04": {
828+
"_id": "1e2261cd081fc04",
860829
"component": "MonocoComponent",
861830
"state": "destroy",
862831
"action": "function destroy() { $component.destroy(this.id()); }",
863832
"core": true,
864833
"useCoreAPI": true
865834
},
866-
"1eda9107201c9b9": {
867-
"_id": "1eda9107201c9b9",
835+
"1dd271944b11a7b": {
836+
"_id": "1dd271944b11a7b",
868837
"component": "MonocoComponent",
869838
"state": "off",
870-
"action": "function off(state, behaviorId) { var args = [], i = 0, length = 0; length = arguments.length; for (i = 0; i < length - 6; i++) { args.push(arguments[i]); } if ($workflow.checkParams({\"component\": this, \"methodName\": \"off\", \"args\": args})) { if ($metamodel.isValidState(state, this.constructor.name)) {$behavior.remove({\"behaviorId\": behaviorId, \"componentId\": this.id(), \"state\": state}); } else { $helper.getMonoco().warning(\"invoke 'off' method of component '\" + this.id() + \"' with an invalid state '\" + state + \"'\"); } } }",
839+
"action": "function off(state, behaviorId) { var args = [], i = 0, length = 0; length = arguments.length; for (i = 0; i < length - 7; i++) { args.push(arguments[i]); } if ($workflow.checkParams({\"component\": this, \"methodName\": \"off\", \"args\": args})) { if ($metamodel.isValidState(state, this.constructor.name)) {$behavior.remove({\"behaviorId\": behaviorId, \"componentId\": this.id(), \"state\": state}); } else { $helper.getMonoco().warning({ \"message\":\"invoke 'off' method of component '\" + this.id() + \"' with an invalid state '\" + state + \"'\"}); } } }",
871840
"core": true,
872841
"useCoreAPI": true
873842
},
874-
"1b8b61591115818": {
875-
"_id": "1b8b61591115818",
843+
"1e3e214e06163b0": {
844+
"_id": "1e3e214e06163b0",
876845
"component": "MonocoComponent",
877846
"state": "require",
878847
"action": "function require(id) { return $component.get(id); }",
879848
"core": true,
880849
"useCoreAPI": true
881850
},
882-
"1f3c917ce81c7e8": {
883-
"_id": "1f3c917ce81c7e8",
851+
"183781de2013941": {
852+
"_id": "183781de2013941",
884853
"component": "MonocoDatabase",
885854
"state": "subsystem",
886855
"action": "function subsystem(params) { return $db.subsystem(params); }",
887856
"core": true,
888857
"useCoreAPI": true
889858
},
890-
"17fe816d6d1e287": {
891-
"_id": "17fe816d6d1e287",
859+
"10e951c5bd1e93e": {
860+
"_id": "10e951c5bd1e93e",
892861
"component": "MonocoDatabase",
893862
"state": "system",
894863
"action": "function system(system) { return $db.system(system); }",
895864
"core": true,
896865
"useCoreAPI": true
897866
},
898-
"1bcb0137b51715a": {
899-
"_id": "1bcb0137b51715a",
867+
"10fcd19bcc1d955": {
868+
"_id": "10fcd19bcc1d955",
900869
"component": "MonocoMetamodel",
901870
"state": "create",
902871
"action": "function create() { $metamodel.create(); }",
903872
"core": true,
904873
"useCoreAPI": true
905874
},
906-
"13bbb1da2e1c444": {
907-
"_id": "13bbb1da2e1c444",
875+
"181841b92c13d7d": {
876+
"_id": "181841b92c13d7d",
908877
"component": "MonocoMetamodel",
909878
"state": "schema",
910879
"action": "function schema(schema) { $metamodel.schema(schema); }",
911880
"core": true,
912881
"useCoreAPI": true
913882
},
914-
"1bcc71aad813af7": {
915-
"_id": "1bcc71aad813af7",
883+
"119251ed051b49e": {
884+
"_id": "119251ed051b49e",
916885
"component": "MonocoMetamodel",
917886
"state": "type",
918887
"action": "function type(type) { $metamodel.type(type); }",
919888
"core": true,
920889
"useCoreAPI": true
921890
},
922-
"19d281ed3818ea8": {
923-
"_id": "19d281ed3818ea8",
891+
"1870c15bc812a9c": {
892+
"_id": "1870c15bc812a9c",
924893
"component": "MonocoSystem",
925894
"state": "sync",
926895
"action": "function sync() { var dump = $db.dump(); this.schemas(dump.schemas); this.types(dump.types); this.behaviors(dump.behaviors); this.components(dump.components); }",
927896
"core": true,
928897
"useCoreAPI": true
929898
},
930-
"1441c144dd14dc2": {
931-
"_id": "1441c144dd14dc2",
899+
"13b5210e6e1fe8f": {
900+
"_id": "13b5210e6e1fe8f",
932901
"component": "e89c617b6b15d24",
933902
"state": "main",
934903
"action": "function main() { var monoco = $component.get('monoco'); monoco.ready(); }",

0 commit comments

Comments
 (0)