spyne 0.19.1 → 0.20.1

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 (132) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +4 -3
  3. package/.travis.yml +24 -11
  4. package/karma.conf.js +77 -87
  5. package/lib/spyne.esm.js +15 -0
  6. package/lib/spyne.esm.js.map +1 -0
  7. package/lib/spyne.js +248 -248
  8. package/lib/spyne.umd.js +3 -0
  9. package/lib/spyne.umd.js.LICENSE.txt +16 -0
  10. package/package.json +48 -27
  11. package/rollup.config.js +26 -0
  12. package/src/spyne/channels/channel-fetch-class.js +39 -43
  13. package/src/spyne/channels/channel-payload-class.js +61 -74
  14. package/src/spyne/channels/channel-proxy.js +25 -26
  15. package/src/spyne/channels/channel.js +141 -149
  16. package/src/spyne/channels/channels-config.js +46 -47
  17. package/src/spyne/channels/channels-map.js +61 -65
  18. package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
  19. package/src/spyne/channels/spyne-channel-route.js +241 -250
  20. package/src/spyne/channels/spyne-channel-ui.js +213 -75
  21. package/src/spyne/channels/spyne-channel-window.js +157 -157
  22. package/src/spyne/spyne-app.js +32 -19
  23. package/src/spyne/spyne-plugins.js +55 -70
  24. package/src/spyne/spyne.js +23 -23
  25. package/src/spyne/utils/channel-config-validator.js +10 -10
  26. package/src/spyne/utils/channel-fetch-util.js +72 -55
  27. package/src/spyne/utils/channel-payload-filter.js +89 -100
  28. package/src/spyne/utils/deep-merge.js +31 -29
  29. package/src/spyne/utils/frp-tools.js +108 -92
  30. package/src/spyne/utils/gc.js +6 -6
  31. package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
  32. package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
  33. package/src/spyne/utils/route-channel-updater.js +23 -29
  34. package/src/spyne/utils/safe-clone.js +40 -58
  35. package/src/spyne/utils/sanitize-html.js +35 -0
  36. package/src/spyne/utils/security-policy.js +11 -0
  37. package/src/spyne/utils/spyne-app-properties.js +110 -114
  38. package/src/spyne/utils/spyne-logger.js +4 -11
  39. package/src/spyne/utils/spyne-plugins-methods.js +38 -63
  40. package/src/spyne/utils/spyne-trait.js +33 -33
  41. package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
  42. package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
  43. package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
  44. package/src/spyne/utils/viewstream-animations.js +12 -12
  45. package/src/spyne/utils/viewstream-observables.js +45 -45
  46. package/src/spyne/views/dom-element-template.js +111 -114
  47. package/src/spyne/views/dom-element.js +82 -84
  48. package/src/spyne/views/view-stream-broadcaster.js +66 -62
  49. package/src/spyne/views/view-stream-element.js +105 -106
  50. package/src/spyne/views/view-stream-payload.js +25 -27
  51. package/src/spyne/views/view-stream-selector.js +157 -163
  52. package/src/spyne/views/view-stream.js +416 -640
  53. package/src/tests/channels/channel-dom.test.js +15 -15
  54. package/src/tests/channels/channel-fetch.test.js +51 -62
  55. package/src/tests/channels/channel-payload-class.test.js +50 -63
  56. package/src/tests/channels/channel-payload-filter.test.js +133 -193
  57. package/src/tests/channels/channel-route.test.js +102 -112
  58. package/src/tests/channels/channel-stream-item.test.js +19 -19
  59. package/src/tests/channels/channel-ui.test.js +15 -27
  60. package/src/tests/channels/channel-util-dom.test.js +31 -31
  61. package/src/tests/channels/channel.test.js +20 -25
  62. package/src/tests/channels/route-utils.test.js +61 -66
  63. package/src/tests/channels/url-utils.test.js +151 -151
  64. package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
  65. package/src/tests/import.test.js +5 -5
  66. package/src/tests/index.js +6 -7
  67. package/src/tests/index.test.js +6 -8
  68. package/src/tests/mocks/channel-payload-data.js +218 -220
  69. package/src/tests/mocks/enhancer.test.js +5 -5
  70. package/src/tests/mocks/payload-ui.js +87 -90
  71. package/src/tests/mocks/routes-data.js +264 -266
  72. package/src/tests/mocks/spyne-docs.mocks.js +3 -3
  73. package/src/tests/mocks/template-renderer.mocks.js +47 -47
  74. package/src/tests/mocks/utils-data.js +78 -79
  75. package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
  76. package/src/tests/mocks/window-events-arr.js +1 -1
  77. package/src/tests/package-json.spec.test.js +9 -0
  78. package/src/tests/spyne-app.test.js +15 -18
  79. package/src/tests/spyne-plugin.test.js +16 -20
  80. package/src/tests/utils/channel-action-filter.test.js +84 -86
  81. package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
  82. package/src/tests/utils/channel-fetch-util.test.js +64 -66
  83. package/src/tests/utils/frp-tools.test.js +19 -19
  84. package/src/tests/utils/plugins-methods.test.js +31 -55
  85. package/src/tests/utils/security.test.js +10 -0
  86. package/src/tests/utils/spyne-app-properties.test.js +4 -8
  87. package/src/tests/views/dom-el-selectors.test.js +112 -119
  88. package/src/tests/views/dom-el-template-proxy.test.js +7 -0
  89. package/src/tests/views/dom-el-template.test.js +186 -156
  90. package/src/tests/views/dom-el.test.js +58 -56
  91. package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
  92. package/src/tests/views/view-stream-enhancer.test.js +11 -11
  93. package/src/tests/views/view-stream.test.js +22 -33
  94. package/webpack.config.js +76 -67
  95. package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
  96. package/docs/DomItem.html +0 -298
  97. package/docs/DomItem_DomItem.html +0 -314
  98. package/docs/ViewStream.html +0 -2249
  99. package/docs/ViewStream_ViewStream.html +0 -503
  100. package/docs/custom/css/jsdoc-viewstream.css +0 -377
  101. package/docs/custom/layout.tmpl +0 -47
  102. package/docs/dom-item.js.html +0 -213
  103. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  104. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  105. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  106. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  107. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  108. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  109. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  110. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  111. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  112. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  113. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  114. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  115. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  116. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  117. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  118. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  119. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  120. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  121. package/docs/global.html +0 -548
  122. package/docs/index-custom.html +0 -79
  123. package/docs/index.html +0 -82
  124. package/docs/jsdoc.config.json +0 -22
  125. package/docs/scripts/linenumber.js +0 -25
  126. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  127. package/docs/scripts/prettify/lang-css.js +0 -2
  128. package/docs/scripts/prettify/prettify.js +0 -28
  129. package/docs/styles/jsdoc-default.css +0 -358
  130. package/docs/styles/prettify-jsdoc.css +0 -111
  131. package/docs/styles/prettify-tomorrow.css +0 -132
  132. package/docs/view-stream.js.html +0 -767
@@ -1,9 +1,9 @@
1
- import { Channel } from './channel';
2
- import { SpyneUtilsChannelRouteUrl } from '../utils/spyne-utils-channel-route-url';
3
- import { SpyneUtilsChannelRoute } from '../utils/spyne-utils-channel-route';
4
- import {SpyneAppProperties} from '../utils/spyne-app-properties';
5
- import { ReplaySubject, merge } from 'rxjs';
6
- import { map } from 'rxjs/operators';
1
+ import { Channel } from './channel'
2
+ import { SpyneUtilsChannelRouteUrl } from '../utils/spyne-utils-channel-route-url'
3
+ import { SpyneUtilsChannelRoute } from '../utils/spyne-utils-channel-route'
4
+ import { SpyneAppProperties } from '../utils/spyne-app-properties'
5
+ import { ReplaySubject, merge } from 'rxjs'
6
+ import { map } from 'rxjs/operators'
7
7
 
8
8
  import {
9
9
  pick,
@@ -28,16 +28,16 @@ import {
28
28
  concat,
29
29
  when,
30
30
  complement,
31
- reverse,
31
+ reverse,
32
32
  curryN,
33
33
  __,
34
34
  test,
35
35
  replace,
36
36
  toPairs,
37
37
  reduce
38
- } from 'ramda';
39
- const ramdaFilter = require('ramda').filter;
40
- const rMerge = require('ramda').mergeRight;
38
+ , filter as ramdaFilter, mergeRight as rMerge
39
+ } from 'ramda'
40
+
41
41
  export class SpyneChannelRoute extends Channel {
42
42
  constructor(name = 'CHANNEL_ROUTE', props = {}) {
43
43
  /**
@@ -134,36 +134,35 @@ export class SpyneChannelRoute extends Channel {
134
134
  * @property {String} CHANNEL_NAME - = 'CHANNEL_ROUTE';
135
135
  *
136
136
  */
137
- props.sendCachedPayload = true;
138
- super('CHANNEL_ROUTE', props);
139
- this.createChannelActionsObj();
140
- this.routeConfigJson = this.getRouteConfig();
141
- this.bindStaticMethods();
142
- this.navToStream$ = new ReplaySubject(1);
143
- this.observer$ = this.navToStream$.pipe(map(info => this.onMapNext(info)));
144
- this.compareRouteKeywords = SpyneUtilsChannelRoute.compareRouteKeywords();
137
+ props.sendCachedPayload = true
138
+ super('CHANNEL_ROUTE', props)
139
+ this.createChannelActionsObj()
140
+ this.routeConfigJson = this.getRouteConfig()
141
+ this.bindStaticMethods()
142
+ this.navToStream$ = new ReplaySubject(1)
143
+ this.observer$ = this.navToStream$.pipe(map(info => this.onMapNext(info)))
144
+ this.compareRouteKeywords = SpyneUtilsChannelRoute.compareRouteKeywords()
145
145
  }
146
146
 
147
- checkConfigForHash(){
147
+ checkConfigForHash() {
148
148
  // LEGACY CHECK TO SIMPLIFY CONFIG FOR HASH;
149
- let isHashType = SpyneAppProperties.config.channels.ROUTE.type==='hash';
150
- if (isHashType === true){
151
- SpyneAppProperties.config.channels.ROUTE.type = 'slash';
152
- SpyneAppProperties.config.channels.ROUTE.isHash = true;
149
+ const isHashType = SpyneAppProperties.config.channels.ROUTE.type === 'hash'
150
+ if (isHashType === true) {
151
+ SpyneAppProperties.config.channels.ROUTE.type = 'slash'
152
+ SpyneAppProperties.config.channels.ROUTE.isHash = true
153
153
  }
154
-
155
154
  }
156
155
 
157
156
  onRegistered() {
158
- this.checkConfigForHash();
159
- this.initStream();
157
+ this.checkConfigForHash()
158
+ this.initStream()
160
159
  }
161
160
 
162
161
  createChannelActionsObj() {
163
- let arr = this.addRegisteredActions();
164
- const converter = str => objOf(str, str);
165
- let obj = mergeAll(chain(converter, arr));
166
- this.channelActions = obj;
162
+ const arr = this.addRegisteredActions()
163
+ const converter = str => objOf(str, str)
164
+ const obj = mergeAll(chain(converter, arr))
165
+ this.channelActions = obj
167
166
  }
168
167
 
169
168
  addRegisteredActions() {
@@ -172,255 +171,247 @@ export class SpyneChannelRoute extends Channel {
172
171
  'CHANNEL_ROUTE_CHANGE_EVENT',
173
172
  'CHANNEL_ROUTE_CONFIG_UPDATED_EVENT',
174
173
  ['CHANNEL_ROUTE_UPDATE_CONFIG_EVENT', 'updateRouteConfig']
175
- ];
174
+ ]
176
175
  }
177
176
 
178
- updateRouteConfig(e){
179
-
180
- const newRoutesObj = pick(['isHash', 'isHidden', 'routes','type'], e.payload);
181
-
182
- SpyneAppProperties.config.channels.ROUTE = mergeRight(SpyneAppProperties.config.channels.ROUTE, newRoutesObj);
177
+ updateRouteConfig(e) {
178
+ const newRoutesObj = pick(['isHash', 'isHidden', 'routes', 'type'], e.payload)
183
179
 
180
+ SpyneAppProperties.config.channels.ROUTE = mergeRight(SpyneAppProperties.config.channels.ROUTE, newRoutesObj)
184
181
 
185
- SpyneAppProperties.conformRouteConfig();
182
+ SpyneAppProperties.conformRouteConfig()
186
183
 
184
+ const routeConfig = this.getRouteConfig()
185
+ const action = 'CHANNEL_ROUTE_CONFIG_UPDATED_EVENT'
187
186
 
188
- const routeConfig = this.getRouteConfig();
189
- const action = 'CHANNEL_ROUTE_CONFIG_UPDATED_EVENT';
187
+ this.routeConfigJson = routeConfig
188
+ this.bindStaticMethodsWithConfigData()
190
189
 
191
- this.routeConfigJson = routeConfig;
192
- this.bindStaticMethodsWithConfigData();
193
-
194
-
195
- this.sendChannelPayload(action, routeConfig, {}, {}, this.navToStream$);
190
+ this.sendChannelPayload(action, routeConfig, {}, {}, this.navToStream$)
196
191
  }
197
192
 
198
193
  getRouteConfig() {
199
- const spyneConfig = SpyneAppProperties.config;
200
- let routeConfig = path(['channels', 'ROUTE'], spyneConfig);
194
+ const spyneConfig = SpyneAppProperties.config
195
+ const routeConfig = path(['channels', 'ROUTE'], spyneConfig)
201
196
  if (routeConfig.type === 'query') {
202
- routeConfig.isHash = false;
197
+ routeConfig.isHash = false
203
198
  }
204
199
 
205
- let arr = SpyneUtilsChannelRoute.flattenConfigObject(routeConfig.routes);
206
- routeConfig['paramsArr'] = arr;
207
- return routeConfig;
200
+ const arr = SpyneUtilsChannelRoute.flattenConfigObject(routeConfig.routes)
201
+ routeConfig.paramsArr = arr
202
+ return routeConfig
208
203
  }
209
204
 
210
205
  initStream() {
211
- this.firstLoadStream$ = new ReplaySubject(1);
212
- this.onIncomingDomEvent(undefined, this.routeConfigJson, '' + 'CHANNEL_ROUTE_DEEPLINK_EVENT');
206
+ this.firstLoadStream$ = new ReplaySubject(1)
207
+ this.onIncomingDomEvent(undefined, this.routeConfigJson, '' + 'CHANNEL_ROUTE_DEEPLINK_EVENT')
213
208
 
214
- SpyneUtilsChannelRoute.createPopStateStream(this.onIncomingDomEvent.bind(this));
209
+ SpyneUtilsChannelRoute.createPopStateStream(this.onIncomingDomEvent.bind(this))
215
210
 
216
211
  this.observer$ = merge(this.firstLoadStream$,
217
- this.navToStream$);
212
+ this.navToStream$)
218
213
  }
219
214
 
220
215
  onMapNext(data, firstLoaded = false) {
221
- data['action'] = 'CHANNEL_ROUTE_CHANGE_EVENT';
222
- return data;
216
+ data.action = 'CHANNEL_ROUTE_CHANGE_EVENT'
217
+ return data
223
218
  }
224
219
 
225
- static removeSSID(payload){
226
- const routeLens = lensProp(['routeData']);
227
- const omitSSID = over(routeLens, omit(['vsid']));
228
- return omitSSID(payload);;
220
+ static removeSSID(payload) {
221
+ const routeLens = lensProp(['routeData'])
222
+ const omitSSID = over(routeLens, omit(['vsid']))
223
+ return omitSSID(payload)
229
224
  }
230
225
 
231
226
  static onIncomingDomEvent(evt, config = this.routeConfigJson, actn) {
232
- let action = actn !== undefined
227
+ const action = actn !== undefined
233
228
  ? actn
234
- : this.channelActions.CHANNEL_ROUTE_CHANGE_EVENT;
229
+ : this.channelActions.CHANNEL_ROUTE_CHANGE_EVENT
235
230
 
236
231
  // CHECK IF THIS IS A HISTORY EVENT BY USING THE routeCount PROPERTY
237
- let eventCount = path(['state', 'routeCount'], evt);
238
- let isHistoryCount = is(Number, eventCount) === true;
239
- let payload = this.getDataFromString(config, isHistoryCount);
240
- if (isHistoryCount===true){
241
- payload.routeCount = eventCount;
242
- }
243
- // ===============================================================
244
-
245
- let keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths);
246
- payload = rMerge(payload, keywordArrs);
247
- this.sendChannelPayload(action, payload, undefined, evt, this.navToStream$);
248
-
232
+ const eventCount = path(['state', 'routeCount'], evt)
233
+ const isHistoryCount = is(Number, eventCount) === true
234
+ let payload = this.getDataFromString(config, isHistoryCount)
235
+ if (isHistoryCount === true) {
236
+ payload.routeCount = eventCount
237
+ }
238
+ // ===============================================================
239
+ if (actn === 'CHANNEL_ROUTE_DEEPLINK_EVENT') {
240
+ payload.linksData = prop('routeDatasetsArr', config)
241
+ }
242
+ const keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths)
243
+ payload = rMerge(payload, keywordArrs)
244
+ this.sendChannelPayload(action, payload, undefined, evt, this.navToStream$)
249
245
  }
250
246
 
251
247
  static checkForRouteParamsOverrides(payload) {
252
- return payload;
248
+ return payload
253
249
  }
254
250
 
255
- static checkForEventMethods(obs){
256
- const re = /^(event)([A-Z].*)([A-Z].*)$/gm;
257
- const getMethods = compose(ramdaFilter(test(re)), keys, prop('payload'));
258
- const methodsArr = getMethods(obs);
259
- if (methodsArr.length>=1) {
260
- const evt = prop('event', obs);
251
+ static checkForEventMethods(obs) {
252
+ const re = /^(event)([A-Z].*)([A-Z].*)$/gm
253
+ const getMethods = compose(ramdaFilter(test(re)), keys, prop('payload'))
254
+ const methodsArr = getMethods(obs)
255
+ if (methodsArr.length >= 1) {
256
+ const evt = prop('event', obs)
261
257
  if (evt !== undefined) {
262
- const methodUpdate = (match,p1,p2,p3,p4)=>String(p2).toLowerCase()+p3+p4;
263
- const methodStrReplace = replace(/^(event)([A-Z])(.*)([A-Z].*)$/gm, methodUpdate);
264
- const runMethod = (methodStr)=>{
265
- const m = methodStrReplace(methodStr);
266
- if (evt[m]!==undefined) {evt[m]();}
267
- };
258
+ const methodUpdate = (match, p1, p2, p3, p4) => String(p2).toLowerCase() + p3 + p4
259
+ const methodStrReplace = replace(/^(event)([A-Z])(.*)([A-Z].*)$/gm, methodUpdate)
260
+ const runMethod = (methodStr) => {
261
+ const m = methodStrReplace(methodStr)
262
+ if (evt[m] !== undefined) { evt[m]() }
263
+ }
268
264
  methodsArr.forEach(runMethod)
269
265
  }
270
266
  }
271
267
 
272
- return obs;
268
+ return obs
273
269
  }
274
270
 
271
+ static checkForEndRoute(pl, routeConfigJson = this.routeConfigJson, debugBool) {
272
+ const endRoute = compose(equals('true'), path(['payload', 'endRoute']))(pl)
275
273
 
276
- static checkForEndRoute(pl, routeConfigJson = this.routeConfigJson, debugBool){
277
-
278
- const endRoute = compose(equals("true"), path(['payload', 'endRoute']))(pl);
279
-
280
- if (endRoute!==true){
281
- return pl;
274
+ if (endRoute !== true) {
275
+ return pl
282
276
  }
283
- const debug = debugBool !== undefined ? debugBool : SpyneAppProperties.debug === true;
284
- const {payload} = pl;
285
-
286
-
287
- const getPropVal = (routePath) => {
288
- const routeName = prop('routeName', routePath);
289
- if (routeName){
290
- const keysArr = compose(keys, omit(['routeName']))(routePath);
291
- let routeNameVal = payload[routeName]
292
- const pred = arrStr => new RegExp(`^${arrStr}$`).test(routeNameVal);
293
- const routeVal = find(pred, keysArr);
294
- return routeVal;
295
-
296
- }
277
+ const debug = debugBool !== undefined ? debugBool : SpyneAppProperties.debug === true
278
+ const { payload } = pl
279
+
280
+ const getPropVal = (routePath) => {
281
+ const routeName = prop('routeName', routePath)
282
+ if (routeName) {
283
+ const keysArr = compose(keys, omit(['routeName']))(routePath)
284
+ const routeNameVal = payload[routeName]
285
+ const pred = arrStr => new RegExp(`^${arrStr}$`).test(routeNameVal)
286
+ const routeVal = find(pred, keysArr)
287
+ return routeVal
297
288
  }
289
+ }
298
290
 
299
- let iter = 0;
300
- const onReduceRoutePaths = (acc=[], arr)=>{
301
- const [key, val] = arr;
302
- const {routePath} = val;
303
- const routeName = prop('routeName', routePath);
304
- const routeNameVal = getPropVal(routePath);
305
- const isObj = is(Object, val);
306
- const isArr = is(Array, val);
307
- const iterObj = isObj === true && isArr === false;
308
- iter = iter+1;
309
- if (iterObj) {
310
- const nextRoutePath = routePath[routeNameVal];
311
- //console.log('key is ',{iter,acc,key, routeName, routeNameVal, iterObj, nextRoutePath});
312
- if (nextRoutePath){
313
- compose(reverse, reduce(onReduceRoutePaths, acc), toPairs)({nextRoutePath})
314
- } else{
315
- //console.log("KEY IS ",{iter,key, routeName, routeNameVal})
316
- if (iter===1){
317
- if (debug) {
318
- console.warn(`Spyne Warning: use of end route method should add start route value of "${routeName}".`)
319
- }
320
- } else {
321
- acc.push(routeName)
291
+ let iter = 0
292
+ const onReduceRoutePaths = (acc = [], arr) => {
293
+ // const [key, val] = arr
294
+ const val = arr[1]
295
+ const { routePath } = val
296
+ const routeName = prop('routeName', routePath)
297
+ const routeNameVal = getPropVal(routePath)
298
+ const isObj = is(Object, val)
299
+ const isArr = is(Array, val)
300
+ const iterObj = isObj === true && isArr === false
301
+ iter = iter + 1
302
+ if (iterObj) {
303
+ const nextRoutePath = routePath[routeNameVal]
304
+ // console.log('key is ',{iter,acc,key, routeName, routeNameVal, iterObj, nextRoutePath});
305
+ if (nextRoutePath) {
306
+ compose(reverse, reduce(onReduceRoutePaths, acc), toPairs)({ nextRoutePath })
307
+ } else {
308
+ // console.log("KEY IS ",{iter,key, routeName, routeNameVal})
309
+ if (iter === 1) {
310
+ if (debug) {
311
+ console.warn(`Spyne Warning: use of end route method should add start route value of "${routeName}".`)
322
312
  }
313
+ } else {
314
+ acc.push(routeName)
323
315
  }
324
316
  }
325
- return acc;
326
-
327
317
  }
318
+ return acc
319
+ }
328
320
 
329
- const {routes} = routeConfigJson;
330
-
331
- const endRouteValArr = compose(reverse, reduce(onReduceRoutePaths, []), toPairs)({routes});
332
- //console.log('end route val arr ',endRouteValArr);
333
- if(endRouteValArr.length===1){
334
- const endRouteVal = endRouteValArr[0];
335
- pl.payload[endRouteVal] = "";
336
- } else{
337
- if (debug) {
338
- // console.warn(`Spyne Warning: the end route param did not yield any results for ${JSON.stringify(payload)} `);
339
- }
340
- }
321
+ const { routes } = routeConfigJson
341
322
 
342
- return pl;
323
+ const endRouteValArr = compose(reverse, reduce(onReduceRoutePaths, []), toPairs)({ routes })
324
+ // console.log('end route val arr ',endRouteValArr);
325
+ if (endRouteValArr.length === 1) {
326
+ const endRouteVal = endRouteValArr[0]
327
+ pl.payload[endRouteVal] = ''
328
+ } else {
329
+ if (debug) {
330
+ // console.warn(`Spyne Warning: the end route param did not yield any results for ${JSON.stringify(payload)} `);
331
+ }
332
+ }
343
333
 
334
+ return pl
344
335
  }
345
336
 
346
337
  onViewStreamInfo(pl) {
347
- let action = this.channelActions.CHANNEL_ROUTE_CHANGE_EVENT;
348
- SpyneChannelRoute.checkForEventMethods(pl);
349
- pl = this.checkForEndRoute(pl);
350
- let payload = this.getDataFromParams(pl);
338
+ const action = this.channelActions.CHANNEL_ROUTE_CHANGE_EVENT
339
+ SpyneChannelRoute.checkForEventMethods(pl)
340
+ pl = this.checkForEndRoute(pl)
341
+ let payload = this.getDataFromParams(pl)
351
342
 
352
- let srcElement = prop('srcElement', pl);
353
- let event = prop('event', pl);
354
- let changeLocationBool = !payload.isHidden;
355
- let keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths);
343
+ const srcElement = prop('srcElement', pl)
344
+ const event = prop('event', pl)
345
+ const changeLocationBool = !payload.isHidden
346
+ const keywordArrs = this.compareRouteKeywords.compare(payload.routeData, payload.paths)
356
347
 
357
- payload = rMerge(payload, keywordArrs);
358
- this.sendRouteStream(payload, changeLocationBool);
348
+ payload = rMerge(payload, keywordArrs)
349
+ this.sendRouteStream(payload, changeLocationBool)
359
350
 
360
- payload = SpyneChannelRoute.removeSSID(payload);
351
+ payload = SpyneChannelRoute.removeSSID(payload)
361
352
 
362
353
  this.sendChannelPayload(action, payload, srcElement, event,
363
- this.navToStream$);
354
+ this.navToStream$)
364
355
  }
365
356
 
366
357
  static checkAndConvertStrWithRegexTokens(routeValue, regexTokenObj) {
367
- let tokenKeysArr = keys(regexTokenObj);
358
+ const tokenKeysArr = keys(regexTokenObj)
368
359
 
369
- return tokenKeysArr;
360
+ return tokenKeysArr
370
361
  }
371
362
 
372
363
  sendRouteStream(payload, changeWindowLoc = true) {
373
364
  if (changeWindowLoc === true) {
374
- this.setWindowLocation(payload);
365
+ this.setWindowLocation(payload)
375
366
  }
376
367
  }
377
368
 
378
369
  static getRouteState() {
379
- return 'CHANNEL_ROUTE_CHANGE_EVENT';
370
+ return 'CHANNEL_ROUTE_CHANGE_EVENT'
380
371
  }
381
372
 
382
373
  static getIsDeepLinkBool(isHistory) {
383
- return isHistory === false && this._routeCount === 0;
374
+ return isHistory === false && this._routeCount === 0
384
375
  }
385
376
 
386
- static getRouteCount(isHistory=false) {
377
+ static getRouteCount(isHistory = false) {
387
378
  if (this._routeCount === undefined) {
388
- this._routeCount = 0;
389
- return this._routeCount;
379
+ this._routeCount = 0
380
+ return this._routeCount
390
381
  }
391
- if (isHistory===false) {
392
- this._routeCount += 1;
382
+ if (isHistory === false) {
383
+ this._routeCount += 1
393
384
  }
394
- return this._routeCount;
385
+ return this._routeCount
395
386
  }
396
387
 
397
- static getExtraPayloadParams(config = this.routeConfigJson, isHistory=false) {
398
- let routeCount = this.getRouteCount(isHistory);
399
- let isDeepLink = this.getIsDeepLinkBool(isHistory);
400
- let isHash = config.isHash;
401
- let isHidden = config.isHidden;
402
- let routeType = config.type;
403
- return { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType };
388
+ static getExtraPayloadParams(config = this.routeConfigJson, isHistory = false) {
389
+ const routeCount = this.getRouteCount(isHistory)
390
+ const isDeepLink = this.getIsDeepLinkBool(isHistory)
391
+ const isHash = config.isHash
392
+ const isHidden = config.isHidden
393
+ const routeType = config.type
394
+ return { routeCount, isDeepLink, isHash, isHistory, isHidden, routeType }
404
395
  }
405
396
 
406
397
  static getDataFromParams(pl, config = this.routeConfigJson) {
407
- let routeData = prop('payload', pl);
398
+ let routeData = prop('payload', pl)
408
399
 
409
- let routeValue = this.getRouteStrFromParams(routeData, config);
400
+ const routeValue = this.getRouteStrFromParams(routeData, config)
410
401
 
411
402
  // WINDOW LOCATION HASN'T BEEN CHANGED YET, SO WILL GET STR PARAMS
412
- const getPropFromConfig = (prp, defalt) => defaultTo(defalt, prop(prp, config));
413
- let typeForStr = getPropFromConfig('type', 'slash');
414
- let isHashForStr = getPropFromConfig('isHash', false);
415
- let nextWindowLoc = SpyneUtilsChannelRouteUrl.formatStrAsWindowLocation(routeValue);
416
- let dataFromStr = this.getDataFromLocationStr(typeForStr, isHashForStr, nextWindowLoc);
403
+ const getPropFromConfig = (prp, defalt) => defaultTo(defalt, prop(prp, config))
404
+ const typeForStr = getPropFromConfig('type', 'slash')
405
+ const isHashForStr = getPropFromConfig('isHash', false)
406
+ const nextWindowLoc = SpyneUtilsChannelRouteUrl.formatStrAsWindowLocation(routeValue)
407
+ const dataFromStr = this.getDataFromLocationStr(typeForStr, isHashForStr, nextWindowLoc)
417
408
 
418
- let { pathInnermost, paths } = dataFromStr;
409
+ const { pathInnermost, paths } = dataFromStr
419
410
 
420
- routeData = rMerge(dataFromStr.routeData, routeData);
411
+ routeData = rMerge(dataFromStr.routeData, routeData)
421
412
 
422
- let { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType } = this.getExtraPayloadParams(
423
- config);
413
+ const { routeCount, isDeepLink, isHash, isHistory, isHidden, routeType } = this.getExtraPayloadParams(
414
+ config)
424
415
  return {
425
416
  isDeepLink,
426
417
  routeCount,
@@ -432,19 +423,19 @@ export class SpyneChannelRoute extends Channel {
432
423
  isHidden,
433
424
  isHistory,
434
425
  routeType
435
- };
426
+ }
436
427
  }
437
428
 
438
- static getDataFromString(config = this.routeConfigJson, isHistory=false) {
439
- const type = config.type;
440
- const hashIsTrue = config.isHash === true;
441
- const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, hashIsTrue);
442
- let { paths, pathInnermost, routeData, routeValue } = SpyneChannelRoute.getParamsFromRouteStr(
443
- str, config, type);
444
- let { routeCount, isDeepLink, isHash, routeType, isHidden } = this.getExtraPayloadParams(
445
- config,isHistory);
429
+ static getDataFromString(config = this.routeConfigJson, isHistory = false) {
430
+ const type = config.type
431
+ const hashIsTrue = config.isHash === true
432
+ const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, hashIsTrue)
433
+ const { paths, pathInnermost, routeData, routeValue } = SpyneChannelRoute.getParamsFromRouteStr(
434
+ str, config, type)
435
+ const { routeCount, isDeepLink, isHash, routeType, isHidden } = this.getExtraPayloadParams(
436
+ config, isHistory)
446
437
 
447
- let obj = {
438
+ const obj = {
448
439
  isDeepLink,
449
440
  routeCount,
450
441
  pathInnermost,
@@ -455,20 +446,20 @@ export class SpyneChannelRoute extends Channel {
455
446
  isHidden,
456
447
  isHistory,
457
448
  routeType
458
- };
459
- return obj;
449
+ }
450
+ return obj
460
451
  }
461
452
 
462
453
  static getDataFromLocationStr(t = 'slash', isHash = this.routeConfigJson.isHash, loc = window.location) {
463
454
  const type = this.routeConfigJson !== undefined
464
455
  ? this.routeConfigJson.type
465
- : t;
456
+ : t
466
457
 
467
- const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, isHash, loc);
468
- let { paths, pathInnermost, routeData, routeValue } = this.getParamsFromRouteStr(
469
- str, this.routeConfigJson, type);
470
- const action = this.getRouteState();
471
- return { paths, pathInnermost, routeData, routeValue, action };
458
+ const str = SpyneUtilsChannelRouteUrl.getLocationStrByType(type, isHash, loc)
459
+ const { paths, pathInnermost, routeData, routeValue } = this.getParamsFromRouteStr(
460
+ str, this.routeConfigJson, type)
461
+ const action = this.getRouteState()
462
+ return { paths, pathInnermost, routeData, routeValue, action }
472
463
  }
473
464
 
474
465
  static getLocationData() {
@@ -481,79 +472,79 @@ export class SpyneChannelRoute extends Channel {
481
472
  'port',
482
473
  'pathname',
483
474
  'search',
484
- 'hash'];
485
- return pickAll(locationParamsArr, window.location);
475
+ 'hash']
476
+ return pickAll(locationParamsArr, window.location)
486
477
  }
487
478
 
488
479
  static getRouteStrFromParams(paramsData, routeConfig, t) {
489
- const type = t !== undefined ? t : routeConfig.type;
490
- let obj = SpyneUtilsChannelRouteUrl.convertParamsToRoute(paramsData, routeConfig, type);
491
- return obj;
480
+ const type = t !== undefined ? t : routeConfig.type
481
+ const obj = SpyneUtilsChannelRouteUrl.convertParamsToRoute(paramsData, routeConfig, type)
482
+ return obj
492
483
  }
493
484
 
494
485
  static getParamsFromRouteStr(str, routeConfig, t) {
495
- const type = t !== undefined ? t : routeConfig.type;
496
- let obj = SpyneUtilsChannelRouteUrl.convertRouteToParams(str, routeConfig, type);
497
- return obj;
486
+ const type = t !== undefined ? t : routeConfig.type
487
+ const obj = SpyneUtilsChannelRouteUrl.convertRouteToParams(str, routeConfig, type)
488
+ return obj
498
489
  }
499
490
 
500
491
  checkEmptyRouteStr(str, isHash = false) {
501
- const isEmptyBool = isEmpty(str);
502
- const pathNameIsEmptyBool = isEmptyBool === true && isHash === false;
503
- const hashNameIsEmptyBool = isEmptyBool === true && isHash === true;
504
- const hashNameBool = isEmptyBool === false && isHash === true;
492
+ const isEmptyBool = isEmpty(str)
493
+ const pathNameIsEmptyBool = isEmptyBool === true && isHash === false
494
+ const hashNameIsEmptyBool = isEmptyBool === true && isHash === true
495
+ const hashNameBool = isEmptyBool === false && isHash === true
505
496
 
506
497
  if (pathNameIsEmptyBool === true || hashNameIsEmptyBool === true) {
507
- return '/';
498
+ return '/'
508
499
  } else if (hashNameBool === true) {
509
- return concat('#', str);
500
+ return concat('#', str)
510
501
  }
511
- return str;
502
+ return str
512
503
  }
504
+
513
505
  static removeLastSlash(str) {
514
- let re = /^(.*)(\/)$/;
515
- return str.replace(re, '$1');
506
+ const re = /^(.*)(\/)$/
507
+ return str.replace(re, '$1')
516
508
  }
517
509
 
518
510
  setWindowLocation(channelPayload) {
519
- let { isHash, routeValue } = channelPayload;
520
- routeValue = this.checkEmptyRouteStr(routeValue, isHash);
521
- let {routeCount} = channelPayload;
522
- if (isHash === true) {
523
- let pathName = SpyneChannelRoute.removeLastSlash(window.location.pathname);
524
- routeValue = pathName + routeValue;
525
- window.history.pushState({routeCount}, '', routeValue);
511
+ let { isHash, routeValue, routeType } = channelPayload
512
+ routeValue = this.checkEmptyRouteStr(routeValue, isHash)
513
+ const { routeCount } = channelPayload
514
+ if (isHash === true || routeType === 'query') {
515
+ const pathName = SpyneChannelRoute.removeLastSlash(window.location.pathname)
516
+ routeValue = pathName + routeValue
517
+ window.history.pushState({ routeCount }, '', routeValue)
526
518
  } else {
527
519
  const checkForSlash = when(
528
- compose(complement(equals('/')), head), concat('/', __));
529
- window.history.pushState({routeCount}, '', checkForSlash(routeValue));
520
+ compose(complement(equals('/')), head), concat('/', __))
521
+ window.history.pushState({ routeCount }, '', checkForSlash(routeValue))
530
522
  }
531
523
  }
532
524
 
533
525
  getWindowLocation() {
534
- return window.location.pathname; // pullHashAndSlashFromPath(window.location.hash);
526
+ return window.location.pathname // pullHashAndSlashFromPath(window.location.hash);
535
527
  }
536
528
 
537
529
  bindStaticMethods() {
538
- this.checkForEndRoute = SpyneChannelRoute.checkForEndRoute.bind(this);
539
- this.getIsDeepLinkBool = SpyneChannelRoute.getIsDeepLinkBool.bind(this);
530
+ this.checkForEndRoute = SpyneChannelRoute.checkForEndRoute.bind(this)
531
+ this.getIsDeepLinkBool = SpyneChannelRoute.getIsDeepLinkBool.bind(this)
540
532
  this.getDataFromLocationStr = SpyneChannelRoute.getDataFromLocationStr.bind(
541
- this);
542
- this.onIncomingDomEvent = SpyneChannelRoute.onIncomingDomEvent.bind(this);
543
- this.getDataFromString = SpyneChannelRoute.getDataFromString.bind(this);
544
- this.getParamsFromRouteStr = SpyneChannelRoute.getParamsFromRouteStr.bind(this);
545
- this.getLocationData = SpyneChannelRoute.getLocationData.bind(this);
546
- this.getRouteState = SpyneChannelRoute.getRouteState.bind(this);
547
- this.getDataFromParams = SpyneChannelRoute.getDataFromParams.bind(this);
548
- this.getRouteCount = SpyneChannelRoute.getRouteCount.bind(this);
549
- this.getExtraPayloadParams = SpyneChannelRoute.getExtraPayloadParams.bind(this);
550
- this.bindStaticMethodsWithConfigData();
551
- }
552
-
553
- bindStaticMethodsWithConfigData(){
554
- const curriedGetRoute = curryN(3, SpyneChannelRoute.getRouteStrFromParams);
533
+ this)
534
+ this.onIncomingDomEvent = SpyneChannelRoute.onIncomingDomEvent.bind(this)
535
+ this.getDataFromString = SpyneChannelRoute.getDataFromString.bind(this)
536
+ this.getParamsFromRouteStr = SpyneChannelRoute.getParamsFromRouteStr.bind(this)
537
+ this.getLocationData = SpyneChannelRoute.getLocationData.bind(this)
538
+ this.getRouteState = SpyneChannelRoute.getRouteState.bind(this)
539
+ this.getDataFromParams = SpyneChannelRoute.getDataFromParams.bind(this)
540
+ this.getRouteCount = SpyneChannelRoute.getRouteCount.bind(this)
541
+ this.getExtraPayloadParams = SpyneChannelRoute.getExtraPayloadParams.bind(this)
542
+ this.bindStaticMethodsWithConfigData()
543
+ }
544
+
545
+ bindStaticMethodsWithConfigData() {
546
+ const curriedGetRoute = curryN(3, SpyneChannelRoute.getRouteStrFromParams)
555
547
  this.getRouteStrFromParams = curriedGetRoute(__, this.routeConfigJson,
556
- this.routeConfigJson.type);
548
+ this.routeConfigJson.type)
557
549
  }
558
-
559
550
  }