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
|
@@ -13,6 +13,7 @@ const SpyneConfigData = {
|
|
|
13
13
|
},
|
|
14
14
|
|
|
15
15
|
ROUTE: {
|
|
16
|
+
routeNamesArr: ['pageId', '', 'imageNum', 'author', 'photogNum', 'pixels'],
|
|
16
17
|
paramsArr: ['pageId', '', 'imageNum', 'author', 'photogNum'],
|
|
17
18
|
type: 'slash', /* "slash", "query" */
|
|
18
19
|
isHash: false,
|
|
@@ -24,8 +25,23 @@ const SpyneConfigData = {
|
|
|
24
25
|
'page-one': {
|
|
25
26
|
'routePath': {
|
|
26
27
|
'routeName': 'imageNum',
|
|
28
|
+
"work" : {
|
|
29
|
+
'routePath': {
|
|
30
|
+
'routeName': 'author',
|
|
31
|
+
'hemingway': 'hemingway'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
27
34
|
'routePath': {
|
|
28
|
-
'routeName': 'author'
|
|
35
|
+
'routeName': 'author',
|
|
36
|
+
'hemingway': 'hemingway'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
'page-one-up': {
|
|
41
|
+
'routePath': {
|
|
42
|
+
'routeName': 'imageNum',
|
|
43
|
+
'routePath': {
|
|
44
|
+
'routeName': 'pixels'
|
|
29
45
|
}
|
|
30
46
|
}
|
|
31
47
|
},
|
|
@@ -36,7 +52,8 @@ const SpyneConfigData = {
|
|
|
36
52
|
},
|
|
37
53
|
'page-.*': {
|
|
38
54
|
'routePath': {
|
|
39
|
-
'routeName': 'randomNum'
|
|
55
|
+
'routeName': 'randomNum',
|
|
56
|
+
"thirty-two" : "32"
|
|
40
57
|
}
|
|
41
58
|
}
|
|
42
59
|
}
|
|
@@ -73,6 +90,7 @@ const routeConfigWithRegexOverride = {
|
|
|
73
90
|
'regexTokens': {
|
|
74
91
|
'^$|index.html': ''
|
|
75
92
|
},
|
|
93
|
+
'routeNamesArr' : ['pageId', 'section', 'menuItem'],
|
|
76
94
|
'paramsArr': [
|
|
77
95
|
'.*',
|
|
78
96
|
'pageId',
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
const {SpyneApp} = require('../spyne/spyne-app');
|
|
3
|
+
|
|
4
|
+
describe('should run spyne app tests', () => {
|
|
5
|
+
before(()=>{
|
|
6
|
+
|
|
7
|
+
//SpyneApp.init();
|
|
8
|
+
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
it('spyne app constructor should exist', () => {
|
|
13
|
+
const constructorName = SpyneApp.constructor.name;
|
|
14
|
+
expect(constructorName).to.equal('SpyneApplication');
|
|
15
|
+
return true;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return warn if trying to initialize spyne application again', ()=>{
|
|
19
|
+
|
|
20
|
+
const warnStr = "The Spyne Application has already been initialized!";
|
|
21
|
+
const spyneAppInit2 = SpyneApp.init({}, true);
|
|
22
|
+
|
|
23
|
+
//console.log('second init returns string ',{spyneAppInit2, warnStr})
|
|
24
|
+
expect(spyneAppInit2).to.equal(warnStr);
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//import {SpyneApp} from '../spyne/spyne';
|
|
2
|
+
//const {SpyneApp} = require('../spyne/spyne');
|
|
3
|
+
const {expect, assert} = require('chai');
|
|
4
|
+
const {SpynePlugin} = require('../spyne/spyne-plugins.js');
|
|
5
|
+
|
|
6
|
+
const name = 'mySpynePlugin';
|
|
7
|
+
const config = {debug:true};
|
|
8
|
+
|
|
9
|
+
describe('should test use of spyne plugin', () => {
|
|
10
|
+
const baseConfig = {debug:false};
|
|
11
|
+
beforeEach(()=>{
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
it('spyne plugin should exist', () => {
|
|
18
|
+
//console.log('spyne plugin1 is ',spyneApp);
|
|
19
|
+
|
|
20
|
+
return true;
|
|
21
|
+
// expect(SpynePlugin).to.exist;
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
it('should get or create new spyne app', ()=>{
|
|
27
|
+
const spyneApp = SpynePlugin.getSpyneApp({name, config})
|
|
28
|
+
console.log("HERE IS ",{name, config, spyneApp})
|
|
29
|
+
|
|
30
|
+
//console.log('spune app is ',spyneApp.constructor.name)
|
|
31
|
+
expect(spyneApp.constructor.name).to.equal('SpyneApp');
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/* it('should set the plugin name', ()=>{
|
|
37
|
+
const spynePluginSetConfig = SpynePlugin.updateSpyneConfig(spyneApp, name, config);
|
|
38
|
+
|
|
39
|
+
expect(spynePluginSetConfig).to.deep.equal(config);
|
|
40
|
+
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should check if spyne plugin name already exists', ()=>{
|
|
44
|
+
const config1 = SpynePlugin.updateSpyneConfig(spyneApp, name, config);
|
|
45
|
+
const configDupe = SpynePlugin.updateSpyneConfig(spyneApp, name, config);
|
|
46
|
+
expect(configDupe).to.be.false;
|
|
47
|
+
})*/
|
|
48
|
+
|
|
49
|
+
});
|
|
@@ -3,6 +3,7 @@ import { internalViewStreamPayload, internvalRouteChannelPayload } from '../mock
|
|
|
3
3
|
import { spyneDocsDomStr } from '../mocks/spyne-docs.mocks';
|
|
4
4
|
|
|
5
5
|
import * as R from 'ramda';
|
|
6
|
+
import {UnsubscriptionError} from 'rxjs';
|
|
6
7
|
internalViewStreamPayload.srcElement.el = document.querySelector('.has-svg.github');
|
|
7
8
|
describe('channel action filter', () => {
|
|
8
9
|
let payload = internalViewStreamPayload;
|
|
@@ -23,7 +24,7 @@ describe('channel action filter', () => {
|
|
|
23
24
|
document.body.removeChild(document.getElementById('app'));
|
|
24
25
|
});
|
|
25
26
|
it('Create a new ChannelPayloadFilter', () => {
|
|
26
|
-
let filter = new ChannelPayloadFilter();
|
|
27
|
+
let filter = new ChannelPayloadFilter({test:true});
|
|
27
28
|
let filterConstructor = filter.constructor.name;
|
|
28
29
|
return filterConstructor.should.equal('Function');
|
|
29
30
|
});
|
|
@@ -41,6 +42,14 @@ describe('channel action filter', () => {
|
|
|
41
42
|
expect(filterVal).to.eq(true);
|
|
42
43
|
});
|
|
43
44
|
|
|
45
|
+
|
|
46
|
+
it('Selectors array as first prop contains match but no data', () => {
|
|
47
|
+
let filter = new ChannelPayloadFilter(['#header ul li:last-child', '#header ul li:first-child']);
|
|
48
|
+
let filterVal = filter(payload);
|
|
49
|
+
expect(filterVal).to.eq(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
|
|
44
53
|
it('Static Data and String Selector returns true', () => {
|
|
45
54
|
let selector = '#header ul li:last-child';
|
|
46
55
|
let propFilters = {
|
|
@@ -78,21 +87,23 @@ describe('channel action filter', () => {
|
|
|
78
87
|
});
|
|
79
88
|
|
|
80
89
|
it('Empty Filter', () => {
|
|
81
|
-
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const testMode = true;
|
|
91
|
+
let filter = new ChannelPayloadFilter({testMode});
|
|
92
|
+
const {selector, propFilters} = filter;
|
|
93
|
+
const isEmpty = selector === undefined && R.isEmpty(propFilters);
|
|
94
|
+
expect(isEmpty).to.eq(true);
|
|
85
95
|
});
|
|
86
96
|
|
|
87
97
|
it('Empty String selector with no data', () => {
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
const testMode = true;
|
|
99
|
+
let filter = new ChannelPayloadFilter('',{},undefined,testMode);
|
|
100
|
+
const {selector, propFilters} = filter;
|
|
101
|
+
const isEmpty = R.isEmpty(selector) && R.isEmpty(propFilters);
|
|
102
|
+
expect(isEmpty).to.eq(true);
|
|
92
103
|
});
|
|
93
104
|
|
|
94
|
-
it('
|
|
95
|
-
let filter = new ChannelPayloadFilter(['', '
|
|
105
|
+
it('Arrays of selectors with no data', () => {
|
|
106
|
+
let filter = new ChannelPayloadFilter(['a.test', 'a.b'], {});
|
|
96
107
|
let filterVal = filter(payload);
|
|
97
108
|
expect(filterVal).to.eq(false);
|
|
98
109
|
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
const R = require('ramda');
|
|
3
|
+
import {ChannelPayloadToTestFilters} from '../mocks/channel-payload-data';
|
|
4
|
+
import {ChannelDataPacketGenerator} from '../../spyne/utils/channel-data-packet-generator';
|
|
5
|
+
import {ChannelDataPacket} from '../../spyne/utils/channel-data-packet';
|
|
6
|
+
|
|
7
|
+
describe('should test the ChannelDataPacketGenerator', () => {
|
|
8
|
+
|
|
9
|
+
it('should test the packet geneator', () => {
|
|
10
|
+
|
|
11
|
+
const packetGenerator = new ChannelDataPacketGenerator();
|
|
12
|
+
|
|
13
|
+
//console.log('packet gen is ',{ChannelPayloadToTestFilters})
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
return true;
|
|
17
|
+
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create a custom label for the map location', ()=>{
|
|
21
|
+
const packetLabel = ChannelDataPacketGenerator.createLabel();
|
|
22
|
+
const isValidString = /^(\w)+$/.test(packetLabel);
|
|
23
|
+
expect(isValidString).to.be.true;
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should create a timestamp',()=>{
|
|
27
|
+
const timestamp = ChannelDataPacketGenerator.createTimeStamp();
|
|
28
|
+
expect(timestamp).to.be.a('number');
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should create an empty unpacked data file', ()=>{
|
|
32
|
+
const unpackedDataArr = ChannelDataPacketGenerator.createUnpackedDataArr(ChannelPayloadToTestFilters);
|
|
33
|
+
expect(unpackedDataArr).to.be.a('array');
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should allow for predicate test filter on packed data ',()=>{
|
|
37
|
+
const map = new Map();
|
|
38
|
+
const label = ChannelDataPacketGenerator.createLabel();
|
|
39
|
+
map.set(label, ChannelPayloadToTestFilters);
|
|
40
|
+
|
|
41
|
+
const filterGateway = ChannelDataPacketGenerator.createFilterGateway(label, map);
|
|
42
|
+
const pred = R.propEq('action', 'CHANNEL_ROUTE_CHANGE_EVENT');
|
|
43
|
+
|
|
44
|
+
const isCorrectAction = filterGateway(pred)
|
|
45
|
+
|
|
46
|
+
expect(isCorrectAction).to.be.true;
|
|
47
|
+
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('should create data packet ',()=>{
|
|
51
|
+
const channelDataPacketGen = new ChannelDataPacketGenerator();
|
|
52
|
+
|
|
53
|
+
console.time('initPacket');
|
|
54
|
+
const channelDataPacket = channelDataPacketGen.createDataPacket(ChannelPayloadToTestFilters, ['channelName', 'action']);
|
|
55
|
+
//console.log('channel data packet ',channelDataPacket.props)
|
|
56
|
+
console.timeEnd('initPacket');
|
|
57
|
+
|
|
58
|
+
//console.log("CHANNEL DATA ALL ",channelDataPacket);
|
|
59
|
+
channelDataPacket.unPacked = true;
|
|
60
|
+
//console.log("CHANNEL DATA ALL 2 ",channelDataPacket.srcElement);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
return true;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
it('should create a stripped down unpacked data obj', ()=>{
|
|
71
|
+
|
|
72
|
+
var obj = {
|
|
73
|
+
'type' : 'dog',
|
|
74
|
+
'says' : 'woof'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var obj2 = {
|
|
78
|
+
'type' : 'cat',
|
|
79
|
+
'says' : 'meow',
|
|
80
|
+
'_unpacked' : false,
|
|
81
|
+
'loc' : 'dog'
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Object.defineProperty(obj2, 'unpacked', {
|
|
88
|
+
|
|
89
|
+
get: ()=>obj2._unpacked,
|
|
90
|
+
set: (b) => {
|
|
91
|
+
if(b===true){
|
|
92
|
+
obj2.type = window[obj2.loc].type;
|
|
93
|
+
obj2.says = window[obj2.loc].says;
|
|
94
|
+
obj2._unpacked = b;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
window['dog'] = obj;
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
//console.log(' both objs is ',window.dog, obj2);
|
|
107
|
+
obj2.unpacked = true;
|
|
108
|
+
// console.log(' both objs is ',window.dog, obj2);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
return true;
|
|
112
|
+
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
import {SpynePluginsMethods} from '../../spyne/utils/spyne-plugins-methods';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const spynePluginMethods = new SpynePluginsMethods();
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const methodsObj = {
|
|
10
|
+
myFn1: ()=>{
|
|
11
|
+
return 'first method value'
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
myFn2: ()=>{
|
|
15
|
+
return 'second method vaue'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const dupeMethods = {
|
|
21
|
+
|
|
22
|
+
myFn1: ()=>{
|
|
23
|
+
return 'this is a dupe method'
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
myFn4: ()=>{
|
|
27
|
+
return 'second method vaue'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const methodsObjWrong = {
|
|
36
|
+
myStr1: "This should be a valid method.",
|
|
37
|
+
|
|
38
|
+
myFn3: ()=>{
|
|
39
|
+
return 'second method vaue'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const methodsArr = [
|
|
47
|
+
{
|
|
48
|
+
myFn1: ()=>{
|
|
49
|
+
return 'first method value'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
//console.log('plugin methods1 is ',{spynePluginMethods})
|
|
57
|
+
|
|
58
|
+
describe('should test spyne plugins methods', () => {
|
|
59
|
+
|
|
60
|
+
it('should test that SpynePluginsMethods exists', () => {
|
|
61
|
+
|
|
62
|
+
expect(spynePluginMethods).to.exist;
|
|
63
|
+
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should get the plugin object', ()=>{
|
|
67
|
+
const pluginsMethodObj = spynePluginMethods.pluginMethodsObj
|
|
68
|
+
expect(pluginsMethodObj).to.be.an('object');
|
|
69
|
+
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should check if methodsObj is valid obj', ()=>{
|
|
73
|
+
const warnStr = spynePluginMethods.addMethods(methodsArr, true);
|
|
74
|
+
expect(warnStr).to.be.a('string');
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should return error for non method vals', ()=>{
|
|
78
|
+
const warnStr = spynePluginMethods.addMethods(methodsObjWrong, true);
|
|
79
|
+
expect(warnStr).to.be.a('string');
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
it('should add methods from key value pairs', ()=>{
|
|
85
|
+
|
|
86
|
+
spynePluginMethods.addMethods(methodsObj);
|
|
87
|
+
|
|
88
|
+
const pluginMethodsObj = spynePluginMethods.pluginMethodsObj;
|
|
89
|
+
const firstMethodVal =pluginMethodsObj.myFn1()
|
|
90
|
+
expect(firstMethodVal).to.equal(methodsObj.myFn1());
|
|
91
|
+
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
it('should capture already created methods', ()=>{
|
|
96
|
+
|
|
97
|
+
const warnStr = spynePluginMethods.addMethods(dupeMethods, true);
|
|
98
|
+
expect(warnStr).to.be.a('string');
|
|
99
|
+
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
});
|
|
@@ -129,7 +129,7 @@ describe('Dom Item Selector', () => {
|
|
|
129
129
|
let el$ = ViewStreamSelector("ul#my-list");
|
|
130
130
|
let el1 = el.querySelector('li:nth-child(1)');
|
|
131
131
|
let liList = el$('li');
|
|
132
|
-
liList.setActiveItem('bar','li:nth-child(
|
|
132
|
+
liList.setActiveItem('bar','li:nth-child(5)');
|
|
133
133
|
let hasBarClassBool = el1.classList.contains('bar');
|
|
134
134
|
expect(hasBarClassBool).to.eq(false);
|
|
135
135
|
});
|
package/webpack.config.js
CHANGED
|
@@ -2,7 +2,13 @@ const path = require('path');
|
|
|
2
2
|
const webpack = require('webpack');
|
|
3
3
|
const PACKAGE = require('./package');
|
|
4
4
|
const version = PACKAGE.version;
|
|
5
|
-
const
|
|
5
|
+
const getEnv = ()=>{
|
|
6
|
+
const npmCommand = process.env.npm_lifecycle_script;
|
|
7
|
+
return String(npmCommand).replace(/^(webpack.*--env)(\s)*(\w+)(.*)$/gm, "$3");
|
|
8
|
+
}
|
|
9
|
+
const env = getEnv();
|
|
10
|
+
|
|
11
|
+
|
|
6
12
|
const libraryName = 'spyne';
|
|
7
13
|
let moduleRulesArr = [];
|
|
8
14
|
let devToolValue = 'eval-source-map';
|
|
@@ -20,14 +26,18 @@ const loaderOptionsPlugin = new webpack.LoaderOptionsPlugin({ options: {
|
|
|
20
26
|
});
|
|
21
27
|
|
|
22
28
|
let bannerPlugin = new webpack.BannerPlugin({
|
|
23
|
-
banner: `spynejs ${version}\nhttps://sypnejs.org\n(c) 2017-present Frank Batista
|
|
29
|
+
banner: `spynejs ${version}\nhttps://sypnejs.org\n(c) 2017-present Frank Batista`,
|
|
30
|
+
entryOnly:true
|
|
24
31
|
})
|
|
25
32
|
|
|
33
|
+
//console.log("ENVI S HERE ===========",env);
|
|
34
|
+
|
|
35
|
+
|
|
26
36
|
let spynePlugins = [loaderOptionsPlugin];
|
|
27
37
|
|
|
28
38
|
if (env === 'build') {
|
|
29
39
|
outputFile = libraryName + '.min.js';
|
|
30
|
-
devToolValue =
|
|
40
|
+
devToolValue = false;
|
|
31
41
|
externalsArr = [
|
|
32
42
|
WebpackRxjsExternals(),
|
|
33
43
|
{ramda : {
|
|
@@ -37,9 +47,9 @@ if (env === 'build') {
|
|
|
37
47
|
root: 'R'
|
|
38
48
|
}}
|
|
39
49
|
];
|
|
40
|
-
} else {
|
|
50
|
+
} else if(env === 'dev') {
|
|
41
51
|
outputFile = libraryName + '.js';
|
|
42
|
-
moduleRulesArr.push(
|
|
52
|
+
/* moduleRulesArr.push(
|
|
43
53
|
{
|
|
44
54
|
test: /(\.js)$/,
|
|
45
55
|
loader: 'babel-loader',
|
|
@@ -60,22 +70,16 @@ if (env === 'build') {
|
|
|
60
70
|
exclude: /(node_modules)/
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
)
|
|
73
|
+
)*/
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
console.log("CONFIG IS ",process.env.BABEL_ENV );
|
|
76
|
+
//console.log("CONFIG IS ",process.env.BABEL_ENV );
|
|
67
77
|
|
|
68
78
|
|
|
69
79
|
const config = {
|
|
70
80
|
entry: path.join(__dirname, '/src/spyne/spyne.js'),
|
|
71
|
-
devtool:
|
|
72
|
-
|
|
73
|
-
path: path.join(__dirname, '/lib'),
|
|
74
|
-
filename: outputFile,
|
|
75
|
-
library: 'spyne',
|
|
76
|
-
libraryTarget: 'umd',
|
|
77
|
-
umdNamedDefine: true
|
|
78
|
-
},
|
|
81
|
+
devtool: false,
|
|
82
|
+
|
|
79
83
|
|
|
80
84
|
|
|
81
85
|
externals: externalsArr,
|
|
@@ -89,5 +93,16 @@ const config = {
|
|
|
89
93
|
},
|
|
90
94
|
plugins: spynePlugins
|
|
91
95
|
};
|
|
96
|
+
//console.log("ENV IS ============ ",env);
|
|
97
|
+
|
|
98
|
+
if (env!==undefined){
|
|
99
|
+
config['output'] = {
|
|
100
|
+
path: path.join(__dirname, '/lib'),
|
|
101
|
+
filename: outputFile,
|
|
102
|
+
library: 'spyne',
|
|
103
|
+
libraryTarget: 'umd',
|
|
104
|
+
umdNamedDefine: true
|
|
105
|
+
};
|
|
106
|
+
}
|
|
92
107
|
|
|
93
108
|
module.exports = config;
|