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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {ChannelsMap} from './channels/channels-map';
|
|
2
|
+
import {ViewStream} from './views/view-stream';
|
|
3
|
+
import {SpyneUtilsChannelRoute} from './utils/spyne-utils-channel-route';
|
|
4
|
+
import {SpyneAppProperties} from './utils/spyne-app-properties';
|
|
5
|
+
import {deepMerge} from './utils/deep-merge';
|
|
6
|
+
const _channels = new ChannelsMap();
|
|
7
|
+
const version = '0.17.3';
|
|
8
|
+
|
|
9
|
+
class SpyneApplication {
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* SpyneApp creates the global Spyne object, and creates the following items
|
|
13
|
+
* <ul>
|
|
14
|
+
*
|
|
15
|
+
* <li>LINK['ChannelsMap', 'channels-controller'] that directs the flow of data to all Channels</li>
|
|
16
|
+
* <li>LINK['SpyneChannelUI', 'spyne-channel-u-i'], that broadcast all user interaction events</li>
|
|
17
|
+
* <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>
|
|
18
|
+
* <li>LINK['SpyneChannelWindow', 'spyne-channel-window'], that broadcast all requested window and document events, such as scrolling, resizing and media queries</li>
|
|
19
|
+
* <li>LINK['SpyneChannelLifecycle', 'spyne-channel-lifecycle'], that broadcasts rendering and removing of ViewStream elements that have been directed to broadcast their lifecycle events</li>
|
|
20
|
+
* </ul>
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* @module SpyneApp
|
|
24
|
+
* @type core
|
|
25
|
+
*
|
|
26
|
+
* @constructor
|
|
27
|
+
* @param {Object} config
|
|
28
|
+
* @property {Object} config - = {}; This global config object is mainly used to provide configuration details for two SpyneChannels, CHANNEL_ROUTE and CHANNEL_WINDOW.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
this.version = version
|
|
33
|
+
|
|
34
|
+
//console.log('spyne app created')
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
get channels(){
|
|
39
|
+
return _channels;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
init(config = {}, testMode=false) {
|
|
43
|
+
//this.channels = new ChannelsMap();
|
|
44
|
+
/*!
|
|
45
|
+
* Spyne 0.17.3
|
|
46
|
+
* https://spynejs.org
|
|
47
|
+
*
|
|
48
|
+
* @license Copyright 2017-2021, 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 = ChannelsMap;
|
|
61
|
+
this.ChannelsBase = Channel;
|
|
62
|
+
this.ChannelPayloadItem = ChannelPayload;*/
|
|
63
|
+
|
|
64
|
+
//console.log('spyne app ',{config,testMode}, SpyneAppProperties.initialized);
|
|
65
|
+
if(SpyneAppProperties.initialized === true){
|
|
66
|
+
|
|
67
|
+
if (testMode){
|
|
68
|
+
return 'The Spyne Application has already been initialized!';
|
|
69
|
+
} else {
|
|
70
|
+
console.warn('The Spyne Application has already been initialized!');
|
|
71
|
+
}
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
let defaultConfig = {
|
|
77
|
+
scrollLock: false,
|
|
78
|
+
scrollLockX: 31,
|
|
79
|
+
scrollLockY: 0,
|
|
80
|
+
debug: true,
|
|
81
|
+
plugins:{
|
|
82
|
+
|
|
83
|
+
},
|
|
84
|
+
tmp: {},
|
|
85
|
+
channels: {
|
|
86
|
+
WINDOW: {
|
|
87
|
+
mediqQueries: {
|
|
88
|
+
|
|
89
|
+
},
|
|
90
|
+
events: [],
|
|
91
|
+
listenForResize: true,
|
|
92
|
+
listenForOrientation: true,
|
|
93
|
+
listenForScroll: false,
|
|
94
|
+
listenForMouseWheel: false,
|
|
95
|
+
debounceMSTimeForResize: 200,
|
|
96
|
+
debounceMSTimeForScroll: 150
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
ROUTE: {
|
|
100
|
+
type: 'slash',
|
|
101
|
+
isHash: false,
|
|
102
|
+
isHidden: false,
|
|
103
|
+
add404s: false,
|
|
104
|
+
routes: {
|
|
105
|
+
'routePath' : {
|
|
106
|
+
'routeName' : 'change'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
if (config !== undefined) {
|
|
114
|
+
config = SpyneAppProperties.initialize(defaultConfig, config, _channels);
|
|
115
|
+
//window.Spyne = this;
|
|
116
|
+
//window.Spyne['config'] = "SDFSD";// {};
|
|
117
|
+
//config = SpyneUtilsChannelRoute.conformRouteObject(config);
|
|
118
|
+
//window.Spyne['config'] = deepMerge(defaultConfig, config)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
//const ranNum = Math.random();
|
|
123
|
+
//console.log('ranNum is ',{ranNum})
|
|
124
|
+
this.pluginsFn = SpyneAppProperties.getPluginsMethodObj(config['pluginMethods']);
|
|
125
|
+
this.getChannelActions = (str) => _channels.getChannelActions(str);
|
|
126
|
+
this.registerChannel = (val) => _channels.registerStream(val);
|
|
127
|
+
this.registerDataChannel = (obs$) => _channels.registerStream(obs$);
|
|
128
|
+
this.listChannels = () => Array.from(_channels.map.keys());
|
|
129
|
+
let nullHolder = new ViewStream({ id:'spyne-null-views' });
|
|
130
|
+
nullHolder.appendToDom(document.body);
|
|
131
|
+
nullHolder.props.el.style.cssText = 'display:none; opacity:0; pointer-events:none;';
|
|
132
|
+
_channels.init();
|
|
133
|
+
//console.log('spyne app initialized ',SpyneAppProperties.config.debug);
|
|
134
|
+
|
|
135
|
+
if (SpyneAppProperties.config.debug===true){
|
|
136
|
+
window.Spyne = {version};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* This is mostly used for debugging purposes
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
|
|
147
|
+
* SpyneApp.listChannels();
|
|
148
|
+
*
|
|
149
|
+
* @returns A list of all registered channels
|
|
150
|
+
*/
|
|
151
|
+
static listChannels() {
|
|
152
|
+
return Array.from(_channels.map.keys());
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* This method is useful to check in the console or in the code what actions are available to be listened to.
|
|
157
|
+
* @param {String} str
|
|
158
|
+
* @returns {Array} An array of Actions that can be listened to
|
|
159
|
+
*/
|
|
160
|
+
static getChannelActions(str) {
|
|
161
|
+
return _channels.getChannelActions(str);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
*
|
|
166
|
+
* This method will add the channel to the registered list so that it can subscribed by all ViewStream and Channel instances.
|
|
167
|
+
* @param {Channel} c
|
|
168
|
+
*
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
static registerChannel(c) {
|
|
172
|
+
if (SpyneAppProperties.initialized === false) {
|
|
173
|
+
console.warn('Spyne has not been initialized');
|
|
174
|
+
} else {
|
|
175
|
+
return _channels.registerStream(c);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
export let SpyneApp = new SpyneApplication();
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {SpyneApp, ViewStream, DomElement, SpyneAppProperties} from './spyne';
|
|
2
|
+
import {prop, path, is, clone, mergeRight, pathSatisfies} from 'ramda';
|
|
3
|
+
export class SpynePlugin {
|
|
4
|
+
|
|
5
|
+
constructor(props={}) {
|
|
6
|
+
let {name, config, parentEl} = props;
|
|
7
|
+
this.props = props;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if (config===undefined){
|
|
11
|
+
config = clone(props);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
//console.log("CONFIG AND PROPS ",{config, props});
|
|
16
|
+
|
|
17
|
+
this.name = name || 'empty';
|
|
18
|
+
this.props.name = name;
|
|
19
|
+
config = SpynePlugin.mergeDefaultConfig(config, this.defaultConfig());
|
|
20
|
+
this.props.parentEl = parentEl || SpynePlugin.createParentEl();
|
|
21
|
+
SpynePlugin.getSpyneApp(name, config);
|
|
22
|
+
//console.log("SPYNE APP ",{name},this.name,this.props.spyneApp);
|
|
23
|
+
// if (this.props.spyneApp===false){
|
|
24
|
+
//console.warn(`Spyne Warning: Spyne Plugin, ${this.name} already exists!`)
|
|
25
|
+
// return false;
|
|
26
|
+
// }
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (this.props.traits!==undefined){
|
|
30
|
+
this.addTraits(this.props.traits);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.onBeforeRegistered();
|
|
34
|
+
this.onRegistered();
|
|
35
|
+
this.onRender();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
addTraits(traits){
|
|
40
|
+
if (traits.constructor.name!=='Array'){
|
|
41
|
+
traits = [traits];
|
|
42
|
+
}
|
|
43
|
+
const addTrait=(TraitClass)=>{
|
|
44
|
+
new TraitClass(this);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
traits.forEach(addTrait);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
onBeforeRegistered(){
|
|
54
|
+
this.props.pluginName = this.props.name;
|
|
55
|
+
//this.props.config = path(['Spyne', 'config', 'plugins', this.props.name], window);
|
|
56
|
+
this.props.config = SpyneAppProperties.getPluginConfigByPluginName(this.props.pluginName);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static mergeDefaultConfig(config={}, defaultConfig=this.defaultConfig()){
|
|
60
|
+
return Object.assign(defaultConfig, config);z
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
defaultConfig(){
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
static getSpyneApp(name, config){
|
|
76
|
+
// const win = window || {};
|
|
77
|
+
// let spyneApp = prop('Spyne', win) ;
|
|
78
|
+
// const spyneInitialized = typeof(spyneApp) === 'object';
|
|
79
|
+
//console.log('spyne app is ',{spyneApp, spyneInitialized}, typeof(spyneApp));
|
|
80
|
+
|
|
81
|
+
// spyneApp = spyneInitialized === true ? spyneApp : new spyneApp();
|
|
82
|
+
if(SpyneAppProperties.initialized===false){
|
|
83
|
+
SpyneApp.init()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
SpyneAppProperties.addPluginConfig(name, config);
|
|
88
|
+
|
|
89
|
+
/* const updateConfig = SpynePlugin.updateSpyneConfig(spyneApp, name, config);
|
|
90
|
+
|
|
91
|
+
if(updateConfig===false){
|
|
92
|
+
return false;
|
|
93
|
+
}*/
|
|
94
|
+
|
|
95
|
+
// spyneApp.config.plugins[name] = config;
|
|
96
|
+
//return spyneApp;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static updateSpyneConfig(spyneApp, pluginName, pluginConfig){
|
|
100
|
+
const pathExists = pathSatisfies(is(Object), ['config', 'plugins', pluginName])(spyneApp);
|
|
101
|
+
// console.log('path exists ',{pathExists}, spyneApp.config.plugins[pluginName])
|
|
102
|
+
|
|
103
|
+
if (pathExists===true){
|
|
104
|
+
if (spyneApp.config.debug===true) {
|
|
105
|
+
console.warn(`Spyne Warning: The plugin, ${pluginName}, already exists`)
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
spyneApp.config.plugins[pluginName] = pluginConfig;
|
|
110
|
+
return spyneApp.config.plugins[pluginName];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static createParentEl(el){
|
|
114
|
+
|
|
115
|
+
const createPluginParentEl = ()=>{
|
|
116
|
+
const pluginEl = document.getElementById('spyne-plugins')
|
|
117
|
+
|
|
118
|
+
const createPluginEl = ()=>{
|
|
119
|
+
const pluginEl = new DomElement({
|
|
120
|
+
id: 'spyne-plugins'
|
|
121
|
+
});
|
|
122
|
+
document.body.appendChild(pluginEl.render());
|
|
123
|
+
const el = document.getElementById('spyne-plugins')
|
|
124
|
+
el.style.cssText="position:absolute; top:0;left:0;width:100%;height:100%;min-height:100vh;z-index:1000000; pointer-events:none";
|
|
125
|
+
return el;
|
|
126
|
+
}
|
|
127
|
+
return pluginEl || createPluginEl();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return el || createPluginParentEl();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onRegistered(){
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
onRender(){
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
package/src/spyne/spyne.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DomElement
|
|
1
|
+
import { ChannelsMap } from './channels/channels-map';
|
|
2
|
+
import { DomElement } from './views/dom-element';
|
|
3
|
+
import {DomElementTemplate} from './views/dom-element-template';
|
|
3
4
|
import { ViewStreamElement } from './views/view-stream-element';
|
|
4
5
|
import { ViewStreamSelector} from './views/view-stream-selector';
|
|
5
6
|
import { ViewStream } from './views/view-stream';
|
|
@@ -11,158 +12,29 @@ import { ChannelFetch } from './channels/channel-fetch-class';
|
|
|
11
12
|
import {ChannelFetchUtil} from './utils/channel-fetch-util';
|
|
12
13
|
import { ChannelPayload } from './channels/channel-payload-class';
|
|
13
14
|
import {ChannelPayloadFilter} from './utils/channel-payload-filter';
|
|
14
|
-
import {
|
|
15
|
+
import {SpynePlugin} from './spyne-plugins';
|
|
15
16
|
import { deepMerge } from './utils/deep-merge';
|
|
17
|
+
import {SpyneAppProperties} from './utils/spyne-app-properties';
|
|
18
|
+
import {SpyneApp} from './spyne-app';
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* SpyneApp creates the global Spyne object, and creates the following items
|
|
21
|
-
* <ul>
|
|
22
|
-
*
|
|
23
|
-
* <li>LINK['ChannelsDelegator', 'channels-controller'] that directs the flow of data to all Channels</li>
|
|
24
|
-
* <li>LINK['SpyneChannelUI', 'spyne-channel-u-i'], that broadcast all user interaction events</li>
|
|
25
|
-
* <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>
|
|
26
|
-
* <li>LINK['SpyneChannelWindow', 'spyne-channel-window'], that broadcast all requested window and document events, such as scrolling, resizing and media queries</li>
|
|
27
|
-
* <li>LINK['SpyneChannelLifecycle', 'spyne-channel-lifecycle'], that broadcasts rendering and removing of ViewStream elements that have been directed to broadcast their lifecycle events</li>
|
|
28
|
-
* </ul>
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @module SpyneApp
|
|
32
|
-
* @type core
|
|
33
|
-
*
|
|
34
|
-
* @constructor
|
|
35
|
-
* @param {Object} config
|
|
36
|
-
* @property {Object} config - = {}; This global config object is mainly used to provide configuration details for two SpyneChannels, CHANNEL_ROUTE and CHANNEL_WINDOW.
|
|
37
|
-
*/
|
|
38
|
-
constructor(config = {}) {
|
|
39
|
-
this.channels = new ChannelsDelegator();
|
|
40
|
-
this.VERSION = '0.14.8';
|
|
41
|
-
/*!
|
|
42
|
-
* Spyne 0.14.8
|
|
43
|
-
* https://spynejs.org
|
|
44
|
-
*
|
|
45
|
-
* @license Copyright 2017-2020, Frank Batista, Relevant Context, LLC. All rights reserved.
|
|
46
|
-
* Spyne is licensed under the GNU Lesser General Public License v3.0
|
|
47
|
-
*
|
|
48
|
-
* @author: Frank Batista,
|
|
49
|
-
* @email: frbatista.nyc@gmail.com
|
|
50
|
-
*/
|
|
51
|
-
/* eslint-disable */
|
|
52
|
-
this.ViewStream = ViewStream;
|
|
53
|
-
this.BasicView = ViewStreamElement;
|
|
54
|
-
this.DomEl = DomElement;
|
|
55
|
-
this.ViewStreamBroadcaster = ViewStreamBroadcaster;
|
|
56
|
-
this.ChannelsPayload = ViewStreamPayload;
|
|
57
|
-
this.ChannelsController = ChannelsDelegator;
|
|
58
|
-
this.ChannelsBase = Channel;
|
|
59
|
-
this.ChannelPayloadItem = ChannelPayload;
|
|
60
|
-
window.Spyne = this;
|
|
61
|
-
let defaultConfig = {
|
|
62
|
-
scrollLock: false,
|
|
63
|
-
scrollLockX: 0,
|
|
64
|
-
scrollLockY: 0,
|
|
65
|
-
debug: false,
|
|
66
|
-
|
|
67
|
-
channels: {
|
|
68
|
-
WINDOW: {
|
|
69
|
-
mediqQueries: {
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
events: [],
|
|
73
|
-
listenForResize: true,
|
|
74
|
-
listenForOrientation: true,
|
|
75
|
-
listenForScroll: false,
|
|
76
|
-
listenForMouseWheel: false,
|
|
77
|
-
debounceMSTimeForResize: 200,
|
|
78
|
-
debounceMSTimeForScroll: 150
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
ROUTE: {
|
|
82
|
-
type: 'slash',
|
|
83
|
-
isHash: false,
|
|
84
|
-
isHidden: false,
|
|
85
|
-
add404s: false,
|
|
86
|
-
routes: {
|
|
87
|
-
'routePath' : {
|
|
88
|
-
'routeName' : 'change'
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
if (config !== undefined) {
|
|
96
|
-
config = SpyneUtilsChannelRoute.conformRouteObject(config);
|
|
97
|
-
window.Spyne['config'] = deepMerge(defaultConfig, config)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.getChannelActions = (str) => window.Spyne.channels.getChannelActions(str);
|
|
103
|
-
this.registerChannel = (val) => this.channels.registerStream(val);
|
|
104
|
-
this.registerDataChannel = (obs$) => this.channels.registerStream(obs$);
|
|
105
|
-
this.listChannels = () => Array.from(window.Spyne.channels.map.keys());
|
|
106
|
-
let nullHolder = new ViewStream({ id:'spyne-null-views' });
|
|
107
|
-
nullHolder.appendToDom(document.body);
|
|
108
|
-
nullHolder.props.el.style.cssText = 'display:none; opacity:0; pointer-events:none;';
|
|
109
|
-
this.channels.init();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* This is mostly used for debugging purposes
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* TITLE['<h4>Listing the registereed Channels in the browser console</h4>']
|
|
117
|
-
* SpyneApp.listChannels();
|
|
118
|
-
*
|
|
119
|
-
* @returns A list of all registered channels
|
|
120
|
-
*/
|
|
121
|
-
static listChannels() {
|
|
122
|
-
return Array.from(window.Spyne.channels.map.keys());
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* This method is useful to check in the console or in the code what actions are available to be listened to.
|
|
127
|
-
* @param {String} str
|
|
128
|
-
* @returns {Array} An array of Actions that can be listened to
|
|
129
|
-
*/
|
|
130
|
-
static getChannelActions(str) {
|
|
131
|
-
return window.Spyne.channels.getChannelActions(str);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
* This method will add the channel to the registered list so that it can subscribed by all ViewStream and Channel instances.
|
|
137
|
-
* @param {Channel} c
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
static registerChannel(c) {
|
|
142
|
-
if (window.Spyne === undefined) {
|
|
143
|
-
console.warn('Spyne has not been initialized');
|
|
144
|
-
} else {
|
|
145
|
-
return window.Spyne.channels.registerStream(c);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
window['Spyne'] = SpyneApp;
|
|
20
|
+
//window['Spyne'] = SpyneApp;
|
|
151
21
|
export {
|
|
152
22
|
ViewStreamElement,
|
|
153
23
|
Channel,
|
|
154
24
|
ChannelFetch,
|
|
155
25
|
ChannelFetchUtil,
|
|
156
|
-
|
|
26
|
+
ChannelsMap,
|
|
157
27
|
ViewStreamPayload,
|
|
158
28
|
ChannelPayload,
|
|
159
29
|
ChannelPayloadFilter,
|
|
160
30
|
DomElement,
|
|
161
|
-
|
|
31
|
+
DomElementTemplate,
|
|
162
32
|
ViewStream,
|
|
163
33
|
ViewStreamSelector,
|
|
164
34
|
ViewStreamBroadcaster,
|
|
165
35
|
SpyneTrait,
|
|
166
36
|
SpyneApp,
|
|
37
|
+
SpyneAppProperties,
|
|
38
|
+
SpynePlugin,
|
|
167
39
|
deepMerge
|
|
168
40
|
};
|
|
@@ -77,7 +77,7 @@ export class ChannelFetchUtil {
|
|
|
77
77
|
const tapLog = debug === true ? tapLogDebug : () => {};
|
|
78
78
|
|
|
79
79
|
let response$ = from(window.fetch(url, serverOptions))
|
|
80
|
-
|
|
80
|
+
.pipe(tap(tapLog), flatMap(r => from(r[responseType]())),
|
|
81
81
|
map(mapFn),
|
|
82
82
|
publish());
|
|
83
83
|
|