spyne 0.16.2 → 0.18.2

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 (82) hide show
  1. package/.travis.yml +1 -1
  2. package/README.md +0 -60
  3. package/karma.conf.js +18 -69
  4. package/lib/spyne.js +29755 -28678
  5. package/lib/spyne.min.js +1 -1
  6. package/lib/spyne.min.js.LICENSE.txt +9 -9
  7. package/package.json +21 -42
  8. package/src/spyne/channels/channel-fetch-class.js +25 -5
  9. package/src/spyne/channels/channel-payload-class.js +36 -23
  10. package/src/spyne/channels/channel-proxy.js +7 -5
  11. package/src/spyne/channels/channel.js +54 -28
  12. package/src/spyne/channels/channels-config.js +2 -4
  13. package/src/spyne/channels/{channels-delegator.js → channels-map.js} +24 -40
  14. package/src/spyne/channels/spyne-channel-lifecycle.js +1 -2
  15. package/src/spyne/channels/spyne-channel-route.js +21 -62
  16. package/src/spyne/channels/spyne-channel-ui.js +1 -2
  17. package/src/spyne/channels/spyne-channel-window.js +24 -35
  18. package/src/spyne/spyne-app.js +165 -0
  19. package/src/spyne/spyne-plugins.js +39 -41
  20. package/src/spyne/spyne.js +6 -158
  21. package/src/spyne/utils/channel-config-validator.js +0 -1
  22. package/src/spyne/utils/channel-fetch-util.js +1 -2
  23. package/src/spyne/utils/channel-payload-filter.js +9 -76
  24. package/src/spyne/utils/frp-tools.js +21 -1
  25. package/src/spyne/utils/gc.js +1 -1
  26. package/src/spyne/utils/route-channel-updater.js +0 -4
  27. package/src/spyne/utils/spyne-app-properties.js +183 -0
  28. package/src/spyne/utils/spyne-logger.js +18 -0
  29. package/src/spyne/utils/spyne-plugins-methods.js +97 -0
  30. package/src/spyne/utils/spyne-trait.js +2 -5
  31. package/src/spyne/utils/spyne-utils-channel-route-url.js +3 -8
  32. package/src/spyne/utils/spyne-utils-channel-route.js +6 -14
  33. package/src/spyne/utils/spyne-utils-channel-window.js +1 -3
  34. package/src/spyne/utils/viewstream-observables.js +2 -3
  35. package/src/spyne/views/dom-element-template.js +2 -7
  36. package/src/spyne/views/dom-element.js +0 -19
  37. package/src/spyne/views/view-stream-broadcaster.js +5 -10
  38. package/src/spyne/views/view-stream-element.js +1 -18
  39. package/src/spyne/views/view-stream-payload.js +31 -37
  40. package/src/spyne/views/view-stream-selector.js +3 -8
  41. package/src/spyne/views/view-stream.js +281 -297
  42. package/src/tests/channels/channel-fetch.test.js +102 -0
  43. package/src/tests/channels/channel-payload-class.test.js +14 -5
  44. package/src/tests/channels/channel-payload-filter.test.js +3 -28
  45. package/src/tests/channels/channel.test.js +38 -0
  46. package/src/tests/index.js +0 -1
  47. package/src/tests/index.test.js +6 -0
  48. package/src/tests/spyne-app.test.js +27 -0
  49. package/src/tests/spyne-plugin.test.js +13 -9
  50. package/src/tests/utils/plugins-methods.test.js +103 -0
  51. package/src/tests/utils/spyne-app-properties.test.js +11 -0
  52. package/webpack.config.js +19 -34
  53. package/lib/channel-action-filter.test.3516417154.js +0 -20
  54. package/lib/channel-dom.test.104366832.js +0 -20
  55. package/lib/channel-fetch-util.test.3506167575.js +0 -20
  56. package/lib/channel-payload-class.test.1081032524.js +0 -20
  57. package/lib/channel-payload-filter.test.977308429.js +0 -20
  58. package/lib/channel-route.test.3513636042.js +0 -20
  59. package/lib/channel-stream-item.test.119388071.js +0 -20
  60. package/lib/channel-ui.test.3778619579.js +0 -20
  61. package/lib/channel-util-dom.test.908537750.js +0 -20
  62. package/lib/commons.js +0 -49274
  63. package/lib/dom-el-selectors.test.1268485916.js +0 -20
  64. package/lib/dom-el-template.test.842696987.js +0 -20
  65. package/lib/dom-el.test.2045076905.js +0 -20
  66. package/lib/frp-tools.test.2503042868.js +0 -20
  67. package/lib/import.test.2658619365.js +0 -20
  68. package/lib/index.test.2372977745.js +0 -20
  69. package/lib/route-utils.test.273346057.js +0 -20
  70. package/lib/runtime.js +0 -172
  71. package/lib/spyne-plugin.test.301647328.js +0 -20
  72. package/lib/spyne.js.map +0 -1
  73. package/lib/url-utils.test.1931189114.js +0 -20
  74. package/lib/view-stream-broadcaster.test.1306675435.js +0 -20
  75. package/lib/view-stream-enhancer-loader.test.3617829096.js +0 -20
  76. package/lib/view-stream-enhancer.test.1053738169.js +0 -20
  77. package/lib/view-stream.test.573231784.js +0 -20
  78. package/src/spyne/channels/lifestream-payload.js +0 -56
  79. package/src/spyne/utils/channel-data-packet-generator.js +0 -200
  80. package/src/spyne/utils/channel-data-packet.js +0 -59
  81. package/src/spyne/utils/viewstream-dom-utils.js +0 -51
  82. package/src/spyne/views/view-stream-enhancer-loader.js +0 -70
@@ -1,17 +1,16 @@
1
1
  import { Channel } from './channel';
2
2
  import { SpyneUtilsChannelRouteUrl } from '../utils/spyne-utils-channel-route-url';
3
3
  import { SpyneUtilsChannelRoute } from '../utils/spyne-utils-channel-route';
4
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
4
5
  import { ReplaySubject, merge } from 'rxjs';
5
6
  import { map } from 'rxjs/operators';
6
7
 
7
8
  import {
8
- clone,
9
9
  pick,
10
- find,
10
+ find,
11
11
  omit,
12
12
  over,
13
13
  mergeRight,
14
- mergeDeepRight,
15
14
  is,
16
15
  objOf,
17
16
  mergeAll,
@@ -32,7 +31,10 @@ import {
32
31
  reverse,
33
32
  curryN,
34
33
  __,
35
- test, replace, fromPairs, toPairs, forEach, reduceRight, reduce
34
+ test,
35
+ replace,
36
+ toPairs,
37
+ reduce
36
38
  } from 'ramda';
37
39
  const ramdaFilter = require('ramda').filter;
38
40
  const rMerge = require('ramda').mergeRight;
@@ -139,16 +141,15 @@ export class SpyneChannelRoute extends Channel {
139
141
  this.bindStaticMethods();
140
142
  this.navToStream$ = new ReplaySubject(1);
141
143
  this.observer$ = this.navToStream$.pipe(map(info => this.onMapNext(info)));
142
- // let compareKeysFn = SpyneUtilsChannelRoute.compareRouteKeywords.bind(this);
143
144
  this.compareRouteKeywords = SpyneUtilsChannelRoute.compareRouteKeywords();
144
145
  }
145
146
 
146
147
  checkConfigForHash(){
147
148
  // LEGACY CHECK TO SIMPLIFY CONFIG FOR HASH;
148
- let isHashType = window.Spyne.config.channels.ROUTE.type==='hash';
149
+ let isHashType = SpyneAppProperties.config.channels.ROUTE.type==='hash';
149
150
  if (isHashType === true){
150
- window.Spyne.config.channels.ROUTE.type = 'slash';
151
- window.Spyne.config.channels.ROUTE.isHash = true;
151
+ SpyneAppProperties.config.channels.ROUTE.type = 'slash';
152
+ SpyneAppProperties.config.channels.ROUTE.isHash = true;
152
153
  }
153
154
 
154
155
  }
@@ -178,13 +179,10 @@ export class SpyneChannelRoute extends Channel {
178
179
 
179
180
  const newRoutesObj = pick(['isHash', 'isHidden', 'routes','type'], e.payload);
180
181
 
181
- window.Spyne.config.channels.ROUTE = mergeRight(window.Spyne.config.channels.ROUTE, newRoutesObj);
182
+ SpyneAppProperties.config.channels.ROUTE = mergeRight(SpyneAppProperties.config.channels.ROUTE, newRoutesObj);
182
183
 
183
- const clonedRoute = clone(window.Spyne.config.channels.ROUTE);
184
184
 
185
- // ADD 404S, EMPTY REGEX AND CONVERT ARRAYS
186
-
187
- window.Spyne.config = SpyneUtilsChannelRoute.conformRouteObject(window.Spyne.config);
185
+ SpyneAppProperties.conformRouteConfig();
188
186
 
189
187
 
190
188
  const routeConfig = this.getRouteConfig();
@@ -194,21 +192,18 @@ export class SpyneChannelRoute extends Channel {
194
192
  this.bindStaticMethodsWithConfigData();
195
193
 
196
194
 
197
- this.sendChannelPayload(action, routeConfig, {}, {},
198
- this.navToStream$);
195
+ this.sendChannelPayload(action, routeConfig, {}, {}, this.navToStream$);
199
196
  }
200
197
 
201
198
  getRouteConfig() {
202
- const spyneConfig = window.Spyne.config;
199
+ const spyneConfig = SpyneAppProperties.config;
203
200
  let routeConfig = path(['channels', 'ROUTE'], spyneConfig);
204
201
  if (routeConfig.type === 'query') {
205
202
  routeConfig.isHash = false;
206
203
  }
207
204
 
208
205
  let arr = SpyneUtilsChannelRoute.flattenConfigObject(routeConfig.routes);
209
- // console.log("FLATTENED CONFIG ",arr);
210
206
  routeConfig['paramsArr'] = arr;
211
- //console.log("ROUTE CONFIG IS ",routeConfig);
212
207
  return routeConfig;
213
208
  }
214
209
 
@@ -223,7 +218,6 @@ export class SpyneChannelRoute extends Channel {
223
218
  }
224
219
 
225
220
  onMapNext(data, firstLoaded = false) {
226
- // console.log("MAP NEXT ",{firstLoaded, data});
227
221
  data['action'] = 'CHANNEL_ROUTE_CHANGE_EVENT';
228
222
  return data;
229
223
  }
@@ -250,15 +244,11 @@ export class SpyneChannelRoute extends Channel {
250
244
 
251
245
  let keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths);
252
246
  payload = rMerge(payload, keywordArrs);
253
- // console.log("SEND STREAM onIncomingDomEvent", payload, keywordArrs);;
254
- // payload = SpyneChannelRoute.removeSSID(payload);
255
- this.sendChannelPayload(action, payload, undefined, undefined, this.navToStream$);
247
+ this.sendChannelPayload(action, payload, undefined, evt, this.navToStream$);
256
248
 
257
249
  }
258
250
 
259
251
  static checkForRouteParamsOverrides(payload) {
260
- // console.log("CHECK FOR OVERRIDES ",payload);
261
-
262
252
  return payload;
263
253
  }
264
254
 
@@ -283,32 +273,14 @@ export class SpyneChannelRoute extends Channel {
283
273
  }
284
274
 
285
275
 
286
-
287
- /*
288
- static checkToPreventDefaultEvent(obs) {
289
- const checkDataForPreventDefault = pathEq(['viewStreamInfo', 'payload', 'eventPreventDefault'], 'true');
290
- const setPreventDefault = (evt) => {
291
- if (evt !== undefined) {
292
- evt.preventDefault();
293
- }
294
- };
295
- const selectEvtAndPreventDefault = compose(setPreventDefault, prop('event'));
296
- const checkForPreventDefault = when(checkDataForPreventDefault, selectEvtAndPreventDefault);
297
- checkForPreventDefault(obs);
298
- }
299
- */
300
-
301
-
302
276
  static checkForEndRoute(pl, routeConfigJson = this.routeConfigJson, debugBool){
303
277
 
304
278
  const endRoute = compose(equals("true"), path(['payload', 'endRoute']))(pl);
305
- //console.log('pl and aend route',{endRoute, pl})
306
279
 
307
280
  if (endRoute!==true){
308
281
  return pl;
309
282
  }
310
- const win = window || {};
311
- const debug = debugBool !== undefined ? debugBool : compose(equals(true), path(['Spyne','config', 'debug']))(win);
283
+ const debug = debugBool !== undefined ? debugBool : SpyneAppProperties.debug === true;
312
284
  const {payload} = pl;
313
285
 
314
286
 
@@ -319,7 +291,6 @@ export class SpyneChannelRoute extends Channel {
319
291
  let routeNameVal = payload[routeName]
320
292
  const pred = arrStr => new RegExp(`^${arrStr}$`).test(routeNameVal);
321
293
  const routeVal = find(pred, keysArr);
322
- // console.log('route val is ',{routeVal, keysArr})
323
294
  return routeVal;
324
295
 
325
296
  }
@@ -350,7 +321,6 @@ export class SpyneChannelRoute extends Channel {
350
321
  acc.push(routeName)
351
322
  }
352
323
  }
353
- // compose(reduce(onReduceRoutePaths), toPairs)(nextRoutePath);
354
324
  }
355
325
  return acc;
356
326
 
@@ -378,17 +348,15 @@ export class SpyneChannelRoute extends Channel {
378
348
  SpyneChannelRoute.checkForEventMethods(pl);
379
349
  pl = this.checkForEndRoute(pl);
380
350
  let payload = this.getDataFromParams(pl);
381
- const {routeConfigJson} = this;
382
- //console.log("LOADING ROUTE FROM LINK ", {pl, payload,routeConfigJson})
383
351
 
384
352
  let srcElement = prop('srcElement', pl);
385
353
  let event = prop('event', pl);
386
354
  let changeLocationBool = !payload.isHidden;
387
355
  let keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths);
356
+
388
357
  payload = rMerge(payload, keywordArrs);
389
- // this.checkForRouteParamsOverrides(payload);
390
358
  this.sendRouteStream(payload, changeLocationBool);
391
- //console.log("SEND STREAM onViewStreamInfo", payload);
359
+
392
360
  payload = SpyneChannelRoute.removeSSID(payload);
393
361
 
394
362
  this.sendChannelPayload(action, payload, srcElement, event,
@@ -429,11 +397,10 @@ export class SpyneChannelRoute extends Channel {
429
397
  static getExtraPayloadParams(config = this.routeConfigJson, isHistory=false) {
430
398
  let routeCount = this.getRouteCount(isHistory);
431
399
  let isDeepLink = this.getIsDeepLinkBool(isHistory);
432
- //console.log("GETTING DEEP LINK ", {routeCount, isDeepLink,isHistory, config})
433
400
  let isHash = config.isHash;
434
401
  let isHidden = config.isHidden;
435
402
  let routeType = config.type;
436
- return { routeCount, isDeepLink, isHash, isHidden, routeType };
403
+ return { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType };
437
404
  }
438
405
 
439
406
  static getDataFromParams(pl, config = this.routeConfigJson) {
@@ -448,12 +415,11 @@ export class SpyneChannelRoute extends Channel {
448
415
  let nextWindowLoc = SpyneUtilsChannelRouteUrl.formatStrAsWindowLocation(routeValue);
449
416
  let dataFromStr = this.getDataFromLocationStr(typeForStr, isHashForStr, nextWindowLoc);
450
417
 
451
- // console.log(" DATA FROM STRING ",{routeValue, pl, dataFromStr});
452
418
  let { pathInnermost, paths } = dataFromStr;
453
419
 
454
420
  routeData = rMerge(dataFromStr.routeData, routeData);
455
421
 
456
- let { routeCount, isDeepLink, isHash, isHidden, routeType } = this.getExtraPayloadParams(
422
+ let { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType } = this.getExtraPayloadParams(
457
423
  config);
458
424
  return {
459
425
  isDeepLink,
@@ -464,6 +430,7 @@ export class SpyneChannelRoute extends Channel {
464
430
  routeValue,
465
431
  isHash,
466
432
  isHidden,
433
+ isHistory,
467
434
  routeType
468
435
  };
469
436
  }
@@ -471,7 +438,6 @@ export class SpyneChannelRoute extends Channel {
471
438
  static getDataFromString(config = this.routeConfigJson, isHistory=false) {
472
439
  const type = config.type;
473
440
  const hashIsTrue = config.isHash === true;
474
- // type = config.isHash === true ? ''
475
441
  const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, hashIsTrue);
476
442
  let { paths, pathInnermost, routeData, routeValue } = SpyneChannelRoute.getParamsFromRouteStr(
477
443
  str, config, type);
@@ -487,6 +453,7 @@ export class SpyneChannelRoute extends Channel {
487
453
  routeValue,
488
454
  isHash,
489
455
  isHidden,
456
+ isHistory,
490
457
  routeType
491
458
  };
492
459
  return obj;
@@ -497,7 +464,6 @@ export class SpyneChannelRoute extends Channel {
497
464
  ? this.routeConfigJson.type
498
465
  : t;
499
466
 
500
- // console.log("DATA CHECK STRING ",loc);
501
467
  const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, isHash, loc);
502
468
  let { paths, pathInnermost, routeData, routeValue } = this.getParamsFromRouteStr(
503
469
  str, this.routeConfigJson, type);
@@ -522,15 +488,12 @@ export class SpyneChannelRoute extends Channel {
522
488
  static getRouteStrFromParams(paramsData, routeConfig, t) {
523
489
  const type = t !== undefined ? t : routeConfig.type;
524
490
  let obj = SpyneUtilsChannelRouteUrl.convertParamsToRoute(paramsData, routeConfig, type);
525
-
526
- // console.log("ROUTE getRouteStrFromParams ",paramsData,obj);
527
491
  return obj;
528
492
  }
529
493
 
530
494
  static getParamsFromRouteStr(str, routeConfig, t) {
531
495
  const type = t !== undefined ? t : routeConfig.type;
532
496
  let obj = SpyneUtilsChannelRouteUrl.convertRouteToParams(str, routeConfig, type);
533
- // console.log("ROUTE getParamsFromRouteStr ",obj);
534
497
  return obj;
535
498
  }
536
499
 
@@ -540,7 +503,6 @@ export class SpyneChannelRoute extends Channel {
540
503
  const hashNameIsEmptyBool = isEmptyBool === true && isHash === true;
541
504
  const hashNameBool = isEmptyBool === false && isHash === true;
542
505
 
543
- // console.log('ROUTE STR CHECK ', {str, isHash});
544
506
  if (pathNameIsEmptyBool === true || hashNameIsEmptyBool === true) {
545
507
  return '/';
546
508
  } else if (hashNameBool === true) {
@@ -560,11 +522,8 @@ export class SpyneChannelRoute extends Channel {
560
522
  if (isHash === true) {
561
523
  let pathName = SpyneChannelRoute.removeLastSlash(window.location.pathname);
562
524
  routeValue = pathName + routeValue;
563
- // window.location.hash = routeValue;
564
- // console.log('ROUTE STR FOR HASH ', routeValue);
565
525
  window.history.pushState({routeCount}, '', routeValue);
566
526
  } else {
567
- // routeValue = when(isEmpty, always('/'))(routeValue);
568
527
  const checkForSlash = when(
569
528
  compose(complement(equals('/')), head), concat('/', __));
570
529
  window.history.pushState({routeCount}, '', checkForSlash(routeValue));
@@ -25,7 +25,6 @@ export class SpyneChannelUI extends Channel {
25
25
  super(name, props);
26
26
  this.keyEventsLoaded = false;
27
27
  this.keyCodeArr = [];
28
- // this.addKeyEvent(13);
29
28
  }
30
29
 
31
30
  addRegisteredActions() {
@@ -44,6 +43,7 @@ export class SpyneChannelUI extends Channel {
44
43
  'CHANNEL_UI_CHECKBOXSTATECHANGE_EVENT',
45
44
  'CHANNEL_UI_CLICK_EVENT',
46
45
  'CHANNEL_UI_COMPLETE_EVENT',
46
+ 'CHANNEL_UI_CONTEXTMENU_EVENT',
47
47
  'CHANNEL_UI_COPY_EVENT',
48
48
  'CHANNEL_UI_CUT_EVENT',
49
49
  'CHANNEL_UI_DBLCLICK_EVENT',
@@ -136,7 +136,6 @@ export class SpyneChannelUI extends Channel {
136
136
  onIncomingObservable(obj) {
137
137
  let eqsName = equals(obj.name, this.props.name);
138
138
  obj.data = SpyneChannelUI.removeSSID(obj.data);
139
- //console.log("OBJECT DATA ",obj.data);
140
139
  let {payload, srcElement} = obj.data;
141
140
  let dataObj = obsVal => ({ payload, srcElement, event: obsVal });
142
141
  let onSuccess = (obj) => obj.observable.pipe(map(dataObj))
@@ -1,9 +1,10 @@
1
1
  import { Channel } from './channel';
2
2
  import { checkIfObjIsNotEmptyOrNil } from '../utils/frp-tools';
3
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
3
4
  import { SpyneUtilsChannelWindow } from '../utils/spyne-utils-channel-window';
4
5
  import { merge } from 'rxjs';
5
6
  import { map, debounceTime, skipWhile } from 'rxjs/operators';
6
- import {curry, pathEq, pick, partialRight, mapObjIndexed, apply} from 'ramda';
7
+ import {curry, pick, partialRight, mapObjIndexed, apply} from 'ramda';
7
8
  import {deepMerge} from '../utils/deep-merge';
8
9
 
9
10
  const rMap = require('ramda').map;
@@ -37,11 +38,11 @@ export class SpyneChannelWindow extends Channel {
37
38
  super(CHANNEL_NAME);
38
39
  this.bindStaticMethods();
39
40
  this.currentScrollY=0;
40
- // this.props.name = 'WINDOW';
41
+
41
42
  }
42
43
 
43
44
  initializeStream() {
44
- this.domChannelConfig = window.Spyne.config.channels.WINDOW;
45
+ this.domChannelConfig = SpyneAppProperties.config.channels.WINDOW;
45
46
  let obs$Arr = this.getActiveObservables();
46
47
  let dom$ = merge(...obs$Arr);
47
48
  this.dom$ = dom$;
@@ -140,10 +141,12 @@ export class SpyneChannelWindow extends Channel {
140
141
  return { action, payload, srcElement, scrollDistance, event };
141
142
  }
142
143
 
143
- createScrollObservable(config, scrollElement=window) {
144
+ createScrollObservable(config, scrollElement=window, isPassive = true) {
144
145
  const skipWhenDirIsMissing = evt => evt.scrollDistance === 0;
145
146
  const dTime = config.debounceMSTimeForScroll;
146
147
 
148
+ const element = scrollElement;
149
+
147
150
 
148
151
  const isWindow = scrollElement === window;
149
152
 
@@ -153,28 +156,19 @@ export class SpyneChannelWindow extends Channel {
153
156
 
154
157
  const scrollDataFn =SpyneChannelWindow.getScrollData();
155
158
  // console.log("SCROLL ELEMENT ",action,scrollElement, scrollElForVals);
156
- const scrollMapFn =partialRight(SpyneChannelWindow.getScrollMapFn, [action, scrollDataFn, scrollElForVals]).bind(this);
159
+ const scrollMapFn =partialRight(SpyneChannelWindow.getScrollMapFn, [action, scrollDataFn, scrollElForVals, isPassive, element]).bind(this);
160
+
161
+ // console.log("createScrollObservable ", {scrollMapFn, scrollDataFn, action, config, scrollElement, element})
162
+
157
163
 
158
- /**
159
- * TODO: curry createDomObservableFromEvent so that element can be other than window.
160
- *
161
- */
162
164
 
163
165
  return SpyneUtilsChannelWindow.createDomObservableFromEvent('scroll',
164
- scrollMapFn)
166
+ scrollMapFn, isPassive, element)
165
167
  .pipe(
166
- /* map(p=>{
167
- if (pathEq(['Spyne', 'config', 'scrollLock'], true)(scrollElement)){
168
- let x = window.Spyne.config.scrollLockX
169
- let y = window.Spyne.config.scrollLockY;
170
- window.scrollTo(x,y);
171
- }
172
- return p;
173
- }),*/
174
168
  debounceTime(dTime),
175
169
  skipWhile(skipWhenDirIsMissing),
176
170
  map(p=>{
177
- const newScrollY = SpyneChannelWindow.getScrollY(window);
171
+ const newScrollY = SpyneChannelWindow.getScrollY(element);
178
172
  p.payload['scrollDistanceAbs'] = Math.abs(this.currentScrollY-newScrollY);
179
173
  this.currentScrollY=newScrollY;
180
174
  return p;
@@ -213,13 +207,11 @@ export class SpyneChannelWindow extends Channel {
213
207
  // CHECK TO ADD MEDIA QUERY OBSERVABLE
214
208
  // ==========================================
215
209
  config['listenForMediaQueries'] = checkIfObjIsNotEmptyOrNil(
216
- config.mediqQueries);
210
+ config.mediaQueries) || checkIfObjIsNotEmptyOrNil(
211
+ config.mediqQueries);
217
212
 
218
213
  // =========================================
219
214
 
220
- // config.listenForResize = false;
221
- // config.listenForMouseWheel = true;
222
- // config.listenForScroll = false;
223
215
  let methods = {
224
216
  'listenForResize': this.createResizeObservable.bind(this),
225
217
  'listenForOrientation': this.createOrientationObservable.bind(this),
@@ -317,6 +309,7 @@ export class SpyneChannelWindow extends Channel {
317
309
  'CHANNEL_WINDOW_RESET_EVENT',
318
310
  'CHANNEL_WINDOW_RESIZE_EVENT',
319
311
  'CHANNEL_WINDOW_ELEMENT_SCROLL_EVENT',
312
+ 'CHANNEL_WINDOW_SCROLL_ELEMENT_ADDED_EVENT',
320
313
  ['CHANNEL_WINDOW_SET_ELEMENT_TO_SCROLL_EVENT', 'onSetElementToScroll'],
321
314
  'CHANNEL_WINDOW_SCROLL_EVENT',
322
315
  'CHANNEL_WINDOW_SCROLL_LOCK_EVENT',
@@ -332,24 +325,20 @@ export class SpyneChannelWindow extends Channel {
332
325
  }
333
326
 
334
327
  onScrollLockEvent(e){
335
- const setScrollPos = ()=>{
336
- window.Spyne.config.scrollLockX = window.scrollX;
337
- window.Spyne.config.scrollLockY = window.scrollY;
338
- };
339
- let {action, scrollLock} = e.payload;
340
- window.Spyne.config.scrollLock = scrollLock;
341
- if (scrollLock === true){
342
- setScrollPos();
343
- }
344
-
345
- this.sendChannelPayload(action, {scrollLock});
328
+ // DEPRECATED -- MOVED TO spyne-plugin-scroll-lock;
346
329
  }
347
330
 
348
331
  onSetElementToScroll(e){
349
332
 
350
- let {config, scrollElement} = e.payload;
333
+ let {config, el, scrollElement} = e.payload;
334
+ config = config || {};
351
335
  config = deepMerge(this.domChannelConfig, config);
352
336
 
337
+ scrollElement = scrollElement || el;
338
+
339
+ const action = "CHANNEL_WINDOW_SCROLL_ELEMENT_ADDED_EVENT";
340
+ this.sendChannelPayload(action, {el}, el);
341
+
353
342
  this.createScrollObservable(config, scrollElement)
354
343
  .subscribe(p => {
355
344
  let { action, payload, srcElement, event } = p;
@@ -0,0 +1,165 @@
1
+ import {ChannelsMap} from './channels/channels-map';
2
+ import {ViewStream} from './views/view-stream';
3
+ import {SpyneAppProperties} from './utils/spyne-app-properties';
4
+ import {deepMerge} from './utils/deep-merge';
5
+ const _channels = new ChannelsMap();
6
+ const version = '0.18.2';
7
+
8
+ class SpyneApplication {
9
+ /**
10
+ *
11
+ * SpyneApp creates the global Spyne object, and creates the following items
12
+ * <ul>
13
+ *
14
+ * <li>LINK['ChannelsMap', 'channels-controller'] that directs the flow of data to all Channels</li>
15
+ * <li>LINK['SpyneChannelUI', 'spyne-channel-u-i'], that broadcast all user interaction events</li>
16
+ * <li>LINK['SpyneChannelRoute', 'spyne-channel-route'], that broadcast window location changes and is the only other channel that can be bound to user events</li>
17
+ * <li>LINK['SpyneChannelWindow', 'spyne-channel-window'], that broadcast all requested window and document events, such as scrolling, resizing and media queries</li>
18
+ * <li>LINK['SpyneChannelLifecycle', 'spyne-channel-lifecycle'], that broadcasts rendering and removing of ViewStream elements that have been directed to broadcast their lifecycle events</li>
19
+ * </ul>
20
+ *
21
+ *
22
+ * @module SpyneApp
23
+ * @type core
24
+ *
25
+ * @constructor
26
+ * @param {Object} config
27
+ * @property {Object} config - = {}; This global config object is mainly used to provide configuration details for two SpyneChannels, CHANNEL_ROUTE and CHANNEL_WINDOW.
28
+ */
29
+
30
+ constructor() {
31
+ this.version = version
32
+
33
+ //console.log('spyne app created')
34
+
35
+
36
+ }
37
+ get channels(){
38
+ return _channels;
39
+ }
40
+
41
+ init(config = {}, testMode=false) {
42
+ //this.channels = new ChannelsMap();
43
+ /*!
44
+ * Spyne 0.18.2
45
+ * https://spynejs.org
46
+ *
47
+ * @license Copyright 2017-2021, Frank Batista, Relevant Context, LLC. All rights reserved.
48
+ * Spyne is licensed under the GNU Lesser General Public License v3.0
49
+ *
50
+ * @author: Frank Batista,
51
+ * @email: frbatista.nyc@gmail.com
52
+ */
53
+ /* eslint-disable */
54
+
55
+
56
+ if(SpyneAppProperties.initialized === true){
57
+ if (testMode){
58
+ return 'The Spyne Application has already been initialized!';
59
+ } else {
60
+ console.warn('The Spyne Application has already been initialized!');
61
+ }
62
+ return
63
+ }
64
+
65
+
66
+ let defaultConfig = {
67
+ scrollLock: false,
68
+ scrollLockX: 31,
69
+ scrollLockY: 0,
70
+ debug: true,
71
+ plugins:{
72
+
73
+ },
74
+ tmp: {},
75
+ channels: {
76
+ WINDOW: {
77
+ mediqQueries: {
78
+
79
+ },
80
+ events: [],
81
+ listenForResize: true,
82
+ listenForOrientation: true,
83
+ listenForScroll: false,
84
+ listenForMouseWheel: false,
85
+ debounceMSTimeForResize: 200,
86
+ debounceMSTimeForScroll: 150
87
+ },
88
+
89
+ ROUTE: {
90
+ type: 'slash',
91
+ isHash: false,
92
+ isHidden: false,
93
+ add404s: false,
94
+ routes: {
95
+ 'routePath' : {
96
+ 'routeName' : 'change'
97
+ }
98
+ }
99
+
100
+ }
101
+ }
102
+ };
103
+ if (config !== undefined) {
104
+ config = SpyneAppProperties.initialize(defaultConfig, config, _channels);
105
+ window.Spyne = this;
106
+ window.Spyne['config'] = deepMerge(defaultConfig, config)
107
+ }
108
+
109
+ this.pluginsFn = SpyneAppProperties.getPluginsMethodObj(config['pluginMethods']);
110
+ this.getChannelActions = (str) => _channels.getChannelActions(str);
111
+ this.registerChannel = (val) => _channels.registerStream(val);
112
+ this.registerDataChannel = (obs$) => _channels.registerStream(obs$);
113
+ this.listChannels = () => Array.from(_channels.map.keys());
114
+ let nullHolder = new ViewStream({ id:'spyne-null-views' });
115
+ nullHolder.appendToDom(document.body);
116
+ nullHolder.props.el.style.cssText = 'display:none; opacity:0; pointer-events:none;';
117
+ _channels.init();
118
+
119
+ if (SpyneAppProperties.config.debug===true){
120
+ //window.Spyne = {version};
121
+ }
122
+
123
+
124
+ }
125
+
126
+ /**
127
+ * This is mostly used for debugging purposes
128
+ *
129
+ * @example
130
+ * TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
131
+ * SpyneApp.listChannels();
132
+ *
133
+ * @returns A list of all registered channels
134
+ */
135
+ static listChannels() {
136
+ return Array.from(_channels.map.keys());
137
+ }
138
+
139
+ /**
140
+ * This method is useful to check in the console or in the code what actions are available to be listened to.
141
+ * @param {String} str
142
+ * @returns {Array} An array of Actions that can be listened to
143
+ */
144
+ static getChannelActions(str) {
145
+ return _channels.getChannelActions(str);
146
+ }
147
+
148
+ /**
149
+ *
150
+ * This method will add the channel to the registered list so that it can subscribed by all ViewStream and Channel instances.
151
+ * @param {Channel} c
152
+ *
153
+ *
154
+ */
155
+ static registerChannel(c) {
156
+ if (SpyneAppProperties.initialized === false) {
157
+ console.warn('Spyne has not been initialized');
158
+ } else {
159
+ return _channels.registerStream(c);
160
+ }
161
+ }
162
+ }
163
+
164
+
165
+ export let SpyneApp = new SpyneApplication();