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.
Files changed (82) hide show
  1. package/.travis.yml +1 -1
  2. package/README.md +0 -60
  3. package/karma.conf.js +18 -69
  4. package/lib/spyne.js +29755 -28678
  5. package/lib/spyne.min.js +1 -1
  6. package/lib/spyne.min.js.LICENSE.txt +9 -9
  7. package/package.json +21 -42
  8. package/src/spyne/channels/channel-fetch-class.js +25 -5
  9. package/src/spyne/channels/channel-payload-class.js +36 -23
  10. package/src/spyne/channels/channel-proxy.js +7 -5
  11. package/src/spyne/channels/channel.js +54 -28
  12. package/src/spyne/channels/channels-config.js +2 -4
  13. package/src/spyne/channels/{channels-delegator.js → channels-map.js} +24 -40
  14. package/src/spyne/channels/spyne-channel-lifecycle.js +1 -2
  15. package/src/spyne/channels/spyne-channel-route.js +21 -62
  16. package/src/spyne/channels/spyne-channel-ui.js +1 -2
  17. package/src/spyne/channels/spyne-channel-window.js +24 -35
  18. package/src/spyne/spyne-app.js +165 -0
  19. package/src/spyne/spyne-plugins.js +39 -41
  20. package/src/spyne/spyne.js +6 -158
  21. package/src/spyne/utils/channel-config-validator.js +0 -1
  22. package/src/spyne/utils/channel-fetch-util.js +1 -2
  23. package/src/spyne/utils/channel-payload-filter.js +9 -76
  24. package/src/spyne/utils/frp-tools.js +21 -1
  25. package/src/spyne/utils/gc.js +1 -1
  26. package/src/spyne/utils/route-channel-updater.js +0 -4
  27. package/src/spyne/utils/spyne-app-properties.js +183 -0
  28. package/src/spyne/utils/spyne-logger.js +18 -0
  29. package/src/spyne/utils/spyne-plugins-methods.js +97 -0
  30. package/src/spyne/utils/spyne-trait.js +2 -5
  31. package/src/spyne/utils/spyne-utils-channel-route-url.js +3 -8
  32. package/src/spyne/utils/spyne-utils-channel-route.js +6 -14
  33. package/src/spyne/utils/spyne-utils-channel-window.js +1 -3
  34. package/src/spyne/utils/viewstream-observables.js +2 -3
  35. package/src/spyne/views/dom-element-template.js +2 -7
  36. package/src/spyne/views/dom-element.js +0 -19
  37. package/src/spyne/views/view-stream-broadcaster.js +5 -10
  38. package/src/spyne/views/view-stream-element.js +1 -18
  39. package/src/spyne/views/view-stream-payload.js +31 -37
  40. package/src/spyne/views/view-stream-selector.js +3 -8
  41. package/src/spyne/views/view-stream.js +281 -297
  42. package/src/tests/channels/channel-fetch.test.js +102 -0
  43. package/src/tests/channels/channel-payload-class.test.js +14 -5
  44. package/src/tests/channels/channel-payload-filter.test.js +3 -28
  45. package/src/tests/channels/channel.test.js +38 -0
  46. package/src/tests/index.js +0 -1
  47. package/src/tests/index.test.js +6 -0
  48. package/src/tests/spyne-app.test.js +27 -0
  49. package/src/tests/spyne-plugin.test.js +13 -9
  50. package/src/tests/utils/plugins-methods.test.js +103 -0
  51. package/src/tests/utils/spyne-app-properties.test.js +11 -0
  52. package/webpack.config.js +19 -34
  53. package/lib/channel-action-filter.test.3516417154.js +0 -20
  54. package/lib/channel-dom.test.104366832.js +0 -20
  55. package/lib/channel-fetch-util.test.3506167575.js +0 -20
  56. package/lib/channel-payload-class.test.1081032524.js +0 -20
  57. package/lib/channel-payload-filter.test.977308429.js +0 -20
  58. package/lib/channel-route.test.3513636042.js +0 -20
  59. package/lib/channel-stream-item.test.119388071.js +0 -20
  60. package/lib/channel-ui.test.3778619579.js +0 -20
  61. package/lib/channel-util-dom.test.908537750.js +0 -20
  62. package/lib/commons.js +0 -49274
  63. package/lib/dom-el-selectors.test.1268485916.js +0 -20
  64. package/lib/dom-el-template.test.842696987.js +0 -20
  65. package/lib/dom-el.test.2045076905.js +0 -20
  66. package/lib/frp-tools.test.2503042868.js +0 -20
  67. package/lib/import.test.2658619365.js +0 -20
  68. package/lib/index.test.2372977745.js +0 -20
  69. package/lib/route-utils.test.273346057.js +0 -20
  70. package/lib/runtime.js +0 -172
  71. package/lib/spyne-plugin.test.301647328.js +0 -20
  72. package/lib/spyne.js.map +0 -1
  73. package/lib/url-utils.test.1931189114.js +0 -20
  74. package/lib/view-stream-broadcaster.test.1306675435.js +0 -20
  75. package/lib/view-stream-enhancer-loader.test.3617829096.js +0 -20
  76. package/lib/view-stream-enhancer.test.1053738169.js +0 -20
  77. package/lib/view-stream.test.573231784.js +0 -20
  78. package/src/spyne/channels/lifestream-payload.js +0 -56
  79. package/src/spyne/utils/channel-data-packet-generator.js +0 -200
  80. package/src/spyne/utils/channel-data-packet.js +0 -59
  81. package/src/spyne/utils/viewstream-dom-utils.js +0 -51
  82. package/src/spyne/views/view-stream-enhancer-loader.js +0 -70
@@ -1,200 +0,0 @@
1
- import {ChannelDataPacket} from './channel-data-packet';
2
- import {deepMerge} from './deep-merge';
3
- import {
4
- keys,
5
- compose,
6
- pick,
7
- mergeAll,
8
- reject,
9
- omit,
10
- map,
11
- path,
12
- clone,
13
- ifElse,
14
- prop,
15
- invoker,
16
- identity,
17
- } from 'ramda';
18
-
19
- export class ChannelDataPacketGenerator {
20
-
21
- constructor() {
22
-
23
-
24
- this._packetMap = new Map();
25
- // this._packetObj = {};
26
- this._iter = 0;
27
- this.createFilterGateway = ChannelDataPacketGenerator.createFilterGateway.bind(this);
28
-
29
- //console.log('data packet controller constructor ',this._packetMap);
30
- this.createDataPacket = ChannelDataPacketGenerator.createDataPacket.bind(this);
31
- this.createLabel = ChannelDataPacketGenerator.createLabel.bind(this);
32
-
33
- }
34
-
35
- static deepFreeze(o) {
36
- try {
37
- Object.freeze(o);
38
- Object.getOwnPropertyNames(o).forEach(function(prop) {
39
- if (o.hasOwnProperty(prop)
40
- && o[prop] !== null
41
- && (typeof o[prop] === "object" || typeof o[prop] === "function")
42
- && !Object.isFrozen(o[prop])) {
43
- ChannelDataPacketGenerator.deepFreeze(o[prop]);
44
- }
45
- });
46
-
47
- } catch(e){
48
- // console.log("FREEZE ERR ",{o,e});
49
- return o;
50
-
51
- }
52
-
53
- return o;
54
- }
55
-
56
- static createDataPacket(_packedData={}, exposedPropsArr=[]){
57
-
58
- _packedData = ChannelDataPacketGenerator.deepFreeze(_packedData);
59
-
60
- //console.log('data packet gen is ', this)
61
- const label = this.createLabel();
62
- //console.time(label);
63
- //window.spyneTmp[label]=_packedData;//(['payload'], _packedData);
64
- // this._packetObj[label]=_packedData;
65
- const isPacket = true;
66
- this._packetMap.set(label, _packedData);
67
-
68
- const _packedDataKeys = compose(keys, omit(['props']))(_packedData);
69
- //console.log("PACKED KEYS IS ",_packedDataKeys)
70
- const _unPacked = false;
71
- const timestamp = ChannelDataPacketGenerator.createTimeStamp();
72
-
73
- const filterGateway = this.createFilterGateway(_packedData);
74
- //console.timeEnd(label);
75
-
76
- const reduceProps = (acc={}, k) => {
77
- if (k ==='props'){
78
- return acc;
79
- }
80
-
81
- acc[k] = _packedData[k];
82
- return acc;
83
- }
84
-
85
- const baseProps = exposedPropsArr.reduce(reduceProps, {});
86
-
87
- //console.log('base props ',{baseProps})
88
-
89
- // const baseProps = pick(exposedPropsArr, data);
90
-
91
- const ifElseFn = ifElse(prop('props'), invoker(0, 'props'), identity);
92
-
93
- const props = () => {
94
- return ifElseFn(this._packetMap.get(label));
95
- }
96
- const props2 = () => {
97
- return this._packetMap.get(label).props();
98
- }
99
- const users = ()=>{
100
- // return window.spyneTmp[label];
101
- return this._packetMap.get(label).payload.users;
102
- // return this._packetObj[label].payload.users;
103
- }
104
-
105
-
106
-
107
- const addBackValuesToKeys = ()=> {
108
- const data = this._packetMap.get(label);
109
- const addValues = (k)=>{
110
- //console.log('k value is ',{k},channelDataPacket)
111
- channelDataPacket[k] = data[k];
112
- }
113
-
114
- _packedDataKeys.forEach(addValues);
115
- }
116
-
117
- const onSetUnpacked = (b)=>{
118
- if (b===true){
119
- addBackValuesToKeys();
120
- }
121
- }
122
-
123
-
124
- /*
125
-
126
- Object.defineProperties(channelDataPacket, {
127
-
128
- props: {
129
- get: getProps
130
- },
131
-
132
- packedData: {
133
- get: ()=>()=>this._packetMap.get(label)
134
- },
135
- unPacked: {
136
- get: ()=>_unPacked,
137
- set: onSetUnpacked
138
-
139
- }
140
-
141
- });
142
-
143
-
144
- */
145
- const packedData = ()=>this._packetMap.get(label);
146
- const unpack = addBackValuesToKeys;
147
-
148
- let obj = Object.create(null);
149
-
150
- let channelDataPacket = mergeAll([{timestamp, label, props,users, isPacket, packedData, unpack, filterGateway}, baseProps]);
151
- channelDataPacket = deepMerge(channelDataPacket, obj);
152
-
153
- //console.log('packet is ',channelDataPacket);
154
- return channelDataPacket;
155
-
156
- }
157
-
158
- static createAllPassFilterGateway(){
159
-
160
-
161
- }
162
-
163
- static createFilterGateway(label, map=this._packetMap){
164
- return (pred)=>{
165
- if (typeof(pred)==='function'){
166
- try {
167
- return pred(map.get(label));
168
- } catch(e){
169
- console.log('predicate not working -> ',e);
170
- }
171
- }
172
-
173
- return false;
174
- }
175
-
176
- }
177
-
178
- static createUnpackedDataArr(data){
179
-
180
- return keys(data);
181
- }
182
-
183
-
184
- static createLabel(iter=this._iter++) {
185
-
186
- return `packet_num_${this._iter}`;
187
- }
188
-
189
- static createTimeStamp(){
190
- return Date.now();
191
- }
192
-
193
-
194
-
195
- static createPacketUnpacker(){
196
-
197
- }
198
-
199
-
200
- }
@@ -1,59 +0,0 @@
1
- export class ChannelDataPacket {
2
-
3
- constructor(details) {
4
- const {unpacker, filterGateway, keys} = details;
5
-
6
-
7
- console.log('create a data packet that can be unpacked')
8
- this._filterUnpackedData = filterGateway;
9
- this._windowPacket = data;
10
- this._packet = keys(data);;
11
- this._isPacket = true;
12
- this._unpacked = false;
13
- this._timeStamp = this.createTimeStamp();
14
- this._packetLocationArr = [];
15
-
16
- }
17
-
18
-
19
- static generateEmptyPacket(){
20
-
21
- }
22
-
23
-
24
- static createEmptyPacket(){
25
-
26
- }
27
-
28
-
29
-
30
- filterPacket(){
31
- console.log("RUN FILTERED METHOD THROUGH WINDOW OBJECT")
32
-
33
- }
34
-
35
- get packetLocationArr(){
36
- return this._packetLocationArr;
37
- }
38
-
39
- set unpacked(bool=false){
40
- console.log("IF BOOL === true, then clone window reference into packet")
41
-
42
- }
43
-
44
-
45
-
46
-
47
-
48
- get isPacket(){
49
- return true;
50
- }
51
-
52
- createTimeStamp(){
53
-
54
- }
55
-
56
-
57
-
58
-
59
- }
@@ -1,51 +0,0 @@
1
- import {path, assocPath} from 'ramda';
2
-
3
- export function createElement(tagName = 'div') {
4
- return document.createElement(tagName);
5
- }
6
- export function setData(data = {}) {
7
- return data;
8
- }
9
- export function addAttributes(el, attrs = {}) {
10
- }
11
-
12
-
13
- export function testDomTemplateForTableTags(HTMLStr){
14
- //const reFromConfig = path(pathArr, window)
15
-
16
- const addREToConfig = function(){
17
- const tableRE = /^([^>]*?)(<){1}(\b)(thead|col|colgroup|tbody|td|tfoot|tr|th)(\b)([^\0]*)$/;
18
- const pathArr = ['Spyne', 'config', 'utils', 'tableRE'];
19
-
20
- if (window){
21
- assocPath(pathArr, tableRE, window);
22
- }
23
- return tableRE;
24
- }
25
- const re = window.Spyne.config.utils['tableRE'] || addREToConfig();
26
- return re.test(HTMLStr)
27
-
28
- }
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
- export function testDomTemplateForTableTags5(HTMLStr){
37
- const pathArr = ['Spyne', 'config', 'utils', 'tableRE'];
38
- const reFromConfig = path(pathArr, window)
39
-
40
- const addREToConfig = function(){
41
- const tableRE = /^([^>]*?)(<){1}(\b)(thead|col|colgroup|tbody|td|tfoot|tr|th)(\b)([^\0]*)$/;
42
-
43
- if (window){
44
- assocPath(pathArr, tableRE, window);
45
- }
46
- return tableRE;
47
- }
48
- const re = reFromConfig ? reFromConfig : addREToConfig();
49
- return re.test(HTMLStr)
50
-
51
- }
@@ -1,70 +0,0 @@
1
- import { getAllMethodNames } from '../utils/frp-tools';
2
- import {concat, includes, __, filter, map, dropWhile, forEach} from 'ramda';
3
-
4
- export class ViewStreamEnhancerLoader {
5
- constructor(parent, enhancersArr) {
6
- this.context = parent;
7
- this.enhancersMap = new Map();
8
- this.enhancersArr = enhancersArr;
9
-
10
- this.initMap();
11
- this.addAllEnhancerMethods();
12
- }
13
-
14
- initMap() {
15
- this.enhancersMap.set('ALL', []);
16
- let allMethodsArr = getAllMethodNames(this.context).allMethods;
17
- this.updateMap('LOCAL', allMethodsArr);
18
- }
19
-
20
- getEnhancersMap() {
21
- return this.enhancersMap;
22
- }
23
-
24
- updateMap(name, arr) {
25
- let allArr = concat(this.enhancersMap.get('ALL'), arr);
26
- this.enhancersMap.set(name, arr);
27
- this.enhancersMap.set('ALL', allArr);
28
- }
29
-
30
- getMethodsArr(str) {
31
- return this.enhancersMap.get(str);
32
- }
33
-
34
- createEnhancerMethodsObj(EnhancerClass) {
35
- const sendError = str => console.error(
36
- `Spyne Error: The following enhancer method, "${str}", already exists and cannot be added to the ${enhancer.name} Enhancer!`);
37
- let enhancer = new EnhancerClass(this.context);
38
-
39
- const validateMethods = arr => {
40
- let methodsExistsFilter = includes(__, this.getMethodsArr('ALL'));
41
- let dupedMethods = filter(methodsExistsFilter, arr);
42
- dupedMethods.forEach(sendError);
43
- return dupedMethods;
44
- };
45
-
46
- let enhancerMethodsObj = enhancer.getEnhancerMethods();
47
- let dupedMethodsArr = validateMethods(enhancerMethodsObj.allMethods);
48
- let dropDupedMethodsFromArr = dropWhile(
49
- includes(__, dupedMethodsArr));
50
-
51
- enhancerMethodsObj = map(dropDupedMethodsFromArr, enhancerMethodsObj);
52
-
53
- this.updateMap(enhancer.name, enhancerMethodsObj.allMethods);
54
-
55
- enhancerMethodsObj['enhancer'] = enhancer;
56
- enhancerMethodsObj['name'] = enhancer.name;
57
-
58
- return enhancerMethodsObj;
59
- }
60
-
61
- addAllEnhancerMethods() {
62
- const addEnhancerMethods = (enhancerClass) => {
63
- let enhancerMethodsObj = this.createEnhancerMethodsObj(enhancerClass);
64
- let enhancer = enhancerMethodsObj.enhancer;
65
- enhancer.bindParentViewStream(enhancerMethodsObj, this.context);
66
- };
67
-
68
- forEach(addEnhancerMethods, this.enhancersArr);
69
- }
70
- }