spyne 0.16.2 → 0.18.2
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 +1 -1
- package/README.md +0 -60
- package/karma.conf.js +18 -69
- package/lib/spyne.js +29755 -28678
- package/lib/spyne.min.js +1 -1
- package/lib/spyne.min.js.LICENSE.txt +9 -9
- package/package.json +21 -42
- package/src/spyne/channels/channel-fetch-class.js +25 -5
- package/src/spyne/channels/channel-payload-class.js +36 -23
- package/src/spyne/channels/channel-proxy.js +7 -5
- package/src/spyne/channels/channel.js +54 -28
- package/src/spyne/channels/channels-config.js +2 -4
- package/src/spyne/channels/{channels-delegator.js → channels-map.js} +24 -40
- package/src/spyne/channels/spyne-channel-lifecycle.js +1 -2
- package/src/spyne/channels/spyne-channel-route.js +21 -62
- package/src/spyne/channels/spyne-channel-ui.js +1 -2
- package/src/spyne/channels/spyne-channel-window.js +24 -35
- package/src/spyne/spyne-app.js +165 -0
- package/src/spyne/spyne-plugins.js +39 -41
- package/src/spyne/spyne.js +6 -158
- package/src/spyne/utils/channel-config-validator.js +0 -1
- package/src/spyne/utils/channel-fetch-util.js +1 -2
- package/src/spyne/utils/channel-payload-filter.js +9 -76
- package/src/spyne/utils/frp-tools.js +21 -1
- package/src/spyne/utils/gc.js +1 -1
- package/src/spyne/utils/route-channel-updater.js +0 -4
- package/src/spyne/utils/spyne-app-properties.js +183 -0
- package/src/spyne/utils/spyne-logger.js +18 -0
- package/src/spyne/utils/spyne-plugins-methods.js +97 -0
- package/src/spyne/utils/spyne-trait.js +2 -5
- package/src/spyne/utils/spyne-utils-channel-route-url.js +3 -8
- package/src/spyne/utils/spyne-utils-channel-route.js +6 -14
- package/src/spyne/utils/spyne-utils-channel-window.js +1 -3
- package/src/spyne/utils/viewstream-observables.js +2 -3
- package/src/spyne/views/dom-element-template.js +2 -7
- package/src/spyne/views/dom-element.js +0 -19
- package/src/spyne/views/view-stream-broadcaster.js +5 -10
- package/src/spyne/views/view-stream-element.js +1 -18
- package/src/spyne/views/view-stream-payload.js +31 -37
- package/src/spyne/views/view-stream-selector.js +3 -8
- package/src/spyne/views/view-stream.js +281 -297
- package/src/tests/channels/channel-fetch.test.js +102 -0
- package/src/tests/channels/channel-payload-class.test.js +14 -5
- package/src/tests/channels/channel-payload-filter.test.js +3 -28
- package/src/tests/channels/channel.test.js +38 -0
- package/src/tests/index.js +0 -1
- package/src/tests/index.test.js +6 -0
- package/src/tests/spyne-app.test.js +27 -0
- package/src/tests/spyne-plugin.test.js +13 -9
- package/src/tests/utils/plugins-methods.test.js +103 -0
- package/src/tests/utils/spyne-app-properties.test.js +11 -0
- package/webpack.config.js +19 -34
- package/lib/channel-action-filter.test.3516417154.js +0 -20
- package/lib/channel-dom.test.104366832.js +0 -20
- package/lib/channel-fetch-util.test.3506167575.js +0 -20
- package/lib/channel-payload-class.test.1081032524.js +0 -20
- package/lib/channel-payload-filter.test.977308429.js +0 -20
- package/lib/channel-route.test.3513636042.js +0 -20
- package/lib/channel-stream-item.test.119388071.js +0 -20
- package/lib/channel-ui.test.3778619579.js +0 -20
- package/lib/channel-util-dom.test.908537750.js +0 -20
- package/lib/commons.js +0 -49274
- package/lib/dom-el-selectors.test.1268485916.js +0 -20
- package/lib/dom-el-template.test.842696987.js +0 -20
- package/lib/dom-el.test.2045076905.js +0 -20
- package/lib/frp-tools.test.2503042868.js +0 -20
- package/lib/import.test.2658619365.js +0 -20
- package/lib/index.test.2372977745.js +0 -20
- package/lib/route-utils.test.273346057.js +0 -20
- package/lib/runtime.js +0 -172
- package/lib/spyne-plugin.test.301647328.js +0 -20
- package/lib/spyne.js.map +0 -1
- package/lib/url-utils.test.1931189114.js +0 -20
- package/lib/view-stream-broadcaster.test.1306675435.js +0 -20
- package/lib/view-stream-enhancer-loader.test.3617829096.js +0 -20
- package/lib/view-stream-enhancer.test.1053738169.js +0 -20
- package/lib/view-stream.test.573231784.js +0 -20
- package/src/spyne/channels/lifestream-payload.js +0 -56
- package/src/spyne/utils/channel-data-packet-generator.js +0 -200
- package/src/spyne/utils/channel-data-packet.js +0 -59
- package/src/spyne/utils/viewstream-dom-utils.js +0 -51
- package/src/spyne/views/view-stream-enhancer-loader.js +0 -70
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {SpyneApp,
|
|
2
|
-
import {
|
|
1
|
+
import {SpyneApp, DomElement, SpyneAppProperties} from './spyne';
|
|
2
|
+
import {is, clone, pathSatisfies} from 'ramda';
|
|
3
3
|
export class SpynePlugin {
|
|
4
4
|
|
|
5
5
|
constructor(props={}) {
|
|
@@ -11,18 +11,14 @@ export class SpynePlugin {
|
|
|
11
11
|
config = clone(props);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
//console.log("CONFIG AND PROPS ",{config, props});
|
|
16
|
-
|
|
17
14
|
this.name = name || 'empty';
|
|
18
15
|
this.props.name = name;
|
|
19
16
|
config = SpynePlugin.mergeDefaultConfig(config, this.defaultConfig());
|
|
20
17
|
this.props.parentEl = parentEl || SpynePlugin.createParentEl();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (this.props.
|
|
24
|
-
|
|
25
|
-
return false;
|
|
18
|
+
SpynePlugin.getSpyneApp(name, config);
|
|
19
|
+
|
|
20
|
+
if (this.props.traits!==undefined){
|
|
21
|
+
this.addTraits(this.props.traits);
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
this.onBeforeRegistered();
|
|
@@ -30,49 +26,24 @@ export class SpynePlugin {
|
|
|
30
26
|
this.onRender();
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
onBeforeRegistered(){
|
|
34
|
-
this.props.pluginName = this.props.name;
|
|
35
|
-
this.props.config = path(['Spyne', 'config', 'plugins', this.props.name], window);
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
29
|
static mergeDefaultConfig(config={}, defaultConfig=this.defaultConfig()){
|
|
40
30
|
return Object.assign(defaultConfig, config);
|
|
41
31
|
}
|
|
42
32
|
|
|
33
|
+
static getSpyneApp(name, config){
|
|
34
|
+
if(SpyneAppProperties.initialized===false){
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
console.warn(`Spyne Warning: Unable to install plugin, ${name}! SpyneApp has not been initialized!`);
|
|
37
|
+
//SpyneApp.init()
|
|
38
|
+
} else{
|
|
39
|
+
SpyneAppProperties.addPluginConfig(name, config);
|
|
49
40
|
}
|
|
50
41
|
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
static getSpyneApp(name, config){
|
|
56
|
-
const win = window || {};
|
|
57
|
-
let spyneApp = prop('Spyne', win) ;
|
|
58
|
-
const spyneInitialized = typeof(spyneApp) === 'object';
|
|
59
|
-
//console.log('spyne app is ',{spyneApp, spyneInitialized}, typeof(spyneApp));
|
|
60
|
-
|
|
61
|
-
spyneApp = spyneInitialized === true ? spyneApp : new spyneApp();
|
|
62
|
-
|
|
63
|
-
const updateConfig = SpynePlugin.updateSpyneConfig(spyneApp, name, config);
|
|
64
|
-
|
|
65
|
-
if(updateConfig===false){
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// spyneApp.config.plugins[name] = config;
|
|
70
|
-
return spyneApp;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
45
|
static updateSpyneConfig(spyneApp, pluginName, pluginConfig){
|
|
74
46
|
const pathExists = pathSatisfies(is(Object), ['config', 'plugins', pluginName])(spyneApp);
|
|
75
|
-
// console.log('path exists ',{pathExists}, spyneApp.config.plugins[pluginName])
|
|
76
47
|
|
|
77
48
|
if (pathExists===true){
|
|
78
49
|
if (spyneApp.config.debug===true) {
|
|
@@ -104,6 +75,32 @@ export class SpynePlugin {
|
|
|
104
75
|
return el || createPluginParentEl();
|
|
105
76
|
}
|
|
106
77
|
|
|
78
|
+
addTraits(traits){
|
|
79
|
+
if (traits.constructor.name!=='Array'){
|
|
80
|
+
traits = [traits];
|
|
81
|
+
}
|
|
82
|
+
const addTrait=(TraitClass)=>{
|
|
83
|
+
return new TraitClass(this);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
traits.forEach(addTrait);
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onBeforeRegistered(){
|
|
91
|
+
this.props.pluginName = this.props.name;
|
|
92
|
+
this.props.config = SpyneAppProperties.getPluginConfigByPluginName(this.props.pluginName);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
defaultConfig(){
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
107
104
|
onRegistered(){
|
|
108
105
|
|
|
109
106
|
|
|
@@ -117,3 +114,4 @@ export class SpynePlugin {
|
|
|
117
114
|
|
|
118
115
|
|
|
119
116
|
}
|
|
117
|
+
|
package/src/spyne/spyne.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DomElement, DomEl } from './views/dom-element';
|
|
1
|
+
import { ChannelsMap } from './channels/channels-map';
|
|
2
|
+
import { DomElement } from './views/dom-element';
|
|
4
3
|
import {DomElementTemplate} from './views/dom-element-template';
|
|
5
4
|
import { ViewStreamElement } from './views/view-stream-element';
|
|
6
5
|
import { ViewStreamSelector} from './views/view-stream-selector';
|
|
@@ -13,179 +12,28 @@ import { ChannelFetch } from './channels/channel-fetch-class';
|
|
|
13
12
|
import {ChannelFetchUtil} from './utils/channel-fetch-util';
|
|
14
13
|
import { ChannelPayload } from './channels/channel-payload-class';
|
|
15
14
|
import {ChannelPayloadFilter} from './utils/channel-payload-filter';
|
|
16
|
-
import {SpyneUtilsChannelRoute} from './utils/spyne-utils-channel-route';
|
|
17
15
|
import {SpynePlugin} from './spyne-plugins';
|
|
18
16
|
import { deepMerge } from './utils/deep-merge';
|
|
17
|
+
import {SpyneAppProperties} from './utils/spyne-app-properties';
|
|
18
|
+
import {SpyneApp} from './spyne-app';
|
|
19
19
|
|
|
20
|
-
class SpyneApp {
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* SpyneApp creates the global Spyne object, and creates the following items
|
|
24
|
-
* <ul>
|
|
25
|
-
*
|
|
26
|
-
* <li>LINK['ChannelsDelegator', 'channels-controller'] that directs the flow of data to all Channels</li>
|
|
27
|
-
* <li>LINK['SpyneChannelUI', 'spyne-channel-u-i'], that broadcast all user interaction events</li>
|
|
28
|
-
* <li>LINK['SpyneChannelRoute', 'spyne-channel-route'], that broadcast window location changes and is the only other channel that can be bound to user events</li>
|
|
29
|
-
* <li>LINK['SpyneChannelWindow', 'spyne-channel-window'], that broadcast all requested window and document events, such as scrolling, resizing and media queries</li>
|
|
30
|
-
* <li>LINK['SpyneChannelLifecycle', 'spyne-channel-lifecycle'], that broadcasts rendering and removing of ViewStream elements that have been directed to broadcast their lifecycle events</li>
|
|
31
|
-
* </ul>
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @module SpyneApp
|
|
35
|
-
* @type core
|
|
36
|
-
*
|
|
37
|
-
* @constructor
|
|
38
|
-
* @param {Object} config
|
|
39
|
-
* @property {Object} config - = {}; This global config object is mainly used to provide configuration details for two SpyneChannels, CHANNEL_ROUTE and CHANNEL_WINDOW.
|
|
40
|
-
*/
|
|
41
|
-
constructor(config = {}) {
|
|
42
|
-
this.channels = new ChannelsDelegator();
|
|
43
|
-
this.VERSION = '0.16.2';
|
|
44
|
-
/*!
|
|
45
|
-
* Spyne 0.16.2
|
|
46
|
-
* https://spynejs.org
|
|
47
|
-
*
|
|
48
|
-
* @license Copyright 2017-2020, Frank Batista, Relevant Context, LLC. All rights reserved.
|
|
49
|
-
* Spyne is licensed under the GNU Lesser General Public License v3.0
|
|
50
|
-
*
|
|
51
|
-
* @author: Frank Batista,
|
|
52
|
-
* @email: frbatista.nyc@gmail.com
|
|
53
|
-
*/
|
|
54
|
-
/* eslint-disable */
|
|
55
|
-
this.ViewStream = ViewStream;
|
|
56
|
-
this.BasicView = ViewStreamElement;
|
|
57
|
-
this.DomEl = DomElement;
|
|
58
|
-
this.ViewStreamBroadcaster = ViewStreamBroadcaster;
|
|
59
|
-
this.ChannelsPayload = ViewStreamPayload;
|
|
60
|
-
this.ChannelsController = ChannelsDelegator;
|
|
61
|
-
this.ChannelsBase = Channel;
|
|
62
|
-
this.ChannelPayloadItem = ChannelPayload;
|
|
63
|
-
this._channelDataPacketGenerator = new ChannelDataPacketGenerator();
|
|
64
|
-
window.Spyne = this;
|
|
65
|
-
let defaultConfig = {
|
|
66
|
-
scrollLock: false,
|
|
67
|
-
scrollLockX: 31,
|
|
68
|
-
scrollLockY: 0,
|
|
69
|
-
debug: false,
|
|
70
|
-
utils: {
|
|
71
|
-
tableRE: /^([^>]*?)(<){1}(\b)(thead|col|colgroup|tbody|td|tfoot|tr|th)(\b)([^\0]*)$/
|
|
72
|
-
},
|
|
73
|
-
tmp:{
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
plugins:{
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
channels: {
|
|
80
|
-
WINDOW: {
|
|
81
|
-
mediqQueries: {
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
events: [],
|
|
85
|
-
listenForResize: true,
|
|
86
|
-
listenForOrientation: true,
|
|
87
|
-
listenForScroll: false,
|
|
88
|
-
listenForMouseWheel: false,
|
|
89
|
-
debounceMSTimeForResize: 200,
|
|
90
|
-
debounceMSTimeForScroll: 150
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
ROUTE: {
|
|
94
|
-
type: 'slash',
|
|
95
|
-
isHash: false,
|
|
96
|
-
isHidden: false,
|
|
97
|
-
add404s: false,
|
|
98
|
-
routes: {
|
|
99
|
-
'routePath' : {
|
|
100
|
-
'routeName' : 'change'
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
CHANNEL_ROUTE: {},
|
|
107
|
-
CHANNEL_UI: {},
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
if (config !== undefined) {
|
|
111
|
-
config = SpyneUtilsChannelRoute.conformRouteObject(config);
|
|
112
|
-
window.Spyne['config'] = deepMerge(defaultConfig, config)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
//const ranNum = Math.random();
|
|
117
|
-
//console.log('ranNum is ',{ranNum})
|
|
118
|
-
this.getChannelActions = (str) => window.Spyne.channels.getChannelActions(str);
|
|
119
|
-
this.registerChannel = (val) => this.channels.registerStream(val);
|
|
120
|
-
this.registerDataChannel = (obs$) => this.channels.registerStream(obs$);
|
|
121
|
-
this.listChannels = () => Array.from(window.Spyne.channels.map.keys());
|
|
122
|
-
let nullHolder = new ViewStream({ id:'spyne-null-views' });
|
|
123
|
-
nullHolder.appendToDom(document.body);
|
|
124
|
-
nullHolder.props.el.style.cssText = 'display:none; opacity:0; pointer-events:none;';
|
|
125
|
-
this.channels.init();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
get createDataPacket(){
|
|
130
|
-
return this._channelDataPacketGenerator.createDataPacket;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* This is mostly used for debugging purposes
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
|
|
138
|
-
* SpyneApp.listChannels();
|
|
139
|
-
*
|
|
140
|
-
* @returns A list of all registered channels
|
|
141
|
-
*/
|
|
142
|
-
static listChannels() {
|
|
143
|
-
return Array.from(window.Spyne.channels.map.keys());
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* This method is useful to check in the console or in the code what actions are available to be listened to.
|
|
148
|
-
* @param {String} str
|
|
149
|
-
* @returns {Array} An array of Actions that can be listened to
|
|
150
|
-
*/
|
|
151
|
-
static getChannelActions(str) {
|
|
152
|
-
return window.Spyne.channels.getChannelActions(str);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
*
|
|
157
|
-
* This method will add the channel to the registered list so that it can subscribed by all ViewStream and Channel instances.
|
|
158
|
-
* @param {Channel} c
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*/
|
|
162
|
-
static registerChannel(c) {
|
|
163
|
-
if (window.Spyne === undefined) {
|
|
164
|
-
console.warn('Spyne has not been initialized');
|
|
165
|
-
} else {
|
|
166
|
-
return window.Spyne.channels.registerStream(c);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
window['Spyne'] = SpyneApp;
|
|
172
20
|
export {
|
|
173
21
|
ViewStreamElement,
|
|
174
22
|
Channel,
|
|
175
23
|
ChannelFetch,
|
|
176
24
|
ChannelFetchUtil,
|
|
177
|
-
|
|
25
|
+
ChannelsMap,
|
|
178
26
|
ViewStreamPayload,
|
|
179
27
|
ChannelPayload,
|
|
180
28
|
ChannelPayloadFilter,
|
|
181
29
|
DomElement,
|
|
182
|
-
DomEl,
|
|
183
30
|
DomElementTemplate,
|
|
184
31
|
ViewStream,
|
|
185
32
|
ViewStreamSelector,
|
|
186
33
|
ViewStreamBroadcaster,
|
|
187
34
|
SpyneTrait,
|
|
188
35
|
SpyneApp,
|
|
36
|
+
SpyneAppProperties,
|
|
189
37
|
SpynePlugin,
|
|
190
38
|
deepMerge
|
|
191
39
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Validation from 'data.validation';
|
|
2
2
|
import {curry, curryN, length, always, reduce} from 'ramda';
|
|
3
|
-
// import { curry, curryN, reduce, length, always } from 'ramda';
|
|
4
3
|
const success = Validation.Success;
|
|
5
4
|
const failure = Validation.Failure;
|
|
6
5
|
let validate = () => {};
|
|
@@ -2,7 +2,6 @@ import { from } from 'rxjs';
|
|
|
2
2
|
import { flatMap, map, publish, tap } from 'rxjs/operators';
|
|
3
3
|
import {compose, prop, defaultTo, over, lensProp, has, propEq, when, propIs, allPass, assoc, pick, mergeDeepRight} from 'ramda';
|
|
4
4
|
export class ChannelFetchUtil {
|
|
5
|
-
// METHOD GET POST PUT PATCH DELETE
|
|
6
5
|
/**
|
|
7
6
|
* @module ChannelFetchUtil
|
|
8
7
|
* @type util
|
|
@@ -49,7 +48,7 @@ export class ChannelFetchUtil {
|
|
|
49
48
|
|
|
50
49
|
|
|
51
50
|
constructor(options, subscriber, testMode) {
|
|
52
|
-
|
|
51
|
+
|
|
53
52
|
const testSubscriber = (p) => console.log('FETCH RETURNED ', p);
|
|
54
53
|
|
|
55
54
|
this._mapFn = ChannelFetchUtil.setMapFn(options);
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
is,
|
|
3
3
|
reject,
|
|
4
|
-
ifElse,
|
|
5
|
-
invoker,
|
|
6
|
-
identity,
|
|
7
|
-
assoc,
|
|
8
4
|
isNil,
|
|
9
|
-
|
|
5
|
+
find,
|
|
10
6
|
allPass,
|
|
11
|
-
tap,
|
|
12
7
|
forEachObjIndexed,
|
|
13
8
|
not,
|
|
14
9
|
isEmpty,
|
|
@@ -19,17 +14,15 @@ import {
|
|
|
19
14
|
where,
|
|
20
15
|
defaultTo,
|
|
21
16
|
mergeAll,
|
|
22
|
-
__,
|
|
23
17
|
omit,
|
|
24
|
-
path,
|
|
25
|
-
call,
|
|
26
|
-
clone,
|
|
27
18
|
flatten,
|
|
28
19
|
any,
|
|
29
|
-
type,
|
|
30
20
|
curry,
|
|
31
|
-
|
|
21
|
+
lte
|
|
32
22
|
} from 'ramda';
|
|
23
|
+
|
|
24
|
+
import {SpyneAppProperties} from './spyne-app-properties';
|
|
25
|
+
|
|
33
26
|
const rMap = require('ramda').map;
|
|
34
27
|
|
|
35
28
|
const isNotArr = compose(not, is(Array));
|
|
@@ -122,8 +115,6 @@ export class ChannelPayloadFilter {
|
|
|
122
115
|
|
|
123
116
|
const debugLabelArr = [debugLabel, prop('debugLabel', filters)]
|
|
124
117
|
|
|
125
|
-
const makeBool = b => Boolean(b);
|
|
126
|
-
|
|
127
118
|
debugLabel = compose(find(is(String)))(debugLabelArr);
|
|
128
119
|
|
|
129
120
|
let props = omit(['debugLabel', 'label', 'selector', 'props', 'testMode', 'propFilters'], filters)
|
|
@@ -137,22 +128,13 @@ export class ChannelPayloadFilter {
|
|
|
137
128
|
filters['propFilters'] = props;
|
|
138
129
|
|
|
139
130
|
let {propFilters} = filters;
|
|
140
|
-
//console.log("selector filters ", {selector, filters})
|
|
141
131
|
|
|
142
|
-
// let {selector,propFilters,debugLabel} = filters;
|
|
143
132
|
|
|
144
133
|
const addStringSelectorFilter = isNonEmptyStr(selector) ? ChannelPayloadFilter.filterSelector([selector], debugLabel) : undefined;
|
|
145
134
|
const addArraySelectorFilter = isNonEmptyArr(selector) ? ChannelPayloadFilter.filterSelector(selector, debugLabel) : undefined;
|
|
146
|
-
|
|
147
|
-
|
|
148
135
|
const addDataFilter = isNonEmptyObjectFn(propFilters) ? ChannelPayloadFilter.filterData(propFilters, debugLabel) : undefined;
|
|
149
136
|
|
|
150
|
-
//console.log("IS STRING ",{selector, addStringSelectorFilter, addArraySelectorFilter, addDataFilter},isNonEmptyStr(selector))
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
137
|
let filtersArr = reject(isNil, [addStringSelectorFilter, addArraySelectorFilter, addDataFilter]);
|
|
155
|
-
// console.log('filtersArr is ',{selector})
|
|
156
138
|
|
|
157
139
|
// IF ARRAY IS EMPTY ALWAYS RETURN FALSE;
|
|
158
140
|
|
|
@@ -160,15 +142,12 @@ export class ChannelPayloadFilter {
|
|
|
160
142
|
|
|
161
143
|
if (filtersAreEmpty){
|
|
162
144
|
filtersArr = [always(false)];
|
|
163
|
-
if (
|
|
145
|
+
if (SpyneAppProperties.debug === true && testMode!==true){
|
|
164
146
|
console.warn(`Spyne Warning: The Channel Filter, with selector: ${selector}, and propFilters:${propFilters} appears to be empty!`);
|
|
165
147
|
}
|
|
166
148
|
|
|
167
149
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
//console.log(" VALUES OF FILTERS ",{selector,propFilters,filters,debugLabel,testMode, filtersAreEmpty});
|
|
171
|
-
if (testMode === true){
|
|
150
|
+
if (testMode === true){
|
|
172
151
|
return {selector, propFilters, debugLabel, filters, testMode, filtersAreEmpty};
|
|
173
152
|
}
|
|
174
153
|
|
|
@@ -178,40 +157,21 @@ export class ChannelPayloadFilter {
|
|
|
178
157
|
static filterData(filterJson, filterdebugLabel) {
|
|
179
158
|
const debugLabel = filterdebugLabel;
|
|
180
159
|
|
|
181
|
-
//console.log('filter data is ',{filterJson, debugLabel})
|
|
182
160
|
let compareData = () => {
|
|
183
161
|
// DO NOT ALLOW AN EMPTY OBJECT TO RETURN TRUEs
|
|
184
162
|
if (isEmpty(filterJson)) {
|
|
185
163
|
return always(false);
|
|
186
164
|
}
|
|
187
165
|
|
|
188
|
-
//console.log("FILTER JSON ",filterJson);
|
|
189
166
|
// CHECKS ALL VALUES IN JSON TO DETERMINE IF THERE ARE FILTERING METHODS
|
|
190
167
|
|
|
191
|
-
//let typeArrFn = compose(values, rMap(type));
|
|
192
|
-
|
|
193
|
-
/*let sendMalFormedWarningBool = uniq(filterValsArr).length > 1;
|
|
194
|
-
if (sendMalFormedWarningBool === true) {
|
|
195
|
-
console.warn('Spyne Warningd: The data values in ChannelActionFilters needs to be either all methods or all static values. DATA: ', filterJson);
|
|
196
|
-
}*/
|
|
197
|
-
|
|
198
168
|
const createCurryComparator = compareStr => (str)=>{
|
|
199
169
|
return str===compareStr;
|
|
200
170
|
};
|
|
201
171
|
const checkToConvertToFn = (val, key, obj)=>val = is(String, val)===true ? createCurryComparator(val) : val;
|
|
202
172
|
filterJson = rMap(checkToConvertToFn, filterJson);
|
|
203
173
|
|
|
204
|
-
// console.log("FILTER JSON: ",{filterJson, newJson});
|
|
205
|
-
//const isAllMethods = all(equals('Function'), filterValsArr);
|
|
206
|
-
|
|
207
|
-
// PULL OUT THE CHANNEL PAYLOAD OBJECT IN THE MAIN PAYLOAD
|
|
208
|
-
// let payload = prop('channelPayload', eventData)
|
|
209
|
-
|
|
210
|
-
// IF THERE ARE METHODS IN THE FILTERING JSON, THEN USE where or whereEq if Basic JSON
|
|
211
|
-
// let fMethod = isAllMethods === true ? where(filterJson) : whereEq(filterJson);
|
|
212
|
-
|
|
213
174
|
// TAP LOGGER
|
|
214
|
-
|
|
215
175
|
const tapLogger = (comparedObj)=>{
|
|
216
176
|
if (debugLabel===undefined){
|
|
217
177
|
return comparedObj;
|
|
@@ -225,13 +185,11 @@ export class ChannelPayloadFilter {
|
|
|
225
185
|
};
|
|
226
186
|
|
|
227
187
|
// END TAP LOGGER
|
|
228
|
-
|
|
229
188
|
let fMethod = where(filterJson);
|
|
230
189
|
|
|
231
190
|
let getFilteringObj = (v)=>{
|
|
232
191
|
const {payload, srcElement, event} = v || {};
|
|
233
|
-
const o = Object.assign({}, v, event,
|
|
234
|
-
|
|
192
|
+
const o = Object.assign({}, v, event, payload);
|
|
235
193
|
//console.log('o is ',o);
|
|
236
194
|
return o;
|
|
237
195
|
}
|
|
@@ -240,29 +198,20 @@ export class ChannelPayloadFilter {
|
|
|
240
198
|
return compose( fMethod, tapLogger, defaultTo({}), getFilteringObj);
|
|
241
199
|
|
|
242
200
|
};
|
|
243
|
-
// const filterLabel = `filtering-${Math.floor(Math.random()*999999)}`;
|
|
244
|
-
//console.time(filterLabel);
|
|
245
|
-
// const val = compareData();
|
|
246
201
|
|
|
247
|
-
//console.timeEnd(filterLabel);
|
|
248
|
-
//return val;
|
|
249
202
|
return compareData();
|
|
250
203
|
}
|
|
251
204
|
|
|
252
205
|
|
|
253
206
|
static checkPayloadSelector(arr, debugLabel, srcPayload) {
|
|
254
|
-
// ELEMENT FROM PAYLOADs
|
|
255
|
-
|
|
256
207
|
|
|
208
|
+
// ELEMENT FROM PAYLOADs
|
|
257
209
|
const {payload, srcElement, event} = srcPayload || {};
|
|
258
|
-
//console.log('payload before ',{srcPayload, payload, srcElement, event})
|
|
259
210
|
|
|
260
211
|
const reduceFindEl = (acc, src) => {
|
|
261
212
|
const el = prop('el', src);
|
|
262
|
-
//console.log("EL IS ",{el, src, acc})
|
|
263
213
|
if (ChannelPayloadFilter.elIsDomElement(el) && acc===undefined){
|
|
264
214
|
acc = el;
|
|
265
|
-
// return acc;
|
|
266
215
|
}
|
|
267
216
|
return acc;
|
|
268
217
|
}
|
|
@@ -270,19 +219,6 @@ export class ChannelPayloadFilter {
|
|
|
270
219
|
const el = [srcElement, payload, prop('srcElement', event), srcPayload].reduce(reduceFindEl, undefined);
|
|
271
220
|
|
|
272
221
|
|
|
273
|
-
//console.log('el check ',{debugLabel, srcElement, payload, event, el})
|
|
274
|
-
|
|
275
|
-
//const o = Object.assign({}, srcPayload, event,srcElement, payload);
|
|
276
|
-
|
|
277
|
-
//console.log('o is ',o);
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
//let payloadIsNotProps = compose(equals('Function'),type, prop('props') )(payload);
|
|
281
|
-
//payload = payloadIsNotProps === true ? payload.payload : payload;
|
|
282
|
-
// console.log('payload after ',{o})
|
|
283
|
-
|
|
284
|
-
// let el = path(['el'], o);
|
|
285
|
-
|
|
286
222
|
// RETURN BOOLEAN MATCH WITH PAYLOAD EL
|
|
287
223
|
const compareEls = (elCompare) => elCompare.isEqualNode((el));
|
|
288
224
|
|
|
@@ -297,10 +233,7 @@ export class ChannelPayloadFilter {
|
|
|
297
233
|
if (debugLabel!==undefined){
|
|
298
234
|
let nodeArrResultsDebugger = compose(flatten, rMap(mapNodeArrWithEl))(arr);
|
|
299
235
|
const selectorsArr = arr;
|
|
300
|
-
|
|
301
236
|
console.log(`%c CHANNEL PAYLOAD FILTER DEBUGGER ["${debugLabel}"] - selectors: `, "color:orange;",{el, selectorsArr, nodeArrResultsDebugger});
|
|
302
|
-
|
|
303
|
-
|
|
304
237
|
}
|
|
305
238
|
|
|
306
239
|
// CHECK IF PAYLOAD EL EXISTS
|
|
@@ -6,6 +6,26 @@ const isIOS = () => {
|
|
|
6
6
|
return ios === true;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
const delayCall = async(fn, time)=>{
|
|
11
|
+
|
|
12
|
+
function sleep (ms) {
|
|
13
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const timeoutHandler = async() => {
|
|
17
|
+
await sleep(1);
|
|
18
|
+
window.requestAnimationFrame(fn);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
window.setTimeout(timeoutHandler, time)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
9
29
|
const getConstructorName = (obj) => {
|
|
10
30
|
if (obj.constructor.name !== undefined) {
|
|
11
31
|
return obj.constructor.name;
|
|
@@ -142,4 +162,4 @@ const pullParams = (str) => str.replace(routeRE, '$4');
|
|
|
142
162
|
const pullTranslateX = str => str.replace(/^(matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*)(,.*)/, '$6');
|
|
143
163
|
const pullTranslateY = str => str.replace(/^(matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d)(.*)/, '$7');
|
|
144
164
|
const pullTranslateYFromHeader = str => str.replace(/^(transform: matrix)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*,)(.*\d*)(\).*;)/, '$6');
|
|
145
|
-
export { getConstructorName, arrFromMapKeys, getAllMethodNames, findStrOrRegexMatchStr, findStrFromRegexArr, checkIfObjIsNotEmptyOrNil, isIOS, pullRouteInfo, pullTranslateYFromHeader, pullSlashFromPath, pullHashAndSlashFromPath, closest, pullTranslateY, pullTranslateX, pullMainRoute, pullParams, right, left, fromNullable, findInObj, ifNilThenUpdate, removeSlashes, subscribeFn, convertDomStringMapToObj };
|
|
165
|
+
export { getConstructorName, arrFromMapKeys, getAllMethodNames, findStrOrRegexMatchStr, findStrFromRegexArr, checkIfObjIsNotEmptyOrNil, isIOS, pullRouteInfo, pullTranslateYFromHeader, pullSlashFromPath, pullHashAndSlashFromPath, closest, pullTranslateY, pullTranslateX, pullMainRoute, pullParams, right, left, fromNullable, findInObj, ifNilThenUpdate, removeSlashes, subscribeFn, convertDomStringMapToObj, delayCall };
|
package/src/spyne/utils/gc.js
CHANGED
|
@@ -7,10 +7,7 @@ export class RouteChannelUpdater{
|
|
|
7
7
|
let id = `${name}_ROUTE_UPDATER`;
|
|
8
8
|
|
|
9
9
|
const sendRouteChannelUpdate = curry(RouteChannelUpdater.createTemporaryViewStreamObj);
|
|
10
|
-
|
|
11
10
|
return sendRouteChannelUpdate({id,name});
|
|
12
|
-
|
|
13
|
-
//RouteChannelUpdater.createTemporaryViewStreamObj({name,id});
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
|
|
@@ -30,7 +27,6 @@ export class RouteChannelUpdater{
|
|
|
30
27
|
};
|
|
31
28
|
|
|
32
29
|
vs.appendToNull();
|
|
33
|
-
//console.log("VIEWSTREAM IS ",{vs, name,id,payload});
|
|
34
30
|
|
|
35
31
|
}
|
|
36
32
|
|