spyne 0.19.1 → 0.20.1
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/.eslintignore +2 -0
- package/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +77 -87
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.js +248 -248
- package/lib/spyne.umd.js +3 -0
- package/lib/spyne.umd.js.LICENSE.txt +16 -0
- package/package.json +48 -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,10 +1,9 @@
|
|
|
1
|
-
import { registeredStreamNames } from './channels-config'
|
|
2
|
-
import { ChannelPayload } from './channel-payload-class'
|
|
3
|
-
import {SpyneAppProperties} from '../utils/spyne-app-properties'
|
|
4
|
-
import {RouteChannelUpdater} from '../utils/route-channel-updater'
|
|
5
|
-
import { ReplaySubject, Subject } from 'rxjs'
|
|
6
|
-
import {filter} from 'rxjs/operators'
|
|
7
|
-
import { map } from 'rxjs/operators';
|
|
1
|
+
import { registeredStreamNames } from './channels-config'
|
|
2
|
+
import { ChannelPayload } from './channel-payload-class'
|
|
3
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
4
|
+
import { RouteChannelUpdater } from '../utils/route-channel-updater'
|
|
5
|
+
import { ReplaySubject, Subject } from 'rxjs'
|
|
6
|
+
import { filter, map } from 'rxjs/operators'
|
|
8
7
|
import {
|
|
9
8
|
ifElse,
|
|
10
9
|
identity,
|
|
@@ -22,8 +21,8 @@ import {
|
|
|
22
21
|
equals,
|
|
23
22
|
prop,
|
|
24
23
|
propEq
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
, map as rMap
|
|
25
|
+
} from 'ramda'
|
|
27
26
|
|
|
28
27
|
export class Channel {
|
|
29
28
|
/**
|
|
@@ -68,37 +67,37 @@ export class Channel {
|
|
|
68
67
|
*
|
|
69
68
|
*/
|
|
70
69
|
constructor(CHANNEL_NAME, props = {}) {
|
|
71
|
-
this.addRegisteredActions.bind(this)
|
|
72
|
-
this.createChannelActionsObj(CHANNEL_NAME, props.extendedActionsArr)
|
|
73
|
-
props.name = CHANNEL_NAME
|
|
74
|
-
props.defaultActions = props.data!==undefined ? [`${props.name}_EVENT`] : []
|
|
75
|
-
this.props = props
|
|
76
|
-
this.props.isRegistered = false
|
|
77
|
-
this.props.isProxy = this.props.isProxy === undefined ? false : this.props.isProxy
|
|
78
|
-
const defaultCachedPayloadBool = this.props
|
|
79
|
-
this.props.sendCachedPayload = this.props.sendCachedPayload === undefined ? defaultCachedPayloadBool : this.props.sendCachedPayload
|
|
80
|
-
this.sendPayloadToRouteChannel = new RouteChannelUpdater(this)
|
|
81
|
-
this.createChannelActionMethods()
|
|
82
|
-
this.streamsController = SpyneAppProperties.channelsMap
|
|
83
|
-
|
|
84
|
-
this.checkForPersistentDataMode = Channel.checkForPersistentDataMode.bind(this)
|
|
85
|
-
this.observer$ = this.props
|
|
86
|
-
|
|
70
|
+
this.addRegisteredActions.bind(this)
|
|
71
|
+
this.createChannelActionsObj(CHANNEL_NAME, props.extendedActionsArr)
|
|
72
|
+
props.name = CHANNEL_NAME
|
|
73
|
+
props.defaultActions = props.data !== undefined ? [`${props.name}_EVENT`] : []
|
|
74
|
+
this.props = props
|
|
75
|
+
this.props.isRegistered = false
|
|
76
|
+
this.props.isProxy = this.props.isProxy === undefined ? false : this.props.isProxy
|
|
77
|
+
const defaultCachedPayloadBool = this.props.data !== undefined
|
|
78
|
+
this.props.sendCachedPayload = this.props.sendCachedPayload === undefined ? defaultCachedPayloadBool : this.props.sendCachedPayload
|
|
79
|
+
this.sendPayloadToRouteChannel = new RouteChannelUpdater(this)
|
|
80
|
+
this.createChannelActionMethods()
|
|
81
|
+
this.streamsController = SpyneAppProperties.channelsMap
|
|
82
|
+
const observer$ = this.getMainObserver()
|
|
83
|
+
this.checkForPersistentDataMode = Channel.checkForPersistentDataMode.bind(this)
|
|
84
|
+
this.observer$ = this.props.observer = observer$
|
|
85
|
+
const dispatcherStream$ = this.streamsController.getStream('DISPATCHER')
|
|
87
86
|
const payloadPredByChannelName = propEq(props.name, 'name')
|
|
88
|
-
dispatcherStream$.pipe(filter(payloadPredByChannelName)).subscribe((val) => this.onReceivedObservable(val))
|
|
87
|
+
dispatcherStream$.pipe(filter(payloadPredByChannelName)).subscribe((val) => this.onReceivedObservable(val))
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
getMainObserver() {
|
|
92
|
-
if (this.streamsController === undefined){
|
|
91
|
+
if (this.streamsController === undefined) {
|
|
93
92
|
console.warn(`Spyne Warning: The following channel, ${this.props.name}, appears to be registered before Spyne has been initialized.`)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
|
|
95
|
+
const proxyExists = this.streamsController.testStream(this.props.name)
|
|
97
96
|
|
|
98
97
|
if (proxyExists === true) {
|
|
99
|
-
return this.streamsController.getProxySubject(this.props.name, this.props.sendCachedPayload)
|
|
98
|
+
return this.streamsController.getProxySubject(this.props.name, this.props.sendCachedPayload)
|
|
100
99
|
} else {
|
|
101
|
-
return this.props.sendCachedPayload === true ? new ReplaySubject(1) : new Subject()
|
|
100
|
+
return this.props.sendCachedPayload === true ? new ReplaySubject(1) : new Subject()
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -116,22 +115,21 @@ export class Channel {
|
|
|
116
115
|
* <p>This method is empty and is called as soon as the Channel has been registered.</p>
|
|
117
116
|
* <p>Tasks such as subscribing to other channels, and sending initial payloads can be added here.</p>
|
|
118
117
|
*/
|
|
119
|
-
onRegistered(props=this.props){
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
onRegistered(props = this.props) {
|
|
119
|
+
if (props.data !== undefined) {
|
|
120
|
+
const action = Object.keys(this.channelActions)[0]
|
|
121
|
+
// console.log("CHANNELS ACTIONS IS ",this.channelActions);
|
|
122
|
+
// Object(this.channelActions).keys[0];
|
|
123
|
+
this.sendChannelPayload(action, props.data)
|
|
124
|
+
}
|
|
127
125
|
}
|
|
128
126
|
|
|
129
127
|
get isProxy() {
|
|
130
|
-
return this.props.isProxy
|
|
128
|
+
return this.props.isProxy
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
get channelName() {
|
|
134
|
-
return this.props.name
|
|
132
|
+
return this.props.name
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
/**
|
|
@@ -140,99 +138,99 @@ export class Channel {
|
|
|
140
138
|
* returns the source observable for the channel
|
|
141
139
|
*/
|
|
142
140
|
get observer() {
|
|
143
|
-
return this.observer
|
|
141
|
+
return this.observer$
|
|
144
142
|
}
|
|
145
143
|
|
|
146
|
-
checkForTraits(){
|
|
147
|
-
const addTraits = (traits)=>{
|
|
148
|
-
if (traits.constructor.name!=='Array'){
|
|
149
|
-
traits = [traits]
|
|
144
|
+
checkForTraits() {
|
|
145
|
+
const addTraits = (traits) => {
|
|
146
|
+
if (traits.constructor.name !== 'Array') {
|
|
147
|
+
traits = [traits]
|
|
148
|
+
}
|
|
149
|
+
const addTrait = (TraitClass) => {
|
|
150
|
+
return new TraitClass(this)
|
|
150
151
|
}
|
|
151
|
-
const addTrait=(TraitClass)=>{
|
|
152
|
-
return new TraitClass(this);
|
|
153
|
-
};
|
|
154
152
|
|
|
155
|
-
traits.forEach(addTrait)
|
|
156
|
-
}
|
|
153
|
+
traits.forEach(addTrait)
|
|
154
|
+
}
|
|
157
155
|
|
|
158
|
-
if (this.props.traits!==undefined){
|
|
159
|
-
addTraits(this.props.traits)
|
|
156
|
+
if (this.props.traits !== undefined) {
|
|
157
|
+
addTraits(this.props.traits)
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
// DO NOT OVERRIDE THIS METHOD
|
|
164
162
|
initializeStream() {
|
|
165
|
-
this.checkForTraits()
|
|
166
|
-
this.onChannelInitialized()
|
|
167
|
-
this.checkForPersistentDataMode()
|
|
168
|
-
this.onRegistered()
|
|
169
|
-
this.props.isRegistered = true
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
this.checkForTraits()
|
|
164
|
+
this.onChannelInitialized()
|
|
165
|
+
this.checkForPersistentDataMode()
|
|
166
|
+
this.onRegistered()
|
|
167
|
+
this.props.isRegistered = true
|
|
172
168
|
}
|
|
173
169
|
|
|
174
|
-
static checkForPersistentDataMode(props=this.props, actionsObj=this.channelActions){
|
|
175
|
-
const actionsObjIsEmpty = isEmpty(actionsObj)
|
|
176
|
-
const dataIsAdded = prop('data', props) !== undefined
|
|
177
|
-
const autoSetToCachedPayload = actionsObjIsEmpty === true && dataIsAdded === true
|
|
178
|
-
const setDefaultActionsObj = ()=>{
|
|
179
|
-
const {name} = props
|
|
180
|
-
const actionStr = `${name}_EVENT
|
|
170
|
+
static checkForPersistentDataMode(props = this.props, actionsObj = this.channelActions) {
|
|
171
|
+
const actionsObjIsEmpty = isEmpty(actionsObj)
|
|
172
|
+
const dataIsAdded = prop('data', props) !== undefined
|
|
173
|
+
const autoSetToCachedPayload = actionsObjIsEmpty === true && dataIsAdded === true
|
|
174
|
+
const setDefaultActionsObj = () => {
|
|
175
|
+
const { name } = props
|
|
176
|
+
const actionStr = `${name}_EVENT`
|
|
181
177
|
return {
|
|
182
178
|
[actionStr] : actionStr
|
|
183
179
|
}
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
if (autoSetToCachedPayload){
|
|
187
|
-
props.sendCachedPayload = true
|
|
188
|
-
actionsObj = setDefaultActionsObj()
|
|
182
|
+
if (autoSetToCachedPayload) {
|
|
183
|
+
props.sendCachedPayload = true
|
|
184
|
+
actionsObj = setDefaultActionsObj()
|
|
189
185
|
|
|
190
|
-
if (this.channelActions!==undefined){
|
|
191
|
-
this.channelActions = actionsObj
|
|
186
|
+
if (this.channelActions !== undefined) {
|
|
187
|
+
this.channelActions = actionsObj
|
|
192
188
|
}
|
|
193
189
|
}
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return {props, actionsObj};
|
|
191
|
+
// console.log("PROPS IS ",{actionsObjIsEmpty, dataIsAdded, props, actionsObj}, this.channelActions)
|
|
192
|
+
return { props, actionsObj }
|
|
198
193
|
}
|
|
199
194
|
|
|
200
195
|
setTrace(bool) {
|
|
201
196
|
}
|
|
202
197
|
|
|
203
|
-
createChannelActionsObj(name, extendedActionsArr=[]) {
|
|
204
|
-
const getActionVal = ifElse(is(String), identity, head)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const converter = str => objOf(str, str)
|
|
208
|
-
|
|
209
|
-
this.channelActions = obj
|
|
198
|
+
createChannelActionsObj(name, extendedActionsArr = []) {
|
|
199
|
+
const getActionVal = ifElse(is(String), identity, head)
|
|
200
|
+
const mainArr = extendedActionsArr.concat(this.addRegisteredActions(name))
|
|
201
|
+
const arr = rMap(getActionVal, mainArr)
|
|
202
|
+
const converter = str => objOf(str, str)
|
|
203
|
+
const obj = mergeAll(chain(converter, arr))
|
|
204
|
+
this.channelActions = obj
|
|
210
205
|
}
|
|
211
206
|
|
|
212
207
|
createChannelActionMethods() {
|
|
213
|
-
const defaultFn = 'onViewStreamInfo'
|
|
214
|
-
const getActionVal = ifElse(is(String), identity, head)
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else {
|
|
221
|
-
console.warn(`"${this.props.name}", REQUIRES THE FOLLOWING METHOD ${methodStr} FOR ACTION, ${val[0]}`);
|
|
208
|
+
const defaultFn = 'onViewStreamInfo'
|
|
209
|
+
const getActionVal = ifElse(is(String), identity, head)
|
|
210
|
+
const delayCheckIfTraitMethodHasBeenAdded = (methodStr, val) => {
|
|
211
|
+
const delayer = () => {
|
|
212
|
+
if (typeof this[methodStr] !== 'function') {
|
|
213
|
+
console.warn(`"${this.props.name}", REQUIRES THE FOLLOWING METHOD ${methodStr} FOR ACTION, ${val[0]}`)
|
|
214
|
+
}
|
|
222
215
|
}
|
|
216
|
+
window.setTimeout(delayer, 100)
|
|
217
|
+
}
|
|
223
218
|
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
const getCustomMethod = val => {
|
|
220
|
+
const methodStr = view(lensIndex(1), val)
|
|
221
|
+
delayCheckIfTraitMethodHasBeenAdded(methodStr, val)
|
|
222
|
+
return methodStr
|
|
223
|
+
}
|
|
226
224
|
|
|
227
|
-
const getArrMethod = ifElse(is(String), always(defaultFn), getCustomMethod)
|
|
225
|
+
const getArrMethod = ifElse(is(String), always(defaultFn), getCustomMethod)
|
|
228
226
|
|
|
229
227
|
const createObj = val => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return [key, method]
|
|
233
|
-
}
|
|
228
|
+
const key = getActionVal(val)
|
|
229
|
+
const method = getArrMethod(val)
|
|
230
|
+
return [key, method]
|
|
231
|
+
}
|
|
234
232
|
|
|
235
|
-
this.channelActionMethods = fromPairs(rMap(createObj, this.addRegisteredActions()))
|
|
233
|
+
this.channelActionMethods = fromPairs(rMap(createObj, this.addRegisteredActions()))
|
|
236
234
|
|
|
237
235
|
// console.log('the channel action methods ',this.channelActionMethods);
|
|
238
236
|
}
|
|
@@ -260,49 +258,51 @@ export class Channel {
|
|
|
260
258
|
*/
|
|
261
259
|
addRegisteredActions() {
|
|
262
260
|
let arr = []
|
|
263
|
-
if (path(['props','data'], this)){
|
|
264
|
-
arr = [`${this.props.name}_EVENT`]
|
|
261
|
+
if (path(['props', 'data'], this)) {
|
|
262
|
+
arr = [`${this.props.name}_EVENT`]
|
|
265
263
|
}
|
|
266
|
-
return arr
|
|
264
|
+
return arr
|
|
267
265
|
}
|
|
268
266
|
|
|
269
267
|
onReceivedObservable(obj) {
|
|
270
|
-
this.onIncomingObservable(obj)
|
|
268
|
+
this.onIncomingObservable(obj)
|
|
271
269
|
}
|
|
272
270
|
|
|
273
271
|
getActionMethodForObservable(obj) {
|
|
274
|
-
obj.unpacked=true
|
|
275
|
-
const defaultFn = this.onViewStreamInfo.bind(this)
|
|
272
|
+
obj.unpacked = true
|
|
273
|
+
const defaultFn = this.onViewStreamInfo.bind(this)
|
|
276
274
|
|
|
277
|
-
|
|
278
|
-
const methodVal = prop(methodStr, this.channelActionMethods)
|
|
275
|
+
const methodStr = path(['data', 'action'], obj)
|
|
276
|
+
const methodVal = prop(methodStr, this.channelActionMethods)
|
|
279
277
|
|
|
280
|
-
let fn = defaultFn
|
|
278
|
+
let fn = defaultFn
|
|
281
279
|
|
|
282
280
|
if (methodVal !== undefined && methodVal !== 'onViewStreamInfo') {
|
|
283
|
-
const methodExists = typeof (this[methodVal]) === 'function'
|
|
281
|
+
const methodExists = typeof (this[methodVal]) === 'function'
|
|
284
282
|
if (methodExists === true) {
|
|
285
|
-
fn = this[methodVal].bind(this)
|
|
283
|
+
fn = this[methodVal].bind(this)
|
|
286
284
|
}
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
return fn
|
|
287
|
+
return fn
|
|
290
288
|
}
|
|
291
289
|
|
|
292
290
|
onIncomingObservable(obj) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
//console.log("INCOMING ",{action, payload, srcElement}, {obj});
|
|
296
|
-
const mergeProps = (d) => mergeAll([d, { action: prop('action', d) }, prop('payload', d), prop('srcElement', d)])
|
|
297
|
-
|
|
291
|
+
const eqsName = equals(obj.name, this.props.name)
|
|
292
|
+
const { action, payload, srcElement } = obj.data
|
|
293
|
+
// console.log("INCOMING ",{action, payload, srcElement}, {obj});
|
|
294
|
+
const mergeProps = (d) => mergeAll([d, { action: prop('action', d) }, prop('payload', d), prop('srcElement', d)])
|
|
295
|
+
const dataObj = obsVal => ({
|
|
298
296
|
clone: () => mergeProps(obj.data),
|
|
299
|
-
action,
|
|
297
|
+
action,
|
|
298
|
+
payload,
|
|
299
|
+
srcElement,
|
|
300
300
|
event: obsVal
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return eqsName === true ? onSuccess(obj) : onError()
|
|
301
|
+
})
|
|
302
|
+
const onSuccess = (obj) => obj.observable.pipe(map(dataObj))
|
|
303
|
+
.subscribe(this.getActionMethodForObservable(obj))
|
|
304
|
+
const onError = () => {}
|
|
305
|
+
return eqsName === true ? onSuccess(obj) : onError()
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
/**
|
|
@@ -327,7 +327,6 @@ export class Channel {
|
|
|
327
327
|
onViewStreamInfo(obj) {
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
|
|
331
330
|
/**
|
|
332
331
|
*
|
|
333
332
|
* @desc
|
|
@@ -357,14 +356,13 @@ export class Channel {
|
|
|
357
356
|
sendChannelPayload(action, payload, srcElement = {}, event = {}, obs$ = this.observer$) {
|
|
358
357
|
// MAKES ALL CHANNEL BASE AND DATA STREAMS CONSISTENT
|
|
359
358
|
|
|
360
|
-
|
|
361
|
-
let channelPayloadItem = new ChannelPayload(this.props.name, action, payload, srcElement, event);
|
|
359
|
+
const channelPayloadItem = new ChannelPayload(this.props.name, action, payload, srcElement, event)
|
|
362
360
|
// console.log("CHANNEL STREEM ITEM ",channelPayloadItem);
|
|
363
361
|
|
|
364
|
-
|
|
365
|
-
//requestAnimationFrame(onNextFrame)
|
|
362
|
+
// const onNextFrame = ()=>obs$.next(channelPayloadItem);
|
|
363
|
+
// requestAnimationFrame(onNextFrame)
|
|
366
364
|
|
|
367
|
-
obs$.next(channelPayloadItem)
|
|
365
|
+
obs$.next(channelPayloadItem)
|
|
368
366
|
}
|
|
369
367
|
|
|
370
368
|
/**
|
|
@@ -374,7 +372,7 @@ export class Channel {
|
|
|
374
372
|
* <p>Knowledge of rxjs is not required to subscribe to and parse Channel data.</p>
|
|
375
373
|
* <p>But accessing the rxjs Subject gives developers the ability to use all of the available rxjs mapping and observable tools.</p>
|
|
376
374
|
*
|
|
377
|
-
* @param {String}
|
|
375
|
+
* @param {String} channelName The registered name of the requested channel.
|
|
378
376
|
* @returns
|
|
379
377
|
* The source rxjs Subject of the requested channel.
|
|
380
378
|
* @example
|
|
@@ -384,31 +382,25 @@ export class Channel {
|
|
|
384
382
|
*
|
|
385
383
|
*
|
|
386
384
|
*/
|
|
387
|
-
getChannel(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
`channel name ${c} is not within ${registeredStreamNames}`)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (payloadFilter!==undefined){
|
|
394
|
-
return obs$.pipe(filter(payloadFilter))
|
|
385
|
+
getChannel(channelName, payloadFilter) {
|
|
386
|
+
const isValidChannel = c => registeredStreamNames().includes(c)
|
|
387
|
+
const error = c => console.warn(
|
|
388
|
+
`channel name ${c} is not within ${registeredStreamNames}`)
|
|
389
|
+
const startSubscribe = (c) => {
|
|
390
|
+
const obs$ = this.streamsController.getStream(c).observer
|
|
391
|
+
if (payloadFilter !== undefined) {
|
|
392
|
+
return obs$.pipe(filter(payloadFilter))
|
|
395
393
|
}
|
|
396
394
|
|
|
397
|
-
return obs
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return fn(
|
|
395
|
+
return obs$
|
|
396
|
+
}
|
|
397
|
+
const fn = ifElse(isValidChannel, startSubscribe, error)
|
|
398
|
+
return fn(channelName)
|
|
401
399
|
}
|
|
402
400
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
SpyneAppProperties.doNotTrackChannel(props.channelName);
|
|
401
|
+
static checkForNotTrackFlag(props = {}) {
|
|
402
|
+
if (props.doNotTrack === true) {
|
|
403
|
+
SpyneAppProperties.doNotTrackChannel(props.channelName)
|
|
407
404
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
405
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
406
|
}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {SpyneAppProperties} from '../utils/spyne-app-properties'
|
|
2
|
-
import {compose, path, is} from 'ramda'
|
|
3
|
-
|
|
4
|
-
const Subject = require('rxjs');
|
|
1
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
2
|
+
import { compose, path, is } from 'ramda'
|
|
3
|
+
import { Observable, Subject } from 'rxjs'
|
|
5
4
|
|
|
6
5
|
// console.log('channels config loaded ',R,Rx);
|
|
7
|
-
|
|
6
|
+
const registeredStreamNames = () => ({
|
|
8
7
|
includes: () => SpyneAppProperties.initialized === true ? SpyneAppProperties.listRegisteredChannels() : ['CHANNEL_ROUTE', 'CHANNEL_UI', 'CHANNEL_WINDOW', 'DISPATCHER']
|
|
9
8
|
|
|
10
|
-
})
|
|
9
|
+
})
|
|
11
10
|
|
|
12
11
|
// getGlobalObj().channelsListArr;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const registeredSteps = ['LOAD', 'RENDER', 'MOUNT', 'UNMOUNT', 'DISPOSE', 'GARBAGE_COLLECT', 'UPDATE']
|
|
13
|
+
const registeredLifeStreamTypes = ['parent', 'self', 'child', 'children', 'view']
|
|
14
|
+
const registeredStreamTypes = ['Observable', 'BehaviorSubject', 'Subject', 'Observer', 'Subscriber', 'FromEventObservable']
|
|
15
|
+
const registeredActions = ['subscribe', 'combineLatest']
|
|
16
|
+
const getRxType = (obs) => obs().constructor.name
|
|
18
17
|
// let getObservableType = (obs) => obs.constructor.name;
|
|
19
|
-
|
|
18
|
+
const confirmObservable = (obs) => obs.subscribe !== undefined
|
|
20
19
|
// let pullMainRoute = (str) => str.replace(/^(\/?)(.*)(\/)(.*)/g, '$2');
|
|
21
|
-
let baseValidations = []; let viewInfoValidations = []; let uiValidations = []
|
|
22
|
-
let lifestreamValidations = []; let stepValidations = []; let stepDisposeValidations = []; let stepUpdateValidations = []
|
|
23
|
-
let routeValidations = []; let StreamsConfig = []
|
|
20
|
+
let baseValidations = []; let viewInfoValidations = []; let uiValidations = []
|
|
21
|
+
let lifestreamValidations = []; let stepValidations = []; let stepDisposeValidations = []; let stepUpdateValidations = []
|
|
22
|
+
let routeValidations = []; let StreamsConfig = []
|
|
24
23
|
|
|
25
24
|
if (compose !== undefined && Observable !== undefined) {
|
|
26
25
|
// ===========================================================================
|
|
@@ -33,7 +32,7 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
33
32
|
},
|
|
34
33
|
|
|
35
34
|
{
|
|
36
|
-
error:
|
|
35
|
+
error: 'param \'observable\' must contain a valid Observable',
|
|
37
36
|
// predicate: payload => registeredStreamTypes.includes(getObservableType(payload.observable))
|
|
38
37
|
predicate: payload => confirmObservable(payload.observable)
|
|
39
38
|
},
|
|
@@ -42,7 +41,7 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
42
41
|
predicate: payload => registeredActions.includes(payload.action)
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
]
|
|
44
|
+
]
|
|
46
45
|
// ===========================================================================
|
|
47
46
|
// THESE VALIDATIONS ARE CONCATENATED WHEN THE OBSERVABLE REFERS TO A VIEW
|
|
48
47
|
// ===========================================================================
|
|
@@ -56,18 +55,18 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
56
55
|
predicate: compose(is(String),
|
|
57
56
|
path(['data', 'srcElement', 'id']))
|
|
58
57
|
}
|
|
59
|
-
]
|
|
58
|
+
]
|
|
60
59
|
|
|
61
60
|
// ===========================================================================
|
|
62
61
|
// NO SPECIFIC UI VALIDATIONS AT THIS TIME -- IT JUST ADD OTHERS
|
|
63
62
|
// ===========================================================================
|
|
64
63
|
uiValidations = function() {
|
|
65
|
-
|
|
66
|
-
return uiValidations.concat(baseValidations).concat(viewInfoValidations)
|
|
67
|
-
}
|
|
64
|
+
const uiValidations = []
|
|
65
|
+
return uiValidations.concat(baseValidations).concat(viewInfoValidations)
|
|
66
|
+
}
|
|
68
67
|
// ===========================================================================
|
|
69
68
|
// NO SPECIFIC LIFESTREAM VALIDATIONS AT THIS TIME -- IT JUST ADD OTHERS
|
|
70
|
-
|
|
69
|
+
const lifeStreamValidations = [
|
|
71
70
|
|
|
72
71
|
{
|
|
73
72
|
error: `need to match a valid name within ${registeredStreamTypes}`,
|
|
@@ -87,46 +86,46 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
87
86
|
error: 'viewId needs to be added ',
|
|
88
87
|
predicate: payload => payload.viewId !== undefined
|
|
89
88
|
}
|
|
90
|
-
]
|
|
89
|
+
]
|
|
91
90
|
|
|
92
91
|
stepValidations = function() {
|
|
93
|
-
|
|
94
|
-
return stepValidations.concat(lifeStreamValidations)
|
|
95
|
-
}
|
|
92
|
+
const stepValidations = []
|
|
93
|
+
return stepValidations.concat(lifeStreamValidations)
|
|
94
|
+
}
|
|
96
95
|
|
|
97
96
|
stepDisposeValidations = function() {
|
|
98
|
-
|
|
97
|
+
const stepUpdateValidations = [
|
|
99
98
|
{
|
|
100
99
|
error: 'DISPOSE STEP requires a disposeItem param in the data object',
|
|
101
100
|
predicate: payload => payload.STEP === 'DISPOSE' &&
|
|
102
101
|
payload.data.disposeItems !== undefined
|
|
103
102
|
}
|
|
104
|
-
]
|
|
105
|
-
return stepUpdateValidations.concat(lifeStreamValidations)
|
|
106
|
-
}
|
|
103
|
+
]
|
|
104
|
+
return stepUpdateValidations.concat(lifeStreamValidations)
|
|
105
|
+
}
|
|
107
106
|
|
|
108
107
|
stepUpdateValidations = function() {
|
|
109
|
-
|
|
108
|
+
const stepUpdateValidations = [
|
|
110
109
|
{
|
|
111
110
|
error: 'UPDATE STEP requires a data object ',
|
|
112
111
|
predicate: payload => payload.STEP === 'UPDATE' && payload.data !==
|
|
113
112
|
undefined
|
|
114
113
|
}
|
|
115
|
-
]
|
|
116
|
-
return stepUpdateValidations.concat(lifeStreamValidations)
|
|
117
|
-
}
|
|
114
|
+
]
|
|
115
|
+
return stepUpdateValidations.concat(lifeStreamValidations)
|
|
116
|
+
}
|
|
118
117
|
// ===========================================================================
|
|
119
118
|
// lifestreamValidations
|
|
120
119
|
// ===========================================================================
|
|
121
120
|
lifestreamValidations = function() {
|
|
122
121
|
return lifeStreamValidations.concat(baseValidations)
|
|
123
|
-
.concat(viewInfoValidations)
|
|
124
|
-
}
|
|
122
|
+
.concat(viewInfoValidations)
|
|
123
|
+
}
|
|
125
124
|
// ===========================================================================
|
|
126
125
|
// HERE IS THE ROUTE VALIDATIONS
|
|
127
126
|
// ===========================================================================
|
|
128
127
|
routeValidations = function() {
|
|
129
|
-
|
|
128
|
+
const routeValidations = [
|
|
130
129
|
/*
|
|
131
130
|
*
|
|
132
131
|
{
|
|
@@ -136,9 +135,9 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
136
135
|
*
|
|
137
136
|
*/
|
|
138
137
|
|
|
139
|
-
]
|
|
140
|
-
return routeValidations.concat(baseValidations).concat(viewInfoValidations)
|
|
141
|
-
}
|
|
138
|
+
]
|
|
139
|
+
return routeValidations.concat(baseValidations).concat(viewInfoValidations)
|
|
140
|
+
}
|
|
142
141
|
// ===========================================================================
|
|
143
142
|
/*
|
|
144
143
|
* THE IDEA OF StreamsConfig IS TO COMPLETELY GENERATE ALL APP STREAMS USING THIS OBJECT
|
|
@@ -146,13 +145,13 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
146
145
|
*/
|
|
147
146
|
// ===========================================================================
|
|
148
147
|
StreamsConfig = function() {
|
|
149
|
-
|
|
148
|
+
const streamValidations = [
|
|
150
149
|
{
|
|
151
|
-
error:
|
|
150
|
+
error: 'param \'name\' must be of a registered type',
|
|
152
151
|
predicate: payload => registeredStreamNames().includes(payload.name)
|
|
153
152
|
},
|
|
154
153
|
{
|
|
155
|
-
error:
|
|
154
|
+
error: 'param \'observable\' must contain a valid Observable',
|
|
156
155
|
predicate: payload => registeredStreamTypes.includes(
|
|
157
156
|
getRxType(payload.observable))
|
|
158
157
|
},
|
|
@@ -161,7 +160,7 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
161
160
|
predicate: payload => registeredActions.includes(payload.action)
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
]
|
|
163
|
+
]
|
|
165
164
|
|
|
166
165
|
return {
|
|
167
166
|
streams: [
|
|
@@ -192,9 +191,9 @@ if (compose !== undefined && Observable !== undefined) {
|
|
|
192
191
|
validations: streamValidations
|
|
193
192
|
}
|
|
194
193
|
]
|
|
195
|
-
}
|
|
196
|
-
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
197
196
|
}
|
|
198
197
|
export {
|
|
199
198
|
stepDisposeValidations, stepUpdateValidations, stepValidations, uiValidations, routeValidations, lifestreamValidations, registeredStreamNames, StreamsConfig
|
|
200
|
-
}
|
|
199
|
+
}
|