spyne 0.19.1 → 0.20.0

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 (129) hide show
  1. package/.eslintrc.js +4 -3
  2. package/.travis.yml +24 -11
  3. package/karma.conf.js +76 -86
  4. package/lib/spyne.esm.js +15 -0
  5. package/lib/spyne.esm.js.map +1 -0
  6. package/lib/spyne.umd.js +9565 -0
  7. package/package.json +47 -27
  8. package/rollup.config.js +26 -0
  9. package/src/spyne/channels/channel-fetch-class.js +39 -43
  10. package/src/spyne/channels/channel-payload-class.js +61 -74
  11. package/src/spyne/channels/channel-proxy.js +25 -26
  12. package/src/spyne/channels/channel.js +141 -149
  13. package/src/spyne/channels/channels-config.js +46 -47
  14. package/src/spyne/channels/channels-map.js +61 -65
  15. package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
  16. package/src/spyne/channels/spyne-channel-route.js +241 -250
  17. package/src/spyne/channels/spyne-channel-ui.js +213 -75
  18. package/src/spyne/channels/spyne-channel-window.js +157 -157
  19. package/src/spyne/spyne-app.js +32 -19
  20. package/src/spyne/spyne-plugins.js +55 -70
  21. package/src/spyne/spyne.js +23 -23
  22. package/src/spyne/utils/channel-config-validator.js +10 -10
  23. package/src/spyne/utils/channel-fetch-util.js +72 -55
  24. package/src/spyne/utils/channel-payload-filter.js +89 -100
  25. package/src/spyne/utils/deep-merge.js +31 -29
  26. package/src/spyne/utils/frp-tools.js +108 -92
  27. package/src/spyne/utils/gc.js +6 -6
  28. package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
  29. package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
  30. package/src/spyne/utils/route-channel-updater.js +23 -29
  31. package/src/spyne/utils/safe-clone.js +40 -58
  32. package/src/spyne/utils/sanitize-html.js +35 -0
  33. package/src/spyne/utils/security-policy.js +11 -0
  34. package/src/spyne/utils/spyne-app-properties.js +110 -114
  35. package/src/spyne/utils/spyne-logger.js +4 -11
  36. package/src/spyne/utils/spyne-plugins-methods.js +38 -63
  37. package/src/spyne/utils/spyne-trait.js +33 -33
  38. package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
  39. package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
  40. package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
  41. package/src/spyne/utils/viewstream-animations.js +12 -12
  42. package/src/spyne/utils/viewstream-observables.js +45 -45
  43. package/src/spyne/views/dom-element-template.js +111 -114
  44. package/src/spyne/views/dom-element.js +82 -84
  45. package/src/spyne/views/view-stream-broadcaster.js +66 -62
  46. package/src/spyne/views/view-stream-element.js +105 -106
  47. package/src/spyne/views/view-stream-payload.js +25 -27
  48. package/src/spyne/views/view-stream-selector.js +157 -163
  49. package/src/spyne/views/view-stream.js +416 -640
  50. package/src/tests/channels/channel-dom.test.js +15 -15
  51. package/src/tests/channels/channel-fetch.test.js +51 -62
  52. package/src/tests/channels/channel-payload-class.test.js +50 -63
  53. package/src/tests/channels/channel-payload-filter.test.js +133 -193
  54. package/src/tests/channels/channel-route.test.js +102 -112
  55. package/src/tests/channels/channel-stream-item.test.js +19 -19
  56. package/src/tests/channels/channel-ui.test.js +15 -27
  57. package/src/tests/channels/channel-util-dom.test.js +31 -31
  58. package/src/tests/channels/channel.test.js +20 -25
  59. package/src/tests/channels/route-utils.test.js +61 -66
  60. package/src/tests/channels/url-utils.test.js +151 -151
  61. package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
  62. package/src/tests/import.test.js +5 -5
  63. package/src/tests/index.js +6 -7
  64. package/src/tests/index.test.js +6 -8
  65. package/src/tests/mocks/channel-payload-data.js +218 -220
  66. package/src/tests/mocks/enhancer.test.js +5 -5
  67. package/src/tests/mocks/payload-ui.js +87 -90
  68. package/src/tests/mocks/routes-data.js +264 -266
  69. package/src/tests/mocks/spyne-docs.mocks.js +3 -3
  70. package/src/tests/mocks/template-renderer.mocks.js +47 -47
  71. package/src/tests/mocks/utils-data.js +78 -79
  72. package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
  73. package/src/tests/mocks/window-events-arr.js +1 -1
  74. package/src/tests/package-json.spec.test.js +9 -0
  75. package/src/tests/spyne-app.test.js +15 -18
  76. package/src/tests/spyne-plugin.test.js +16 -20
  77. package/src/tests/utils/channel-action-filter.test.js +84 -86
  78. package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
  79. package/src/tests/utils/channel-fetch-util.test.js +64 -66
  80. package/src/tests/utils/frp-tools.test.js +19 -19
  81. package/src/tests/utils/plugins-methods.test.js +31 -55
  82. package/src/tests/utils/security.test.js +10 -0
  83. package/src/tests/utils/spyne-app-properties.test.js +4 -8
  84. package/src/tests/views/dom-el-selectors.test.js +112 -119
  85. package/src/tests/views/dom-el-template-proxy.test.js +7 -0
  86. package/src/tests/views/dom-el-template.test.js +186 -156
  87. package/src/tests/views/dom-el.test.js +58 -56
  88. package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
  89. package/src/tests/views/view-stream-enhancer.test.js +11 -11
  90. package/src/tests/views/view-stream.test.js +22 -33
  91. package/webpack.config.js +76 -67
  92. package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
  93. package/docs/DomItem.html +0 -298
  94. package/docs/DomItem_DomItem.html +0 -314
  95. package/docs/ViewStream.html +0 -2249
  96. package/docs/ViewStream_ViewStream.html +0 -503
  97. package/docs/custom/css/jsdoc-viewstream.css +0 -377
  98. package/docs/custom/layout.tmpl +0 -47
  99. package/docs/dom-item.js.html +0 -213
  100. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  101. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  102. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  103. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  104. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  105. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  106. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  107. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  108. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  109. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  110. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  111. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  112. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  113. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  114. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  115. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  116. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  117. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  118. package/docs/global.html +0 -548
  119. package/docs/index-custom.html +0 -79
  120. package/docs/index.html +0 -82
  121. package/docs/jsdoc.config.json +0 -22
  122. package/docs/scripts/linenumber.js +0 -25
  123. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  124. package/docs/scripts/prettify/lang-css.js +0 -2
  125. package/docs/scripts/prettify/prettify.js +0 -28
  126. package/docs/styles/jsdoc-default.css +0 -358
  127. package/docs/styles/prettify-jsdoc.css +0 -111
  128. package/docs/styles/prettify-tomorrow.css +0 -132
  129. package/docs/view-stream.js.html +0 -767
package/package.json CHANGED
@@ -1,35 +1,53 @@
1
1
  {
2
2
  "name": "spyne",
3
- "sideEffects": false,
4
- "version": "0.19.1",
3
+ "version": "0.20.0",
5
4
  "description": "Reactive Real-DOM Framework for Advanced Javascript applications",
6
- "main": "lib/spyne.min.js",
7
- "module": "src/spyne/spyne.js",
5
+ "sideEffects": true,
6
+ "main": "./lib/spyne.umd.js",
7
+ "module": "./lib/spyne.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./lib/spyne.esm.js",
11
+ "require": "./lib/spyne.umd.js"
12
+ },
13
+ "./lib/*": "./lib/*.js"
14
+ },
8
15
  "scripts": {
9
16
  "eslint-fix-dry": "eslint 'src/spyne/**' --fix-dry-run",
10
- "eslint-fix": "eslint --fix 'src/spyne/**'",
11
- "eslint-fix-tests": "eslint --fix 'src/tests/**'",
17
+ "eslint-fix": "eslint --fix 'src/spyne/**'",
18
+ "eslint-fix-tests": "eslint --fix 'src/tests/**'",
12
19
  "report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
13
20
  "commit": "git-cz",
14
- "build": "webpack --mode production --env build ",
15
- "start": "webpack-dev-server --hot ",
16
- "dev": "webpack --mode development --progress --watch --env dev ",
17
- "stats": "webpack --profile --json --optimize-minimize --mode production --env build > stats.json",
18
- "docs": "jsdoc --readme README.md -d docs -c docs/jsdoc.config.json -r",
19
- "esdocs": "esdoc -d esdocs -c esdocs/esdoc.config.json -r",
21
+ "start": "webpack-dev-server --hot",
22
+ "build": "webpack --config webpack.config.js --mode production",
23
+ "build:esm": "rollup --config rollup.config.js",
24
+ "dev": "webpack --config webpack.config.js --mode development",
25
+ "stats": "webpack --profile --json --optimize-minimize --mode production --env build > stats.json",
26
+ "docs": "jsdoc --readme README.md -d docs -c docs/jsdoc.config.json -r",
27
+ "esdocs": "esdoc -d esdocs -c esdocs/esdoc.config.json -r",
20
28
  "test": "karma start --browsers Chrome",
21
- "test:single": "npm test -- --single-run",
22
29
  "watch:test": "npm test -- --auto-watch --no-single-run",
23
- "test:mocha": "mocha tests"
30
+ "test:mocha": "mocha tests",
31
+ "lint": "eslint 'src/spyne/**' --fix"
24
32
  },
25
33
  "repository": {
26
34
  "type": "git",
27
- "url": "https://github.com/spynejs/spyne.git"
35
+ "url": "git+https://github.com/spynejs/spyne.git"
28
36
  },
29
- "keywords": [],
37
+ "keywords": [
38
+ "reactive",
39
+ "real-dom",
40
+ "framework",
41
+ "javascript",
42
+ "JavaScript Framework",
43
+ "Single-Page-Application Framework"
44
+ ],
30
45
  "author": "Frank Batista",
31
- "license": "LGPL",
46
+ "license": "UNLICENSED",
32
47
  "devDependencies": {
48
+ "@rollup/plugin-commonjs": "^28.0.2",
49
+ "@rollup/plugin-json": "^6.1.0",
50
+ "@rollup/plugin-node-resolve": "^16.0.0",
33
51
  "chai": "^4.3.9",
34
52
  "chai-dom": "^1.11.0",
35
53
  "clean-webpack-plugin": "^4.0.0",
@@ -39,29 +57,31 @@
39
57
  "eslint-config-standard": "^17.1.0",
40
58
  "eslint-plugin-import": "^2.28.1",
41
59
  "eslint-plugin-node": "^11.1.0",
42
- "eslint-plugin-promise": "^6.1.1",
43
- "eslint-plugin-standard": "^5.0.0",
60
+ "eslint-webpack-plugin": "^4.2.0",
44
61
  "file-loader": "^6.2.0",
45
- "karma": "^6.4.2",
62
+ "karma": "^6.4.4",
46
63
  "karma-chai": "^0.1.0",
47
64
  "karma-chrome-launcher": "^3.2.0",
48
65
  "karma-coverage": "^2.2.1",
49
66
  "karma-mocha": "^2.0.1",
50
- "karma-webpack": "^5.0.0",
51
- "mocha": "^10.2.0",
52
- "webpack": "^5.88.2",
67
+ "karma-webpack": "^5.0.1",
68
+ "mocha": "^10.7.3",
69
+ "rollup": "^2.79.2",
70
+ "rollup-plugin-terser": "^7.0.2",
71
+ "webpack": "^5.94.0",
53
72
  "webpack-cli": "^5.1.4",
54
- "webpack-dev-middleware": "^6.1.1",
55
- "webpack-dev-server": "^4.15.1",
73
+ "webpack-dev-middleware": "^7.4.2",
74
+ "webpack-dev-server": "^5.1.0",
56
75
  "webpack-rxjs-externals": "^2.0.0"
57
76
  },
58
77
  "config": {
59
78
  "ghooks": {
60
- "pre-commit": "npm run test:single"
79
+ "pre-commit": "npm run test"
61
80
  }
62
81
  },
63
82
  "dependencies": {
64
- "ramda": "^0.29.0",
83
+ "dompurify": "^3.1.6",
84
+ "ramda": "^0.30.1",
65
85
  "rxjs": "^7.8.1"
66
86
  }
67
87
  }
@@ -0,0 +1,26 @@
1
+ // rollup.config.js
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import json from '@rollup/plugin-json';
5
+ import { terser } from 'rollup-plugin-terser';
6
+
7
+ export default {
8
+ input: 'src/spyne/spyne.js', // Your main entry (the "barrel")
9
+ output: {
10
+ file: 'lib/spyne.esm.js',
11
+ format: 'es', // "es" = pure ESM
12
+ sourcemap: true
13
+ },
14
+ // If you want to keep certain libraries external, define them here:
15
+ external: ['ramda', 'rxjs'],
16
+ plugins: [
17
+ // Allows Rollup to resolve packages from node_modules
18
+ resolve(),
19
+ // Converts CommonJS modules to ES modules
20
+ commonjs(),
21
+ // Allows importing JSON files
22
+ json(),
23
+ // Minify the output (optional)
24
+ terser()
25
+ ]
26
+ };
@@ -1,6 +1,6 @@
1
- import { Channel } from './channel';
2
- import { ChannelFetchUtil } from '../utils/channel-fetch-util';
3
- import {path, pick, mergeDeepRight, all, allPass, either, values, defaultTo, reject, compose, isNil} from 'ramda';
1
+ import { Channel } from './channel'
2
+ import { ChannelFetchUtil } from '../utils/channel-fetch-util'
3
+ import { path, pick, mergeDeepRight, all, allPass, either, values, defaultTo, reject, compose, isNil } from 'ramda'
4
4
 
5
5
  export class ChannelFetch extends Channel {
6
6
  /**
@@ -46,91 +46,87 @@ export class ChannelFetch extends Channel {
46
46
  *
47
47
  */
48
48
 
49
-
50
49
  constructor(name, props = {}) {
51
-
52
50
  // ALLOW FOR GENERIC MAP PROPERTY
53
51
 
54
- ChannelFetch.validateMapMethod(props, name);
52
+ ChannelFetch.validateMapMethod(props, name)
55
53
 
56
- if (props.map!==undefined){
57
-
58
- props.mapFn = props.map;
54
+ if (props.map !== undefined) {
55
+ props.mapFn = props.map
59
56
  }
60
57
  props.extendedActionsArr = [
61
58
  `${name}_DATA_EVENT`,
62
59
  [`${name}_UPDATE_DATA_EVENT`, 'onFetchUpdate']
63
- ];
64
- props.sendCachedPayload = true;
65
- super(name, props);
60
+ ]
61
+ props.sendCachedPayload = true
62
+ super(name, props)
66
63
  }
67
64
 
68
- static validateMapMethod(props, name, testMode=false){
69
- const isNotEmpty = arr=>arr.length>=1
70
- const isNotFunction = val => typeof(val)!=='function';
65
+ static validateMapMethod(props, name, testMode = false) {
66
+ const isNotEmpty = arr => arr.length >= 1
67
+ const isNotFunction = val => typeof (val) !== 'function'
71
68
  const isUndefinedOrWrongType = either(isNil, isNotFunction)
72
- const isUndefined = all(isUndefinedOrWrongType);
69
+ const isUndefined = all(isUndefinedOrWrongType)
73
70
  const isNotUndefinedAndIsNotEmpty = allPass([isUndefined, isNotEmpty])
74
- const mapMethodIsInvalid = compose(isNotUndefinedAndIsNotEmpty,values, pick(['map', 'mapFn']))(props)
71
+ const mapMethodIsInvalid = compose(isNotUndefinedAndIsNotEmpty, values, pick(['map', 'mapFn']))(props)
75
72
 
76
- if (mapMethodIsInvalid){
77
- if(testMode===false) {
78
- console.warn(`Spyne Warning: The map method for ChannelFetch, ${name}, appears to be invalid`);
73
+ if (mapMethodIsInvalid) {
74
+ if (testMode === false) {
75
+ console.warn(`Spyne Warning: The map method for ChannelFetch, ${name}, appears to be invalid`)
79
76
  }
80
- return false;
77
+ return false
81
78
  }
82
79
 
83
- return true;
84
-
80
+ return true
85
81
  }
86
82
 
87
83
  onRegistered() {
88
- this.startFetch();
84
+ this.startFetch()
89
85
  }
90
86
 
91
87
  addRegisteredActions(name) {
92
- let arr = [
88
+ const arr = [
93
89
  'CHANNEL_DATA_EVENT',
94
90
  ['CHANNEL_UPDATE_DATA_EVENT', 'onFetchUpdate']
95
- ];
91
+ ]
96
92
 
97
- let extendedArr = compose(defaultTo([]), path(['props', 'extendedActionsArr']));
98
- return arr.concat(extendedArr(this));
93
+ const extendedArr = compose(defaultTo([]), path(['props', 'extendedActionsArr']))
94
+ return arr.concat(extendedArr(this))
99
95
  }
100
96
 
101
97
  startFetch(options = {}, subscriber = this.onFetchReturned.bind(this)) {
102
- let fetchProps = this.consolidateAllFetchProps(options);
103
- return new ChannelFetchUtil(fetchProps, subscriber, false, this.props.name);
98
+ const fetchProps = this.consolidateAllFetchProps(options)
99
+ return new ChannelFetchUtil(fetchProps, subscriber, false, this.props.name)
104
100
  }
105
101
 
106
102
  onFetchUpdate(evt) {
107
- let propsOptions = this.getPropsForFetch(evt);
108
- this.startFetch(propsOptions);
103
+ const propsOptions = this.getPropsForFetch(evt)
104
+ this.startFetch(propsOptions)
109
105
  }
110
106
 
111
107
  onFetchReturned(streamItem) {
112
- return this.createChannelPayloadItem(streamItem);
108
+ return this.createChannelPayloadItem(streamItem)
113
109
  }
114
110
 
115
111
  createChannelPayloadItem(payload, action = `${this.props.name}_DATA_EVENT`) {
116
- const {name, sendCachedPayload, url} = this.props;
117
- const srcElement = {name, sendCachedPayload, url};
118
- this.sendChannelPayload(action, payload, srcElement);
112
+ const { name, sendCachedPayload, url } = this.props
113
+ const srcElement = { name, sendCachedPayload, url }
114
+ this.sendChannelPayload(action, payload, srcElement)
119
115
  }
120
116
 
121
117
  getPropsForFetch(evt) {
122
- let dataObj = path(['viewStreamInfo', 'payload'], evt);
123
- return pick(['mapFn', 'url', 'header', 'body', 'mode', 'method', 'responseType', 'debug'], dataObj);
118
+ const dataObj = path(['viewStreamInfo', 'payload'], evt)
119
+ return pick(['mapFn', 'url', 'header', 'body', 'mode', 'method', 'responseType', 'debug'], dataObj)
124
120
  }
125
121
 
126
122
  consolidateAllFetchProps(options, props = this.props) {
127
- let propsOptions = pick(['mapFn', 'url', 'header', 'body', 'mode', 'method', 'responseType', 'debug'], props);
128
- const mergeOptions = (o1, o2) => mergeDeepRight(o1, o2);
129
- const filterOutUndefined = reject(isNil);
130
- return compose(filterOutUndefined, mergeOptions)(propsOptions, options);
123
+ const propsOptions = pick(['mapFn', 'url', 'header', 'body', 'mode', 'method', 'responseType', 'debug'], props)
124
+ const mergeOptions = (o1, o2) => mergeDeepRight(o1, o2)
125
+ const filterOutUndefined = reject(isNil)
126
+ return compose(filterOutUndefined, mergeOptions)(propsOptions, options)
131
127
  }
132
128
 
133
129
  get observer() {
134
- return this.observer$;
130
+ return this.observer$
135
131
  }
136
132
  }
@@ -10,9 +10,9 @@ import {
10
10
  defaultTo,
11
11
  prop,
12
12
  is
13
- } from 'ramda';
14
- import {SpyneAppProperties} from '../utils/spyne-app-properties';
15
- import {safeClone} from '../utils/safe-clone';
13
+ } from 'ramda'
14
+ import { SpyneAppProperties } from '../utils/spyne-app-properties'
15
+ import { safeClone } from '../utils/safe-clone'
16
16
 
17
17
  export class ChannelPayload {
18
18
  /**
@@ -36,17 +36,17 @@ export class ChannelPayload {
36
36
  * @returns Validated ChannelPayload json object
37
37
  */
38
38
  constructor(channelName, action, payload, srcElement, event, timeLabel) {
39
- let channel = channelName;
40
- //payload = ChannelPayload.deepFreeze(payload);
39
+ const channel = channelName
40
+ // payload = ChannelPayload.deepFreeze(payload);
41
41
 
42
- if(timeLabel){
43
- console.time(timeLabel);
42
+ if (timeLabel) {
43
+ console.time(timeLabel)
44
44
  }
45
45
 
46
- let channelPayloadItemObj = { channelName, action, srcElement, event };
47
- // Object.defineProperty(channelPayloadItemObj, 'payload', {get: () => clone(payload)});
48
- const frozenPayload = ChannelPayload.deepFreeze(payload);
49
- channelPayloadItemObj['payload'] = frozenPayload;
46
+ const channelPayloadItemObj = { channelName, action, srcElement, event }
47
+ // Object.defineProperty(channelPayloadItemObj, 'payload', {get: () => clone(payload)});
48
+ const frozenPayload = ChannelPayload.deepFreeze(payload)
49
+ channelPayloadItemObj.payload = frozenPayload
50
50
  /**
51
51
  * This is a convenience method that helps with destructuring by merging all properties.
52
52
  *
@@ -60,71 +60,63 @@ export class ChannelPayload {
60
60
  *
61
61
  */
62
62
 
63
-
64
-
65
- if (SpyneAppProperties.debug === true){
66
- if (Object.prototype.hasOwnProperty.call(payload, 'payload')){
67
- let payloadStr = JSON.stringify(payload);
68
- console.warn(`Spyne Warning: the following payload contains a nested payload property which may create conflicts: Action: ${action}, ${payloadStr}`);
63
+ if (SpyneAppProperties.debug === true) {
64
+ if (Object.prototype.hasOwnProperty.call(payload, 'payload')) {
65
+ const payloadStr = JSON.stringify(payload)
66
+ console.warn(`Spyne Warning: the following payload contains a nested payload property which may create conflicts: Action: ${action}, ${payloadStr}`)
69
67
  }
70
68
 
71
- const channelActionsArr = SpyneAppProperties.getChannelActions(channel);
72
-
73
- ChannelPayload.validateAction(action, channel, channelActionsArr);
74
-
69
+ const channelActionsArr = SpyneAppProperties.getChannelActions(channel)
75
70
 
71
+ ChannelPayload.validateAction(action, channel, channelActionsArr)
76
72
  }
77
73
 
78
-
79
-
80
74
  channelPayloadItemObj.clone = () => mergeAll([
81
- {payload:safeClone(channelPayloadItemObj.payload)},
75
+ { payload:safeClone(channelPayloadItemObj.payload) },
82
76
  channelPayloadItemObj.payload,
83
- { channel: clone(channel) },
84
- { event: clone(event) },
85
- {srcElement: srcElement},
86
- clone(channelPayloadItemObj.srcElement), {
87
- action: clone(channelPayloadItemObj.action) }
88
- ]);
89
-
90
-
77
+ { channel: clone(channel) },
78
+ { event: clone(event) },
79
+ { srcElement },
80
+ clone(channelPayloadItemObj.srcElement), { action: clone(channelPayloadItemObj.action) }
81
+ ])
91
82
 
92
83
  const channelPayloadItemObjProps = {
93
84
  $dir: {
94
85
  get: () => channelPayloadItemObj._dir,
95
- set: (val) => channelPayloadItemObj._dir=val
86
+ set: (val) => {
87
+ channelPayloadItemObj._dir = val
88
+ return val
89
+ }
96
90
  }
97
91
  }
98
92
 
99
-
100
-
101
93
  if (channel === 'CHANNEL_ROUTE') {
102
- //channelPayloadItemObj['location'] = ChannelPayload.getLocationData();
103
- channelPayloadItemObjProps['location'] = {
104
- get: ()=>ChannelPayload.getLocationData()
94
+ // channelPayloadItemObj['location'] = ChannelPayload.getLocationData();
95
+ channelPayloadItemObjProps.location = {
96
+ get: () => ChannelPayload.getLocationData()
105
97
  }
106
- /* channelPayloadItemObjProps['routeData'] = {
98
+ /* channelPayloadItemObjProps['routeData'] = {
107
99
  get: ()=>prop('routeData', frozenPayload)
108
100
  }
109
101
  */
110
102
  }
111
103
 
112
- channelPayloadItemObj._dir = undefined;
104
+ channelPayloadItemObj._dir = undefined
113
105
 
114
106
  Object.defineProperties(channelPayloadItemObj, channelPayloadItemObjProps)
115
107
 
116
- if(timeLabel){
117
- console.timeEnd(timeLabel);
108
+ if (timeLabel) {
109
+ console.timeEnd(timeLabel)
118
110
  }
119
- return channelPayloadItemObj;
111
+ return channelPayloadItemObj
120
112
  }
121
113
 
122
114
  static validateAction(action, channel, arr) {
123
- let isInArr = includes(action, arr);
115
+ const isInArr = includes(action, arr)
124
116
  if (isInArr === false && SpyneAppProperties.initialized === true) {
125
- console.warn(`warning: Action: '${action}' is not registered within the ${channel} channel!`);
117
+ console.warn(`warning: Action: '${action}' is not registered within the ${channel} channel!`)
126
118
  }
127
- return isInArr;
119
+ return isInArr
128
120
  }
129
121
 
130
122
  static getLocationData() {
@@ -137,8 +129,8 @@ export class ChannelPayload {
137
129
  'port',
138
130
  'pathname',
139
131
  'search',
140
- 'hash'];
141
- return pickAll(locationParamsArr, window.location);
132
+ 'hash']
133
+ return pickAll(locationParamsArr, window.location)
142
134
  }
143
135
 
144
136
  static getStreamItem() {
@@ -146,43 +138,38 @@ export class ChannelPayload {
146
138
  }
147
139
 
148
140
  static deepClone(o) {
149
- const isArr = is(Array);
150
- const isObj = is(Object);
151
- const isIter = ob => isArr(ob)===false && isObj(ob)===true;
152
- const isIterable = isIter(o);
153
- return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o);
154
-
141
+ const isArr = is(Array)
142
+ const isObj = is(Object)
143
+ const isIter = ob => isArr(ob) === false && isObj(ob) === true
144
+ const isIterable = isIter(o)
145
+ return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o)
155
146
  }
156
147
 
157
-
158
-
159
148
  static deepFreeze(o) {
160
- //return o;
161
- //return Object.freeze(o);
162
- const elIsDomElement = compose(lte(0), defaultTo(-1), prop('nodeType'));
149
+ // return o;
150
+ // return Object.freeze(o);
151
+ const elIsDomElement = compose(lte(0), defaultTo(-1), prop('nodeType'))
163
152
 
164
153
  try {
165
- Object.freeze(o);
154
+ Object.freeze(o)
166
155
  Object.getOwnPropertyNames(o).forEach(function(prop) {
167
- if (Object.prototype.hasOwnProperty.call(o,prop)
168
- && elIsDomElement(o[prop]) === false
169
- && o[prop] !== null
170
- && (typeof o[prop] === "object" || typeof o[prop] === "function")
171
- && !Object.isFrozen(o[prop])) {
172
- ChannelPayload.deepFreeze(o[prop]);
156
+ if (Object.prototype.hasOwnProperty.call(o, prop) &&
157
+ elIsDomElement(o[prop]) === false &&
158
+ o[prop] !== null &&
159
+ (typeof o[prop] === 'object' || typeof o[prop] === 'function') &&
160
+ !Object.isFrozen(o[prop])) {
161
+ ChannelPayload.deepFreeze(o[prop])
173
162
  }
174
- });
175
-
176
- } catch(e){
177
- //console.log("FREEZE ERR ",{o,e});
178
- return o;
179
-
163
+ })
164
+ } catch (e) {
165
+ // console.log("FREEZE ERR ",{o,e});
166
+ return o
180
167
  }
181
168
 
182
- return o;
169
+ return o
183
170
  }
184
171
 
185
172
  static getMouseEventKeys() {
186
- return ['altKey', 'bubbles', 'cancelBubble', 'cancelable', 'clientX', 'clientY', 'composed', 'ctrlKey', 'currentTarget', 'defaultPrevented', 'detail', 'eventPhase', 'fromElement', 'isTrusted', 'layerX', 'layerY', 'metaKey', 'movementX', 'movementY', 'offsetX', 'offsetY', 'pageX', 'pageY', 'path', 'relatedTarget', 'returnValue', 'screenX', 'screenY', 'shiftKey', 'sourceCapabilities', 'srcElement', 'target', 'timeStamp', 'toElement', 'type', 'view', 'which', 'x', 'y'];
173
+ return ['altKey', 'bubbles', 'cancelBubble', 'cancelable', 'clientX', 'clientY', 'composed', 'ctrlKey', 'currentTarget', 'defaultPrevented', 'detail', 'eventPhase', 'fromElement', 'isTrusted', 'layerX', 'layerY', 'metaKey', 'movementX', 'movementY', 'offsetX', 'offsetY', 'pageX', 'pageY', 'path', 'relatedTarget', 'returnValue', 'screenX', 'screenY', 'shiftKey', 'sourceCapabilities', 'srcElement', 'target', 'timeStamp', 'toElement', 'type', 'view', 'which', 'x', 'y']
187
174
  }
188
175
  }
@@ -1,8 +1,8 @@
1
- import { Channel } from './channel';
2
- import {SpyneAppProperties} from '../utils/spyne-app-properties';
3
- import { Subject, ReplaySubject, merge } from 'rxjs';
4
- import {includes} from 'ramda';
5
- import {delayCall} from '../utils/frp-tools';
1
+ import { Channel } from './channel'
2
+ import { SpyneAppProperties } from '../utils/spyne-app-properties'
3
+ import { Subject, ReplaySubject, merge } from 'rxjs'
4
+ import { includes } from 'ramda'
5
+ import { delayCall } from '../utils/frp-tools'
6
6
 
7
7
  export class ChannelProxy extends Channel {
8
8
  /**
@@ -18,41 +18,40 @@ export class ChannelProxy extends Channel {
18
18
  *
19
19
  */
20
20
  constructor(name, props = {}) {
21
- props.isProxy = true;
22
- super(name, props);
23
- this.props = props;
24
- this.subject$ = new Subject();
25
- this.replaySub$ = new ReplaySubject(1);
26
- this.observer$ = merge(this.subject$, this.replaySub$);
27
- const isDevMode = SpyneAppProperties.debug;
28
- if (isDevMode === true){
29
- this.checkIfChannelIsStillProxy(name);
21
+ props.isProxy = true
22
+ super(name, props)
23
+ this.props = props
24
+ this.subject$ = new Subject()
25
+ this.replaySub$ = new ReplaySubject(1)
26
+ this.observer$ = merge(this.subject$, this.replaySub$)
27
+ const isDevMode = SpyneAppProperties.debug
28
+ if (isDevMode === true) {
29
+ this.checkIfChannelIsStillProxy(name)
30
30
  }
31
31
  }
32
32
 
33
33
  getMergedSubject(peristData = false) {
34
- return peristData === true ? this.replaySub$ : this.subject$;
34
+ return peristData === true ? this.replaySub$ : this.subject$
35
35
  }
36
36
 
37
- checkIfChannelIsStillProxy(channelName){
38
- let name = channelName;
37
+ checkIfChannelIsStillProxy(channelName) {
38
+ const name = channelName
39
39
 
40
- const checkIfProxy=()=>{
41
- let bool = includes(name, SpyneAppProperties.listRegisteredChannels());
42
- if (bool!==true){
43
- console.warn(`Spyne Warning: The channel, ${name} does not appear to be registered!`);
40
+ const checkIfProxy = () => {
41
+ const bool = includes(name, SpyneAppProperties.listRegisteredChannels())
42
+ if (bool !== true) {
43
+ console.warn(`Spyne Warning: The channel, ${name} does not appear to be registered!`)
44
44
  }
45
- };
46
-
47
- delayCall(checkIfProxy, 1000);
45
+ }
48
46
 
47
+ delayCall(checkIfProxy, 1000)
49
48
  }
50
49
 
51
50
  get replaySubject() {
52
- return this.replaySub$;
51
+ return this.replaySub$
53
52
  }
54
53
 
55
54
  get subject() {
56
- return this.subject$;
55
+ return this.subject$
57
56
  }
58
57
  }