spyne 0.14.8 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.travis.yml +2 -2
  2. package/karma.conf.js +27 -20
  3. package/lib/channel-action-filter.test.2418910233.js +20 -0
  4. package/lib/channel-dom.test.1490741340.js +20 -0
  5. package/lib/channel-fetch-util.test.3681936279.js +20 -0
  6. package/lib/channel-fetch.test.380764798.js +20 -0
  7. package/lib/channel-payload-class.test.2325155642.js +20 -0
  8. package/lib/channel-payload-filter.test.1598505124.js +20 -0
  9. package/lib/channel-route.test.921296320.js +20 -0
  10. package/lib/channel-stream-item.test.159699696.js +20 -0
  11. package/lib/channel-ui.test.291129654.js +20 -0
  12. package/lib/channel-util-dom.test.181212370.js +20 -0
  13. package/lib/channel.test.706832124.js +20 -0
  14. package/lib/commons.js +50363 -0
  15. package/lib/dom-el-selectors.test.3296414834.js +20 -0
  16. package/lib/dom-el-template.test.1459850380.js +20 -0
  17. package/lib/dom-el.test.2449130808.js +20 -0
  18. package/lib/frp-tools.test.1620088187.js +20 -0
  19. package/lib/import.test.723835576.js +20 -0
  20. package/lib/index.test.2146503294.js +20 -0
  21. package/lib/plugins-methods.test.3482246428.js +20 -0
  22. package/lib/route-utils.test.2932649409.js +20 -0
  23. package/lib/runtime.js +174 -0
  24. package/lib/spyne-app-properties.test.485192211.js +20 -0
  25. package/lib/spyne-app.test.4150724251.js +20 -0
  26. package/lib/spyne-plugin.test.3993976219.js +20 -0
  27. package/lib/spyne.js +15477 -18467
  28. package/lib/spyne.min.js +2 -12
  29. package/lib/spyne.min.js.LICENSE.txt +10 -0
  30. package/lib/url-utils.test.3668806082.js +20 -0
  31. package/lib/view-stream-broadcaster.test.2534955231.js +20 -0
  32. package/lib/view-stream-enhancer-loader.test.3395418180.js +20 -0
  33. package/lib/view-stream-enhancer.test.1043626253.js +20 -0
  34. package/lib/view-stream.test.1765314964.js +20 -0
  35. package/package.json +37 -65
  36. package/src/spyne/channels/channel-fetch-class.js +24 -1
  37. package/src/spyne/channels/channel-payload-class.js +102 -11
  38. package/src/spyne/channels/channel-proxy.js +6 -4
  39. package/src/spyne/channels/channel.js +66 -6
  40. package/src/spyne/channels/channels-config.js +2 -2
  41. package/src/spyne/channels/{channels-delegator.js → channels-map.js} +37 -21
  42. package/src/spyne/channels/spyne-channel-lifecycle.js +1 -1
  43. package/src/spyne/channels/spyne-channel-route.js +95 -15
  44. package/src/spyne/channels/spyne-channel-ui.js +1 -0
  45. package/src/spyne/channels/spyne-channel-window.js +60 -20
  46. package/src/spyne/spyne-app.js +181 -0
  47. package/src/spyne/spyne-plugins.js +146 -0
  48. package/src/spyne/spyne.js +11 -139
  49. package/src/spyne/utils/channel-fetch-util.js +1 -1
  50. package/src/spyne/utils/channel-payload-filter.js +166 -30
  51. package/src/spyne/utils/frp-tools.js +21 -1
  52. package/src/spyne/utils/mixins/base-streams-mixins.js +1 -0
  53. package/src/spyne/utils/spyne-app-properties.js +213 -0
  54. package/src/spyne/utils/spyne-logger.js +18 -0
  55. package/src/spyne/utils/spyne-plugins-methods.js +105 -0
  56. package/src/spyne/utils/spyne-scroll-lock.js +95 -0
  57. package/src/spyne/utils/spyne-utils-channel-route-url.js +2 -1
  58. package/src/spyne/utils/spyne-utils-channel-route.js +3 -1
  59. package/src/spyne/utils/spyne-utils-channel-window.js +2 -2
  60. package/src/spyne/views/dom-element-template.js +52 -23
  61. package/src/spyne/views/dom-element.js +11 -2
  62. package/src/spyne/views/view-stream-broadcaster.js +3 -3
  63. package/src/spyne/views/view-stream-payload.js +76 -15
  64. package/src/spyne/views/view-stream-selector.js +2 -2
  65. package/src/spyne/views/view-stream.js +219 -115
  66. package/src/tests/channels/channel-fetch.test.js +102 -0
  67. package/src/tests/channels/channel-payload-class.test.js +149 -0
  68. package/src/tests/channels/channel-payload-filter.test.js +298 -0
  69. package/src/tests/channels/channel-route.test.js +76 -1
  70. package/src/tests/channels/channel-stream-item.test.js +3 -2
  71. package/src/tests/channels/channel.test.js +38 -0
  72. package/src/tests/channels/route-utils.test.js +1 -1
  73. package/src/tests/index.js +0 -1
  74. package/src/tests/index.test.js +6 -0
  75. package/src/tests/mocks/channel-payload-data.js +93 -1
  76. package/src/tests/mocks/msf-user-data-small.json +4103 -0
  77. package/src/tests/mocks/msf-user-data.json +47035 -0
  78. package/src/tests/mocks/utils-data.js +20 -2
  79. package/src/tests/spyne-app.test.js +27 -0
  80. package/src/tests/spyne-plugin.test.js +49 -0
  81. package/src/tests/utils/channel-action-filter.test.js +22 -11
  82. package/src/tests/utils/channel-data-packet-generator.unused.js +119 -0
  83. package/src/tests/utils/plugins-methods.test.js +103 -0
  84. package/src/tests/utils/spyne-app-properties.test.js +11 -0
  85. package/src/tests/views/dom-el-selectors.test.js +1 -1
  86. package/webpack.config.js +30 -15
  87. package/lib/spyne.js.map +0 -1
  88. package/src/spyne/utils/viewstream-dom-utils.js +0 -8
@@ -1,5 +1,47 @@
1
- import {is, reject, ifElse, invoker, identity, isNil, allPass, tap, forEachObjIndexed, not, isEmpty, always, compose, equals, prop, where, defaultTo, path, flatten, any,type, curry} from 'ramda';
1
+ import {
2
+ is,
3
+ reject,
4
+ ifElse,
5
+ invoker,
6
+ identity,
7
+ assoc,
8
+ isNil,
9
+ find,
10
+ allPass,
11
+ tap,
12
+ forEachObjIndexed,
13
+ not,
14
+ isEmpty,
15
+ always,
16
+ compose,
17
+ equals,
18
+ prop,
19
+ where,
20
+ defaultTo,
21
+ mergeAll,
22
+ __,
23
+ omit,
24
+ path,
25
+ call,
26
+ clone,
27
+ flatten,
28
+ any,
29
+ type,
30
+ curry,
31
+ mergeRight, lte,
32
+ } from 'ramda';
33
+
34
+ import {SpyneAppProperties} from './spyne-app-properties';
35
+
2
36
  const rMap = require('ramda').map;
37
+
38
+ const isNotArr = compose(not, is(Array));
39
+ const isNotEmpty = compose(not, isEmpty);
40
+ const isNonEmptyStr = allPass([is(String), isNotEmpty]);
41
+ const isNonEmptyArr = allPass([is(Array), isNotEmpty]);
42
+ const isObjectFn = compose(allPass([isNotArr, is(Object)]))
43
+ const isNonEmptyObjectFn = compose(allPass([isNotEmpty, isNotArr, is(Object)]))
44
+
3
45
  export class ChannelPayloadFilter {
4
46
  /**
5
47
  * @module ChannelPayloadFilter
@@ -19,8 +61,8 @@ export class ChannelPayloadFilter {
19
61
  * </ul>
20
62
  *
21
63
  * @constructor
22
- * @param {Object} filters Object that contains the selector, props, and label params.
23
64
  * @property {String|Array|HTMLElement} selector The matching element
65
+ * @param {Object} filters Object that contains the selector, props, and debugLabel params.
24
66
  * @property {Object} propFilters A json object containing filtering methods for channel props variables.
25
67
  *
26
68
  * @property {String|Array|HTMLElement} selector - = ''; The matching element.
@@ -67,43 +109,79 @@ export class ChannelPayloadFilter {
67
109
  * .subscribe(myChannelMethod);
68
110
  *
69
111
  */
70
- constructor(filters={}) {
112
+ constructor(selector, filters={}, debugLabel, testMode) {
113
+
114
+
115
+
116
+ const selectorIsObj = isObjectFn(selector);
117
+
118
+ if(selectorIsObj){
119
+ filters = selector;
120
+ selector = prop('selector', filters);
121
+ testMode = testMode || prop("testMode", filters);
122
+
123
+ }
124
+
125
+
126
+ const debugLabelArr = [debugLabel, prop('debugLabel', filters)]
127
+
128
+ const makeBool = b => Boolean(b);
129
+
130
+ debugLabel = compose(find(is(String)))(debugLabelArr);
131
+
132
+ let props = omit(['debugLabel', 'label', 'selector', 'props', 'testMode', 'propFilters'], filters)
71
133
  if (filters.props!==undefined) {
72
- filters['propFilters'] = prop('props', filters);
134
+ props = mergeAll([filters.props, props])
135
+
136
+ } else if (filters.propFilters!==undefined) {
137
+ props = mergeAll([filters.propFilters, props])
73
138
  }
74
- let {selector,propFilters,label} = filters;
75
- //console.log("VALUES OF FILTERS ",{selector,propFilters,label});
76
- const isNotEmpty = compose(not, isEmpty);
77
- const isNonEmptyStr = allPass([is(String), isNotEmpty]);
78
- const isNonEmptyArr = allPass([is(Array), isNotEmpty]);
79
- const addStringSelectorFilter = isNonEmptyStr(selector) ? ChannelPayloadFilter.filterSelector([selector]) : undefined;
80
- const addArraySelectorFilter = isNonEmptyArr(selector) ? ChannelPayloadFilter.filterSelector(selector) : undefined;
81
139
 
140
+ filters['propFilters'] = props;
141
+
142
+ let {propFilters} = filters;
143
+ //console.log("selector filters ", {selector, filters})
144
+
145
+ // let {selector,propFilters,debugLabel} = filters;
146
+
147
+ const addStringSelectorFilter = isNonEmptyStr(selector) ? ChannelPayloadFilter.filterSelector([selector], debugLabel) : undefined;
148
+ const addArraySelectorFilter = isNonEmptyArr(selector) ? ChannelPayloadFilter.filterSelector(selector, debugLabel) : undefined;
82
149
 
83
- const addDataFilter = is(Object, propFilters) ? ChannelPayloadFilter.filterData(propFilters, label) : undefined;
150
+
151
+ const addDataFilter = isNonEmptyObjectFn(propFilters) ? ChannelPayloadFilter.filterData(propFilters, debugLabel) : undefined;
84
152
 
85
153
  //console.log("IS STRING ",{selector, addStringSelectorFilter, addArraySelectorFilter, addDataFilter},isNonEmptyStr(selector))
86
154
 
87
155
 
88
156
 
89
157
  let filtersArr = reject(isNil, [addStringSelectorFilter, addArraySelectorFilter, addDataFilter]);
158
+ // console.log('filtersArr is ',{selector})
90
159
 
91
160
  // IF ARRAY IS EMPTY ALWAYS RETURN FALSE;
92
161
 
93
- if (isEmpty(filtersArr)){
94
- filtersArr = [always(false)];
162
+ const filtersAreEmpty = isEmpty(filtersArr);
95
163
 
96
- if (path(['Spyne', 'config', 'debug'], window) === true){
164
+ if (filtersAreEmpty){
165
+ filtersArr = [always(false)];
166
+ if (SpyneAppProperties.debug === true && testMode!==true){
97
167
  console.warn(`Spyne Warning: The Channel Filter, with selector: ${selector}, and propFilters:${propFilters} appears to be empty!`);
98
168
  }
99
169
 
100
170
  }
101
171
 
172
+
173
+ //console.log(" VALUES OF FILTERS ",{selector,propFilters,filters,debugLabel,testMode, filtersAreEmpty});
174
+ if (testMode === true){
175
+ return {selector, propFilters, debugLabel, filters, testMode, filtersAreEmpty};
176
+ }
177
+
102
178
  return allPass(filtersArr);
103
179
  }
104
180
 
105
- static filterData(filterJson, filterLabel) {
106
- const label = filterLabel;
181
+ static filterData(filterJson, filterdebugLabel) {
182
+ const debugLabel = filterdebugLabel;
183
+
184
+ //console.log('filter data is ',{filterJson, debugLabel})
107
185
  let compareData = () => {
108
186
  // DO NOT ALLOW AN EMPTY OBJECT TO RETURN TRUEs
109
187
  if (isEmpty(filterJson)) {
@@ -138,35 +216,74 @@ export class ChannelPayloadFilter {
138
216
  // TAP LOGGER
139
217
 
140
218
  const tapLogger = (comparedObj)=>{
141
- if (label===undefined){
219
+ if (debugLabel===undefined){
142
220
  return comparedObj;
143
221
  }
144
- const propsBooleans = {};
145
- const mapBools = (value,key)=>propsBooleans[key] = value(prop(key, comparedObj));
146
- forEachObjIndexed(mapBools, filterJson);
147
- console.log(`%c CHANNEL PAYLOAD FILTER DEBUGGER '${label}': `, "color:orange;",{propsBooleans, comparedObj});
222
+ const propsBooleans = {};
223
+ const mapBools = (value,key)=>propsBooleans[key] = value(prop(key, comparedObj));
224
+ forEachObjIndexed(mapBools, filterJson);
225
+ console.log(`%c CHANNEL PAYLOAD FILTER DEBUGGER ["${debugLabel}"] - values: `, "color:orange;",{propsBooleans, comparedObj});
148
226
 
149
227
  return comparedObj;
150
- };
228
+ };
151
229
 
152
230
  // END TAP LOGGER
153
231
 
154
232
  let fMethod = where(filterJson);
155
- const getFilteringObj = ifElse(prop('props'), invoker(0, 'props'), identity);
233
+
234
+ let getFilteringObj = (v)=>{
235
+ const {payload, srcElement, event} = v || {};
236
+ const o = Object.assign({}, v, event, payload);
237
+ //console.log('o is ',o);
238
+ return o;
239
+ }
240
+
241
+
156
242
  return compose( fMethod, tapLogger, defaultTo({}), getFilteringObj);
243
+
157
244
  };
245
+ // const filterLabel = `filtering-${Math.floor(Math.random()*999999)}`;
246
+ //console.time(filterLabel);
247
+ // const val = compareData();
158
248
 
249
+ //console.timeEnd(filterLabel);
250
+ //return val;
159
251
  return compareData();
160
252
  }
161
253
 
162
- static checkPayloadSelector(arr, payload) {
254
+
255
+ static checkPayloadSelector(arr, debugLabel, srcPayload) {
163
256
  // ELEMENT FROM PAYLOADs
164
257
 
165
- let payloadIsNotProps = compose(equals('Function'),type, prop('props') )(payload);
166
- payload = payloadIsNotProps === true ? payload.props() : payload;
167
258
 
259
+ const {payload, srcElement, event} = srcPayload || {};
260
+ //console.log('payload before ',{srcPayload, payload, srcElement, event})
261
+
262
+ const reduceFindEl = (acc, src) => {
263
+ const el = prop('el', src);
264
+ //console.log("EL IS ",{el, src, acc})
265
+ if (ChannelPayloadFilter.elIsDomElement(el) && acc===undefined){
266
+ acc = el;
267
+ // return acc;
268
+ }
269
+ return acc;
270
+ }
271
+
272
+ const el = [srcElement, payload, prop('srcElement', event), srcPayload].reduce(reduceFindEl, undefined);
273
+
274
+
275
+ //console.log('el check ',{debugLabel, srcElement, payload, event, el})
276
+
277
+ //const o = Object.assign({}, srcPayload, event,srcElement, payload);
278
+
279
+ //console.log('o is ',o);
168
280
 
169
- let el = path(['el'], payload);
281
+
282
+ //let payloadIsNotProps = compose(equals('Function'),type, prop('props') )(payload);
283
+ //payload = payloadIsNotProps === true ? payload.payload : payload;
284
+ // console.log('payload after ',{o})
285
+
286
+ // let el = path(['el'], o);
170
287
 
171
288
  // RETURN BOOLEAN MATCH WITH PAYLOAD EL
172
289
  const compareEls = (elCompare) => elCompare.isEqualNode((el));
@@ -179,6 +296,15 @@ export class ChannelPayloadFilter {
179
296
  return rMap(compareEls, nodeArr);
180
297
  };
181
298
 
299
+ if (debugLabel!==undefined){
300
+ let nodeArrResultsDebugger = compose(flatten, rMap(mapNodeArrWithEl))(arr);
301
+ const selectorsArr = arr;
302
+
303
+ console.log(`%c CHANNEL PAYLOAD FILTER DEBUGGER ["${debugLabel}"] - selectors: `, "color:orange;",{el, selectorsArr, nodeArrResultsDebugger});
304
+
305
+
306
+ }
307
+
182
308
  // CHECK IF PAYLOAD EL EXISTS
183
309
  if (typeof (el) !== 'object') {
184
310
  return false;
@@ -193,9 +319,19 @@ export class ChannelPayloadFilter {
193
319
  return any(equals(true), nodeArrResult);
194
320
  }
195
321
 
196
- static filterSelector(selectorArr) {
322
+ static elIsDomElement(o) {
323
+ if (is(String,o)){
324
+ o = document.querySelector(o);
325
+ }
326
+
327
+
328
+ return compose(lte(0), defaultTo(-1), prop('nodeType'))(o);
329
+ }
330
+
331
+
332
+ static filterSelector(selectorArr, debugLabel) {
197
333
  let arr = reject(isEmpty, selectorArr);
198
334
  let payloadCheck = curry(ChannelPayloadFilter.checkPayloadSelector);
199
- return payloadCheck(arr);
335
+ return payloadCheck(arr, debugLabel);
200
336
  }
201
337
  }
@@ -6,6 +6,26 @@ const isIOS = () => {
6
6
  return ios === true;
7
7
  };
8
8
 
9
+
10
+ const delayCall = async(fn, time)=>{
11
+
12
+ function sleep (ms) {
13
+ return new Promise(resolve => setTimeout(resolve, ms))
14
+ }
15
+
16
+ const timeoutHandler = async() => {
17
+ await sleep(1);
18
+ window.requestAnimationFrame(fn);
19
+ }
20
+
21
+ window.setTimeout(timeoutHandler, time)
22
+
23
+
24
+ }
25
+
26
+
27
+
28
+
9
29
  const getConstructorName = (obj) => {
10
30
  if (obj.constructor.name !== undefined) {
11
31
  return obj.constructor.name;
@@ -142,4 +162,4 @@ const pullParams = (str) => str.replace(routeRE, '$4');
142
162
  const pullTranslateX = str => str.replace(/^(matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*)(,.*)/, '$6');
143
163
  const pullTranslateY = str => str.replace(/^(matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d)(.*)/, '$7');
144
164
  const pullTranslateYFromHeader = str => str.replace(/^(transform: matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*)(\).*;)/, '$6');
145
- export { getConstructorName, arrFromMapKeys, getAllMethodNames, findStrOrRegexMatchStr, findStrFromRegexArr, checkIfObjIsNotEmptyOrNil, isIOS, pullRouteInfo, pullTranslateYFromHeader, pullSlashFromPath, pullHashAndSlashFromPath, closest, pullTranslateY, pullTranslateX, pullMainRoute, pullParams, right, left, fromNullable, findInObj, ifNilThenUpdate, removeSlashes, subscribeFn, convertDomStringMapToObj };
165
+ export { getConstructorName, arrFromMapKeys, getAllMethodNames, findStrOrRegexMatchStr, findStrFromRegexArr, checkIfObjIsNotEmptyOrNil, isIOS, pullRouteInfo, pullTranslateYFromHeader, pullSlashFromPath, pullHashAndSlashFromPath, closest, pullTranslateY, pullTranslateX, pullMainRoute, pullParams, right, left, fromNullable, findInObj, ifNilThenUpdate, removeSlashes, subscribeFn, convertDomStringMapToObj, delayCall };
@@ -6,6 +6,7 @@ export function baseStreamsMixins() {
6
6
  console.log('stream mixin is ', str);
7
7
  },
8
8
  sendRoutePayload: function(obs, data) {
9
+ /**TODO: ADD A CHECK FOR END ROUTE AND TRANSFORM TO EMPTY*/
9
10
  return new ViewStreamPayload('CHANNEL_ROUTE', obs, data, 'subscribe');
10
11
  },
11
12
  sendUIPayload: function(obs, data) {
@@ -0,0 +1,213 @@
1
+ import {SpyneUtilsChannelRoute} from './spyne-utils-channel-route';
2
+ import {SpyneScrollLock} from './spyne-scroll-lock';
3
+ import {SpynePluginsMethods} from './spyne-plugins-methods';
4
+ import {ChannelsMap} from '../channels/channels-map';
5
+ import {deepMerge} from './deep-merge';
6
+ import {prop, path} from 'ramda';
7
+
8
+ let _config;
9
+ let _channels;
10
+ let _channelsMap
11
+ let _initialized = false;
12
+ let _debug = true;
13
+
14
+ const _spyneScrollLock = new SpyneScrollLock();
15
+ const _spynePluginMethods = new SpynePluginsMethods();
16
+
17
+
18
+ class SpyneAppPropertiesClass{
19
+
20
+ constructor() {
21
+
22
+
23
+ }
24
+
25
+
26
+
27
+ initialize(defaultConfig={}, config={}, channelsMap){
28
+ _channels = channelsMap;
29
+ const userConfig = SpyneUtilsChannelRoute.conformRouteObject(config);
30
+ _config = deepMerge(defaultConfig, userConfig);
31
+ _debug = _config.debug!== undefined ? _config.debug : _debug;
32
+ this.getChannelActions = _channels.getChannelActions.bind(_channels);
33
+ this.listRegisteredChannels = _channels.listRegisteredChannels.bind(_channels);
34
+ _initialized = true;
35
+ // if (channelsMap!==undefined) {
36
+ this.setChannelsMap();
37
+ //}
38
+
39
+ return _config;
40
+
41
+ }
42
+
43
+ conformRouteConfig(add404Props=false){
44
+ /**
45
+ * THIS METHOD IS PRIMARILY USED FOR SPA GEN SITE GENERATION
46
+ */
47
+
48
+ _config = SpyneUtilsChannelRoute.conformRouteObject(_config, add404Props);
49
+
50
+ }
51
+
52
+
53
+
54
+ setChannelsMap(){
55
+ let obj = {};
56
+
57
+
58
+
59
+ const getStream = _channels.getStream.bind(_channels);
60
+ const testStream = _channels.testStream.bind(_channels);
61
+ const getProxySubject = _channels.getProxySubject.bind(_channels);
62
+
63
+
64
+ _channelsMap = {getStream, testStream, getProxySubject}
65
+
66
+
67
+
68
+ }
69
+
70
+ setProp(key, val){
71
+ _config.tmp[key]=val;
72
+ }
73
+
74
+ getProp(key){
75
+ return path(['tmp', key], _config);
76
+ }
77
+
78
+ get channelsMap(){
79
+ return _channelsMap;
80
+ }
81
+
82
+ get initialized(){
83
+ return _initialized;
84
+ }
85
+
86
+ get scrollLock(){
87
+ return _spyneScrollLock;
88
+ }
89
+
90
+
91
+
92
+
93
+ setChannelConfig(channelName, config){
94
+ _config.channels[channelName] = config;
95
+ return _config.channels[channelName];
96
+ }
97
+
98
+
99
+ getChannelConfig(channelName, config=_config){
100
+ if (channelName === 'CHANNEL_ROUTE'){
101
+ channelName = "ROUTE";
102
+ } else if (channelName === 'CHANNEL_WINDOW'){
103
+ channelName = "WINDOW";
104
+ }
105
+
106
+ if (config === undefined || _config.channels === undefined){
107
+ console.warn('Spyne warning: Spyne config object is empty!')
108
+ return;
109
+ }
110
+
111
+ const channelConfig = _config.channels[channelName];
112
+
113
+ if (channelConfig === undefined){
114
+ console.warn(`Spyne warning: Spyne configuration for channel, ${channelName} is empty!`)
115
+ return;
116
+ }
117
+
118
+ //console.log("MAIN CONFIG IS ",{channelName, channelConfig, config});
119
+
120
+ return channelConfig;
121
+ }
122
+
123
+
124
+
125
+
126
+ get config(){
127
+ return _config;
128
+ }
129
+
130
+ /**
131
+ * This is mostly used for debugging purposes
132
+ *
133
+ * @example
134
+ * TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
135
+ * SpyneApp.listChannels();
136
+ *
137
+ * @returns A list of all registered channels
138
+ */
139
+ static listChannels() {
140
+ return Array.from(_channels.map.keys());
141
+ }
142
+
143
+ /**
144
+ * This method is useful to check in the console or in the code what actions are available to be listened to.
145
+ * @param {String} channelName
146
+ * @returns {Array} An array of Actions that can be listened to
147
+ */
148
+ /* getChannelActions(channelName) {
149
+ return _channels.getChannelActions(channelName);
150
+ }*/
151
+
152
+
153
+ registerChannel(){
154
+
155
+
156
+ }
157
+
158
+ addPluginConfig(pluginName, pluginConfig={}){
159
+ if (_config['plugins']===undefined){
160
+ _config['plugins'] = {};
161
+ }
162
+ this.addPluginMethods(pluginConfig['pluginMethods'])
163
+
164
+ _config.plugins[pluginName]=pluginConfig;
165
+
166
+ }
167
+
168
+ getPluginsMethodObj(pluginMethodsObj){
169
+ if(pluginMethodsObj){
170
+ this.addPluginMethods(pluginMethodsObj);
171
+ }
172
+
173
+ return _spynePluginMethods.pluginMethodsObj;
174
+ }
175
+
176
+ addPluginMethods(pluginMethods){
177
+
178
+ if (pluginMethods){
179
+
180
+ _spynePluginMethods.addMethods(pluginMethods);
181
+
182
+ }
183
+
184
+
185
+ }
186
+
187
+ getPluginConfigByPluginName(pluginName){
188
+ return _config.plugins[pluginName];
189
+ }
190
+
191
+
192
+
193
+
194
+ tempGetChannelsInstance(){
195
+
196
+ }
197
+
198
+ tempGetConfig(){
199
+
200
+
201
+ }
202
+
203
+ get debug(){
204
+ return _debug;
205
+ //return _config['debug']===true;
206
+ }
207
+
208
+
209
+
210
+
211
+ }
212
+
213
+ export let SpyneAppProperties = new SpyneAppPropertiesClass();
@@ -0,0 +1,18 @@
1
+ class SpyneLoggerClass{
2
+
3
+ constructor(props) {
4
+
5
+ this._warnings = [];
6
+ }
7
+
8
+ static warn(){
9
+
10
+
11
+
12
+ }
13
+
14
+
15
+
16
+ }
17
+
18
+ export let SpyneLogger = new SpyneLoggerClass();
@@ -0,0 +1,105 @@
1
+ const _pluginMethodsObj = Object.create({});
2
+
3
+ _pluginMethodsObj['foo'] = ()=>console.log("used for testing purposes.");
4
+
5
+ import {allPass, compose, is, isEmpty, keys, not, prop} from 'ramda';
6
+
7
+
8
+ const isNotArr = compose(not, is(Array));
9
+ const isNotEmpty = compose(not, isEmpty);
10
+ const isNonEmptyStr = allPass([is(String), isNotEmpty]);
11
+ const isNonEmptyArr = allPass([is(Array), isNotEmpty]);
12
+ const isObjectFn = compose(allPass([isNotArr, is(Object)]))
13
+ const isNonEmptyObjectFn = compose(allPass([isNotEmpty, isNotArr, is(Object)]))
14
+
15
+
16
+ export class SpynePluginsMethods{
17
+
18
+
19
+ constructor(){
20
+
21
+
22
+
23
+ }
24
+
25
+
26
+
27
+ addMethod(key, fn, test=false){
28
+ //console.log('has method is 2',typeof(_pluginMethodsObj),{_pluginMethodsObj})
29
+
30
+ if (_pluginMethodsObj.hasOwnProperty(key)===true){
31
+ const warnStr = `Spyne Warning: the method name, ${key}, already exists.`;
32
+
33
+ if (test){
34
+ return warnStr;
35
+ }
36
+ console.warn(warnStr);
37
+ } else {
38
+ _pluginMethodsObj[key] = fn;
39
+ }
40
+
41
+ }
42
+
43
+
44
+ addMethods(methodsObj={}, test=false){
45
+
46
+ let warnStr;
47
+
48
+ const isObj = isObjectFn(methodsObj);
49
+
50
+ if (isObj === false){
51
+ warnStr = `Spyne Warning: the pluginMethods property, ${JSON.stringify(methodsObj)} needs to be an object.`
52
+ if (test){
53
+ //console.log('this is a test ',{methodsObj})
54
+ return warnStr;
55
+ }
56
+ console.warn(warnStr);
57
+ return;
58
+
59
+ }
60
+
61
+ const checkEachKeyForValidMethod = (keyStr) => {
62
+ const methodVal = prop(keyStr, methodsObj);
63
+
64
+ const isFunction = typeof(methodVal) === 'function';
65
+
66
+ //console.log('method to add ',{keyStr, isFunction})
67
+
68
+ if (isFunction){
69
+ this.addMethod(keyStr, methodVal, test);
70
+ } else{
71
+ warnStr = `the value for ${keyStr} is not a valid function.`
72
+ if (test){
73
+ return warnStr;
74
+ } else {
75
+ console.warn(warnStr);
76
+ }
77
+ }
78
+
79
+ }
80
+
81
+ const methodKeys = keys(methodsObj);
82
+
83
+ return methodKeys.map(checkEachKeyForValidMethod).join(',');
84
+
85
+ }
86
+
87
+ checkIfMethodExists(key){
88
+
89
+ }
90
+
91
+ test1(){
92
+ //console.log('test 1 is ');
93
+ }
94
+
95
+
96
+ get pluginMethodsObj(){
97
+ return _pluginMethodsObj;
98
+ }
99
+
100
+
101
+
102
+
103
+
104
+
105
+ }