spyne 0.16.0 → 0.18.0

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 (81) hide show
  1. package/.travis.yml +2 -2
  2. package/karma.conf.js +18 -69
  3. package/lib/spyne.js +29752 -28672
  4. package/lib/spyne.min.js +1 -1
  5. package/lib/spyne.min.js.LICENSE.txt +9 -9
  6. package/package.json +21 -42
  7. package/src/spyne/channels/channel-fetch-class.js +25 -5
  8. package/src/spyne/channels/channel-payload-class.js +36 -23
  9. package/src/spyne/channels/channel-proxy.js +7 -5
  10. package/src/spyne/channels/channel.js +54 -28
  11. package/src/spyne/channels/channels-config.js +2 -4
  12. package/src/spyne/channels/{channels-delegator.js → channels-map.js} +25 -41
  13. package/src/spyne/channels/spyne-channel-lifecycle.js +1 -2
  14. package/src/spyne/channels/spyne-channel-route.js +21 -62
  15. package/src/spyne/channels/spyne-channel-ui.js +1 -2
  16. package/src/spyne/channels/spyne-channel-window.js +24 -35
  17. package/src/spyne/spyne-app.js +163 -0
  18. package/src/spyne/spyne-plugins.js +43 -40
  19. package/src/spyne/spyne.js +6 -157
  20. package/src/spyne/utils/channel-config-validator.js +0 -1
  21. package/src/spyne/utils/channel-fetch-util.js +1 -2
  22. package/src/spyne/utils/channel-payload-filter.js +9 -76
  23. package/src/spyne/utils/frp-tools.js +21 -1
  24. package/src/spyne/utils/gc.js +1 -1
  25. package/src/spyne/utils/route-channel-updater.js +0 -4
  26. package/src/spyne/utils/spyne-app-properties.js +183 -0
  27. package/src/spyne/utils/spyne-logger.js +18 -0
  28. package/src/spyne/utils/spyne-plugins-methods.js +97 -0
  29. package/src/spyne/utils/spyne-trait.js +2 -5
  30. package/src/spyne/utils/spyne-utils-channel-route-url.js +3 -8
  31. package/src/spyne/utils/spyne-utils-channel-route.js +6 -14
  32. package/src/spyne/utils/spyne-utils-channel-window.js +1 -3
  33. package/src/spyne/utils/viewstream-observables.js +2 -3
  34. package/src/spyne/views/dom-element-template.js +2 -7
  35. package/src/spyne/views/dom-element.js +0 -19
  36. package/src/spyne/views/view-stream-broadcaster.js +5 -10
  37. package/src/spyne/views/view-stream-element.js +1 -18
  38. package/src/spyne/views/view-stream-payload.js +31 -37
  39. package/src/spyne/views/view-stream-selector.js +3 -8
  40. package/src/spyne/views/view-stream.js +281 -297
  41. package/src/tests/channels/channel-fetch.test.js +102 -0
  42. package/src/tests/channels/channel-payload-class.test.js +14 -5
  43. package/src/tests/channels/channel-payload-filter.test.js +3 -28
  44. package/src/tests/channels/channel.test.js +38 -0
  45. package/src/tests/index.js +0 -1
  46. package/src/tests/index.test.js +6 -0
  47. package/src/tests/spyne-app.test.js +27 -0
  48. package/src/tests/spyne-plugin.test.js +13 -9
  49. package/src/tests/utils/plugins-methods.test.js +103 -0
  50. package/src/tests/utils/spyne-app-properties.test.js +11 -0
  51. package/webpack.config.js +19 -34
  52. package/lib/channel-action-filter.test.3516417154.js +0 -20
  53. package/lib/channel-dom.test.104366832.js +0 -20
  54. package/lib/channel-fetch-util.test.3506167575.js +0 -20
  55. package/lib/channel-payload-class.test.1081032524.js +0 -20
  56. package/lib/channel-payload-filter.test.977308429.js +0 -20
  57. package/lib/channel-route.test.3513636042.js +0 -20
  58. package/lib/channel-stream-item.test.119388071.js +0 -20
  59. package/lib/channel-ui.test.3778619579.js +0 -20
  60. package/lib/channel-util-dom.test.908537750.js +0 -20
  61. package/lib/commons.js +0 -49268
  62. package/lib/dom-el-selectors.test.1268485916.js +0 -20
  63. package/lib/dom-el-template.test.842696987.js +0 -20
  64. package/lib/dom-el.test.2045076905.js +0 -20
  65. package/lib/frp-tools.test.2503042868.js +0 -20
  66. package/lib/import.test.2658619365.js +0 -20
  67. package/lib/index.test.2372977745.js +0 -20
  68. package/lib/route-utils.test.273346057.js +0 -20
  69. package/lib/runtime.js +0 -172
  70. package/lib/spyne-plugin.test.301647328.js +0 -20
  71. package/lib/spyne.js.map +0 -1
  72. package/lib/url-utils.test.1931189114.js +0 -20
  73. package/lib/view-stream-broadcaster.test.1306675435.js +0 -20
  74. package/lib/view-stream-enhancer-loader.test.3617829096.js +0 -20
  75. package/lib/view-stream-enhancer.test.1053738169.js +0 -20
  76. package/lib/view-stream.test.573231784.js +0 -20
  77. package/src/spyne/channels/lifestream-payload.js +0 -56
  78. package/src/spyne/utils/channel-data-packet-generator.js +0 -200
  79. package/src/spyne/utils/channel-data-packet.js +0 -59
  80. package/src/spyne/utils/viewstream-dom-utils.js +0 -51
  81. package/src/spyne/views/view-stream-enhancer-loader.js +0 -70
@@ -0,0 +1,183 @@
1
+ import {SpyneUtilsChannelRoute} from './spyne-utils-channel-route';
2
+ import {SpynePluginsMethods} from './spyne-plugins-methods';
3
+ import {deepMerge} from './deep-merge';
4
+ import {path} from 'ramda';
5
+
6
+ let _config;
7
+ let _channels;
8
+ let _channelsMap
9
+ let _initialized = false;
10
+ let _debug = true;
11
+
12
+ const _spynePluginMethods = new SpynePluginsMethods();
13
+
14
+
15
+ class SpyneAppPropertiesClass{
16
+
17
+ constructor() {
18
+
19
+
20
+ }
21
+
22
+ get channelsMap(){
23
+ return _channelsMap;
24
+ }
25
+
26
+ get initialized(){
27
+ return _initialized;
28
+ }
29
+
30
+ get config(){
31
+ return _config;
32
+ }
33
+
34
+ get debug(){
35
+ return _debug;
36
+ }
37
+
38
+ /**
39
+ * This is mostly used for debugging purposes
40
+ *
41
+ * @example
42
+ * TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
43
+ * SpyneApp.listChannels();
44
+ *
45
+ * @returns A list of all registered channels
46
+ */
47
+ static listChannels() {
48
+ return Array.from(_channels.map.keys());
49
+ }
50
+
51
+ initialize(defaultConfig={}, config={}, channelsMap){
52
+ _channels = channelsMap;
53
+ let userConfig = config;
54
+ if (config.channels && config.channels.ROUTE) {
55
+ userConfig = SpyneUtilsChannelRoute.conformRouteObject(config);
56
+ }
57
+ _config = deepMerge(defaultConfig, userConfig);
58
+ _debug = _config.debug!== undefined ? _config.debug : _debug;
59
+ this.getChannelActions = _channels.getChannelActions.bind(_channels);
60
+ this.listRegisteredChannels = _channels.listRegisteredChannels.bind(_channels);
61
+ _initialized = true;
62
+ this.setChannelsMap();
63
+
64
+
65
+ return _config;
66
+
67
+ }
68
+
69
+ conformRouteConfig(add404Props=false){
70
+ /**
71
+ * THIS METHOD IS PRIMARILY USED FOR SPA GEN SITE GENERATION
72
+ */
73
+
74
+ _config = SpyneUtilsChannelRoute.conformRouteObject(_config, add404Props);
75
+
76
+ }
77
+
78
+ setChannelsMap(){
79
+ const getStream = _channels.getStream.bind(_channels);
80
+ const testStream = _channels.testStream.bind(_channels);
81
+ const getProxySubject = _channels.getProxySubject.bind(_channels);
82
+
83
+ _channelsMap = {getStream, testStream, getProxySubject}
84
+
85
+ }
86
+
87
+ setProp(key, val){
88
+ _config.tmp[key]=val;
89
+ }
90
+
91
+ getProp(key){
92
+ return path(['tmp', key], _config);
93
+ }
94
+
95
+ setChannelConfig(channelName, config){
96
+ _config.channels[channelName] = config;
97
+ return _config.channels[channelName];
98
+ }
99
+
100
+ /**
101
+ * This method is useful to check in the console or in the code what actions are available to be listened to.
102
+ * @param {String} channelName
103
+ * @returns {Array} An array of Actions that can be listened to
104
+ */
105
+ /* getChannelActions(channelName) {
106
+ return _channels.getChannelActions(channelName);
107
+ }*/
108
+
109
+ getChannelConfig(channelName, config=_config){
110
+ if (channelName === 'CHANNEL_ROUTE'){
111
+ channelName = "ROUTE";
112
+ } else if (channelName === 'CHANNEL_WINDOW'){
113
+ channelName = "WINDOW";
114
+ }
115
+
116
+ if (config === undefined || _config.channels === undefined){
117
+ console.warn('Spyne warning: Spyne config object is empty!')
118
+ return;
119
+ }
120
+
121
+ const channelConfig = _config.channels[channelName];
122
+
123
+ if (channelConfig === undefined){
124
+ console.warn(`Spyne warning: Spyne configuration for channel, ${channelName} is empty!`)
125
+ return;
126
+ }
127
+
128
+ return channelConfig;
129
+ }
130
+
131
+ registerChannel(){
132
+
133
+
134
+ }
135
+
136
+ addPluginConfig(pluginName, pluginConfig={}){
137
+ if (_config['plugins']===undefined){
138
+ _config['plugins'] = {};
139
+ }
140
+ this.addPluginMethods(pluginConfig['pluginMethods'])
141
+
142
+ _config.plugins[pluginName]=pluginConfig;
143
+
144
+ }
145
+
146
+ getPluginsMethodObj(pluginMethodsObj){
147
+ if(pluginMethodsObj){
148
+ this.addPluginMethods(pluginMethodsObj);
149
+ }
150
+
151
+ return _spynePluginMethods.pluginMethodsObj;
152
+ }
153
+
154
+ addPluginMethods(pluginMethods){
155
+
156
+ if (pluginMethods){
157
+
158
+ _spynePluginMethods.addMethods(pluginMethods);
159
+
160
+ }
161
+
162
+
163
+ }
164
+
165
+ getPluginConfigByPluginName(pluginName){
166
+ return _config.plugins[pluginName];
167
+ }
168
+
169
+ tempGetChannelsInstance(){
170
+
171
+ }
172
+
173
+ tempGetConfig(){
174
+
175
+
176
+ }
177
+
178
+
179
+
180
+
181
+ }
182
+
183
+ export let SpyneAppProperties = new SpyneAppPropertiesClass();
@@ -0,0 +1,18 @@
1
+ class SpyneLoggerClass{
2
+
3
+ constructor(props) {
4
+
5
+ this._warnings = [];
6
+ }
7
+
8
+ static warn(){
9
+
10
+
11
+
12
+ }
13
+
14
+
15
+
16
+ }
17
+
18
+ export let SpyneLogger = new SpyneLoggerClass();
@@ -0,0 +1,97 @@
1
+ const _pluginMethodsObj = Object.create({});
2
+
3
+ _pluginMethodsObj['foo'] = ()=>console.log("used for testing purposes.");
4
+
5
+ import {allPass, compose, is, isEmpty, keys, not, prop} from 'ramda';
6
+
7
+
8
+ const isNotArr = compose(not, is(Array));
9
+ const isNotEmpty = compose(not, isEmpty);
10
+ const isNonEmptyStr = allPass([is(String), isNotEmpty]);
11
+ const isNonEmptyArr = allPass([is(Array), isNotEmpty]);
12
+ const isObjectFn = compose(allPass([isNotArr, is(Object)]))
13
+ const isNonEmptyObjectFn = compose(allPass([isNotEmpty, isNotArr, is(Object)]))
14
+
15
+
16
+ export class SpynePluginsMethods{
17
+
18
+
19
+ constructor(){
20
+
21
+
22
+
23
+ }
24
+
25
+
26
+
27
+ addMethod(key, fn, test=false){
28
+
29
+ if (Object.prototype.hasOwnProperty.call(_pluginMethodsObj, key)===true){
30
+ const warnStr = `Spyne Warning: the method name, ${key}, already exists.`;
31
+ if (test){
32
+ return warnStr;
33
+ }
34
+ console.warn(warnStr);
35
+ } else {
36
+ _pluginMethodsObj[key] = fn;
37
+ }
38
+
39
+ }
40
+
41
+
42
+ addMethods(methodsObj={}, test=false){
43
+
44
+ let warnStr;
45
+
46
+ const isObj = isObjectFn(methodsObj);
47
+
48
+ if (isObj === false){
49
+ warnStr = `Spyne Warning: the pluginMethods property, ${JSON.stringify(methodsObj)} needs to be an object.`
50
+ if (test){
51
+ return warnStr;
52
+ }
53
+ console.warn(warnStr);
54
+ return;
55
+
56
+ }
57
+
58
+ const checkEachKeyForValidMethod = (keyStr) => {
59
+ const methodVal = prop(keyStr, methodsObj);
60
+
61
+ const isFunction = typeof(methodVal) === 'function';
62
+
63
+
64
+ if (isFunction){
65
+ this.addMethod(keyStr, methodVal, test);
66
+ } else{
67
+ warnStr = `the value for ${keyStr} is not a valid function.`
68
+ if (test){
69
+ return warnStr;
70
+ } else {
71
+ console.warn(warnStr);
72
+ }
73
+ }
74
+
75
+ }
76
+
77
+ const methodKeys = keys(methodsObj);
78
+
79
+ return methodKeys.map(checkEachKeyForValidMethod).join(',');
80
+
81
+ }
82
+
83
+ checkIfMethodExists(key){
84
+
85
+ }
86
+
87
+
88
+ get pluginMethodsObj(){
89
+ return _pluginMethodsObj;
90
+ }
91
+
92
+
93
+
94
+
95
+
96
+
97
+ }
@@ -1,5 +1,5 @@
1
1
  import { getAllMethodNames } from './frp-tools';
2
- import {reject, test, curryN, __, map} from 'ramda';
2
+ import {reject, curryN, __, map} from 'ramda';
3
3
 
4
4
  export class SpyneTrait {
5
5
  /**
@@ -63,13 +63,10 @@ export class SpyneTrait {
63
63
  this.checkForMalformedMethods(methodsObj.allMethods);
64
64
  let obj = {};
65
65
  const bindMethodsToParentViewStream = (str, isStatic = false) => {
66
- const addMethod = s => {
67
- return context[s] = constructorType[s].bind(context);
68
- };
69
66
  let constructorType = isStatic === true ? this.constructor : this;
70
67
  let propertyType = typeof (constructorType[str]);
71
68
  if (propertyType === 'function') {
72
- obj[str] = addMethod(str);
69
+ obj[str] = context[str] = constructorType[str].bind(context);
73
70
  }
74
71
  };
75
72
 
@@ -1,4 +1,5 @@
1
1
  import {isEmpty, head, values, compose, prop, complement, isNil, allPass, reduce, filter, equals, toPairs, replace, either, propEq, __,invert,path,zipObj, reject, keys, find, assoc, is,has, when, split, always, concat, join, flatten, map, ifElse, test, findLastIndex,last, defaultTo,fromPairs } from 'ramda';
2
+ import {SpyneAppProperties} from './spyne-app-properties';
2
3
 
3
4
  export class SpyneUtilsChannelRouteUrl {
4
5
  constructor() {
@@ -61,7 +62,6 @@ export class SpyneUtilsChannelRouteUrl {
61
62
  let keyword = routeObj.routeName; // PARAM FORM SPYNE CONFIG
62
63
  let paramValFromData = data[keyword] !== undefined ? data[keyword] : prop(keyword, paramsFromLoc); // PULL VALUE FOR THIS PARAM FROM DATA
63
64
  const paramValType = typeof (routeObj[paramValFromData]);
64
- // console.log({routeObj, paramValType, paramValFromData, keyword})
65
65
 
66
66
  if (paramValType === 'string') {
67
67
  paramValFromData = routeObj[paramValFromData];
@@ -71,12 +71,9 @@ export class SpyneUtilsChannelRouteUrl {
71
71
 
72
72
  urlObj[keyword] = paramValFromData;
73
73
 
74
- // console.log("URL OBJ ",urlObj);
75
74
  if (this.checkIfObjIsNotEmptyOrNil(urlObj)) {
76
- // console.log("FOUND ",{paramValFromData, paramValType, urlObj, routeObj});
77
75
  urlArr.push(urlObj);
78
76
  } else {
79
- // console.log("NOT FOUND ",paramValFromData, paramValType, urlObj, routeObj);
80
77
 
81
78
  }
82
79
 
@@ -84,10 +81,8 @@ export class SpyneUtilsChannelRouteUrl {
84
81
  const objectParamExists = has(paramValFromData, routeObj);
85
82
  const objectContainsRoute = has('routePath', routeObj);
86
83
  const recursivelyCallLoopBool = objectParamExists && isObject;
87
- // console.log("CHECKS ", {isObject, objectParamExists, objectContainsRoute, recursivelyCallLoopBool})
88
84
  if (recursivelyCallLoopBool === true) {
89
85
  let newObj = routeObj[paramValFromData];
90
- // console.log("NEW OBJ ",{paramValFromData, routeObj, newObj});
91
86
  if (has('routePath', newObj)) {
92
87
  loopThroughParam(newObj.routePath);
93
88
  }
@@ -163,7 +158,7 @@ export class SpyneUtilsChannelRouteUrl {
163
158
  return map(mapUrlProps, urlsArr);
164
159
  }
165
160
 
166
- static convertParamsToRoute(data, r = window.Spyne.config.channels.ROUTE, t, locStr) {
161
+ static convertParamsToRoute(data, r = SpyneAppProperties.config.channels.ROUTE, t, locStr) {
167
162
  const urlType = t !== undefined ? t : r.type;
168
163
  const isHash = r.isHash;
169
164
  let route = r.routes.routePath;
@@ -239,7 +234,7 @@ export class SpyneUtilsChannelRouteUrl {
239
234
  let getParamInverted = compose(head, defaultTo([]), prop(param));
240
235
  let paramInverted = getParamInverted(invertedObj);
241
236
  // spyne 11.0.1;
242
- let re = /^([-\$\w]*)$/;
237
+ let re = /^([-$\w]*)$/;
243
238
  let keyMatch = re.test(paramInverted);
244
239
 
245
240
  if (keyMatch === true && is(String, paramInverted) === true) {
@@ -1,7 +1,6 @@
1
1
  import { fromEventPattern } from 'rxjs';
2
- import {last, mapObjIndexed, flatten, clone, pick, prop, propOr, pickAll, path, equals, compose, keys, filter, propEq, uniq, map, __, chain,is, includes, fromPairs, reject, mergeDeepRight, mergeRight, reverse, test, omit, reduceRight, nth, toPairs, values} from 'ramda';
2
+ import {last, flatten, clone, pick, prop, pickAll, path, equals, compose, keys, filter, propEq, uniq, map, __, chain,is, includes, fromPairs, reject, mergeDeepRight, mergeRight, test, toPairs, values} from 'ramda';
3
3
  import {SpyneUtilsChannelRouteUrl} from './spyne-utils-channel-route-url';
4
- import {RouteDataForTests} from '../../tests/mocks/utils-data';
5
4
 
6
5
  export class SpyneUtilsChannelRoute {
7
6
  constructor() {
@@ -102,7 +101,7 @@ export class SpyneUtilsChannelRoute {
102
101
  // create href and check to see if need to convert to hash href links
103
102
  const getHREF = (obj)=>{
104
103
  const santizeHREF = str => {
105
- const hrefRE = /^(.*\/)([\w\-]*\/?)(.*)$/gm
104
+ const hrefRE = /^(.*\/)([\w-]*\/?)(.*)$/gm
106
105
  //const hrefRE = /^(.*\/)([\w-]*)(.*)$/gm;
107
106
  str = str.replace(hrefRE, "$1$2");
108
107
  // str = String(str).replace('^$', "");
@@ -119,7 +118,7 @@ export class SpyneUtilsChannelRoute {
119
118
 
120
119
 
121
120
  // test whether to use key or val
122
- const isValidStrRE = /^([A-Za-z0-9_\-])+$/m;
121
+ const isValidStrRE = /^([A-Za-z0-9_-])+$/m;
123
122
 
124
123
  const createInitialValFn = (accMain=[], routePathObj, objAcc={})=>{
125
124
  let {routeName} = routePathObj;
@@ -129,7 +128,9 @@ export class SpyneUtilsChannelRoute {
129
128
  const [key, val] = arrPair;
130
129
  const isObject = is(Object, val);
131
130
 
132
- const getLinkText = str => test(isValidStrRE, str) ? String(str).toUpperCase() : key;
131
+ const createTitle = (str)=>String(str).replace(/([-_])/g, " ").toUpperCase();
132
+
133
+ const getLinkText = str => test(isValidStrRE, str) ? createTitle(str) : key;
133
134
 
134
135
  if (key === 'routeName' || key === '404'){
135
136
  return acc;
@@ -177,7 +178,6 @@ export class SpyneUtilsChannelRoute {
177
178
  return getMainKeys(datasetsArr);
178
179
  }
179
180
  const routeNamesArr = getNavProps(routeDatasetsArr);
180
- //console.log('validate route names arr is ',routeNamesArr);
181
181
 
182
182
  return {routeDatasetsArr, routeNamesArr};
183
183
  }
@@ -187,7 +187,6 @@ export class SpyneUtilsChannelRoute {
187
187
  const channelsRoutePath = path(['channels', 'ROUTE'], channelRouteObj);
188
188
  let {add404s} = channelsRoutePath !== undefined ? channelsRoutePath : channelRouteObj;
189
189
  add404s = add404s || add404Props;
190
- //console.log("add 404s is1 ",{add404s, channelsRoutePath})
191
190
  const parseRoutePath = (a) => {
192
191
  let val = a[1];
193
192
  const isArr = is(Array, val);
@@ -217,24 +216,17 @@ export class SpyneUtilsChannelRoute {
217
216
  }
218
217
 
219
218
  const configMapperFn = compose(fromPairs, map(transduceConfig), toPairs);
220
- //console.log('route obj ',channelRouteObj);
221
219
 
222
220
 
223
221
  if (channelsRoutePath !== undefined){
224
222
  channelRouteObj.channels.ROUTE = configMapperFn(channelRouteObj.channels.ROUTE)
225
223
  const extraRouteData = SpyneUtilsChannelRoute.addRouteDatasets(channelRouteObj.channels.ROUTE);
226
224
  channelRouteObj.channels.ROUTE = mergeRight(channelRouteObj.channels.ROUTE, extraRouteData);
227
- //console.log("CHANNEL ROUTE OBJ ",channelRouteObj.channels.ROUTE);
228
- //channelRouteObj.channels.ROUTE.linkDatasets = SpyneUtilsChannelRoute.addRouteDatasets(channelRouteObj.channels.ROUTE);
229
225
  return channelRouteObj;
230
226
  }
231
227
 
232
-
233
-
234
228
  return configMapperFn(channelRouteObj);
235
229
 
236
-
237
-
238
230
  }
239
231
 
240
232
  static getLocationData() {
@@ -66,7 +66,7 @@ export class SpyneUtilsChannelWindow {
66
66
  }
67
67
 
68
68
  static createMergedObsFromObj(config) {
69
- let mediaQueriesObj = config.mediqQueries;
69
+ let mediaQueriesObj = config.mediaQueries || config.mediqQueries;
70
70
  let arr = [];
71
71
 
72
72
  const loopQueries = (val, key, obj) => {
@@ -78,8 +78,6 @@ export class SpyneUtilsChannelWindow {
78
78
  };
79
79
 
80
80
  mapObjIndexed(loopQueries, mediaQueriesObj);
81
- // let obs$ = Observable.merge(...arr);
82
- // console.log('arr is ',arr);
83
81
  return arr;
84
82
  }
85
83
  }
@@ -65,12 +65,11 @@ export class ViewStreamObservable {
65
65
 
66
66
  const raw$ = obs$
67
67
  .pipe(filter((payload) => payload !== undefined && payload.action !== undefined));
68
- // .filter(p => p.$dir !== undefined)
69
- // .do(p => console.log('payload : ', p.$dir, p));
68
+
70
69
  const toInternal$ = obs$.pipe(filter(filterInternal), map(addInternalfrom$));
71
70
  const toParent$ = obs$.pipe(filter(filterParent), map(addParentfrom$));
72
71
  const toChild$ = obs$.pipe(filter(filterChild), map(addChildfrom$));
73
- // const upObs$ = obs$.do(p => console.log('UP: ', p));
72
+
74
73
  const streamObj = {
75
74
  parent: toParent$,
76
75
  internal: toInternal$,
@@ -1,5 +1,5 @@
1
- import {includes, __, ifElse, compose,path,split,prop, reject, is, defaultTo, isNil, isEmpty} from 'ramda';
2
- import {testDomTemplateForTableTags} from "../utils/viewstream-dom-utils";
1
+ import {includes, __, ifElse, path, prop, reject, is, isNil, isEmpty} from 'ramda';
2
+
3
3
  /**
4
4
  * @module DomElTemplate
5
5
  * @type util
@@ -136,9 +136,6 @@ export class DomElementTemplate {
136
136
  constructor(template, data) {
137
137
  this.template = this.formatTemplate(template);
138
138
 
139
- //const tempL = `template-${Math.floor(Math.random()*99999)}`
140
- // this.tempL=tempL
141
-
142
139
  const checkForArrayData = ()=>{
143
140
  if (is(Array, data) === true) {
144
141
  data = {spyneData:data};
@@ -206,8 +203,6 @@ export class DomElementTemplate {
206
203
 
207
204
 
208
205
  renderDocFrag() {
209
-
210
-
211
206
  const html = this.finalArr.join('');
212
207
  const isTableSubTag = /^([^>]*?)(<){1}(\b)(thead|col|colgroup|tbody|td|tfoot|tr|th)(\b)([^\0]*)$/.test(html);
213
208
  const el = isTableSubTag ? html : document.createRange().createContextualFragment(html);
@@ -1,12 +1,7 @@
1
- // import {createElement} from '../utils/dom-methods';
2
1
  import { baseCoreMixins } from '../utils/mixins/base-core-mixins';
3
2
  import { DomElementTemplate } from './dom-element-template';
4
3
  import { deepMerge } from '../utils/deep-merge';
5
- // import {DomElementTemplate} from './template-renderer';
6
-
7
4
  import {is, defaultTo, pick, mapObjIndexed, forEachObjIndexed, pipe} from 'ramda';
8
- //import {ViewStreamElement} from './view-stream-element';
9
- //import {getConstructorName} from '../utils/frp-tools';
10
5
 
11
6
  class DomElement {
12
7
  /**
@@ -31,35 +26,21 @@ class DomElement {
31
26
  */
32
27
 
33
28
  constructor(props={}) {
34
- //let isSimpleView = both(is(String), complement(isEmpty))(attributes);
35
- // if (isSimpleView === true) {
36
- // data = attributes;
37
- // attributes = {};
38
29
 
39
- // }
40
30
  const checkDefault = (dflt, val)=>defaultTo(dflt)(val);
41
31
 
42
32
  props.tagName = checkDefault('div', props.tagName);
43
33
 
44
-
45
34
  props.attributes = props.attributes!==undefined ? props.attributes : this.getDomAttributes(props);
46
35
  props.attrs = this.updateAttrs(props.attributes);
47
36
 
48
37
  props.fragment = document.createDocumentFragment()
49
38
  this.props = props;
50
39
 
51
- //this.setProp('tagName', tagName);
52
- //this.setProp('attrs', this.updateAttrs(attributes));
53
- //this.setProp('data', data);
54
- // this.setProp('template', template);
55
-
56
- // this.setProp('fragment', document.createDocumentFragment());
57
-
58
40
  this.addMixins();
59
41
  }
60
42
 
61
43
  setProp(key, val) {
62
- //this.props.set(key, val);
63
44
  this.props[key] = val;
64
45
  }
65
46
 
@@ -1,9 +1,9 @@
1
1
  import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins';
2
2
  import { convertDomStringMapToObj } from '../utils/frp-tools';
3
-
3
+ import {SpyneAppProperties} from '../utils/spyne-app-properties';
4
4
  import { fromEvent } from 'rxjs';
5
5
  import { map } from 'rxjs/operators';
6
- import {clone, omit, path} from 'ramda';
6
+ import {clone, omit} from 'ramda';
7
7
 
8
8
  export class ViewStreamBroadcaster {
9
9
  /**
@@ -47,9 +47,7 @@ export class ViewStreamBroadcaster {
47
47
  };
48
48
  // spread operator to select variables from arrays
49
49
  let [selector, event, local] = args;
50
- // console.log('args is ',args);
51
50
  // btn query
52
- // let query = this.props.el.querySelectorAll(selector);
53
51
  let channel; // hoist channel and later check if chnl exists
54
52
  let query = this.props.el.querySelectorAll(selector);
55
53
 
@@ -85,8 +83,6 @@ export class ViewStreamBroadcaster {
85
83
  data['channel'] = channel;
86
84
  // payload needs vsid# to pass verification
87
85
 
88
- // data['event'] = event;
89
- // data['el'] = q;
90
86
  data['srcElement'] = {};// pick(['vsid','viewName'], data);
91
87
  data.srcElement['id'] = this.props.id;
92
88
  data.srcElement['vsid'] = this.props.vsid;
@@ -99,11 +95,11 @@ export class ViewStreamBroadcaster {
99
95
  // run payload
100
96
  channelPayload(observable, data);
101
97
  };
102
- let isDevMode = path(['Spyne', 'config', 'debug'], window) === true;
98
+ let isDevMode = SpyneAppProperties.debug === true;
103
99
  let queryIsNil = query === undefined || query.length <= 0;
104
100
  if (queryIsNil === true && isDevMode === true) {
105
- console.warn(`Spyne Warning: The item ${selector}, does not appear to exist!`);
106
- // query = this.props.el;
101
+ console.warn(`Spyne Warning: The item ${selector}, does not appear to exist in ${this.props.name} --> vsid:${this.props.vsid}!`);
102
+
107
103
  // addObservable(query, event);
108
104
  } else {
109
105
  query.forEach = Array.prototype.forEach;
@@ -124,6 +120,5 @@ export class ViewStreamBroadcaster {
124
120
  let streamMixins = baseStreamsMixins();
125
121
  this.sendUIPayload = streamMixins.sendUIPayload;
126
122
  this.sendRoutePayload = streamMixins.sendRoutePayload;
127
- //this.createLifeStreamPayload = streamMixins.createLifeStreamPayload;
128
123
  }
129
124
  }
@@ -1,6 +1,4 @@
1
- //import { baseCoreMixins } from '../utils/mixins/base-core-mixins';
2
1
  import { DomElement } from './dom-element';
3
- //import { ifNilThenUpdate, convertDomStringMapToObj } from '../utils/frp-tools';
4
2
  import { fadein, fadeout } from '../utils/viewstream-animations';
5
3
  import { ViewStreamObservable } from '../utils/viewstream-observables';
6
4
  import { deepMerge } from '../utils/deep-merge';
@@ -108,7 +106,6 @@ export class ViewStreamElement {
108
106
 
109
107
  let fadeOutObs = bindCallback(animateOut);
110
108
  let onFadeoutCompleted = (e) => {
111
- // console.log('fade out completed ', e, d);
112
109
  this._source$.next(gcData);
113
110
  };
114
111
 
@@ -139,7 +136,6 @@ export class ViewStreamElement {
139
136
  }
140
137
 
141
138
  onGarbageCollect(p) {
142
- // console.log('MEDIATOR onGarbageCollect ', this.vsid, this.vsName, p);
143
139
  if (this.domItem!==undefined) {
144
140
  this.domItem.unmount();
145
141
  }
@@ -161,9 +157,7 @@ export class ViewStreamElement {
161
157
  let append = (node, item) => node.appendChild(item);
162
158
  // DETERMINE WHETHER TO USE APPEND OR PREPEND
163
159
  // ON CONNECTING DOM ITEMS TO EACH OTHER
164
- // this.domItemEl = this.domItem.render();
165
160
  let attachFunc = d.attachType === 'appendChild' ? append : prepend;
166
- // d.node = isNil(d.query) ? d.node : d.query;
167
161
  attachFunc(container, this.domItem.render());
168
162
  this.setAnimateIn(d);
169
163
  }
@@ -177,7 +171,6 @@ export class ViewStreamElement {
177
171
  onAttachChildToSelf(p) {
178
172
  let data = p.childRenderData;
179
173
  this.combineDomItems(data);
180
- //console.log("ATTACHING CHID TO SELF ===============")
181
174
  return {
182
175
  action: 'CHILD_ATTACHED',
183
176
  $dir: this.$dirs.PI
@@ -201,13 +194,8 @@ export class ViewStreamElement {
201
194
  }
202
195
 
203
196
  renderDomItem(d) {
204
- let tagName, attributes, data, template;
205
- [tagName,attributes,data,template]=d;
206
- //console.log("RENDER DOM EL ",{tagName, attributes, data,template,d});
207
-
208
- //this.domItem = new DomElement(...d);
197
+ const [tagName,attributes,data,template]=d;
209
198
  this.domItem = new DomElement({tagName,attributes,data,template});
210
-
211
199
  return this.domItem;
212
200
  }
213
201
 
@@ -232,7 +220,6 @@ export class ViewStreamElement {
232
220
  */
233
221
  onRenderAndAttachToDom(d) {
234
222
  let getEl = (data) => this.renderDomItem(data);
235
- // let getEl = (data) => new DomElement(...data);
236
223
  d.attachData['el'] = getEl(props(['tagName', 'domAttributes', 'data', 'template'], d));
237
224
  this.combineDomItems(d.attachData);
238
225
  return {
@@ -252,13 +239,9 @@ export class ViewStreamElement {
252
239
  let action = payload.action;
253
240
  let defaultToFn = defaultTo((data) => this.extendedMethods(data));
254
241
  let fn = defaultToFn(this.options.hashMethods[action]);
255
- // console.log('MEDIATOR onObsSinkSubscribe before ', this.vsid, action, payload);
256
242
  let data = fn(payload);
257
- // data = this.addDefaultDir(data);
258
- // console.log('add default dir ', data);
259
243
  let sendData = (d) => this._source$.next(d);
260
244
  if (data !== undefined) {
261
- // console.log('MEDIATOR onObsSinkSubscribe ', this.vsid, data, payload);
262
245
  sendData(Object.freeze(data));
263
246
  }
264
247
  }