spyne 0.19.1 → 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 +47 -27
- 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,6 +1,6 @@
|
|
|
1
|
-
import { fromEventPattern } from 'rxjs'
|
|
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
|
-
import {SpyneUtilsChannelRouteUrl} from './spyne-utils-channel-route-url'
|
|
1
|
+
import { fromEventPattern } from 'rxjs'
|
|
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
|
+
import { SpyneUtilsChannelRouteUrl } from './spyne-utils-channel-route-url'
|
|
4
4
|
|
|
5
5
|
export class SpyneUtilsChannelRoute {
|
|
6
6
|
constructor() {
|
|
@@ -13,219 +13,209 @@ export class SpyneUtilsChannelRoute {
|
|
|
13
13
|
* Internal utility methods for the SpyneRouteChannel
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
this.createPopStateStream = SpyneUtilsChannelRoute.createPopStateStream.bind(this)
|
|
16
|
+
this.createPopStateStream = SpyneUtilsChannelRoute.createPopStateStream.bind(this)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
static createPopStateStream(subscribeFn) {
|
|
20
|
-
|
|
21
|
-
window.onpopstate = handler
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
window.onpopstate = function() {}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
popupObs$.subscribe(subscribeFn)
|
|
20
|
+
const addHandler = function(handler) {
|
|
21
|
+
window.onpopstate = handler
|
|
22
|
+
}
|
|
23
|
+
const removeHandler = function() {
|
|
24
|
+
window.onpopstate = function() {}
|
|
25
|
+
}
|
|
26
|
+
const popupObs$ = fromEventPattern(addHandler, removeHandler)
|
|
27
|
+
|
|
28
|
+
popupObs$.subscribe(subscribeFn)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static getLastArrVal(arr) {
|
|
32
|
-
const getLastParam = (a) => last(a) !== undefined ? last(a) : ''
|
|
33
|
-
return getLastParam(arr)
|
|
32
|
+
const getLastParam = (a) => last(a) !== undefined ? last(a) : ''
|
|
33
|
+
return getLastParam(arr)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static compareRouteKeywords(obj = {}, arr) {
|
|
37
|
-
const pickValues = (o, a) => a !== undefined ? pick(a, o) : o
|
|
38
|
-
let obj1 = pickValues(obj, arr)
|
|
37
|
+
const pickValues = (o, a) => a !== undefined ? pick(a, o) : o
|
|
38
|
+
let obj1 = pickValues(obj, arr)
|
|
39
39
|
return {
|
|
40
40
|
pickValues,
|
|
41
41
|
compare: (obj = {}, arr) => {
|
|
42
|
-
|
|
42
|
+
const obj2 = pickValues(obj, arr)
|
|
43
43
|
const compareProps = p => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
const p1 = prop(p, obj1)
|
|
45
|
+
const p2 = prop(p, obj2)
|
|
46
|
+
const same = equals(p1, p2)
|
|
47
|
+
const previousExists = p1 !== undefined
|
|
48
|
+
const nextExists = p2 !== undefined
|
|
49
|
+
const changed = !same
|
|
50
|
+
const added = previousExists === false && nextExists === true
|
|
51
|
+
const removed = previousExists === true && nextExists === false
|
|
52
52
|
// console.log("P: ",p,{same, previousExists, nextExists});
|
|
53
|
-
|
|
54
|
-
obj[p] = { same, changed, added, removed, previousExists, nextExists }
|
|
55
|
-
return obj
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const createPred = p => compose(keys, filter(propEq(true, p)))
|
|
59
|
-
|
|
60
|
-
const getPropsState = compose(map(compareProps), uniq, chain(keys))([obj1, obj2])
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
obj1 = obj2
|
|
65
|
-
return { pathsAdded, pathsRemoved, pathsChanged }
|
|
53
|
+
const obj = {}
|
|
54
|
+
obj[p] = { same, changed, added, removed, previousExists, nextExists }
|
|
55
|
+
return obj
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const createPred = p => compose(keys, filter(propEq(true, p)))
|
|
59
|
+
|
|
60
|
+
const getPropsState = compose(map(compareProps), uniq, chain(keys))([obj1, obj2])
|
|
61
|
+
const pathsChanged = chain(createPred('changed'), getPropsState)
|
|
62
|
+
const pathsAdded = chain(createPred('added'), getPropsState)
|
|
63
|
+
const pathsRemoved = chain(createPred('removed'), getPropsState)
|
|
64
|
+
obj1 = obj2
|
|
65
|
+
return { pathsAdded, pathsRemoved, pathsChanged }
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
getComparer: () => obj1
|
|
69
69
|
|
|
70
|
-
}
|
|
70
|
+
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
static getRouteArrData(routeArr, paramsArr) {
|
|
74
|
-
|
|
75
|
-
const pathInnermost = SpyneUtilsChannelRoute.getLastArrVal(paths)
|
|
74
|
+
const paths = filter(includes(__, routeArr), paramsArr)
|
|
75
|
+
const pathInnermost = SpyneUtilsChannelRoute.getLastArrVal(paths)
|
|
76
76
|
// console.log('arr and routeName ',{paths, pathInnermost});
|
|
77
|
-
return { paths, pathInnermost }
|
|
77
|
+
return { paths, pathInnermost }
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
static flattenConfigObject(obj) {
|
|
81
81
|
const go = obj_ => chain(([k, v]) => {
|
|
82
82
|
if (Object.prototype.toString.call(v) === '[object Object]') {
|
|
83
|
-
return map(([k_, v_]) => [`${k}.${k_}`, v_], go(v))
|
|
83
|
+
return map(([k_, v_]) => [`${k}.${k_}`, v_], go(v))
|
|
84
84
|
} else {
|
|
85
|
-
return [[k, v]]
|
|
85
|
+
return [[k, v]]
|
|
86
86
|
}
|
|
87
|
-
}, toPairs(obj_))
|
|
87
|
+
}, toPairs(obj_))
|
|
88
88
|
|
|
89
89
|
// console.log("FLATTEN: ",values(fromPairs(go(obj))));
|
|
90
|
-
return values(fromPairs(go(obj)))
|
|
90
|
+
return values(fromPairs(go(obj)))
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
static addRouteDatasets(channelRouteObj) {
|
|
94
|
+
// channelRouteObj.type='query';
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
static addRouteDatasets(channelRouteObj){
|
|
96
|
-
// channelRouteObj.type='query';
|
|
97
|
-
|
|
98
|
-
const {type, isHash} = channelRouteObj;
|
|
96
|
+
const { type, isHash } = channelRouteObj
|
|
99
97
|
|
|
100
98
|
// create href and check to see if need to convert to hash href links
|
|
101
|
-
const getHREF = (obj)=>{
|
|
99
|
+
const getHREF = (obj) => {
|
|
102
100
|
const santizeHREF = str => {
|
|
103
101
|
const hrefRE = /^(.*\/)([\w-]*\/?)(.*)$/gm
|
|
104
|
-
//const hrefRE = /^(.*\/)([\w-]*)(.*)$/gm;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return str
|
|
102
|
+
// const hrefRE = /^(.*\/)([\w-]*)(.*)$/gm;
|
|
103
|
+
str = str.replace(hrefRE, '$1$2')
|
|
104
|
+
// str = String(str).replace('^$', "");
|
|
105
|
+
return str
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
const headStrVal = type === 'query' ?
|
|
111
|
-
const hrefStr = SpyneUtilsChannelRouteUrl.convertParamsToRoute(obj, channelRouteObj)
|
|
112
|
-
return headStrVal+santizeHREF(hrefStr)
|
|
108
|
+
const headStrVal = type === 'query' ? '' : isHash === true ? '#' : '/'
|
|
109
|
+
const hrefStr = SpyneUtilsChannelRouteUrl.convertParamsToRoute(obj, channelRouteObj)
|
|
110
|
+
return headStrVal + santizeHREF(hrefStr)
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
// remove special chars from href
|
|
116
|
-
const sanitizeStr = (str)=>String(str).replace(/([^A-Za-z0-9-_])/g,
|
|
117
|
-
|
|
114
|
+
const sanitizeStr = (str) => String(str).replace(/([^A-Za-z0-9-_])/g, '')
|
|
118
115
|
|
|
119
116
|
// test whether to use key or val
|
|
120
|
-
const isValidStrRE = /^([A-Za-z0-9_-])+$/m
|
|
121
|
-
|
|
122
|
-
const createInitialValFn = (accMain=[], routePathObj, objAcc={})=>{
|
|
123
|
-
let {routeName} = routePathObj;
|
|
117
|
+
const isValidStrRE = /^([A-Za-z0-9_-])+$/m
|
|
124
118
|
|
|
119
|
+
const createInitialValFn = (accMain = [], routePathObj, objAcc = {}) => {
|
|
120
|
+
let { routeName } = routePathObj
|
|
125
121
|
|
|
126
|
-
const propsReducer = (acc, arrPair)=>{
|
|
127
|
-
const [key, val] = arrPair
|
|
128
|
-
const isObject = is(Object, val)
|
|
122
|
+
const propsReducer = (acc, arrPair) => {
|
|
123
|
+
const [key, val] = arrPair
|
|
124
|
+
const isObject = is(Object, val)
|
|
129
125
|
|
|
130
|
-
const createTitle = (str)=>String(str).replace(/([-_])/g,
|
|
126
|
+
const createTitle = (str) => String(str).replace(/([-_])/g, ' ').toUpperCase()
|
|
131
127
|
|
|
132
|
-
const getLinkText = str => test(isValidStrRE, str) ? createTitle(str) : key
|
|
128
|
+
const getLinkText = str => test(isValidStrRE, str) ? createTitle(str) : key
|
|
133
129
|
|
|
134
|
-
if (key === 'routeName' || key === '404'){
|
|
135
|
-
return acc
|
|
130
|
+
if (key === 'routeName' || key === '404') {
|
|
131
|
+
return acc
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
routeName = routeName ||
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let o = clone(objAcc)
|
|
142
|
-
o[routeName] =sanitizeStr(key)
|
|
143
|
-
|
|
144
|
-
if (isObject === true){
|
|
145
|
-
if (keys(o).length===1){
|
|
146
|
-
const subRouteName = path(['routePath', 'routeName'], val)
|
|
147
|
-
if (subRouteName){
|
|
148
|
-
const oBase = clone(o)
|
|
149
|
-
oBase[subRouteName] =
|
|
150
|
-
oBase
|
|
151
|
-
oBase
|
|
152
|
-
oBase
|
|
153
|
-
acc.push(oBase)
|
|
134
|
+
routeName = routeName || prop('routeName', val)
|
|
135
|
+
// console.log("THE KEY IS ",{key,val,routeName})
|
|
136
|
+
|
|
137
|
+
let o = clone(objAcc)
|
|
138
|
+
o[routeName] = sanitizeStr(key)
|
|
139
|
+
|
|
140
|
+
if (isObject === true) {
|
|
141
|
+
if (keys(o).length === 1) {
|
|
142
|
+
const subRouteName = path(['routePath', 'routeName'], val)
|
|
143
|
+
if (subRouteName) {
|
|
144
|
+
const oBase = clone(o)
|
|
145
|
+
oBase[subRouteName] = ''
|
|
146
|
+
oBase.navLevel = keys(objAcc).length
|
|
147
|
+
oBase.title = getLinkText(key)
|
|
148
|
+
oBase.href = getHREF(oBase)
|
|
149
|
+
acc.push(oBase)
|
|
154
150
|
}
|
|
155
151
|
}
|
|
156
|
-
o = createInitialValFn(accMain, val, o)
|
|
152
|
+
o = createInitialValFn(accMain, val, o)
|
|
157
153
|
} else {
|
|
158
|
-
o
|
|
159
|
-
o
|
|
154
|
+
o.title = getLinkText(key)
|
|
155
|
+
o.href = getHREF(o)
|
|
160
156
|
}
|
|
161
|
-
o
|
|
162
|
-
acc.push(o)
|
|
163
|
-
return acc
|
|
164
|
-
|
|
157
|
+
o.navLevel = keys(objAcc).length
|
|
158
|
+
acc.push(o)
|
|
159
|
+
return acc
|
|
165
160
|
}
|
|
166
161
|
|
|
167
|
-
return toPairs(routePathObj).reduce(propsReducer, [])
|
|
168
|
-
|
|
162
|
+
return toPairs(routePathObj).reduce(propsReducer, [])
|
|
169
163
|
}
|
|
170
164
|
|
|
171
|
-
|
|
172
|
-
const routeDatasetsArr = flatten(reducedArr)
|
|
165
|
+
const reducedArr = createInitialValFn([], channelRouteObj.routes)
|
|
166
|
+
const routeDatasetsArr = flatten(reducedArr)
|
|
173
167
|
|
|
174
168
|
const getNavProps = (datasetsArr) => {
|
|
175
169
|
const exclude = reject(includes(__, ['title', 'href', 'navLevel']))
|
|
176
|
-
const getMainKeys = compose(uniq,exclude, flatten, map(keys))
|
|
177
|
-
return getMainKeys(datasetsArr)
|
|
170
|
+
const getMainKeys = compose(uniq, exclude, flatten, map(keys))
|
|
171
|
+
return getMainKeys(datasetsArr)
|
|
178
172
|
}
|
|
179
|
-
const routeNamesArr = getNavProps(routeDatasetsArr)
|
|
173
|
+
const routeNamesArr = getNavProps(routeDatasetsArr)
|
|
180
174
|
|
|
181
|
-
return {routeDatasetsArr, routeNamesArr}
|
|
175
|
+
return { routeDatasetsArr, routeNamesArr }
|
|
182
176
|
}
|
|
183
177
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
add404s = add404s || add404Props;
|
|
178
|
+
static conformRouteObject(channelRouteObj = {}, add404Props = false) {
|
|
179
|
+
const channelsRoutePath = path(['channels', 'ROUTE'], channelRouteObj)
|
|
180
|
+
let { add404s } = channelsRoutePath !== undefined ? channelsRoutePath : channelRouteObj
|
|
181
|
+
add404s = add404s || add404Props
|
|
189
182
|
const parseRoutePath = (a) => {
|
|
190
|
-
|
|
191
|
-
const isArr = is(Array, val)
|
|
192
|
-
if (val ===
|
|
193
|
-
a[1] =
|
|
194
|
-
} else if (isArr){
|
|
195
|
-
a[1] = val.join('|')
|
|
183
|
+
const val = a[1]
|
|
184
|
+
const isArr = is(Array, val)
|
|
185
|
+
if (val === '') {
|
|
186
|
+
a[1] = '^$'
|
|
187
|
+
} else if (isArr) {
|
|
188
|
+
a[1] = val.join('|')
|
|
196
189
|
}
|
|
197
|
-
return a
|
|
190
|
+
return a
|
|
198
191
|
}
|
|
199
192
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
const isRoutePath = key === 'routePath';
|
|
193
|
+
const transduceConfig = (arr) => {
|
|
194
|
+
const [key, val] = arr
|
|
195
|
+
const obj404 = add404s ? { 404: '.+' } : {}
|
|
196
|
+
const isObj = is(Object, val)
|
|
197
|
+
const isArr = is(Array, val)
|
|
198
|
+
const iterObj = isObj === true && isArr === false
|
|
199
|
+
const isRoutePath = key === 'routePath'
|
|
208
200
|
if (iterObj) {
|
|
209
|
-
arr[1] = configMapperFn(arr[1])
|
|
210
|
-
if (isRoutePath){
|
|
211
|
-
arr[1] =
|
|
201
|
+
arr[1] = configMapperFn(arr[1])
|
|
202
|
+
if (isRoutePath) {
|
|
203
|
+
arr[1] = compose(mergeDeepRight(obj404), fromPairs, map(parseRoutePath), toPairs)(arr[1])
|
|
212
204
|
}
|
|
213
205
|
}
|
|
214
|
-
return arr
|
|
206
|
+
return arr
|
|
215
207
|
}
|
|
216
208
|
|
|
217
|
-
const configMapperFn = compose(fromPairs, map(transduceConfig), toPairs)
|
|
209
|
+
const configMapperFn = compose(fromPairs, map(transduceConfig), toPairs)
|
|
218
210
|
|
|
219
|
-
|
|
220
|
-
if (channelsRoutePath !== undefined){
|
|
211
|
+
if (channelsRoutePath !== undefined) {
|
|
221
212
|
channelRouteObj.channels.ROUTE = configMapperFn(channelRouteObj.channels.ROUTE)
|
|
222
|
-
const extraRouteData = SpyneUtilsChannelRoute.addRouteDatasets(channelRouteObj.channels.ROUTE)
|
|
223
|
-
channelRouteObj.channels.ROUTE = mergeRight(channelRouteObj.channels.ROUTE, extraRouteData)
|
|
224
|
-
return channelRouteObj
|
|
213
|
+
const extraRouteData = SpyneUtilsChannelRoute.addRouteDatasets(channelRouteObj.channels.ROUTE)
|
|
214
|
+
channelRouteObj.channels.ROUTE = mergeRight(channelRouteObj.channels.ROUTE, extraRouteData)
|
|
215
|
+
return channelRouteObj
|
|
225
216
|
}
|
|
226
217
|
|
|
227
|
-
return configMapperFn(channelRouteObj)
|
|
228
|
-
|
|
218
|
+
return configMapperFn(channelRouteObj)
|
|
229
219
|
}
|
|
230
220
|
|
|
231
221
|
static getLocationData() {
|
|
@@ -238,7 +228,7 @@ export class SpyneUtilsChannelRoute {
|
|
|
238
228
|
'port',
|
|
239
229
|
'pathname',
|
|
240
230
|
'search',
|
|
241
|
-
'hash']
|
|
242
|
-
return pickAll(locationParamsArr, window.location)
|
|
231
|
+
'hash']
|
|
232
|
+
return pickAll(locationParamsArr, window.location)
|
|
243
233
|
}
|
|
244
234
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fromEventPattern } from 'rxjs'
|
|
2
|
-
import { map } from 'rxjs/operators'
|
|
3
|
-
import {mapObjIndexed} from 'ramda'
|
|
1
|
+
import { fromEventPattern } from 'rxjs'
|
|
2
|
+
import { map } from 'rxjs/operators'
|
|
3
|
+
import { mapObjIndexed } from 'ramda'
|
|
4
4
|
|
|
5
5
|
export class SpyneUtilsChannelWindow {
|
|
6
6
|
/**
|
|
@@ -15,69 +15,69 @@ export class SpyneUtilsChannelWindow {
|
|
|
15
15
|
*/
|
|
16
16
|
constructor() {
|
|
17
17
|
this.createDomObservableFromEvent = SpyneUtilsChannelWindow.createDomObservableFromEvent.bind(
|
|
18
|
-
this)
|
|
18
|
+
this)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static createDomObservableFromEvent(eventName, mapFn, isPassive = true, element=window) {
|
|
22
|
-
|
|
23
|
-
{ passive: isPassive })
|
|
24
|
-
|
|
25
|
-
mapFn = mapFn === undefined ? (p) => p : mapFn
|
|
26
|
-
return fromEventPattern(addHandler, removeHandler).pipe(map(mapFn))
|
|
21
|
+
static createDomObservableFromEvent(eventName, mapFn, isPassive = true, element = window) {
|
|
22
|
+
const addHandler = handler => element.addEventListener(eventName, handler,
|
|
23
|
+
{ passive: isPassive })
|
|
24
|
+
const removeHandler = () => { element[eventName] = (p) => p }
|
|
25
|
+
mapFn = mapFn === undefined ? (p) => p : mapFn
|
|
26
|
+
return fromEventPattern(addHandler, removeHandler).pipe(map(mapFn))
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// MEDIA QUERIES
|
|
30
30
|
static createMediaQuery(str) {
|
|
31
|
-
const mq = window.matchMedia(str)
|
|
32
|
-
this.checkIfValidMediaQuery(mq, str)
|
|
33
|
-
return mq !== false ? mq : false
|
|
31
|
+
const mq = window.matchMedia(str)
|
|
32
|
+
this.checkIfValidMediaQuery(mq, str)
|
|
33
|
+
return mq !== false ? mq : false
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static checkIfValidMediaQuery(mq, str) {
|
|
37
|
-
const noSpaces = str => str.replace(/\s+/gm, '')
|
|
38
|
-
const isValidBool = mq.matches!==undefined
|
|
39
|
-
const warnMsg = str => console.warn(`Spyne Info: the following query string, "${str}", has been optimized to "${mq.media}" by the browser and may not be a valid Media Query item!`)
|
|
37
|
+
const noSpaces = str => str.replace(/\s+/gm, '')
|
|
38
|
+
const isValidBool = mq.matches !== undefined && noSpaces(mq.media).indexOf(noSpaces(str)) >= 0
|
|
39
|
+
const warnMsg = str => console.warn(`Spyne Info: the following query string, "${str}", has been optimized to "${mq.media}" by the browser and may not be a valid Media Query item!`)
|
|
40
40
|
if (isValidBool === false) {
|
|
41
|
-
warnMsg(str)
|
|
41
|
+
warnMsg(str)
|
|
42
42
|
}
|
|
43
|
-
return isValidBool
|
|
43
|
+
return isValidBool
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
static createMediaQueryHandler(query, key) {
|
|
47
|
-
|
|
48
|
-
p
|
|
49
|
-
return p
|
|
50
|
-
}
|
|
47
|
+
const keyFn = key => p => {
|
|
48
|
+
p.mediaQueryName = key
|
|
49
|
+
return p
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const mapKey = keyFn(key)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
const handlers = (q) => {
|
|
55
55
|
return {
|
|
56
|
-
addHandler: (handler) => { q.addListener(handler)
|
|
57
|
-
removeHandler: (handler) => { q.onchange = () => {}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
56
|
+
addHandler: (handler) => { q.addListener(handler) },
|
|
57
|
+
removeHandler: (handler) => { q.onchange = () => {} }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const mediaQueryHandler = handlers(query)
|
|
61
61
|
/* eslint-disable new-cap */
|
|
62
62
|
return new fromEventPattern(
|
|
63
63
|
mediaQueryHandler.addHandler,
|
|
64
64
|
mediaQueryHandler.removeHandler)
|
|
65
|
-
.pipe(map(mapKey))
|
|
65
|
+
.pipe(map(mapKey))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
static createMergedObsFromObj(config) {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const mediaQueriesObj = config.mediaQueries || config.mediaQueries
|
|
70
|
+
const arr = []
|
|
71
71
|
|
|
72
72
|
const loopQueries = (val, key, obj) => {
|
|
73
|
-
|
|
74
|
-
if (mq!==false) {
|
|
75
|
-
arr.push(SpyneUtilsChannelWindow.createMediaQueryHandler(mq, key))
|
|
73
|
+
const mq = SpyneUtilsChannelWindow.createMediaQuery(val)
|
|
74
|
+
if (mq !== false) {
|
|
75
|
+
arr.push(SpyneUtilsChannelWindow.createMediaQueryHandler(mq, key))
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
}
|
|
77
|
+
return arr
|
|
78
|
+
}
|
|
79
79
|
|
|
80
|
-
mapObjIndexed(loopQueries, mediaQueriesObj)
|
|
81
|
-
return arr
|
|
80
|
+
mapObjIndexed(loopQueries, mediaQueriesObj)
|
|
81
|
+
return arr
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return `${initOpacityZero}transition: opacity ${t}s ${e}; opacity: ${opacity}
|
|
5
|
-
}
|
|
1
|
+
const createFaderInlineText = (isInBool = false, t = 1, e = 'ease', startZeroBool = false) => {
|
|
2
|
+
const initOpacityZero = startZeroBool === true ? 'opacity:0;' : ''
|
|
3
|
+
const opacity = isInBool === true ? 1 : 0
|
|
4
|
+
return `${initOpacityZero}transition: opacity ${t}s ${e}; opacity: ${opacity};`
|
|
5
|
+
}
|
|
6
6
|
export function fadein(el, t) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
el.style.cssText += inlineCss
|
|
7
|
+
const currentOpacity = window.getComputedStyle(el).opacity * 1
|
|
8
|
+
const startAtZero = currentOpacity === 1
|
|
9
|
+
const inlineCss = createFaderInlineText(true, t, 'ease', startAtZero)
|
|
10
|
+
el.style.cssText += inlineCss
|
|
11
11
|
}
|
|
12
12
|
export function fadeout(el, t, callback) {
|
|
13
|
-
|
|
14
|
-
el.style.cssText += inlineCss
|
|
13
|
+
const inlineCss = createFaderInlineText(false, t, 'ease')
|
|
14
|
+
el.style.cssText += inlineCss
|
|
15
15
|
|
|
16
16
|
// window.setTimeout(callback, t * 1000);
|
|
17
|
-
el.addEventListener('transitionend', callback, false)
|
|
17
|
+
el.addEventListener('transitionend', callback, false)
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Subject } from 'rxjs'
|
|
2
|
-
import { filter, map } from 'rxjs/operators'
|
|
3
|
-
import {flip, mergeRight, clone, forEach, propSatisfies} from 'ramda'
|
|
1
|
+
import { Subject } from 'rxjs'
|
|
2
|
+
import { filter, map } from 'rxjs/operators'
|
|
3
|
+
import { flip, mergeRight, clone, forEach, propSatisfies } from 'ramda'
|
|
4
4
|
export class ViewStreamObservable {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
/**
|
|
@@ -11,13 +11,13 @@ export class ViewStreamObservable {
|
|
|
11
11
|
* @desc
|
|
12
12
|
* Internal observable that creates the ViewStream Observable that branches out to parent, internal and child directions
|
|
13
13
|
*/
|
|
14
|
-
this.props.observableStreams = ViewStreamObservable.createDirectionalObservables()
|
|
14
|
+
this.props.observableStreams = ViewStreamObservable.createDirectionalObservables()
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
static createDirectionalFiltersObject() {
|
|
18
|
-
const dirInternal = 'internal'
|
|
19
|
-
const dirParent = 'parent'
|
|
20
|
-
const dirChild = 'child'
|
|
18
|
+
const dirInternal = 'internal'
|
|
19
|
+
const dirParent = 'parent'
|
|
20
|
+
const dirChild = 'child'
|
|
21
21
|
return {
|
|
22
22
|
P: [dirParent],
|
|
23
23
|
C: [dirChild],
|
|
@@ -25,84 +25,84 @@ export class ViewStreamObservable {
|
|
|
25
25
|
CI: [dirChild, dirInternal],
|
|
26
26
|
PI: [dirParent, dirInternal],
|
|
27
27
|
PC: [dirParent, dirChild]
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static addDefaultDir(obj) {
|
|
32
|
-
const defaults = flip(mergeRight)
|
|
33
|
-
return defaults({ $dir:['internal'] }, clone(obj))
|
|
32
|
+
const defaults = flip(mergeRight)
|
|
33
|
+
return defaults({ $dir:['internal'] }, clone(obj))
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static addDownInternalDir(obj, arr = ['internal', 'down']) {
|
|
37
|
-
const defaults = flip(mergeRight)
|
|
38
|
-
return defaults(clone(obj), { $dir:arr })
|
|
37
|
+
const defaults = flip(mergeRight)
|
|
38
|
+
return defaults(clone(obj), { $dir:arr })
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
static addChildAndInternalDir(obj, arr = ['child', 'down']) {
|
|
42
|
-
const defaults = flip(mergeRight)
|
|
43
|
-
return defaults(clone(obj), { $dir:arr })
|
|
42
|
+
const defaults = flip(mergeRight)
|
|
43
|
+
return defaults(clone(obj), { $dir:arr })
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
static mapToDefaultDir(p) {
|
|
47
|
-
return this.addDefaultDir(p)
|
|
47
|
+
return this.addDefaultDir(p)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
static createDirectionalObservables(obs$ = new Subject(), viewName, vsid) {
|
|
51
51
|
if (viewName !== undefined && vsid !== undefined) {
|
|
52
|
-
obs
|
|
53
|
-
obs
|
|
52
|
+
obs$.viewName = viewName
|
|
53
|
+
obs$.vsid = vsid
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const filterStreams = val => propSatisfies(arrType => arrType.includes(val), '$dir')
|
|
57
|
-
const filterParent = filterStreams('parent')
|
|
58
|
-
const filterChild = filterStreams('child')
|
|
59
|
-
const filterInternal = filterStreams('internal')
|
|
56
|
+
const filterStreams = val => propSatisfies(arrType => arrType.includes(val), '$dir')
|
|
57
|
+
const filterParent = filterStreams('parent')
|
|
58
|
+
const filterChild = filterStreams('child')
|
|
59
|
+
const filterInternal = filterStreams('internal')
|
|
60
60
|
|
|
61
|
-
const addfrom$ = relStr => mergeRight({ from$:relStr })
|
|
62
|
-
const addParentfrom$ = addfrom$('child')
|
|
63
|
-
const addInternalfrom$ = addfrom$('internal')
|
|
64
|
-
const addChildfrom$ = addfrom$('parent')
|
|
61
|
+
const addfrom$ = relStr => mergeRight({ from$:relStr })
|
|
62
|
+
const addParentfrom$ = addfrom$('child')
|
|
63
|
+
const addInternalfrom$ = addfrom$('internal')
|
|
64
|
+
const addChildfrom$ = addfrom$('parent')
|
|
65
65
|
|
|
66
66
|
const raw$ = obs$
|
|
67
|
-
.pipe(filter((payload) => payload !== undefined && payload.action !== undefined))
|
|
67
|
+
.pipe(filter((payload) => payload !== undefined && payload.action !== undefined))
|
|
68
68
|
|
|
69
|
-
const toInternal$ = obs$.pipe(filter(filterInternal), map(addInternalfrom$))
|
|
70
|
-
const toParent$ = obs$.pipe(filter(filterParent), map(addParentfrom$))
|
|
71
|
-
const toChild$ = obs$.pipe(filter(filterChild), map(addChildfrom$))
|
|
69
|
+
const toInternal$ = obs$.pipe(filter(filterInternal), map(addInternalfrom$))
|
|
70
|
+
const toParent$ = obs$.pipe(filter(filterParent), map(addParentfrom$))
|
|
71
|
+
const toChild$ = obs$.pipe(filter(filterChild), map(addChildfrom$))
|
|
72
72
|
|
|
73
73
|
const streamObj = {
|
|
74
74
|
parent: toParent$,
|
|
75
75
|
internal: toInternal$,
|
|
76
76
|
child: toChild$
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
|
|
79
79
|
const completeStream = (arr = []) => {
|
|
80
80
|
const endStream = o => {
|
|
81
|
-
o.complete()
|
|
82
|
-
o.isStopped = true
|
|
83
|
-
}
|
|
81
|
+
o.complete()
|
|
82
|
+
o.isStopped = true
|
|
83
|
+
}
|
|
84
84
|
|
|
85
85
|
const setCompleteStream = (str) => {
|
|
86
86
|
if (streamObj[str] !== undefined) {
|
|
87
|
-
|
|
88
|
-
endStream(obs$)
|
|
87
|
+
const obs$ = streamObj[str]
|
|
88
|
+
endStream(obs$)
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
|
|
92
92
|
if (arr !== undefined && arr.length >= 1) {
|
|
93
|
-
arr.forEach(setCompleteStream)
|
|
93
|
+
arr.forEach(setCompleteStream)
|
|
94
94
|
}
|
|
95
|
-
}
|
|
95
|
+
}
|
|
96
96
|
const completeAll = () => {
|
|
97
|
-
|
|
98
|
-
o.complete()
|
|
99
|
-
o.isStopped = true
|
|
100
|
-
}
|
|
101
|
-
forEach(completeStream, [raw$, toInternal$, toParent$, toChild$])
|
|
102
|
-
}
|
|
97
|
+
const completeStream = o => {
|
|
98
|
+
o.complete()
|
|
99
|
+
o.isStopped = true
|
|
100
|
+
}
|
|
101
|
+
forEach(completeStream, [raw$, toInternal$, toParent$, toChild$])
|
|
102
|
+
}
|
|
103
103
|
|
|
104
104
|
return {
|
|
105
105
|
raw$, toInternal$, toParent$, toChild$, completeAll, completeStream
|
|
106
|
-
}
|
|
106
|
+
}
|
|
107
107
|
}
|
|
108
108
|
}
|