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,9 +1,10 @@
|
|
|
1
|
-
import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins'
|
|
2
|
-
import { convertDomStringMapToObj } from '../utils/frp-tools'
|
|
3
|
-
import {SpyneAppProperties} from '../utils/spyne-app-properties'
|
|
4
|
-
import { fromEvent } from 'rxjs'
|
|
5
|
-
import { map } from 'rxjs/operators'
|
|
6
|
-
import {clone, omit} from 'ramda'
|
|
1
|
+
import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins'
|
|
2
|
+
import { convertDomStringMapToObj } from '../utils/frp-tools'
|
|
3
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
4
|
+
import { fromEvent } from 'rxjs'
|
|
5
|
+
import { map } from 'rxjs/operators'
|
|
6
|
+
import { clone, omit } from 'ramda'
|
|
7
|
+
const isDevMode = SpyneAppProperties.debug === true
|
|
7
8
|
|
|
8
9
|
export class ViewStreamBroadcaster {
|
|
9
10
|
/**
|
|
@@ -17,99 +18,102 @@ export class ViewStreamBroadcaster {
|
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
constructor(props, broadcastFn) {
|
|
20
|
-
this.addMixins()
|
|
21
|
-
this.props = props
|
|
22
|
-
this.broadcastFn = broadcastFn
|
|
23
|
-
this.broadcaster(this.broadcastFn)
|
|
21
|
+
this.addMixins()
|
|
22
|
+
this.props = props
|
|
23
|
+
this.broadcastFn = broadcastFn
|
|
24
|
+
this.broadcaster(this.broadcastFn)
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
addDblClickEvt(q) {
|
|
27
|
-
|
|
28
|
+
const dblclick$ = fromEvent(q, 'dblclick')
|
|
28
29
|
// console.log('ADDING DBL CLICK ', q);
|
|
29
|
-
|
|
30
|
+
const stream$ = dblclick$.pipe(
|
|
30
31
|
map(p => {
|
|
31
|
-
|
|
32
|
+
const data = clone(p)
|
|
32
33
|
// ADD DOUBLECLICK TO UI EVENTS
|
|
33
|
-
data
|
|
34
|
-
return data
|
|
35
|
-
}))
|
|
36
|
-
return stream
|
|
34
|
+
data.typeOverRide = 'dblclick'
|
|
35
|
+
return data
|
|
36
|
+
}))
|
|
37
|
+
return stream$
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// ==================================================================
|
|
40
41
|
// BROADCAST BUTTON EVENTS
|
|
41
42
|
// ==================================================================
|
|
42
43
|
broadcast(args) {
|
|
44
|
+
if (args.length <= 0 && isDevMode === true) {
|
|
45
|
+
console.warn(`Spyne Warning: The nested array in ${this.props.name}.broadcastEvents appears to be empty --> vsid:${this.props.vsid}!`)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
43
48
|
// payloads to send, based on either the array or the elements dataMap
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
49
|
+
const channelPayloads = {
|
|
50
|
+
UI: this.sendUIPayload,
|
|
51
|
+
ROUTE: this.sendRoutePayload
|
|
52
|
+
}
|
|
48
53
|
// spread operator to select variables from arrays
|
|
49
|
-
|
|
54
|
+
const [selector, event, local] = args
|
|
50
55
|
// btn query
|
|
51
|
-
let channel
|
|
52
|
-
let query = this.props.el.querySelectorAll(selector)
|
|
56
|
+
let channel // hoist channel and later check if chnl exists
|
|
57
|
+
let query = this.props.el.querySelectorAll(selector)
|
|
53
58
|
|
|
54
59
|
if (query.length <= 0) {
|
|
55
|
-
|
|
60
|
+
const el = this.props.el
|
|
56
61
|
const checkParentEls = (element) => {
|
|
57
62
|
if (element === el) {
|
|
58
|
-
query = [element]
|
|
63
|
+
query = [element]
|
|
59
64
|
}
|
|
60
|
-
}
|
|
65
|
+
}
|
|
61
66
|
|
|
62
67
|
const pluckElFromParent = () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
elSelected.forEach = Array.prototype.forEach
|
|
66
|
-
elSelected.forEach(checkParentEls)
|
|
67
|
-
}
|
|
68
|
+
const elParent = el.parentElement !== null ? el.parentElement : document
|
|
69
|
+
const elSelected = elParent.querySelectorAll(selector)
|
|
70
|
+
elSelected.forEach = Array.prototype.forEach
|
|
71
|
+
elSelected.forEach(checkParentEls)
|
|
72
|
+
}
|
|
68
73
|
|
|
69
|
-
pluckElFromParent()
|
|
74
|
+
pluckElFromParent()
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
const isLocalEvent = local !== undefined
|
|
78
|
+
const addObservable = (q) => {
|
|
74
79
|
// the btn observable
|
|
75
|
-
|
|
80
|
+
const observable = event !== 'dblClick'
|
|
76
81
|
? fromEvent(q, event, { preventDefault: () => true })
|
|
77
|
-
: this.addDblClickEvt(q)
|
|
82
|
+
: this.addDblClickEvt(q)
|
|
78
83
|
// select channel and data values from either the array or the element's dom Map
|
|
79
|
-
channel = q.dataset.channel
|
|
80
|
-
|
|
81
|
-
data
|
|
82
|
-
data.payload = omit(['channel'], data.payload)
|
|
83
|
-
data
|
|
84
|
+
channel = q.dataset.channel// ifNilThenUpdate(chnl, q.dataset.channel);
|
|
85
|
+
const data = {}// convertDomStringMapToObj(q.dataset);
|
|
86
|
+
data.payload = convertDomStringMapToObj(q.dataset)
|
|
87
|
+
data.payload = omit(['channel'], data.payload)
|
|
88
|
+
data.channel = channel
|
|
84
89
|
// payload needs vsid# to pass verification
|
|
85
90
|
|
|
86
|
-
data
|
|
87
|
-
data.srcElement
|
|
88
|
-
data.srcElement
|
|
89
|
-
data.srcElement
|
|
90
|
-
//data.srcElement['viewName'] = this.props.name;
|
|
91
|
-
data.srcElement
|
|
92
|
-
data.srcElement
|
|
91
|
+
data.srcElement = {}// pick(['vsid','viewName'], data);
|
|
92
|
+
data.srcElement.id = this.props.id
|
|
93
|
+
data.srcElement.vsid = this.props.vsid
|
|
94
|
+
data.srcElement.isLocalEvent = isLocalEvent
|
|
95
|
+
// data.srcElement['viewName'] = this.props.name;
|
|
96
|
+
data.srcElement.srcEvent = event
|
|
97
|
+
data.srcElement.el = q
|
|
93
98
|
// select the correct payload
|
|
94
|
-
|
|
99
|
+
const channelPayload = channel !== undefined ? channelPayloads[channel] : channelPayloads.UI
|
|
95
100
|
// run payload
|
|
96
|
-
channelPayload(observable, data)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
let queryIsNil = query === undefined || query.length <= 0;
|
|
101
|
+
channelPayload(observable, data)
|
|
102
|
+
}
|
|
103
|
+
const queryIsNil = query === undefined || query.length <= 0
|
|
100
104
|
if (queryIsNil === true && isDevMode === true) {
|
|
101
|
-
console.warn(`Spyne Warning: The item ${selector}, does not appear to exist in ${this.props.name} --> vsid:${this.props.vsid}!`)
|
|
105
|
+
console.warn(`Spyne Warning: The item ${selector}, does not appear to exist in ${this.props.name} --> vsid:${this.props.vsid}!`)
|
|
102
106
|
|
|
103
107
|
// addObservable(query, event);
|
|
104
108
|
} else {
|
|
105
|
-
query.forEach = Array.prototype.forEach
|
|
106
|
-
query.forEach(addObservable)
|
|
109
|
+
query.forEach = Array.prototype.forEach
|
|
110
|
+
query.forEach(addObservable)
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
broadcaster(arrFn) {
|
|
111
|
-
|
|
112
|
-
broadcastArr.forEach(args => this.broadcast(args))
|
|
115
|
+
const broadcastArr = arrFn()
|
|
116
|
+
broadcastArr.forEach(args => this.broadcast(args))
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
// =================================================================
|
|
@@ -117,8 +121,8 @@ export class ViewStreamBroadcaster {
|
|
|
117
121
|
// ==================================
|
|
118
122
|
// BASE STREAM MIXINS
|
|
119
123
|
// ==================================
|
|
120
|
-
|
|
121
|
-
this.sendUIPayload = streamMixins.sendUIPayload
|
|
122
|
-
this.sendRoutePayload = streamMixins.sendRoutePayload
|
|
124
|
+
const streamMixins = baseStreamsMixins()
|
|
125
|
+
this.sendUIPayload = streamMixins.sendUIPayload
|
|
126
|
+
this.sendRoutePayload = streamMixins.sendRoutePayload
|
|
123
127
|
}
|
|
124
128
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DomElement } from './dom-element'
|
|
2
|
-
import { fadein, fadeout } from '../utils/viewstream-animations'
|
|
3
|
-
import { ViewStreamObservable } from '../utils/viewstream-observables'
|
|
4
|
-
import { deepMerge } from '../utils/deep-merge'
|
|
5
|
-
import { Subject, bindCallback } from 'rxjs'
|
|
6
|
-
import {filter, isNil, pick, props, defaultTo} from 'ramda'
|
|
1
|
+
import { DomElement } from './dom-element'
|
|
2
|
+
import { fadein, fadeout } from '../utils/viewstream-animations'
|
|
3
|
+
import { ViewStreamObservable } from '../utils/viewstream-observables'
|
|
4
|
+
import { deepMerge } from '../utils/deep-merge'
|
|
5
|
+
import { Subject, bindCallback } from 'rxjs'
|
|
6
|
+
import { filter, isNil, pick, props, defaultTo } from 'ramda'
|
|
7
7
|
|
|
8
8
|
export class ViewStreamElement {
|
|
9
9
|
/**
|
|
@@ -20,52 +20,54 @@ export class ViewStreamElement {
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
constructor(sink$, viewProps = {}, vsid = '', vsName = 'theName') {
|
|
23
|
-
this.addMixins()
|
|
24
|
-
this._state = 'INIT'
|
|
25
|
-
this.vsid = vsid
|
|
26
|
-
this.vsName = vsName
|
|
23
|
+
this.addMixins()
|
|
24
|
+
this._state = 'INIT'
|
|
25
|
+
this.vsid = vsid
|
|
26
|
+
this.vsName = vsName
|
|
27
27
|
this.defaults = {
|
|
28
28
|
debug:false,
|
|
29
29
|
extendedHashMethods: {}
|
|
30
|
-
}
|
|
31
|
-
this.options = deepMerge(this.defaults, viewProps)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.options.extendedHashMethods[action] = (p) => this[funcStr](p)
|
|
35
|
-
}
|
|
36
|
-
this.addActionListeners().forEach(createExtraStatesMethod)
|
|
37
|
-
this.options.hashMethods = this.setHashMethods(this.options.extendedHashMethods)
|
|
38
|
-
this.sink$ = sink
|
|
30
|
+
}
|
|
31
|
+
this.options = deepMerge(this.defaults, viewProps)
|
|
32
|
+
const createExtraStatesMethod = (arr) => {
|
|
33
|
+
const [action, funcStr] = arr
|
|
34
|
+
this.options.extendedHashMethods[action] = (p) => this[funcStr](p)
|
|
35
|
+
}
|
|
36
|
+
this.addActionListeners().forEach(createExtraStatesMethod)
|
|
37
|
+
this.options.hashMethods = this.setHashMethods(this.options.extendedHashMethods)
|
|
38
|
+
this.sink$ = sink$
|
|
39
39
|
this.sink$
|
|
40
|
-
.subscribe(this.onObsSinkSubscribe.bind(this))
|
|
40
|
+
.subscribe(this.onObsSinkSubscribe.bind(this))
|
|
41
41
|
|
|
42
|
-
this.$dirs = ViewStreamObservable.createDirectionalFiltersObject()
|
|
43
|
-
this.addDefaultDir = ViewStreamObservable.addDefaultDir
|
|
44
|
-
this.sourceStreams = ViewStreamObservable.createDirectionalObservables(new Subject(), this.vsName, this.vsid)
|
|
45
|
-
this._source$ = this.sourceStreams.toInternal
|
|
42
|
+
this.$dirs = ViewStreamObservable.createDirectionalFiltersObject()
|
|
43
|
+
this.addDefaultDir = ViewStreamObservable.addDefaultDir
|
|
44
|
+
this.sourceStreams = ViewStreamObservable.createDirectionalObservables(new Subject(), this.vsName, this.vsid)
|
|
45
|
+
this._source$ = this.sourceStreams.toInternal$ // new Subject();
|
|
46
46
|
}
|
|
47
|
+
|
|
47
48
|
addActionListeners() {
|
|
48
|
-
return []
|
|
49
|
+
return []
|
|
49
50
|
}
|
|
51
|
+
|
|
50
52
|
setHashMethods(extendedHashMethodsObj = {}) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
return deepMerge(defaultHashMethods, extendedHashMethodsObj)
|
|
53
|
+
const defaultHashMethods = {
|
|
54
|
+
VS_DETRITUS_COLLECT : (p) => this.onGarbageCollect(p),
|
|
55
|
+
READY_FOR_VS_DETRITUS_COLLECT : (p) => this.onReadyForGC(p),
|
|
56
|
+
EXTIRPATE : (p) => this.onDispose(p),
|
|
57
|
+
VS_SPAWN : (p) => this.onRender(p),
|
|
58
|
+
VS_SPAWN_AND_ATTACH_TO_PARENT : (p) => this.onRenderAndAttachToParent(p),
|
|
59
|
+
VS_SPAWN_AND_ATTACH_TO_DOM : (p) => this.onRenderAndAttachToDom(p),
|
|
60
|
+
ATTACH_CHILD_TO_SELF : (p) => this.onAttachChildToSelf(p)
|
|
61
|
+
}
|
|
62
|
+
return deepMerge(defaultHashMethods, extendedHashMethodsObj)
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
createDomItem() {
|
|
64
|
-
this.props = this.props !== undefined ? this.props : {}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return new DomElement(tagName, attrs, data, template)
|
|
66
|
+
this.props = this.props !== undefined ? this.props : {}
|
|
67
|
+
const removeIsNil = (val) => val !== undefined
|
|
68
|
+
const attrs = filter(removeIsNil, pick(['id', 'className'], this.props))
|
|
69
|
+
const { tagName, data, template } = this.props
|
|
70
|
+
return new DomElement(tagName, attrs, data, template)
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
onDisposeCompleted(d) {
|
|
@@ -73,22 +75,21 @@ export class ViewStreamElement {
|
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
animateInTween(el, time) {
|
|
76
|
-
fadein(el, time)
|
|
78
|
+
fadein(el, time)
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
animateOutTween(el, time, callback) {
|
|
80
82
|
// console.log('anim out ', {el, time, callback});
|
|
81
|
-
fadeout(el, time, callback)
|
|
83
|
+
fadeout(el, time, callback)
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
setAnimateIn(d) {
|
|
85
87
|
if (d.animateIn === true) {
|
|
86
|
-
|
|
87
|
-
this.animateInTween(el, d.animateInTime)
|
|
88
|
+
const el = d.el !== undefined ? d.el : this.domItem.el
|
|
89
|
+
this.animateInTween(el, d.animateInTime)
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
|
|
92
93
|
/**
|
|
93
94
|
*
|
|
94
95
|
* @param {Object} d
|
|
@@ -96,78 +97,77 @@ export class ViewStreamElement {
|
|
|
96
97
|
*/
|
|
97
98
|
|
|
98
99
|
disposeMethod(d) {
|
|
99
|
-
|
|
100
|
+
const el = d.el.el !== undefined ? d.el.el : d.el // DOM ITEMS HAVE THEIR EL ITEMS NESTED
|
|
100
101
|
|
|
101
|
-
const gcData = { action:'READY_FOR_VS_DETRITUS_COLLECT', $dir:this.$dirs.PI, el }
|
|
102
|
+
const gcData = { action:'READY_FOR_VS_DETRITUS_COLLECT', $dir:this.$dirs.PI, el }
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
this.animateOutTween(el, d.animateOutTime, callback)
|
|
105
|
-
}
|
|
104
|
+
const animateOut = (d, callback) => {
|
|
105
|
+
this.animateOutTween(el, d.animateOutTime, callback)
|
|
106
|
+
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this._source$.next(gcData)
|
|
110
|
-
}
|
|
108
|
+
const fadeOutObs = bindCallback(animateOut)
|
|
109
|
+
const onFadeoutCompleted = (e) => {
|
|
110
|
+
this._source$.next(gcData)
|
|
111
|
+
}
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
const onFadeoutObs = (d) => {
|
|
113
114
|
fadeOutObs(d)
|
|
114
|
-
.subscribe(onFadeoutCompleted)
|
|
115
|
-
return { action:'EXTIRPATING', $dir:this.$dirs.CI }
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return fn(d)
|
|
115
|
+
.subscribe(onFadeoutCompleted)
|
|
116
|
+
return { action:'EXTIRPATING', $dir:this.$dirs.CI }
|
|
117
|
+
}
|
|
118
|
+
const onEmptyObs = () => ({ action:'EXTIRPATE_AND_READY_FOR_VS_DETRITUS_COLLECT', $dir:this.$dirs.CI })
|
|
119
|
+
const fn = d.animateOut === true ? onFadeoutObs : onEmptyObs
|
|
120
|
+
return fn(d)
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
onDispose(d) {
|
|
123
|
-
return this.disposeMethod(d)
|
|
124
|
+
return this.disposeMethod(d)
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
removeStream() {
|
|
127
128
|
// this.sourceStreams.completeAll();
|
|
128
129
|
if (this.sourceStreams !== undefined) {
|
|
129
|
-
this.sourceStreams.completeStream(['internal', 'child'])
|
|
130
|
+
this.sourceStreams.completeStream(['internal', 'child'])
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
|
|
134
134
|
onReadyForGC(p) {
|
|
135
|
-
this.removeStream()
|
|
135
|
+
this.removeStream()
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
onGarbageCollect(p) {
|
|
139
|
-
if (this.domItem!==undefined) {
|
|
140
|
-
this.domItem.unmount()
|
|
139
|
+
if (this.domItem !== undefined) {
|
|
140
|
+
this.domItem.unmount()
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
if (this.sourceStreams !== undefined) {
|
|
144
|
-
this.sourceStreams.completeStream(['parent'])
|
|
144
|
+
this.sourceStreams.completeStream(['parent'])
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
delete this
|
|
147
|
+
delete this
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
getSourceStream() {
|
|
151
|
-
return this._source
|
|
151
|
+
return this._source$
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
combineDomItems(d) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const container = isNil(d.query) ? d.node : d.query
|
|
156
|
+
const prepend = (node, item) => node.insertBefore(item, node.firstChild)
|
|
157
|
+
const append = (node, item) => node.appendChild(item)
|
|
158
|
+
const after = (node, item) => node.after(item)
|
|
159
159
|
|
|
160
|
-
const defaultFn = prepend
|
|
160
|
+
const defaultFn = prepend
|
|
161
161
|
const attachTypeHash = {
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
appendChild : append,
|
|
163
|
+
after
|
|
164
164
|
}
|
|
165
165
|
// DETERMINE WHETHER TO USE APPEND OR PREPEND
|
|
166
166
|
// ON CONNECTING DOM ITEMS TO EACH OTHER
|
|
167
|
-
//let attachFunc = d.attachType === 'appendChild' ? append : prepend;
|
|
168
|
-
const attachFunc = attachTypeHash[d.attachType] || defaultFn
|
|
169
|
-
attachFunc(container, this.domItem.render())
|
|
170
|
-
this.setAnimateIn(d)
|
|
167
|
+
// let attachFunc = d.attachType === 'appendChild' ? append : prepend;
|
|
168
|
+
const attachFunc = attachTypeHash[d.attachType] || defaultFn
|
|
169
|
+
attachFunc(container, this.domItem.render())
|
|
170
|
+
this.setAnimateIn(d)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
@@ -177,44 +177,43 @@ export class ViewStreamElement {
|
|
|
177
177
|
*/
|
|
178
178
|
|
|
179
179
|
onAttachChildToSelf(p) {
|
|
180
|
-
|
|
181
|
-
this.combineDomItems(data)
|
|
180
|
+
const data = p.childRenderData
|
|
181
|
+
this.combineDomItems(data)
|
|
182
182
|
return {
|
|
183
183
|
action: 'CHILD_ATTACHED',
|
|
184
184
|
$dir: this.$dirs.PI
|
|
185
|
-
}
|
|
185
|
+
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
189
188
|
/**
|
|
190
189
|
*
|
|
191
190
|
* @param {Object} d
|
|
192
191
|
* @returns payload that attaches current child element to parent
|
|
193
192
|
*/
|
|
194
193
|
onRenderAndAttachToParent(d) {
|
|
195
|
-
this.onRender(d)
|
|
196
|
-
this.combineDomItems(d)
|
|
194
|
+
this.onRender(d)
|
|
195
|
+
this.combineDomItems(d)
|
|
197
196
|
return {
|
|
198
197
|
action: 'VS_SPAWNED_AND_ATTACHED_TO_PARENT',
|
|
199
198
|
el: this.domItem.el,
|
|
200
199
|
$dir: this.$dirs.PI
|
|
201
|
-
}
|
|
200
|
+
}
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
renderDomItem(d) {
|
|
205
|
-
const [tagName,attributes,data,template]=d
|
|
206
|
-
this.domItem = new DomElement({tagName,attributes,data,template})
|
|
207
|
-
return this.domItem
|
|
204
|
+
const [tagName, attributes, data, template] = d
|
|
205
|
+
this.domItem = new DomElement({ tagName, attributes, data, template })
|
|
206
|
+
return this.domItem
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
onRender(d) {
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
const getEl = (data) => this.renderDomItem(data)
|
|
211
|
+
const el = getEl(props(['tagName', 'domAttributes', 'data', 'template'], d))
|
|
213
212
|
return {
|
|
214
213
|
action: 'VS_SPAWNED',
|
|
215
214
|
el,
|
|
216
215
|
$dir: this.$dirs.I
|
|
217
|
-
}
|
|
216
|
+
}
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
extendedMethods(data) {
|
|
@@ -227,14 +226,14 @@ export class ViewStreamElement {
|
|
|
227
226
|
* Payload containing the action, internal observable and element.
|
|
228
227
|
*/
|
|
229
228
|
onRenderAndAttachToDom(d) {
|
|
230
|
-
|
|
231
|
-
d.attachData
|
|
232
|
-
this.combineDomItems(d.attachData)
|
|
229
|
+
const getEl = (data) => this.renderDomItem(data)
|
|
230
|
+
d.attachData.el = getEl(props(['tagName', 'domAttributes', 'data', 'template'], d))
|
|
231
|
+
this.combineDomItems(d.attachData)
|
|
233
232
|
return {
|
|
234
233
|
action: 'VS_SPAWNED_AND_ATTACHED_TO_DOM',
|
|
235
|
-
el: d.attachData
|
|
234
|
+
el: d.attachData.el.el,
|
|
236
235
|
$dir: this.$dirs.CI
|
|
237
|
-
}
|
|
236
|
+
}
|
|
238
237
|
}
|
|
239
238
|
|
|
240
239
|
/**
|
|
@@ -244,13 +243,13 @@ export class ViewStreamElement {
|
|
|
244
243
|
* @param {Object} payload
|
|
245
244
|
*/
|
|
246
245
|
onObsSinkSubscribe(payload) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
const action = payload.action
|
|
247
|
+
const defaultToFn = defaultTo((data) => this.extendedMethods(data))
|
|
248
|
+
const fn = defaultToFn(this.options.hashMethods[action])
|
|
249
|
+
const data = fn(payload)
|
|
250
|
+
const sendData = (d) => this._source$.next(d)
|
|
252
251
|
if (data !== undefined) {
|
|
253
|
-
sendData(Object.freeze(data))
|
|
252
|
+
sendData(Object.freeze(data))
|
|
254
253
|
}
|
|
255
254
|
}
|
|
256
255
|
|
|
@@ -258,6 +257,6 @@ export class ViewStreamElement {
|
|
|
258
257
|
// ==================================
|
|
259
258
|
// BASE CORE MIXINS
|
|
260
259
|
// ==================================
|
|
261
|
-
//let coreMixins = baseCoreMixins();
|
|
260
|
+
// let coreMixins = baseCoreMixins();
|
|
262
261
|
}
|
|
263
262
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {SpyneAppProperties} from '../utils/spyne-app-properties'
|
|
2
|
-
import {safeClone} from '../utils/safe-clone'
|
|
3
|
-
import { gc } from '../utils/gc'
|
|
1
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
2
|
+
import { safeClone } from '../utils/safe-clone'
|
|
3
|
+
import { gc } from '../utils/gc'
|
|
4
4
|
import {
|
|
5
5
|
compose,
|
|
6
6
|
clone,
|
|
7
7
|
fromPairs,
|
|
8
8
|
toPairs,
|
|
9
|
-
is
|
|
10
|
-
} from 'ramda'
|
|
9
|
+
is
|
|
10
|
+
} from 'ramda'
|
|
11
11
|
|
|
12
12
|
export class ViewStreamPayload {
|
|
13
13
|
/**
|
|
@@ -25,41 +25,39 @@ export class ViewStreamPayload {
|
|
|
25
25
|
* @param {Boolean} debug
|
|
26
26
|
*/
|
|
27
27
|
constructor(name, observable, data, action = 'subscribe', debug = false) {
|
|
28
|
-
//this.addMixins();
|
|
28
|
+
// this.addMixins();
|
|
29
29
|
const options = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
this.sendToDirectorStream(options)
|
|
30
|
+
name,
|
|
31
|
+
observable,
|
|
32
|
+
data,
|
|
33
|
+
action
|
|
34
|
+
}
|
|
35
|
+
this.sendToDirectorStream(options)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
sendToDirectorStream(payload) {
|
|
39
|
-
|
|
40
|
-
const frozenPayload = safeClone(payload)
|
|
41
|
-
//console.log("VS PAYLOAD ",frozenPayload);
|
|
42
|
-
directorStream$.next(frozenPayload)
|
|
43
|
-
payload = undefined
|
|
39
|
+
const directorStream$ = SpyneAppProperties.channelsMap.getStream('DISPATCHER')
|
|
40
|
+
const frozenPayload = safeClone(payload)
|
|
41
|
+
// console.log("VS PAYLOAD ",frozenPayload);
|
|
42
|
+
directorStream$.next(frozenPayload)
|
|
43
|
+
payload = undefined
|
|
44
44
|
|
|
45
|
-
delete this
|
|
45
|
+
delete this
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
static deepClone(o) {
|
|
49
|
-
const isArr = is(Array)
|
|
50
|
-
const isObj = is(Object)
|
|
51
|
-
const isIter = ob => isArr(ob)===false && isObj(ob)===true
|
|
52
|
-
const isIterable = isIter(o)
|
|
53
|
-
return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o)
|
|
54
|
-
|
|
49
|
+
const isArr = is(Array)
|
|
50
|
+
const isObj = is(Object)
|
|
51
|
+
const isIter = ob => isArr(ob) === false && isObj(ob) === true
|
|
52
|
+
const isIterable = isIter(o)
|
|
53
|
+
return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
|
|
58
56
|
static getMouseEventKeys() {
|
|
59
|
-
return ['altKey', 'bubbles', 'cancelBubble', 'cancelable', 'clientX', 'clientY', 'composed', 'ctrlKey', 'currentTarget', 'defaultPrevented', 'detail', 'eventPhase', 'fromElement', 'isTrusted', 'layerX', 'layerY', 'metaKey', 'movementX', 'movementY', 'offsetX', 'offsetY', 'pageX', 'pageY', 'path', 'relatedTarget', 'returnValue', 'screenX', 'screenY', 'shiftKey', 'sourceCapabilities', 'srcElement', 'target', 'timeStamp', 'toElement', 'type', 'view', 'which', 'x', 'y']
|
|
57
|
+
return ['altKey', 'bubbles', 'cancelBubble', 'cancelable', 'clientX', 'clientY', 'composed', 'ctrlKey', 'currentTarget', 'defaultPrevented', 'detail', 'eventPhase', 'fromElement', 'isTrusted', 'layerX', 'layerY', 'metaKey', 'movementX', 'movementY', 'offsetX', 'offsetY', 'pageX', 'pageY', 'path', 'relatedTarget', 'returnValue', 'screenX', 'screenY', 'shiftKey', 'sourceCapabilities', 'srcElement', 'target', 'timeStamp', 'toElement', 'type', 'view', 'which', 'x', 'y']
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
addMixins() {
|
|
63
|
-
this.gc = gc
|
|
61
|
+
this.gc = gc
|
|
64
62
|
}
|
|
65
63
|
}
|