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.
- package/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +76 -86
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.umd.js +9565 -0
- package/package.json +46 -26
- package/rollup.config.js +26 -0
- package/src/spyne/channels/channel-fetch-class.js +39 -43
- package/src/spyne/channels/channel-payload-class.js +61 -74
- package/src/spyne/channels/channel-proxy.js +25 -26
- package/src/spyne/channels/channel.js +141 -149
- package/src/spyne/channels/channels-config.js +46 -47
- package/src/spyne/channels/channels-map.js +61 -65
- package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
- package/src/spyne/channels/spyne-channel-route.js +241 -250
- package/src/spyne/channels/spyne-channel-ui.js +213 -75
- package/src/spyne/channels/spyne-channel-window.js +157 -157
- package/src/spyne/spyne-app.js +32 -19
- package/src/spyne/spyne-plugins.js +55 -70
- package/src/spyne/spyne.js +23 -23
- package/src/spyne/utils/channel-config-validator.js +10 -10
- package/src/spyne/utils/channel-fetch-util.js +72 -55
- package/src/spyne/utils/channel-payload-filter.js +89 -100
- package/src/spyne/utils/deep-merge.js +31 -29
- package/src/spyne/utils/frp-tools.js +108 -92
- package/src/spyne/utils/gc.js +6 -6
- package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
- package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
- package/src/spyne/utils/route-channel-updater.js +23 -29
- package/src/spyne/utils/safe-clone.js +40 -58
- package/src/spyne/utils/sanitize-html.js +35 -0
- package/src/spyne/utils/security-policy.js +11 -0
- package/src/spyne/utils/spyne-app-properties.js +110 -114
- package/src/spyne/utils/spyne-logger.js +4 -11
- package/src/spyne/utils/spyne-plugins-methods.js +38 -63
- package/src/spyne/utils/spyne-trait.js +33 -33
- package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
- package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
- package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
- package/src/spyne/utils/viewstream-animations.js +12 -12
- package/src/spyne/utils/viewstream-observables.js +45 -45
- package/src/spyne/views/dom-element-template.js +111 -114
- package/src/spyne/views/dom-element.js +82 -84
- package/src/spyne/views/view-stream-broadcaster.js +66 -62
- package/src/spyne/views/view-stream-element.js +105 -106
- package/src/spyne/views/view-stream-payload.js +25 -27
- package/src/spyne/views/view-stream-selector.js +157 -163
- package/src/spyne/views/view-stream.js +416 -640
- package/src/tests/channels/channel-dom.test.js +15 -15
- package/src/tests/channels/channel-fetch.test.js +51 -62
- package/src/tests/channels/channel-payload-class.test.js +50 -63
- package/src/tests/channels/channel-payload-filter.test.js +133 -193
- package/src/tests/channels/channel-route.test.js +102 -112
- package/src/tests/channels/channel-stream-item.test.js +19 -19
- package/src/tests/channels/channel-ui.test.js +15 -27
- package/src/tests/channels/channel-util-dom.test.js +31 -31
- package/src/tests/channels/channel.test.js +20 -25
- package/src/tests/channels/route-utils.test.js +61 -66
- package/src/tests/channels/url-utils.test.js +151 -151
- package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
- package/src/tests/import.test.js +5 -5
- package/src/tests/index.js +6 -7
- package/src/tests/index.test.js +6 -8
- package/src/tests/mocks/channel-payload-data.js +218 -220
- package/src/tests/mocks/enhancer.test.js +5 -5
- package/src/tests/mocks/payload-ui.js +87 -90
- package/src/tests/mocks/routes-data.js +264 -266
- package/src/tests/mocks/spyne-docs.mocks.js +3 -3
- package/src/tests/mocks/template-renderer.mocks.js +47 -47
- package/src/tests/mocks/utils-data.js +78 -79
- package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
- package/src/tests/mocks/window-events-arr.js +1 -1
- package/src/tests/package-json.spec.test.js +9 -0
- package/src/tests/spyne-app.test.js +15 -18
- package/src/tests/spyne-plugin.test.js +16 -20
- package/src/tests/utils/channel-action-filter.test.js +84 -86
- package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
- package/src/tests/utils/channel-fetch-util.test.js +64 -66
- package/src/tests/utils/frp-tools.test.js +19 -19
- package/src/tests/utils/plugins-methods.test.js +31 -55
- package/src/tests/utils/security.test.js +10 -0
- package/src/tests/utils/spyne-app-properties.test.js +4 -8
- package/src/tests/views/dom-el-selectors.test.js +112 -119
- package/src/tests/views/dom-el-template-proxy.test.js +7 -0
- package/src/tests/views/dom-el-template.test.js +186 -156
- package/src/tests/views/dom-el.test.js +58 -56
- package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
- package/src/tests/views/view-stream-enhancer.test.js +11 -11
- package/src/tests/views/view-stream.test.js +22 -33
- package/webpack.config.js +76 -67
- package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
- package/docs/DomItem.html +0 -298
- package/docs/DomItem_DomItem.html +0 -314
- package/docs/ViewStream.html +0 -2249
- package/docs/ViewStream_ViewStream.html +0 -503
- package/docs/custom/css/jsdoc-viewstream.css +0 -377
- package/docs/custom/layout.tmpl +0 -47
- package/docs/dom-item.js.html +0 -213
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -548
- package/docs/index-custom.html +0 -79
- package/docs/index.html +0 -82
- package/docs/jsdoc.config.json +0 -22
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs/view-stream.js.html +0 -767
|
@@ -1,97 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
import { allPass, compose, is, keys, not, prop } from 'ramda'
|
|
2
2
|
|
|
3
|
-
_pluginMethodsObj
|
|
3
|
+
const _pluginMethodsObj = Object.create({})
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
let warnStr;
|
|
32
|
+
const isObj = isObjectFn(methodsObj)
|
|
45
33
|
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
55
|
+
const malformedMethodsArr = reject(hasPrefix, methodsArr)
|
|
56
56
|
if (malformedMethodsArr.length >= 1) {
|
|
57
|
-
|
|
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
|
-
|
|
63
|
+
this.checkForMalformedMethods(methodsObj.allMethods)
|
|
64
|
+
const obj = {}
|
|
65
65
|
const bindMethodsToParentViewStream = (str, isStatic = false) => {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const constructorType = isStatic === true ? this.constructor : this
|
|
67
|
+
const propertyType = typeof (constructorType[str])
|
|
68
68
|
if (propertyType === 'function') {
|
|
69
|
-
|
|
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
|
-
|
|
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
|
}
|