spyne 0.14.8 → 0.17.3
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/.travis.yml +2 -2
- package/karma.conf.js +27 -20
- package/lib/channel-action-filter.test.2418910233.js +20 -0
- package/lib/channel-dom.test.1490741340.js +20 -0
- package/lib/channel-fetch-util.test.3681936279.js +20 -0
- package/lib/channel-fetch.test.380764798.js +20 -0
- package/lib/channel-payload-class.test.2325155642.js +20 -0
- package/lib/channel-payload-filter.test.1598505124.js +20 -0
- package/lib/channel-route.test.921296320.js +20 -0
- package/lib/channel-stream-item.test.159699696.js +20 -0
- package/lib/channel-ui.test.291129654.js +20 -0
- package/lib/channel-util-dom.test.181212370.js +20 -0
- package/lib/channel.test.706832124.js +20 -0
- package/lib/commons.js +50363 -0
- package/lib/dom-el-selectors.test.3296414834.js +20 -0
- package/lib/dom-el-template.test.1459850380.js +20 -0
- package/lib/dom-el.test.2449130808.js +20 -0
- package/lib/frp-tools.test.1620088187.js +20 -0
- package/lib/import.test.723835576.js +20 -0
- package/lib/index.test.2146503294.js +20 -0
- package/lib/plugins-methods.test.3482246428.js +20 -0
- package/lib/route-utils.test.2932649409.js +20 -0
- package/lib/runtime.js +174 -0
- package/lib/spyne-app-properties.test.485192211.js +20 -0
- package/lib/spyne-app.test.4150724251.js +20 -0
- package/lib/spyne-plugin.test.3993976219.js +20 -0
- package/lib/spyne.js +15477 -18467
- package/lib/spyne.min.js +2 -12
- package/lib/spyne.min.js.LICENSE.txt +10 -0
- package/lib/url-utils.test.3668806082.js +20 -0
- package/lib/view-stream-broadcaster.test.2534955231.js +20 -0
- package/lib/view-stream-enhancer-loader.test.3395418180.js +20 -0
- package/lib/view-stream-enhancer.test.1043626253.js +20 -0
- package/lib/view-stream.test.1765314964.js +20 -0
- package/package.json +37 -65
- package/src/spyne/channels/channel-fetch-class.js +24 -1
- package/src/spyne/channels/channel-payload-class.js +102 -11
- package/src/spyne/channels/channel-proxy.js +6 -4
- package/src/spyne/channels/channel.js +66 -6
- package/src/spyne/channels/channels-config.js +2 -2
- package/src/spyne/channels/{channels-delegator.js → channels-map.js} +37 -21
- package/src/spyne/channels/spyne-channel-lifecycle.js +1 -1
- package/src/spyne/channels/spyne-channel-route.js +95 -15
- package/src/spyne/channels/spyne-channel-ui.js +1 -0
- package/src/spyne/channels/spyne-channel-window.js +60 -20
- package/src/spyne/spyne-app.js +181 -0
- package/src/spyne/spyne-plugins.js +146 -0
- package/src/spyne/spyne.js +11 -139
- package/src/spyne/utils/channel-fetch-util.js +1 -1
- package/src/spyne/utils/channel-payload-filter.js +166 -30
- package/src/spyne/utils/frp-tools.js +21 -1
- package/src/spyne/utils/mixins/base-streams-mixins.js +1 -0
- package/src/spyne/utils/spyne-app-properties.js +213 -0
- package/src/spyne/utils/spyne-logger.js +18 -0
- package/src/spyne/utils/spyne-plugins-methods.js +105 -0
- package/src/spyne/utils/spyne-scroll-lock.js +95 -0
- package/src/spyne/utils/spyne-utils-channel-route-url.js +2 -1
- package/src/spyne/utils/spyne-utils-channel-route.js +3 -1
- package/src/spyne/utils/spyne-utils-channel-window.js +2 -2
- package/src/spyne/views/dom-element-template.js +52 -23
- package/src/spyne/views/dom-element.js +11 -2
- package/src/spyne/views/view-stream-broadcaster.js +3 -3
- package/src/spyne/views/view-stream-payload.js +76 -15
- package/src/spyne/views/view-stream-selector.js +2 -2
- package/src/spyne/views/view-stream.js +219 -115
- package/src/tests/channels/channel-fetch.test.js +102 -0
- package/src/tests/channels/channel-payload-class.test.js +149 -0
- package/src/tests/channels/channel-payload-filter.test.js +298 -0
- package/src/tests/channels/channel-route.test.js +76 -1
- package/src/tests/channels/channel-stream-item.test.js +3 -2
- package/src/tests/channels/channel.test.js +38 -0
- package/src/tests/channels/route-utils.test.js +1 -1
- package/src/tests/index.js +0 -1
- package/src/tests/index.test.js +6 -0
- package/src/tests/mocks/channel-payload-data.js +93 -1
- package/src/tests/mocks/msf-user-data-small.json +4103 -0
- package/src/tests/mocks/msf-user-data.json +47035 -0
- package/src/tests/mocks/utils-data.js +20 -2
- package/src/tests/spyne-app.test.js +27 -0
- package/src/tests/spyne-plugin.test.js +49 -0
- package/src/tests/utils/channel-action-filter.test.js +22 -11
- package/src/tests/utils/channel-data-packet-generator.unused.js +119 -0
- package/src/tests/utils/plugins-methods.test.js +103 -0
- package/src/tests/utils/spyne-app-properties.test.js +11 -0
- package/src/tests/views/dom-el-selectors.test.js +1 -1
- package/webpack.config.js +30 -15
- package/lib/spyne.js.map +0 -1
- package/src/spyne/utils/viewstream-dom-utils.js +0 -8
|
@@ -4,16 +4,17 @@ import { SpyneChannelRoute } from './spyne-channel-route';
|
|
|
4
4
|
import { SpyneChannelUI } from './spyne-channel-ui';
|
|
5
5
|
import { SpyneChannelWindow } from './spyne-channel-window';
|
|
6
6
|
import { SpyneChannelLifecycle } from './spyne-channel-lifecycle';
|
|
7
|
-
import { validate } from '../utils/channel-config-validator';
|
|
7
|
+
//import { validate } from '../utils/channel-config-validator';
|
|
8
8
|
|
|
9
9
|
import { Subject } from 'rxjs';
|
|
10
10
|
import { ChannelProxy } from './channel-proxy';
|
|
11
|
-
import {propEq, pluck, prop, filter, reject, compose, join} from 'ramda';
|
|
11
|
+
import {propEq, pluck, prop, filter, pathEq, clone, reject, compose, join} from 'ramda';
|
|
12
12
|
const rMap = require('ramda').map;
|
|
13
|
+
const _map = new Map();
|
|
13
14
|
|
|
14
15
|
// import * as R from 'ramda';
|
|
15
16
|
|
|
16
|
-
export class
|
|
17
|
+
export class ChannelsMap {
|
|
17
18
|
/**
|
|
18
19
|
* @module ChannelsDelegator
|
|
19
20
|
* @type internal
|
|
@@ -28,14 +29,17 @@ export class ChannelsDelegator {
|
|
|
28
29
|
|
|
29
30
|
constructor() {
|
|
30
31
|
this.addMixins();
|
|
31
|
-
|
|
32
|
+
//_map = new Map();
|
|
32
33
|
|
|
33
34
|
// console.log('Rx is ',Rx);
|
|
34
35
|
// console.log('RX IS ', Subject);
|
|
35
|
-
|
|
36
|
-
this.listRegisteredChannels =
|
|
37
|
-
this.getChannelsList =
|
|
38
|
-
|
|
36
|
+
_map.set('DISPATCHER', new Subject());
|
|
37
|
+
this.listRegisteredChannels = ChannelsMap.listRegisteredChannels.bind(this);
|
|
38
|
+
this.getChannelsList = ChannelsMap.getChannelsList.bind(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get map(){
|
|
42
|
+
return _map;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
static getChannelsList() {
|
|
@@ -44,7 +48,7 @@ export class ChannelsDelegator {
|
|
|
44
48
|
let val = k[1].constructor.name;
|
|
45
49
|
return { key, val };
|
|
46
50
|
};
|
|
47
|
-
return Array.from(
|
|
51
|
+
return Array.from(_map, proxyMapFn);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
static listRegisteredChannels(showOnlyProxies = false) {
|
|
@@ -79,59 +83,71 @@ export class ChannelsDelegator {
|
|
|
79
83
|
this.createMainStreams();
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
/*
|
|
82
87
|
createObserver(obj) {
|
|
83
88
|
// RIGHT NOW THIS CREATES THE DISPATCHER STREAM
|
|
84
89
|
validate(obj.validations, obj.init);
|
|
85
|
-
|
|
90
|
+
_map.set(obj.init.name, obj.init.observable());
|
|
86
91
|
}
|
|
92
|
+
*/
|
|
87
93
|
|
|
88
94
|
createMainStreams() {
|
|
89
95
|
this.routeStream = new SpyneChannelRoute();
|
|
90
|
-
|
|
96
|
+
_map.set('CHANNEL_ROUTE', this.routeStream);
|
|
91
97
|
|
|
92
98
|
this.uiStream = new SpyneChannelUI();
|
|
93
|
-
|
|
99
|
+
_map.set('CHANNEL_UI', this.uiStream);
|
|
94
100
|
|
|
95
101
|
this.domStream = new SpyneChannelWindow();
|
|
96
|
-
|
|
102
|
+
_map.set('CHANNEL_WINDOW', this.domStream);
|
|
97
103
|
|
|
98
104
|
this.viewStreamLifecycle = new SpyneChannelLifecycle();
|
|
99
|
-
|
|
105
|
+
_map.set('CHANNEL_LIFECYCLE', this.viewStreamLifecycle);
|
|
100
106
|
|
|
101
107
|
this.routeStream.initializeStream();
|
|
102
108
|
this.domStream.initializeStream();
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
addKeyEvent(key) {
|
|
106
|
-
|
|
112
|
+
_map.get('UI').addKeyEvent(key);
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
registerStream(val) {
|
|
110
116
|
let name = val.channelName;
|
|
111
|
-
|
|
117
|
+
const nameExists = _map.has(name);
|
|
118
|
+
if (nameExists){
|
|
119
|
+
const isAlreadyRegisterd = compose(pathEq(['props', 'isRegistered'], true))(_map.get(name));
|
|
120
|
+
if(isAlreadyRegisterd){
|
|
121
|
+
console.warn(`Spyne Warning: The Channel, ${name}, has already been registered!`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
_map.set(name, val);
|
|
112
128
|
val.initializeStream();
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
getChannelActions(str) {
|
|
116
|
-
return
|
|
132
|
+
return _map.get(str).addRegisteredActions();
|
|
117
133
|
}
|
|
118
134
|
|
|
119
135
|
getProxySubject(name, isReplaySubject = false) {
|
|
120
136
|
let subjectType = isReplaySubject === true ? 'replaySubject' : 'subject';
|
|
121
137
|
|
|
122
|
-
return
|
|
138
|
+
return _map.get(name)[subjectType];
|
|
123
139
|
}
|
|
124
140
|
|
|
125
141
|
testStream(name) {
|
|
126
|
-
return
|
|
142
|
+
return _map.get(name) !== undefined;
|
|
127
143
|
}
|
|
128
144
|
|
|
129
145
|
getStream(name) {
|
|
130
146
|
if (this.testStream(name) === false) {
|
|
131
|
-
|
|
147
|
+
_map.set(name, new ChannelProxy(name));
|
|
132
148
|
}
|
|
133
149
|
|
|
134
|
-
return
|
|
150
|
+
return _map.get(name);
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
addMixins() {
|
|
@@ -30,7 +30,7 @@ export class SpyneChannelLifecycle extends Channel {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
onViewStreamInfo(obj) {
|
|
33
|
-
let {data, action, srcElement} = obj
|
|
33
|
+
let {data, action, srcElement} = obj;
|
|
34
34
|
let payload = srcElement;
|
|
35
35
|
payload['action'] = action;
|
|
36
36
|
this.onSendEvent(action, payload);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
2
|
import { SpyneUtilsChannelRouteUrl } from '../utils/spyne-utils-channel-route-url';
|
|
3
3
|
import { SpyneUtilsChannelRoute } from '../utils/spyne-utils-channel-route';
|
|
4
|
+
import {SpyneAppProperties} from '../utils/spyne-app-properties';
|
|
4
5
|
import { ReplaySubject, merge } from 'rxjs';
|
|
5
6
|
import { map } from 'rxjs/operators';
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
clone,
|
|
9
10
|
pick,
|
|
11
|
+
find,
|
|
10
12
|
omit,
|
|
11
13
|
over,
|
|
12
14
|
mergeRight,
|
|
@@ -28,9 +30,10 @@ import {
|
|
|
28
30
|
concat,
|
|
29
31
|
when,
|
|
30
32
|
complement,
|
|
33
|
+
reverse,
|
|
31
34
|
curryN,
|
|
32
35
|
__,
|
|
33
|
-
test, replace,
|
|
36
|
+
test, replace, fromPairs, toPairs, forEach, reduceRight, reduce
|
|
34
37
|
} from 'ramda';
|
|
35
38
|
const ramdaFilter = require('ramda').filter;
|
|
36
39
|
const rMerge = require('ramda').mergeRight;
|
|
@@ -143,10 +146,10 @@ export class SpyneChannelRoute extends Channel {
|
|
|
143
146
|
|
|
144
147
|
checkConfigForHash(){
|
|
145
148
|
// LEGACY CHECK TO SIMPLIFY CONFIG FOR HASH;
|
|
146
|
-
let isHashType =
|
|
149
|
+
let isHashType = SpyneAppProperties.config.channels.ROUTE.type==='hash';
|
|
147
150
|
if (isHashType === true){
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
SpyneAppProperties.config.channels.ROUTE.type = 'slash';
|
|
152
|
+
SpyneAppProperties.config.channels.ROUTE.isHash = true;
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
}
|
|
@@ -176,13 +179,10 @@ export class SpyneChannelRoute extends Channel {
|
|
|
176
179
|
|
|
177
180
|
const newRoutesObj = pick(['isHash', 'isHidden', 'routes','type'], e.payload);
|
|
178
181
|
|
|
179
|
-
|
|
182
|
+
SpyneAppProperties.config.channels.ROUTE = mergeRight(SpyneAppProperties.config.channels.ROUTE, newRoutesObj);
|
|
180
183
|
|
|
181
|
-
const clonedRoute = clone(window.Spyne.config.channels.ROUTE);
|
|
182
184
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
window.Spyne.config = SpyneUtilsChannelRoute.conformRouteObject(window.Spyne.config);
|
|
185
|
+
SpyneAppProperties.conformRouteConfig();
|
|
186
186
|
|
|
187
187
|
|
|
188
188
|
const routeConfig = this.getRouteConfig();
|
|
@@ -192,12 +192,11 @@ export class SpyneChannelRoute extends Channel {
|
|
|
192
192
|
this.bindStaticMethodsWithConfigData();
|
|
193
193
|
|
|
194
194
|
|
|
195
|
-
this.sendChannelPayload(action, routeConfig, {}, {},
|
|
196
|
-
this.navToStream$);
|
|
195
|
+
this.sendChannelPayload(action, routeConfig, {}, {}, this.navToStream$);
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
getRouteConfig() {
|
|
200
|
-
const spyneConfig =
|
|
199
|
+
const spyneConfig = SpyneAppProperties.config;
|
|
201
200
|
let routeConfig = path(['channels', 'ROUTE'], spyneConfig);
|
|
202
201
|
if (routeConfig.type === 'query') {
|
|
203
202
|
routeConfig.isHash = false;
|
|
@@ -250,7 +249,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
250
249
|
payload = rMerge(payload, keywordArrs);
|
|
251
250
|
// console.log("SEND STREAM onIncomingDomEvent", payload, keywordArrs);;
|
|
252
251
|
// payload = SpyneChannelRoute.removeSSID(payload);
|
|
253
|
-
this.sendChannelPayload(action, payload, undefined,
|
|
252
|
+
this.sendChannelPayload(action, payload, undefined, evt, this.navToStream$);
|
|
254
253
|
|
|
255
254
|
}
|
|
256
255
|
|
|
@@ -297,10 +296,88 @@ export class SpyneChannelRoute extends Channel {
|
|
|
297
296
|
*/
|
|
298
297
|
|
|
299
298
|
|
|
299
|
+
static checkForEndRoute(pl, routeConfigJson = this.routeConfigJson, debugBool){
|
|
300
|
+
|
|
301
|
+
const endRoute = compose(equals("true"), path(['payload', 'endRoute']))(pl);
|
|
302
|
+
//console.log('pl and aend route',{endRoute, pl})
|
|
303
|
+
|
|
304
|
+
if (endRoute!==true){
|
|
305
|
+
return pl;
|
|
306
|
+
}
|
|
307
|
+
const win = window || {};
|
|
308
|
+
const debug = debugBool !== undefined ? debugBool : SpyneAppProperties.debug === true;
|
|
309
|
+
const {payload} = pl;
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
const getPropVal = (routePath) => {
|
|
313
|
+
const routeName = prop('routeName', routePath);
|
|
314
|
+
if (routeName){
|
|
315
|
+
const keysArr = compose(keys, omit(['routeName']))(routePath);
|
|
316
|
+
let routeNameVal = payload[routeName]
|
|
317
|
+
const pred = arrStr => new RegExp(`^${arrStr}$`).test(routeNameVal);
|
|
318
|
+
const routeVal = find(pred, keysArr);
|
|
319
|
+
// console.log('route val is ',{routeVal, keysArr})
|
|
320
|
+
return routeVal;
|
|
321
|
+
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let iter = 0;
|
|
326
|
+
const onReduceRoutePaths = (acc=[], arr)=>{
|
|
327
|
+
const [key, val] = arr;
|
|
328
|
+
const {routePath} = val;
|
|
329
|
+
const routeName = prop('routeName', routePath);
|
|
330
|
+
const routeNameVal = getPropVal(routePath);
|
|
331
|
+
const isObj = is(Object, val);
|
|
332
|
+
const isArr = is(Array, val);
|
|
333
|
+
const iterObj = isObj === true && isArr === false;
|
|
334
|
+
iter = iter+1;
|
|
335
|
+
if (iterObj) {
|
|
336
|
+
const nextRoutePath = routePath[routeNameVal];
|
|
337
|
+
//console.log('key is ',{iter,acc,key, routeName, routeNameVal, iterObj, nextRoutePath});
|
|
338
|
+
if (nextRoutePath){
|
|
339
|
+
compose(reverse, reduce(onReduceRoutePaths, acc), toPairs)({nextRoutePath})
|
|
340
|
+
} else{
|
|
341
|
+
//console.log("KEY IS ",{iter,key, routeName, routeNameVal})
|
|
342
|
+
if (iter===1){
|
|
343
|
+
if (debug) {
|
|
344
|
+
console.warn(`Spyne Warning: use of end route method should add start route value of "${routeName}".`)
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
acc.push(routeName)
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// compose(reduce(onReduceRoutePaths), toPairs)(nextRoutePath);
|
|
351
|
+
}
|
|
352
|
+
return acc;
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const {routes} = routeConfigJson;
|
|
357
|
+
|
|
358
|
+
const endRouteValArr = compose(reverse, reduce(onReduceRoutePaths, []), toPairs)({routes});
|
|
359
|
+
//console.log('end route val arr ',endRouteValArr);
|
|
360
|
+
if(endRouteValArr.length===1){
|
|
361
|
+
const endRouteVal = endRouteValArr[0];
|
|
362
|
+
pl.payload[endRouteVal] = "";
|
|
363
|
+
} else{
|
|
364
|
+
if (debug) {
|
|
365
|
+
// console.warn(`Spyne Warning: the end route param did not yield any results for ${JSON.stringify(payload)} `);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return pl;
|
|
370
|
+
|
|
371
|
+
}
|
|
372
|
+
|
|
300
373
|
onViewStreamInfo(pl) {
|
|
301
374
|
let action = this.channelActions.CHANNEL_ROUTE_CHANGE_EVENT;
|
|
302
375
|
SpyneChannelRoute.checkForEventMethods(pl);
|
|
376
|
+
pl = this.checkForEndRoute(pl);
|
|
303
377
|
let payload = this.getDataFromParams(pl);
|
|
378
|
+
const {routeConfigJson} = this;
|
|
379
|
+
//console.log("LOADING ROUTE FROM LINK ", {pl, payload,routeConfigJson})
|
|
380
|
+
|
|
304
381
|
let srcElement = prop('srcElement', pl);
|
|
305
382
|
let event = prop('event', pl);
|
|
306
383
|
let changeLocationBool = !payload.isHidden;
|
|
@@ -353,7 +430,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
353
430
|
let isHash = config.isHash;
|
|
354
431
|
let isHidden = config.isHidden;
|
|
355
432
|
let routeType = config.type;
|
|
356
|
-
return { routeCount, isDeepLink, isHash, isHidden, routeType };
|
|
433
|
+
return { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType };
|
|
357
434
|
}
|
|
358
435
|
|
|
359
436
|
static getDataFromParams(pl, config = this.routeConfigJson) {
|
|
@@ -373,7 +450,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
373
450
|
|
|
374
451
|
routeData = rMerge(dataFromStr.routeData, routeData);
|
|
375
452
|
|
|
376
|
-
let { routeCount, isDeepLink, isHash, isHidden, routeType } = this.getExtraPayloadParams(
|
|
453
|
+
let { routeCount, isDeepLink, isHash,isHistory, isHidden, routeType } = this.getExtraPayloadParams(
|
|
377
454
|
config);
|
|
378
455
|
return {
|
|
379
456
|
isDeepLink,
|
|
@@ -384,6 +461,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
384
461
|
routeValue,
|
|
385
462
|
isHash,
|
|
386
463
|
isHidden,
|
|
464
|
+
isHistory,
|
|
387
465
|
routeType
|
|
388
466
|
};
|
|
389
467
|
}
|
|
@@ -407,6 +485,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
407
485
|
routeValue,
|
|
408
486
|
isHash,
|
|
409
487
|
isHidden,
|
|
488
|
+
isHistory,
|
|
410
489
|
routeType
|
|
411
490
|
};
|
|
412
491
|
return obj;
|
|
@@ -496,6 +575,7 @@ export class SpyneChannelRoute extends Channel {
|
|
|
496
575
|
}
|
|
497
576
|
|
|
498
577
|
bindStaticMethods() {
|
|
578
|
+
this.checkForEndRoute = SpyneChannelRoute.checkForEndRoute.bind(this);
|
|
499
579
|
this.getIsDeepLinkBool = SpyneChannelRoute.getIsDeepLinkBool.bind(this);
|
|
500
580
|
this.getDataFromLocationStr = SpyneChannelRoute.getDataFromLocationStr.bind(
|
|
501
581
|
this);
|
|
@@ -44,6 +44,7 @@ export class SpyneChannelUI extends Channel {
|
|
|
44
44
|
'CHANNEL_UI_CHECKBOXSTATECHANGE_EVENT',
|
|
45
45
|
'CHANNEL_UI_CLICK_EVENT',
|
|
46
46
|
'CHANNEL_UI_COMPLETE_EVENT',
|
|
47
|
+
'CHANNEL_UI_CONTEXTMENU_EVENT',
|
|
47
48
|
'CHANNEL_UI_COPY_EVENT',
|
|
48
49
|
'CHANNEL_UI_CUT_EVENT',
|
|
49
50
|
'CHANNEL_UI_DBLCLICK_EVENT',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Channel } from './channel';
|
|
2
2
|
import { checkIfObjIsNotEmptyOrNil } from '../utils/frp-tools';
|
|
3
|
+
import {SpyneAppProperties} from '../utils/spyne-app-properties';
|
|
3
4
|
import { SpyneUtilsChannelWindow } from '../utils/spyne-utils-channel-window';
|
|
4
5
|
import { merge } from 'rxjs';
|
|
5
6
|
import { map, debounceTime, skipWhile } from 'rxjs/operators';
|
|
6
|
-
import {curry, pathEq, pick, partialRight, mapObjIndexed, apply} from 'ramda';
|
|
7
|
+
import {curry, pathEq, path, pick, partialRight, mapObjIndexed, apply} from 'ramda';
|
|
7
8
|
import {deepMerge} from '../utils/deep-merge';
|
|
8
9
|
|
|
9
10
|
const rMap = require('ramda').map;
|
|
@@ -37,11 +38,13 @@ export class SpyneChannelWindow extends Channel {
|
|
|
37
38
|
super(CHANNEL_NAME);
|
|
38
39
|
this.bindStaticMethods();
|
|
39
40
|
this.currentScrollY=0;
|
|
41
|
+
|
|
42
|
+
//this.spyneScrollLock = SpyneAppProperties.scrollLock;
|
|
40
43
|
// this.props.name = 'WINDOW';
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
initializeStream() {
|
|
44
|
-
this.domChannelConfig =
|
|
47
|
+
this.domChannelConfig = SpyneAppProperties.config.channels.WINDOW;
|
|
45
48
|
let obs$Arr = this.getActiveObservables();
|
|
46
49
|
let dom$ = merge(...obs$Arr);
|
|
47
50
|
this.dom$ = dom$;
|
|
@@ -140,10 +143,12 @@ export class SpyneChannelWindow extends Channel {
|
|
|
140
143
|
return { action, payload, srcElement, scrollDistance, event };
|
|
141
144
|
}
|
|
142
145
|
|
|
143
|
-
createScrollObservable(config, scrollElement=window) {
|
|
146
|
+
createScrollObservable(config, scrollElement=window, isPassive = true) {
|
|
144
147
|
const skipWhenDirIsMissing = evt => evt.scrollDistance === 0;
|
|
145
148
|
const dTime = config.debounceMSTimeForScroll;
|
|
146
149
|
|
|
150
|
+
const element = scrollElement;
|
|
151
|
+
|
|
147
152
|
|
|
148
153
|
const isWindow = scrollElement === window;
|
|
149
154
|
|
|
@@ -153,20 +158,19 @@ export class SpyneChannelWindow extends Channel {
|
|
|
153
158
|
|
|
154
159
|
const scrollDataFn =SpyneChannelWindow.getScrollData();
|
|
155
160
|
// console.log("SCROLL ELEMENT ",action,scrollElement, scrollElForVals);
|
|
156
|
-
const scrollMapFn =partialRight(SpyneChannelWindow.getScrollMapFn, [action, scrollDataFn, scrollElForVals]).bind(this);
|
|
161
|
+
const scrollMapFn =partialRight(SpyneChannelWindow.getScrollMapFn, [action, scrollDataFn, scrollElForVals, isPassive, element]).bind(this);
|
|
162
|
+
|
|
163
|
+
// console.log("createScrollObservable ", {scrollMapFn, scrollDataFn, action, config, scrollElement, element})
|
|
164
|
+
|
|
157
165
|
|
|
158
|
-
/**
|
|
159
|
-
* TODO: curry createDomObservableFromEvent so that element can be other than window.
|
|
160
|
-
*
|
|
161
|
-
*/
|
|
162
166
|
|
|
163
167
|
return SpyneUtilsChannelWindow.createDomObservableFromEvent('scroll',
|
|
164
|
-
scrollMapFn)
|
|
168
|
+
scrollMapFn, isPassive, element)
|
|
165
169
|
.pipe(
|
|
166
170
|
/* map(p=>{
|
|
167
171
|
if (pathEq(['Spyne', 'config', 'scrollLock'], true)(scrollElement)){
|
|
168
|
-
let x =
|
|
169
|
-
let y =
|
|
172
|
+
let x = SpyneAppProperties.config.scrollLockX
|
|
173
|
+
let y = SpyneAppProperties.config.scrollLockY;
|
|
170
174
|
window.scrollTo(x,y);
|
|
171
175
|
}
|
|
172
176
|
return p;
|
|
@@ -174,7 +178,8 @@ export class SpyneChannelWindow extends Channel {
|
|
|
174
178
|
debounceTime(dTime),
|
|
175
179
|
skipWhile(skipWhenDirIsMissing),
|
|
176
180
|
map(p=>{
|
|
177
|
-
const newScrollY = SpyneChannelWindow.getScrollY(
|
|
181
|
+
const newScrollY = SpyneChannelWindow.getScrollY(element);
|
|
182
|
+
//console.log("SCROLL P IS ",{p});
|
|
178
183
|
p.payload['scrollDistanceAbs'] = Math.abs(this.currentScrollY-newScrollY);
|
|
179
184
|
this.currentScrollY=newScrollY;
|
|
180
185
|
return p;
|
|
@@ -213,7 +218,8 @@ export class SpyneChannelWindow extends Channel {
|
|
|
213
218
|
// CHECK TO ADD MEDIA QUERY OBSERVABLE
|
|
214
219
|
// ==========================================
|
|
215
220
|
config['listenForMediaQueries'] = checkIfObjIsNotEmptyOrNil(
|
|
216
|
-
config.
|
|
221
|
+
config.mediaQueries) || checkIfObjIsNotEmptyOrNil(
|
|
222
|
+
config.mediqQueries);
|
|
217
223
|
|
|
218
224
|
// =========================================
|
|
219
225
|
|
|
@@ -317,6 +323,7 @@ export class SpyneChannelWindow extends Channel {
|
|
|
317
323
|
'CHANNEL_WINDOW_RESET_EVENT',
|
|
318
324
|
'CHANNEL_WINDOW_RESIZE_EVENT',
|
|
319
325
|
'CHANNEL_WINDOW_ELEMENT_SCROLL_EVENT',
|
|
326
|
+
'CHANNEL_WINDOW_SCROLL_ELEMENT_ADDED_EVENT',
|
|
320
327
|
['CHANNEL_WINDOW_SET_ELEMENT_TO_SCROLL_EVENT', 'onSetElementToScroll'],
|
|
321
328
|
'CHANNEL_WINDOW_SCROLL_EVENT',
|
|
322
329
|
'CHANNEL_WINDOW_SCROLL_LOCK_EVENT',
|
|
@@ -333,23 +340,56 @@ export class SpyneChannelWindow extends Channel {
|
|
|
333
340
|
|
|
334
341
|
onScrollLockEvent(e){
|
|
335
342
|
const setScrollPos = ()=>{
|
|
336
|
-
|
|
337
|
-
|
|
343
|
+
SpyneAppProperties.config.scrollLockX = window.scrollX;
|
|
344
|
+
SpyneAppProperties.config.scrollLockY = window.scrollY;
|
|
345
|
+
this.spyneScrollLock.setScroll();
|
|
338
346
|
};
|
|
339
|
-
let {action, scrollLock} = e.
|
|
340
|
-
|
|
347
|
+
let {action, scrollLock, el} = e.payload;
|
|
348
|
+
SpyneAppProperties.config.scrollLock = scrollLock;
|
|
349
|
+
el = el || window;
|
|
341
350
|
if (scrollLock === true){
|
|
342
|
-
|
|
351
|
+
// setScrollPos();
|
|
352
|
+
|
|
353
|
+
this.spyneScrollLock.disableBodyScroll();
|
|
354
|
+
const id = path(['srcElement', 'id'], e);
|
|
355
|
+
/**
|
|
356
|
+
* TODO: ADD EL TO Scroll lock --- this is hard coded .scroll-lock class
|
|
357
|
+
*
|
|
358
|
+
* */
|
|
359
|
+
//el = document.querySelector(`#${id} .card-scroll`);
|
|
360
|
+
//console.log("E TO SCROLL IS ",{id,el,e});
|
|
361
|
+
// this.onSetElementToScroll({}, el);
|
|
362
|
+
|
|
363
|
+
this.createScrollObservable(this.domChannelConfig, el, true)
|
|
364
|
+
.subscribe(p => {
|
|
365
|
+
let { action, payload, srcElement, event } = p;
|
|
366
|
+
//console.log("SCROLL OBS IS ",p)
|
|
367
|
+
this.sendChannelPayload(action, payload, srcElement, event);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
} else {
|
|
373
|
+
this.spyneScrollLock.enableBodyScroll();
|
|
343
374
|
}
|
|
344
375
|
|
|
345
|
-
|
|
376
|
+
//console.log('scroll lock window channel ',{action,scrollLock});
|
|
377
|
+
|
|
378
|
+
this.sendChannelPayload(action, {scrollLock}, el);
|
|
346
379
|
}
|
|
347
380
|
|
|
348
381
|
onSetElementToScroll(e){
|
|
349
382
|
|
|
350
|
-
let {config, scrollElement} = e.
|
|
383
|
+
let {config, el, scrollElement} = e.payload;
|
|
384
|
+
config = config || {};
|
|
351
385
|
config = deepMerge(this.domChannelConfig, config);
|
|
352
386
|
|
|
387
|
+
scrollElement = scrollElement || el;
|
|
388
|
+
//console.log('set elemenet to scroll ',{scrollElement})
|
|
389
|
+
|
|
390
|
+
const action = "CHANNEL_WINDOW_SCROLL_ELEMENT_ADDED_EVENT";
|
|
391
|
+
this.sendChannelPayload(action, {el}, el);
|
|
392
|
+
|
|
353
393
|
this.createScrollObservable(config, scrollElement)
|
|
354
394
|
.subscribe(p => {
|
|
355
395
|
let { action, payload, srcElement, event } = p;
|