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,4 +1,5 @@
1
1
  import { baseCoreMixins } from '../utils/mixins/base-core-mixins';
2
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
2
3
  //import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins';
3
4
  import { deepMerge } from '../utils/deep-merge';
4
5
  import {
@@ -16,7 +17,41 @@ import { ViewStreamObservable } from '../utils/viewstream-observables';
16
17
  import {ViewStreamSelector} from './view-stream-selector';
17
18
  import { Subject, of } from 'rxjs';
18
19
  import { mergeMap, map, takeWhile, filter, tap, skip, finalize } from 'rxjs/operators';
19
- import {pick, compose, isNil, all, isEmpty, forEach, toLower, either, findIndex, partial, apply, test, flatten ,prop, always, lte, defaultTo, propSatisfies, allPass, curry, nth, is,slice, path, omit, ifElse, lensPath, view, clone, mergeRight, where, equals} from 'ramda';
20
+ import {
21
+ pick,
22
+ compose,
23
+ isNil,
24
+ all,
25
+ isEmpty,
26
+ forEach,
27
+ toLower,
28
+ either,
29
+ findIndex,
30
+ partial,
31
+ apply,
32
+ test,
33
+ flatten,
34
+ prop,
35
+ always,
36
+ lte,
37
+ defaultTo,
38
+ propSatisfies,
39
+ allPass,
40
+ curry,
41
+ nth,
42
+ is,
43
+ slice,
44
+ path,
45
+ omit,
46
+ ifElse,
47
+ lensPath,
48
+ view,
49
+ clone,
50
+ mergeRight,
51
+ where,
52
+ equals,
53
+ assocPath,
54
+ } from 'ramda';
20
55
 
21
56
  const rMap = require('ramda').map;
22
57
 
@@ -36,7 +71,7 @@ export class ViewStream {
36
71
  <li>LINK['ViewStreamBroadcaster', 'view-stream-broadcaster']: Takes the nested array from the <i>BroadcastEvents</i> method and creates RxJs observables that are delegated to either the CHANNEL_UI or CHANNEL_ROUTE
37
72
  <li>LINK['ViewStreamSelector', 'view-stream-selector']: Provides selector and CSS utility methods.
38
73
  <li>LINK['ViewStreamPayload', 'view-stream-payload']: Payload format for sending data to Channels using the <i>sendInfoToChannel</i> method.
39
- </ul>
74
+ </ul>
40
75
  *
41
76
  *
42
77
  * <h4>Rendering</h4>
@@ -166,7 +201,7 @@ export class ViewStream {
166
201
  this.sink$ = new Subject();
167
202
  const ViewClass = this.props.viewClass;
168
203
  this.view = new ViewClass(this.sink$, {}, this.props.vsid,
169
- this.props.id);// new this.props.viewClass(this.sink$);
204
+ this.props.id);// new this.props.viewClass(this.sink$);
170
205
  this.sourceStreams = this.view.sourceStreams;
171
206
  this._rawSource$ = this.view.getSourceStream();
172
207
  this._rawSource$['viewName'] = this.props.name;
@@ -186,7 +221,7 @@ export class ViewStream {
186
221
  const elIsDomElement = compose(lte(0), defaultTo(-1), prop('nodeType'));
187
222
  const elIsRendered = el => document.body.contains(el);
188
223
  const elIsReadyBool = propSatisfies(
189
- allPass([elIsRendered, elIsDomElement]), 'el');
224
+ allPass([elIsRendered, elIsDomElement]), 'el');
190
225
 
191
226
  if (elIsReadyBool(this.props)) {
192
227
  this.updatePropsToMatchEl();
@@ -208,11 +243,11 @@ export class ViewStream {
208
243
  actionFilter = new ChannelPayloadFilter({selector:actionFilter});
209
244
  }
210
245
  this.props.extendedSourcesHashMethods[action] = channelFn(funcStr,
211
- actionFilter);
246
+ actionFilter);
212
247
  };
213
248
  this.addActionListeners().forEach(createExtraStatesMethod);
214
249
  this.props.hashSourceMethods = this.setSourceHashMethods(
215
- this.props.extendedSourcesHashMethods);
250
+ this.props.extendedSourcesHashMethods);
216
251
  }
217
252
 
218
253
  /**
@@ -251,11 +286,22 @@ export class ViewStream {
251
286
  obj['$dir'] = this.$dirs.C;
252
287
  this.sourceStreams.raw$.next(obj);
253
288
  }
254
- let filterPayload = defaultTo(always(true), actionFilter);
255
- if (filterPayload(p.props()) === true) {
256
- // p = omit(['dir$'],p);
289
+ let filterPayload = defaultTo(always(true), actionFilter);
290
+ const filterLabel = `filtering-${Math.floor(Math.random() * 999999)}`;
291
+
292
+ if (actionFilter !== undefined) {
293
+ //console.time(filterLabel);
294
+
295
+
296
+ }
297
+ if (filterPayload(p) === true) {
298
+ // p = omit(['dir$'],p);
257
299
  p = omit(['$dir'], p)
258
- //console.log(' payload vs ',p);
300
+ if (actionFilter !== undefined) {
301
+
302
+ // console.log(`pf - ${filterLabel}: `, p);
303
+ //console.timeEnd(filterLabel);
304
+ }
259
305
  runFunc(p);
260
306
  //this[str](p);
261
307
  }
@@ -280,7 +326,7 @@ export class ViewStream {
280
326
  // ====================== MAIN STREAM METHODS ==========================
281
327
  initViewStream() {
282
328
  this._source$ = this._rawSource$.pipe(map(
283
- (payload) => this.onMapViewSource(payload)), takeWhile(this.notGCSTATE));
329
+ (payload) => this.onMapViewSource(payload)), takeWhile(this.notGCSTATE));
284
330
 
285
331
  this.initAutoMergeSourceStreams();
286
332
  this.updateSourceSubscription(this._source$, true);
@@ -320,8 +366,8 @@ export class ViewStream {
320
366
  };
321
367
 
322
368
  this.parent$ = obs.pipe(
323
- filter(filterOutNullData),
324
- map(checkIfDisposeOrFadeout));
369
+ filter(filterOutNullData),
370
+ map(checkIfDisposeOrFadeout));
325
371
  this.updateSourceSubscription(this.parent$, false, 'PARENT');
326
372
  this.renderAndAttachToParent(attachData);
327
373
  }
@@ -330,12 +376,12 @@ export class ViewStream {
330
376
  let filterOutNullData = (data) => data !== undefined && data.action !==
331
377
  undefined;
332
378
  let child$ = obs$.pipe(
333
- filter(filterOutNullData),
334
- tap(p => this.tracer('addChildStraem do ', p)),
335
- map((p) => {
336
- return p;
337
- }),
338
- finalize(p => this.onChildCompleted(child$.source)));
379
+ filter(filterOutNullData),
380
+ tap(p => this.tracer('addChildStraem do ', p)),
381
+ map((p) => {
382
+ return p;
383
+ }),
384
+ finalize(p => this.onChildCompleted(child$.source)));
339
385
  this.updateSourceSubscription(child$, true, 'CHILD');
340
386
  }
341
387
 
@@ -360,6 +406,8 @@ export class ViewStream {
360
406
  return childCompletedData;
361
407
  }
362
408
 
409
+
410
+
363
411
  initAutoMergeSourceStreams() {
364
412
  // ====================== SUBSCRIPTION SOURCE =========================
365
413
  let subscriber = {
@@ -373,6 +421,7 @@ export class ViewStream {
373
421
  // =====================================================================
374
422
  // ========== METHODS TO CHECK FOR WHEN TO COMPLETE THE STREAM =========
375
423
  let completeAll = () => {
424
+
376
425
  this.props.el$ = undefined;
377
426
  this.uberSource$.complete();
378
427
  this.autoSubscriber$.complete();
@@ -395,7 +444,7 @@ export class ViewStream {
395
444
  let incrementObservablesThatCloses = () => { obsCount += 1; };
396
445
  this.autoMergeSubject$ = this.uberSource$.pipe(mergeMap((obsData) => {
397
446
  let branchObservable$ = obsData.observable.pipe(filter(
398
- (p) => p !== undefined && p.action !== undefined), map(p => {
447
+ (p) => p !== undefined && p.action !== undefined), map(p => {
399
448
  // console.log('PAYLOAD IS ', p, this.constructor.name)
400
449
  let payload = deepMerge({}, p);
401
450
  payload.action = p.action;// addRelationToState(obsData.rel, p.action);
@@ -412,9 +461,9 @@ export class ViewStream {
412
461
  }));
413
462
  // ============================= SUBSCRIBER ==============================
414
463
  this.autoSubscriber$ = this.autoMergeSubject$
415
- // .do((p) => console.log('SINK DATA ', this.constructor.name, p))
416
- .pipe(filter((p) => p !== undefined && p.action !== undefined))
417
- .subscribe(subscriber);
464
+ // .do((p) => console.log('SINK DATA ', this.constructor.name, p))
465
+ .pipe(filter((p) => p !== undefined && p.action !== undefined))
466
+ .subscribe(subscriber);
418
467
  }
419
468
 
420
469
  // ========================= MERGE STREAMS TO MAIN SUBSCRIBER =================
@@ -436,7 +485,7 @@ export class ViewStream {
436
485
  // ****USE REGEX AS PREDICATE CHECK FOR PAYLOAD.ACTION IN HASH METHODS OBJ
437
486
  // const hashAction = this.props.hashSourceMethods[payload.action];
438
487
  const hashActionStr = findStrOrRegexMatchStr(this.props.hashSourceMethods,
439
- payload.action);
488
+ payload.action);
440
489
  const hashAction = this.props.hashSourceMethods[hashActionStr];
441
490
  // console.log('S PAYLOAD ', this.props.name, typeof (hashAction), payload);
442
491
 
@@ -489,13 +538,13 @@ export class ViewStream {
489
538
  this.openSpigot('VS_SPAWN_AND_ATTACH_TO_DOM', { attachData });
490
539
  }
491
540
 
492
- /*
493
- attachChildToView(data) {
494
- // let childRenderData = data.attachData;
495
- // console.log('CHILD DATA ', this.constructor.name, childRenderData);
496
- // this.openSpigot('ATTACH_CHILD_TO_SELF', {childRenderData});
497
- }
498
- */
541
+ /*
542
+ attachChildToView(data) {
543
+ // let childRenderData = data.attachData;
544
+ // console.log('CHILD DATA ', this.constructor.name, childRenderData);
545
+ // this.openSpigot('ATTACH_CHILD_TO_SELF', {childRenderData});
546
+ }
547
+ */
499
548
 
500
549
  // ===================================== EXTIRPATE METHODS =================================
501
550
  checkParentDispose(p) {
@@ -560,12 +609,14 @@ export class ViewStream {
560
609
  if (this.props !== undefined) {
561
610
  this.props.action = action;
562
611
  let data = mergeRight(this.props, obj);
612
+ //let data = Object.assign({}, this.props, obj);
613
+
563
614
  this.sink$.next(Object.freeze(data));
564
615
  }
565
616
  }
566
617
 
567
618
  static isDevMode(){
568
- return path(['Spyne', 'config', 'debug'], window)===true;
619
+ return SpyneAppProperties.debug;
569
620
  }
570
621
 
571
622
  setAttachData(attachType, query) {
@@ -599,11 +650,12 @@ export class ViewStream {
599
650
 
600
651
  setAttachParentData(attachType, query, level) {
601
652
  query = query!=="" ? query : undefined;
653
+ const node = this.getParentEls(this.props.el, level);
602
654
  return {
603
- node: this.getParentEls(this.props.el, level),
655
+ node,
604
656
  type: 'ViewStreamObservable',
605
657
  attachType,
606
- query: this.props.el.parentElement.querySelector(query)
658
+ query: node.querySelector(query)
607
659
  };
608
660
  }
609
661
 
@@ -705,7 +757,7 @@ export class ViewStream {
705
757
 
706
758
  appendViewToParentEl(v, query, level = 1) {
707
759
  this.exchangeViewsWithChild(v,
708
- this.setAttachParentData('appendChild', query, level));
760
+ this.setAttachParentData('appendChild', query, level));
709
761
  }
710
762
 
711
763
  /**
@@ -728,7 +780,7 @@ export class ViewStream {
728
780
  * */
729
781
  prependViewToParentEl(v, query, level = 1) {
730
782
  this.exchangeViewsWithChild(v,
731
- this.setAttachParentData('prependChild', query, level));
783
+ this.setAttachParentData('prependChild', query, level));
732
784
  }
733
785
 
734
786
  /**
@@ -779,7 +831,12 @@ export class ViewStream {
779
831
  postRender() {
780
832
  this.beforeAfterRender();
781
833
  this.afterRender();
834
+
782
835
  this.onRendered();
836
+ const startAnimFrameAfterRendered = ()=>this.onAnimFrameAfterRendered();
837
+ requestAnimationFrame(startAnimFrameAfterRendered);
838
+
839
+
783
840
 
784
841
  if (this.isDevMode === true ){
785
842
  const eventsArr = this.broadcastEvents();
@@ -791,8 +848,8 @@ export class ViewStream {
791
848
  }
792
849
 
793
850
  this.viewsStreamBroadcaster = new ViewStreamBroadcaster(this.props,
794
- this.broadcastEvents.bind(this));
795
- this.afterBroadcastEvents();
851
+ this.broadcastEvents.bind(this));
852
+ this.afterBroadcastEvents();
796
853
  }
797
854
 
798
855
  addTraits(traits){
@@ -813,57 +870,56 @@ export class ViewStream {
813
870
 
814
871
  afterBroadcastEvents(){
815
872
 
816
- if (this.isDevMode === true ){
817
- const pullActionsFromList = (arr)=>arr[0];
818
- const nestedActionsArr = this.addActionListeners();
819
-
820
- let actionsArr = nestedActionsArr.map(pullActionsFromList);
873
+ if (this.isDevMode === true ){
874
+ const pullActionsFromList = (arr)=>arr[0];
875
+ const nestedActionsArr = this.addActionListeners();
821
876
 
822
- const isValidArr = ViewStream.isValidNestedArr(nestedActionsArr);
877
+ let actionsArr = nestedActionsArr.map(pullActionsFromList);
823
878
 
824
- if (isValidArr === false){
825
- console.warn(`Spyne Warning: The array returned from addActionsListeners in ${this.props.name}, '${JSON.stringify(nestedActionsArr)}', does not appear to be properly formatted!`);
826
- } else {
827
- const checkForExistingMethod = (arr)=>{
828
- const method = defaultTo('', arr[1]);
829
- const isMethod = is(Function, this[method]);
830
- if (isMethod === false){
831
- console.warn(`Spyne Warning: The method in addActionListeners nested Array, '${JSON.stringify(arr)}', in ${this.props.name}, does not appear to exist!`);
832
- }
879
+ const isValidArr = ViewStream.isValidNestedArr(nestedActionsArr);
833
880
 
881
+ if (isValidArr === false){
882
+ console.warn(`Spyne Warning: The array returned from addActionsListeners in ${this.props.name}, '${JSON.stringify(nestedActionsArr)}', does not appear to be properly formatted!`);
883
+ } else {
884
+ const checkForExistingMethod = (arr)=>{
885
+ const method = defaultTo('', arr[1]);
886
+ const isMethod = is(Function, this[method]);
887
+ if (isMethod === false){
888
+ console.warn(`Spyne Warning: The method in addActionListeners nested Array, '${JSON.stringify(arr)}', in ${this.props.name}, does not appear to exist!`);
834
889
  }
835
- compose(forEach(checkForExistingMethod), defaultTo([]))(nestedActionsArr);
836
- }
837
890
 
838
- const delayForProxyChannelResets = ()=>{
839
- if (path(['props','addedChannels'], this) !== undefined) {
840
- ViewStream.checkIfActionsAreRegistered.bind(this)(this.props.addedChannels, actionsArr);
841
- }
842
- };
843
- this.setTimeout(delayForProxyChannelResets, 500);
891
+ }
892
+ compose(forEach(checkForExistingMethod), defaultTo([]))(nestedActionsArr);
844
893
  }
894
+
895
+ const delayForProxyChannelResets = ()=>{
896
+ if (path(['props','addedChannels'], this) !== undefined) {
897
+ ViewStream.checkIfActionsAreRegistered.bind(this)(this.props.addedChannels, actionsArr);
898
+ }
899
+ };
900
+ this.setTimeout(delayForProxyChannelResets, 500);
901
+ }
845
902
  }
846
903
  static checkIfActionsAreRegistered(channelsArr=[], actionsArr){
847
- //const getActionsFn = path(['Spyne', 'channels', 'getChannelActions'], window);
848
- if (actionsArr.length>0){
849
- const getAllActions = (a)=>{
850
- const getRegisteredActionsArr = (str)=>window.Spyne.channels.getChannelActions(str);
851
- let arr = a.map(getRegisteredActionsArr);
852
- return flatten(arr);
853
- }
854
- const checkForMatch = (strMatch) => {
855
- let re = new RegExp(strMatch);
856
- let actionIndex = findIndex(test(re), getAllActionsArr)
857
- if (actionIndex<0){
858
- let channelSyntax = channelsArr.length === 1 ? "from added channel. \nDid you forget to add the Channel to this ViewStream?" : "from added channels. \nDid you forget to add the Channel to this ViewStream?";
859
- console.warn(`Spyne Warning: The action, ${strMatch}, in ${this.props.name}, does not match any of the registered actions ${channelSyntax}, ${channelsArr.join(', ')}`)
860
- }
861
- // const vsnum = ()=> R.test(new RegExp(str), "CHANNEL_ROUTE_TEST_EVENT")
904
+ if (actionsArr.length>0){
905
+ const getAllActions = (a)=>{
906
+ const getRegisteredActionsArr = (str)=>SpyneAppProperties.getChannelActions(str);
907
+ let arr = a.map(getRegisteredActionsArr);
908
+ return flatten(arr);
909
+ }
910
+ const checkForMatch = (strMatch) => {
911
+ let re = new RegExp(strMatch);
912
+ let actionIndex = findIndex(test(re), getAllActionsArr)
913
+ if (actionIndex<0){
914
+ let channelSyntax = channelsArr.length === 1 ? "from added channel" : "from added channels";
915
+ console.warn(`Spyne Warning: The action, ${strMatch}, in ${this.props.name}, does not match any of the registered actions ${channelSyntax}, ${channelsArr.join(', ')}`)
862
916
  }
863
- let getAllActionsArr = getAllActions(channelsArr);
864
- actionsArr.forEach(checkForMatch);
865
-
917
+ // const vsnum = ()=> R.test(new RegExp(str), "CHANNEL_ROUTE_TEST_EVENT")
866
918
  }
919
+ let getAllActionsArr = getAllActions(channelsArr);
920
+ actionsArr.forEach(checkForMatch);
921
+
922
+ }
867
923
 
868
924
  }
869
925
 
@@ -872,11 +928,11 @@ export class ViewStream {
872
928
  }
873
929
 
874
930
  beforeAfterRender() {
875
- /* let dm2 = function(el) {
876
- return function(str = '') {
877
- return new DomItemSelectors(el, str);
878
- };
879
- };*/
931
+ /* let dm2 = function(el) {
932
+ return function(str = '') {
933
+ return new DomItemSelectors(el, str);
934
+ };
935
+ };*/
880
936
 
881
937
  //this.props.el$ = dm2(this.props.el);
882
938
  this.setDataVSID();
@@ -901,6 +957,17 @@ export class ViewStream {
901
957
  onRendered() {
902
958
  }
903
959
 
960
+ /**
961
+ *
962
+ * This method is useful to add animation classes to be called immediately after rendering.
963
+ *
964
+ */
965
+
966
+ onAnimFrameAfterRendered() {
967
+ }
968
+
969
+
970
+
904
971
 
905
972
 
906
973
  /**
@@ -919,12 +986,12 @@ export class ViewStream {
919
986
  * @example
920
987
  *
921
988
  * broadcastEvents() {
922
- * // ADD BUTTON EVENTS AS NESTED ARRAYS
923
- * return [
924
- * ['#my-button', 'mouseover'],
925
- * ['#my-input', 'change']
926
- * ]
927
- * }
989
+ * // ADD BUTTON EVENTS AS NESTED ARRAYS
990
+ * return [
991
+ * ['#my-button', 'mouseover'],
992
+ * ['#my-input', 'change']
993
+ * ]
994
+ * }
928
995
  *
929
996
  *
930
997
  * */
@@ -964,9 +1031,9 @@ export class ViewStream {
964
1031
  getChannel(channel) {
965
1032
  let isValidChannel = c => registeredStreamNames().includes(c);
966
1033
  let error = c => console.warn(
967
- `channel name ${c} is not within ${registeredStreamNames}`);
1034
+ `channel name ${c} is not within ${registeredStreamNames}`);
968
1035
  let startSubscribe = (c) => {
969
- let obs$ = window.Spyne.channels.getStream(c).observer;
1036
+ let obs$ = SpyneAppProperties.channelsMap.getStream(c).observer;
970
1037
 
971
1038
  return obs$.pipe(takeWhile(p => this.deleted !== true));
972
1039
  };// getGlobalParam('streamsController').getStream(c).observer;
@@ -991,34 +1058,32 @@ export class ViewStream {
991
1058
  * let routeChannel = this.addChannel('ROUTE');
992
1059
  *
993
1060
  * addActionListeners() {
994
- * return [
995
- * ['CHANNEL_ROUTE_CHANGE_EVENT', 'onMapRouteEvent']
996
- * ]
997
- * }
1061
+ * return [
1062
+ * ['CHANNEL_ROUTE_CHANGE_EVENT', 'onMapRouteEvent']
1063
+ * ]
1064
+ * }
998
1065
  *
999
1066
  * onMapRouteEvent(p) {
1000
- * console.log('the route value is ', p);
1001
- * }
1067
+ * console.log('the route value is ', p);
1068
+ * }
1002
1069
  *
1003
1070
  *
1004
1071
  * */
1005
1072
 
1006
1073
  addChannel(str, skipFirst=false, sendDownStream = false, bool = false) {
1007
1074
 
1008
-
1009
-
1010
- if (skipFirst === true){
1011
-
1012
- }
1013
-
1014
-
1015
1075
  const directionArr = sendDownStream === true ? this.$dirs.CI : this.$dirs.I;
1016
1076
  const mapDirection = p => {
1017
- let p2 = defaultTo({}, clone(p));
1018
- let dirObj = { $dir: directionArr };
1019
- return deepMerge(dirObj, p2);
1077
+ //et p2 = defaultTo({}, clone(p));
1078
+ let pl = p;// || {};
1079
+ pl['$dir'] = directionArr;
1080
+ return pl;
1081
+ //return deepMerge(dirObj, p2);
1020
1082
  // Object.assign({$dir: directionArr}, clone(p))
1021
1083
  };
1084
+
1085
+
1086
+
1022
1087
  const isLocalEventCheck = path(['srcElement', 'isLocalEvent']);
1023
1088
  const cidCheck = path(['srcElement', 'vsid']);
1024
1089
  const cidMatches = p => {
@@ -1041,7 +1106,7 @@ export class ViewStream {
1041
1106
 
1042
1107
 
1043
1108
  checkIfChannelExists(channelName) {
1044
- let channelExists = window.Spyne.channels.map.get(channelName) !== undefined;
1109
+ let channelExists = SpyneAppProperties.channelsMap.testStream(channelName);
1045
1110
  if (channelExists !== true) {
1046
1111
  console.warn(`SPYNE WARNING: The ChannelPayload from ${this.props.name}, has been sent to a channel, ${channelName}, that has not been registered!`);
1047
1112
  }
@@ -1063,13 +1128,42 @@ export class ViewStream {
1063
1128
  *
1064
1129
  */
1065
1130
 
1066
- sendInfoToChannel(channelName, payload = {}, action = 'VIEWSTREAM_EVENT') {
1131
+ sendInfoToChannel(channelName, pl = {}, action) {
1132
+ const payload = pl;
1133
+
1134
+ let defaultToAction = defaultTo('VIEWSTREAM_EVENT');
1135
+ const channelDefaultActionHash = {
1136
+ CHANNEL_ROUTE: "CHANNEL_ROUTE_CHANGE_EVENT"
1137
+ }
1138
+ const getActionFn = compose(defaultToAction, prop(channelName))
1139
+
1140
+ action = action || getActionFn(channelDefaultActionHash);
1141
+
1142
+
1067
1143
  let data = { payload, action };
1144
+
1145
+
1068
1146
  data.srcElement = compose(pick(['id','vsid','class','tagName']), prop('props'))(this);
1069
1147
  if (this.checkIfChannelExists(channelName) === true) {
1070
- let obs$ = of(data);
1071
- return new ViewStreamPayload(channelName, obs$, data);
1072
- }
1148
+ if (/CHANNEL_LIFECYCLE/.test(action)===false){
1149
+ Object.defineProperties(data, {
1150
+ payload: {
1151
+ get: ()=> clone(pl)
1152
+
1153
+ }
1154
+ })
1155
+
1156
+ }
1157
+ let obs$ = of(data);
1158
+ return new ViewStreamPayload(channelName, obs$, data);
1159
+
1160
+ }
1161
+
1162
+
1163
+
1164
+
1165
+
1166
+
1073
1167
  }
1074
1168
 
1075
1169
  tracer(...args) {
@@ -1098,8 +1192,18 @@ export class ViewStream {
1098
1192
 
1099
1193
  isLocalEvent(channelPayloadItem) {
1100
1194
  const itemEl = path(['srcElement', 'el'], channelPayloadItem);
1101
- return itemEl !== undefined &&
1102
- this.props.el.contains(channelPayloadItem.srcElement.el);
1195
+ const thisEl = path(['props', 'el'], this);
1196
+ //console.log('this el is ',{thisEl, itemEl});
1197
+ return ViewStream.elIsDomElement(thisEl) && ViewStream.elIsDomElement(itemEl) && thisEl.contains(itemEl);
1198
+ }
1199
+
1200
+ static elIsDomElement(o) {
1201
+ if (is(String,o)){
1202
+ o = document.querySelector(o);
1203
+ }
1204
+
1205
+
1206
+ return compose(lte(0), defaultTo(-1), prop('nodeType'))(o);
1103
1207
  }
1104
1208
 
1105
1209
  get attributesArray() {
@@ -0,0 +1,102 @@
1
+ const {expect, assert} = require('chai');
2
+ const {ChannelFetch} = require('../../spyne/channels/channel-fetch-class')
3
+
4
+ describe('should test ChannelFetch', () => {
5
+ const mapFn = (p) => {
6
+ //console.log('mapping fetched data ', p);
7
+ return p;
8
+ };
9
+
10
+ const channelName = "CHANNEL_MY_FETCHED_DATA"
11
+ let url = 'https://jsonplaceholder.typicode.com/posts/1';
12
+
13
+
14
+ it('should return true for valid mapFn method', () => {
15
+ let props = {
16
+ mapFn,
17
+ url,
18
+ method: 'GET'
19
+ };
20
+
21
+ const mapMethodIsValid = ChannelFetch.validateMapMethod(props, channelName);
22
+ //console.log('mapFn method is valid ',{mapMethodIsValid})
23
+ expect(mapMethodIsValid).to.be.true;
24
+
25
+ });
26
+
27
+ it('should return true for valid map method', () => {
28
+ const map = mapFn;
29
+ let props = {
30
+ map,
31
+ url,
32
+ method: 'GET'
33
+ };
34
+
35
+ const mapMethodIsValid = ChannelFetch.validateMapMethod(props, channelName);
36
+ //console.log('map method is valid ',{mapMethodIsValid})
37
+ expect(mapMethodIsValid).to.be.true;
38
+
39
+ });
40
+
41
+ it('should return true non existing map methods', () => {
42
+ let props = {
43
+ url
44
+ };
45
+
46
+ const noMapMethodAdded = ChannelFetch.validateMapMethod(props, channelName);
47
+ //console.log('map methods not added and is valid ',{noMapMethodAdded})
48
+ expect(noMapMethodAdded).to.be.true;
49
+
50
+ });
51
+
52
+ it('should return false for map of wrong type', () => {
53
+ const map = 4;
54
+ let props = {
55
+ map,
56
+ url
57
+ };
58
+
59
+ const mapTypeIsCorrect = ChannelFetch.validateMapMethod(props, "MY_TEST_NAME", true);
60
+ //console.log('map methods is not of correct type added and is valid1 ',{mapTypeIsCorrect}) ; expect(mapTypeIsCorrect).to.be.false;
61
+
62
+ });
63
+
64
+ it('should return false for mapFn of wrong type', () => {
65
+ const mapFn = 'my str';
66
+ let props = {
67
+ mapFn,
68
+ url
69
+ };
70
+
71
+ const mapTypeIsCorrect = ChannelFetch.validateMapMethod(props, "MY_TEST_NAME_2", true);
72
+ //console.log('map methods is not of correct type added and is valid2 ',{mapTypeIsCorrect}) ; expect(mapTypeIsCorrect).to.be.false;
73
+
74
+ });
75
+
76
+ it('should return false for map of wrong type', () => {
77
+ const map = undefined;
78
+ let props = {
79
+ map,
80
+ url
81
+ };
82
+
83
+ const mapTypeUndefined = ChannelFetch.validateMapMethod(props, "MY_TEST_NAME", true);
84
+ //console.log('map methods is not of correct type added and is valid3 ',{mapTypeUndefined}) ; expect(mapTypeUndefined).to.be.false;
85
+
86
+ });
87
+
88
+ it('should return false for mapFn of wrong type', () => {
89
+ const mapFn = undefined;
90
+ let props = {
91
+ mapFn,
92
+ url
93
+ };
94
+
95
+ const mapTypeUndefined = ChannelFetch.validateMapMethod(props, "MY_TEST_NAME_2", true);
96
+ //console.log('map methods is not of correct type added and is valid4 ',{mapTypeUndefined}) ; expect(mapTypeUndefined).to.be.false;
97
+
98
+ });
99
+
100
+
101
+
102
+ });