spyne 0.19.0 → 0.20.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 (129) hide show
  1. package/.eslintrc.js +4 -3
  2. package/.travis.yml +24 -11
  3. package/karma.conf.js +76 -86
  4. package/lib/spyne.esm.js +15 -0
  5. package/lib/spyne.esm.js.map +1 -0
  6. package/lib/spyne.umd.js +9565 -0
  7. package/package.json +46 -26
  8. package/rollup.config.js +26 -0
  9. package/src/spyne/channels/channel-fetch-class.js +39 -43
  10. package/src/spyne/channels/channel-payload-class.js +61 -74
  11. package/src/spyne/channels/channel-proxy.js +25 -26
  12. package/src/spyne/channels/channel.js +141 -149
  13. package/src/spyne/channels/channels-config.js +46 -47
  14. package/src/spyne/channels/channels-map.js +61 -65
  15. package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
  16. package/src/spyne/channels/spyne-channel-route.js +241 -250
  17. package/src/spyne/channels/spyne-channel-ui.js +213 -75
  18. package/src/spyne/channels/spyne-channel-window.js +157 -157
  19. package/src/spyne/spyne-app.js +32 -19
  20. package/src/spyne/spyne-plugins.js +55 -70
  21. package/src/spyne/spyne.js +23 -23
  22. package/src/spyne/utils/channel-config-validator.js +10 -10
  23. package/src/spyne/utils/channel-fetch-util.js +72 -55
  24. package/src/spyne/utils/channel-payload-filter.js +89 -100
  25. package/src/spyne/utils/deep-merge.js +31 -29
  26. package/src/spyne/utils/frp-tools.js +108 -92
  27. package/src/spyne/utils/gc.js +6 -6
  28. package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
  29. package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
  30. package/src/spyne/utils/route-channel-updater.js +23 -29
  31. package/src/spyne/utils/safe-clone.js +40 -58
  32. package/src/spyne/utils/sanitize-html.js +35 -0
  33. package/src/spyne/utils/security-policy.js +11 -0
  34. package/src/spyne/utils/spyne-app-properties.js +110 -114
  35. package/src/spyne/utils/spyne-logger.js +4 -11
  36. package/src/spyne/utils/spyne-plugins-methods.js +38 -63
  37. package/src/spyne/utils/spyne-trait.js +33 -33
  38. package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
  39. package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
  40. package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
  41. package/src/spyne/utils/viewstream-animations.js +12 -12
  42. package/src/spyne/utils/viewstream-observables.js +45 -45
  43. package/src/spyne/views/dom-element-template.js +111 -114
  44. package/src/spyne/views/dom-element.js +82 -84
  45. package/src/spyne/views/view-stream-broadcaster.js +66 -62
  46. package/src/spyne/views/view-stream-element.js +105 -106
  47. package/src/spyne/views/view-stream-payload.js +25 -27
  48. package/src/spyne/views/view-stream-selector.js +157 -163
  49. package/src/spyne/views/view-stream.js +416 -640
  50. package/src/tests/channels/channel-dom.test.js +15 -15
  51. package/src/tests/channels/channel-fetch.test.js +51 -62
  52. package/src/tests/channels/channel-payload-class.test.js +50 -63
  53. package/src/tests/channels/channel-payload-filter.test.js +133 -193
  54. package/src/tests/channels/channel-route.test.js +102 -112
  55. package/src/tests/channels/channel-stream-item.test.js +19 -19
  56. package/src/tests/channels/channel-ui.test.js +15 -27
  57. package/src/tests/channels/channel-util-dom.test.js +31 -31
  58. package/src/tests/channels/channel.test.js +20 -25
  59. package/src/tests/channels/route-utils.test.js +61 -66
  60. package/src/tests/channels/url-utils.test.js +151 -151
  61. package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
  62. package/src/tests/import.test.js +5 -5
  63. package/src/tests/index.js +6 -7
  64. package/src/tests/index.test.js +6 -8
  65. package/src/tests/mocks/channel-payload-data.js +218 -220
  66. package/src/tests/mocks/enhancer.test.js +5 -5
  67. package/src/tests/mocks/payload-ui.js +87 -90
  68. package/src/tests/mocks/routes-data.js +264 -266
  69. package/src/tests/mocks/spyne-docs.mocks.js +3 -3
  70. package/src/tests/mocks/template-renderer.mocks.js +47 -47
  71. package/src/tests/mocks/utils-data.js +78 -79
  72. package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
  73. package/src/tests/mocks/window-events-arr.js +1 -1
  74. package/src/tests/package-json.spec.test.js +9 -0
  75. package/src/tests/spyne-app.test.js +15 -18
  76. package/src/tests/spyne-plugin.test.js +16 -20
  77. package/src/tests/utils/channel-action-filter.test.js +84 -86
  78. package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
  79. package/src/tests/utils/channel-fetch-util.test.js +64 -66
  80. package/src/tests/utils/frp-tools.test.js +19 -19
  81. package/src/tests/utils/plugins-methods.test.js +31 -55
  82. package/src/tests/utils/security.test.js +10 -0
  83. package/src/tests/utils/spyne-app-properties.test.js +4 -8
  84. package/src/tests/views/dom-el-selectors.test.js +112 -119
  85. package/src/tests/views/dom-el-template-proxy.test.js +7 -0
  86. package/src/tests/views/dom-el-template.test.js +186 -156
  87. package/src/tests/views/dom-el.test.js +58 -56
  88. package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
  89. package/src/tests/views/view-stream-enhancer.test.js +11 -11
  90. package/src/tests/views/view-stream.test.js +22 -33
  91. package/webpack.config.js +76 -67
  92. package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
  93. package/docs/DomItem.html +0 -298
  94. package/docs/DomItem_DomItem.html +0 -314
  95. package/docs/ViewStream.html +0 -2249
  96. package/docs/ViewStream_ViewStream.html +0 -503
  97. package/docs/custom/css/jsdoc-viewstream.css +0 -377
  98. package/docs/custom/layout.tmpl +0 -47
  99. package/docs/dom-item.js.html +0 -213
  100. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  101. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  102. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  103. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  104. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  105. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  106. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  107. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  108. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  109. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  110. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  111. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  112. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  113. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  114. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  115. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  116. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  117. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  118. package/docs/global.html +0 -548
  119. package/docs/index-custom.html +0 -79
  120. package/docs/index.html +0 -82
  121. package/docs/jsdoc.config.json +0 -22
  122. package/docs/scripts/linenumber.js +0 -25
  123. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  124. package/docs/scripts/prettify/lang-css.js +0 -2
  125. package/docs/scripts/prettify/prettify.js +0 -28
  126. package/docs/styles/jsdoc-default.css +0 -358
  127. package/docs/styles/prettify-jsdoc.css +0 -111
  128. package/docs/styles/prettify-tomorrow.css +0 -132
  129. package/docs/view-stream.js.html +0 -767
@@ -1,97 +1,72 @@
1
- const _pluginMethodsObj = Object.create({});
1
+ import { allPass, compose, is, keys, not, prop } from 'ramda'
2
2
 
3
- _pluginMethodsObj['foo'] = ()=>console.log("used for testing purposes.");
3
+ const _pluginMethodsObj = Object.create({})
4
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]);
5
+ const isNotArr = compose(not, is(Array))
6
+ // const isNotEmpty = compose(not, isEmpty)
7
+ // const isNonEmptyStr = allPass([is(String), isNotEmpty])
8
+ // const isNonEmptyArr = allPass([is(Array), isNotEmpty])
12
9
  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
-
10
+ // const isNonEmptyObjectFn = compose(allPass([isNotEmpty, isNotArr, is(Object)]))
22
11
 
12
+ export class SpynePluginsMethods {
13
+ constructor() {
14
+ _pluginMethodsObj.foo = () => console.log('used for testing purposes.')
23
15
  }
24
16
 
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;
17
+ addMethod(key, fn, test = false) {
18
+ if (Object.prototype.hasOwnProperty.call(_pluginMethodsObj, key) === true) {
19
+ const warnStr = `Spyne Warning: the method name, ${key}, already exists.`
20
+ if (test) {
21
+ return warnStr
33
22
  }
34
- console.warn(warnStr);
23
+ console.warn(warnStr)
35
24
  } else {
36
- _pluginMethodsObj[key] = fn;
25
+ _pluginMethodsObj[key] = fn
37
26
  }
38
-
39
27
  }
40
28
 
29
+ addMethods(methodsObj = {}, test = false) {
30
+ let warnStr
41
31
 
42
- addMethods(methodsObj={}, test=false){
43
-
44
- let warnStr;
32
+ const isObj = isObjectFn(methodsObj)
45
33
 
46
- const isObj = isObjectFn(methodsObj);
47
-
48
- if (isObj === false){
34
+ if (isObj === false) {
49
35
  warnStr = `Spyne Warning: the pluginMethods property, ${JSON.stringify(methodsObj)} needs to be an object.`
50
- if (test){
51
- return warnStr;
36
+ if (test) {
37
+ return warnStr
52
38
  }
53
- console.warn(warnStr);
54
- return;
55
-
39
+ console.warn(warnStr)
40
+ return
56
41
  }
57
42
 
58
43
  const checkEachKeyForValidMethod = (keyStr) => {
59
- const methodVal = prop(keyStr, methodsObj);
60
-
61
- const isFunction = typeof(methodVal) === 'function';
44
+ const methodVal = prop(keyStr, methodsObj)
62
45
 
46
+ const isFunction = typeof (methodVal) === 'function'
63
47
 
64
- if (isFunction){
65
- this.addMethod(keyStr, methodVal, test);
66
- } else{
48
+ if (isFunction) {
49
+ this.addMethod(keyStr, methodVal, test)
50
+ } else {
67
51
  warnStr = `the value for ${keyStr} is not a valid function.`
68
- if (test){
69
- return warnStr;
52
+ if (test) {
53
+ return warnStr
70
54
  } else {
71
- console.warn(warnStr);
55
+ console.warn(warnStr)
72
56
  }
73
57
  }
74
-
75
58
  }
76
59
 
77
- const methodKeys = keys(methodsObj);
78
-
79
- return methodKeys.map(checkEachKeyForValidMethod).join(',');
60
+ const methodKeys = keys(methodsObj)
80
61
 
62
+ return methodKeys.map(checkEachKeyForValidMethod).join(',')
81
63
  }
82
64
 
83
- checkIfMethodExists(key){
65
+ checkIfMethodExists(key) {
84
66
 
85
67
  }
86
68
 
87
-
88
- get pluginMethodsObj(){
89
- return _pluginMethodsObj;
69
+ get pluginMethodsObj() {
70
+ return _pluginMethodsObj
90
71
  }
91
-
92
-
93
-
94
-
95
-
96
-
97
72
  }
@@ -1,5 +1,5 @@
1
- import { getAllMethodNames } from './frp-tools';
2
- import {reject, curryN, __, map} from 'ramda';
1
+ import { getAllMethodNames } from './frp-tools'
2
+ import { reject, curryN, __, map } from 'ramda'
3
3
 
4
4
  export class SpyneTrait {
5
5
  /**
@@ -17,72 +17,72 @@ export class SpyneTrait {
17
17
  */
18
18
 
19
19
  constructor(parentContext, prefix = '', autoInit = true) {
20
- this.parentContext = parentContext;
20
+ this.parentContext = parentContext
21
21
  this.omittedMethods = [
22
22
  'autoBinder',
23
23
  'initAutoBinder',
24
24
  'getEnhancerMethods',
25
25
  'checkForMalformedMethods',
26
- 'caller',
27
- 'arguments',
28
- 'bindParentViewStream'];
26
+ 'caller',
27
+ 'arguments',
28
+ 'bindParentViewStream']
29
29
 
30
- this.prefix = prefix;
30
+ this.prefix = prefix
31
31
 
32
32
  if (autoInit === true) {
33
- this.autoBinder();
33
+ this.autoBinder()
34
34
  }
35
- return this.allMethodsList;
35
+ return this.allMethodsList
36
36
  }
37
37
 
38
38
  initAutoBinder() {
39
- this.autoBinder();
39
+ this.autoBinder()
40
40
  }
41
41
 
42
42
  getEnhancerMethods() {
43
- return getAllMethodNames(this, this.omittedMethods);
43
+ return getAllMethodNames(this, this.omittedMethods)
44
44
  }
45
45
 
46
46
  checkForMalformedMethods(methodsArr) {
47
47
  if (this.prefix === '') {
48
- console.warn(`SPYNE WARNING: The following SpyneTrait ${this.constructor.name} needs a prefix`);
49
- return;
48
+ console.warn(`SPYNE WARNING: The following SpyneTrait ${this.constructor.name} needs a prefix`)
49
+ return
50
50
  }
51
- //let reStr = `^(${this.prefix})(.*)$`;
52
- //let re = new RegExp(reStr);
53
- const hasPrefix = (str)=>str.indexOf(this.prefix)===0;
51
+ // let reStr = `^(${this.prefix})(.*)$`;
52
+ // let re = new RegExp(reStr);
53
+ const hasPrefix = (str) => str.indexOf(this.prefix) === 0
54
54
 
55
- let malformedMethodsArr = reject(hasPrefix, methodsArr);
55
+ const malformedMethodsArr = reject(hasPrefix, methodsArr)
56
56
  if (malformedMethodsArr.length >= 1) {
57
- let warningStr = `Spyne Warning: The following method(s) in ${this.constructor.name} require the prefix, "${this.prefix}": [${malformedMethodsArr.join(', ')}];`;
58
- console.warn(warningStr);
57
+ const warningStr = `Spyne Warning: The following method(s) in ${this.constructor.name} require the prefix, "${this.prefix}": [${malformedMethodsArr.join(', ')}];`
58
+ console.warn(warningStr)
59
59
  }
60
60
  }
61
61
 
62
62
  bindParentViewStream(methodsObj, context) {
63
- this.checkForMalformedMethods(methodsObj.allMethods);
64
- let obj = {};
63
+ this.checkForMalformedMethods(methodsObj.allMethods)
64
+ const obj = {}
65
65
  const bindMethodsToParentViewStream = (str, isStatic = false) => {
66
- let constructorType = isStatic === true ? this.constructor : this;
67
- let propertyType = typeof (constructorType[str]);
66
+ const constructorType = isStatic === true ? this.constructor : this
67
+ const propertyType = typeof (constructorType[str])
68
68
  if (propertyType === 'function') {
69
- obj[str] = context[str] = constructorType[str].bind(context);
69
+ obj[str] = context[str] = constructorType[str].bind(context)
70
70
  }
71
- };
71
+ }
72
72
 
73
- const bindCurry = curryN(2, bindMethodsToParentViewStream);
74
- const bindStaticMethodsToParentViewStream = bindCurry(__, true);
73
+ const bindCurry = curryN(2, bindMethodsToParentViewStream)
74
+ const bindStaticMethodsToParentViewStream = bindCurry(__, true)
75
75
  // MAP STATIC METHODS
76
- map(bindStaticMethodsToParentViewStream, methodsObj.staticMethods);
76
+ map(bindStaticMethodsToParentViewStream, methodsObj.staticMethods)
77
77
  // MAP MAIN METHODS
78
- map(bindMethodsToParentViewStream, methodsObj.methods);
79
- return obj;
78
+ map(bindMethodsToParentViewStream, methodsObj.methods)
79
+ return obj
80
80
  }
81
81
 
82
82
  autoBinder() {
83
- let allMethods = this.getEnhancerMethods();
83
+ const allMethods = this.getEnhancerMethods()
84
84
  // console.log('all ',allMethods);
85
- this.allMethodsList = this.bindParentViewStream(allMethods, this.parentContext);
86
- return this.allMethodsList;
85
+ this.allMethodsList = this.bindParentViewStream(allMethods, this.parentContext)
86
+ return this.allMethodsList
87
87
  }
88
88
  }