spyne 0.19.1 → 0.20.1
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/.eslintignore +2 -0
- package/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +77 -87
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.js +248 -248
- package/lib/spyne.umd.js +3 -0
- package/lib/spyne.umd.js.LICENSE.txt +16 -0
- package/package.json +48 -27
- package/rollup.config.js +26 -0
- package/src/spyne/channels/channel-fetch-class.js +39 -43
- package/src/spyne/channels/channel-payload-class.js +61 -74
- package/src/spyne/channels/channel-proxy.js +25 -26
- package/src/spyne/channels/channel.js +141 -149
- package/src/spyne/channels/channels-config.js +46 -47
- package/src/spyne/channels/channels-map.js +61 -65
- package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
- package/src/spyne/channels/spyne-channel-route.js +241 -250
- package/src/spyne/channels/spyne-channel-ui.js +213 -75
- package/src/spyne/channels/spyne-channel-window.js +157 -157
- package/src/spyne/spyne-app.js +32 -19
- package/src/spyne/spyne-plugins.js +55 -70
- package/src/spyne/spyne.js +23 -23
- package/src/spyne/utils/channel-config-validator.js +10 -10
- package/src/spyne/utils/channel-fetch-util.js +72 -55
- package/src/spyne/utils/channel-payload-filter.js +89 -100
- package/src/spyne/utils/deep-merge.js +31 -29
- package/src/spyne/utils/frp-tools.js +108 -92
- package/src/spyne/utils/gc.js +6 -6
- package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
- package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
- package/src/spyne/utils/route-channel-updater.js +23 -29
- package/src/spyne/utils/safe-clone.js +40 -58
- package/src/spyne/utils/sanitize-html.js +35 -0
- package/src/spyne/utils/security-policy.js +11 -0
- package/src/spyne/utils/spyne-app-properties.js +110 -114
- package/src/spyne/utils/spyne-logger.js +4 -11
- package/src/spyne/utils/spyne-plugins-methods.js +38 -63
- package/src/spyne/utils/spyne-trait.js +33 -33
- package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
- package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
- package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
- package/src/spyne/utils/viewstream-animations.js +12 -12
- package/src/spyne/utils/viewstream-observables.js +45 -45
- package/src/spyne/views/dom-element-template.js +111 -114
- package/src/spyne/views/dom-element.js +82 -84
- package/src/spyne/views/view-stream-broadcaster.js +66 -62
- package/src/spyne/views/view-stream-element.js +105 -106
- package/src/spyne/views/view-stream-payload.js +25 -27
- package/src/spyne/views/view-stream-selector.js +157 -163
- package/src/spyne/views/view-stream.js +416 -640
- package/src/tests/channels/channel-dom.test.js +15 -15
- package/src/tests/channels/channel-fetch.test.js +51 -62
- package/src/tests/channels/channel-payload-class.test.js +50 -63
- package/src/tests/channels/channel-payload-filter.test.js +133 -193
- package/src/tests/channels/channel-route.test.js +102 -112
- package/src/tests/channels/channel-stream-item.test.js +19 -19
- package/src/tests/channels/channel-ui.test.js +15 -27
- package/src/tests/channels/channel-util-dom.test.js +31 -31
- package/src/tests/channels/channel.test.js +20 -25
- package/src/tests/channels/route-utils.test.js +61 -66
- package/src/tests/channels/url-utils.test.js +151 -151
- package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
- package/src/tests/import.test.js +5 -5
- package/src/tests/index.js +6 -7
- package/src/tests/index.test.js +6 -8
- package/src/tests/mocks/channel-payload-data.js +218 -220
- package/src/tests/mocks/enhancer.test.js +5 -5
- package/src/tests/mocks/payload-ui.js +87 -90
- package/src/tests/mocks/routes-data.js +264 -266
- package/src/tests/mocks/spyne-docs.mocks.js +3 -3
- package/src/tests/mocks/template-renderer.mocks.js +47 -47
- package/src/tests/mocks/utils-data.js +78 -79
- package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
- package/src/tests/mocks/window-events-arr.js +1 -1
- package/src/tests/package-json.spec.test.js +9 -0
- package/src/tests/spyne-app.test.js +15 -18
- package/src/tests/spyne-plugin.test.js +16 -20
- package/src/tests/utils/channel-action-filter.test.js +84 -86
- package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
- package/src/tests/utils/channel-fetch-util.test.js +64 -66
- package/src/tests/utils/frp-tools.test.js +19 -19
- package/src/tests/utils/plugins-methods.test.js +31 -55
- package/src/tests/utils/security.test.js +10 -0
- package/src/tests/utils/spyne-app-properties.test.js +4 -8
- package/src/tests/views/dom-el-selectors.test.js +112 -119
- package/src/tests/views/dom-el-template-proxy.test.js +7 -0
- package/src/tests/views/dom-el-template.test.js +186 -156
- package/src/tests/views/dom-el.test.js +58 -56
- package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
- package/src/tests/views/view-stream-enhancer.test.js +11 -11
- package/src/tests/views/view-stream.test.js +22 -33
- package/webpack.config.js +76 -67
- package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
- package/docs/DomItem.html +0 -298
- package/docs/DomItem_DomItem.html +0 -314
- package/docs/ViewStream.html +0 -2249
- package/docs/ViewStream_ViewStream.html +0 -503
- package/docs/custom/css/jsdoc-viewstream.css +0 -377
- package/docs/custom/layout.tmpl +0 -47
- package/docs/dom-item.js.html +0 -213
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -548
- package/docs/index-custom.html +0 -79
- package/docs/index.html +0 -82
- package/docs/jsdoc.config.json +0 -22
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs/view-stream.js.html +0 -767
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Spyne 0.20.1
|
|
3
|
+
* https://spynejs.org
|
|
4
|
+
*
|
|
5
|
+
* @license Copyright 2017-2021, Frank Batista, Relevant Context, LLC. All rights reserved.
|
|
6
|
+
* Spyne is licensed under the GNU Lesser General Public License v3.0
|
|
7
|
+
*
|
|
8
|
+
* @author: Frank Batista,
|
|
9
|
+
* @email: frbatista.nyc@gmail.com
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*!
|
|
13
|
+
* spynejs 0.20.1
|
|
14
|
+
* https://spynejs.org
|
|
15
|
+
* (c) 2017-present Frank Batista
|
|
16
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spyne",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.19.1",
|
|
3
|
+
"version": "0.20.1",
|
|
5
4
|
"description": "Reactive Real-DOM Framework for Advanced Javascript applications",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
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
|
|
11
|
-
"eslint-fix-tests": "eslint --fix
|
|
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
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"test
|
|
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",
|
|
28
|
+
"test": "karma start karma.conf.js",
|
|
29
|
+
"test:single": "karma start karma.conf.js --single-run",
|
|
22
30
|
"watch:test": "npm test -- --auto-watch --no-single-run",
|
|
23
|
-
"test:mocha": "mocha tests"
|
|
31
|
+
"test:mocha": "mocha tests",
|
|
32
|
+
"lint": "eslint 'src/spyne/**' --fix"
|
|
24
33
|
},
|
|
25
34
|
"repository": {
|
|
26
35
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/spynejs/spyne.git"
|
|
36
|
+
"url": "git+https://github.com/spynejs/spyne.git"
|
|
28
37
|
},
|
|
29
|
-
"keywords": [
|
|
38
|
+
"keywords": [
|
|
39
|
+
"reactive",
|
|
40
|
+
"real-dom",
|
|
41
|
+
"framework",
|
|
42
|
+
"javascript",
|
|
43
|
+
"JavaScript Framework",
|
|
44
|
+
"Single-Page-Application Framework"
|
|
45
|
+
],
|
|
30
46
|
"author": "Frank Batista",
|
|
31
47
|
"license": "LGPL",
|
|
32
48
|
"devDependencies": {
|
|
49
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
50
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
51
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
33
52
|
"chai": "^4.3.9",
|
|
34
53
|
"chai-dom": "^1.11.0",
|
|
35
54
|
"clean-webpack-plugin": "^4.0.0",
|
|
@@ -39,29 +58,31 @@
|
|
|
39
58
|
"eslint-config-standard": "^17.1.0",
|
|
40
59
|
"eslint-plugin-import": "^2.28.1",
|
|
41
60
|
"eslint-plugin-node": "^11.1.0",
|
|
42
|
-
"eslint-plugin
|
|
43
|
-
"eslint-plugin-standard": "^5.0.0",
|
|
61
|
+
"eslint-webpack-plugin": "^4.2.0",
|
|
44
62
|
"file-loader": "^6.2.0",
|
|
45
|
-
"karma": "^6.4.
|
|
63
|
+
"karma": "^6.4.4",
|
|
46
64
|
"karma-chai": "^0.1.0",
|
|
47
65
|
"karma-chrome-launcher": "^3.2.0",
|
|
48
66
|
"karma-coverage": "^2.2.1",
|
|
49
67
|
"karma-mocha": "^2.0.1",
|
|
50
|
-
"karma-webpack": "^5.0.
|
|
51
|
-
"mocha": "^10.
|
|
52
|
-
"
|
|
68
|
+
"karma-webpack": "^5.0.1",
|
|
69
|
+
"mocha": "^10.7.3",
|
|
70
|
+
"rollup": "^2.79.2",
|
|
71
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
72
|
+
"webpack": "^5.94.0",
|
|
53
73
|
"webpack-cli": "^5.1.4",
|
|
54
|
-
"webpack-dev-middleware": "^
|
|
55
|
-
"webpack-dev-server": "^
|
|
74
|
+
"webpack-dev-middleware": "^7.4.2",
|
|
75
|
+
"webpack-dev-server": "^5.1.0",
|
|
56
76
|
"webpack-rxjs-externals": "^2.0.0"
|
|
57
77
|
},
|
|
58
78
|
"config": {
|
|
59
79
|
"ghooks": {
|
|
60
|
-
"pre-commit": "npm run test
|
|
80
|
+
"pre-commit": "npm run test"
|
|
61
81
|
}
|
|
62
82
|
},
|
|
63
83
|
"dependencies": {
|
|
64
|
-
"
|
|
84
|
+
"dompurify": "^3.1.6",
|
|
85
|
+
"ramda": "^0.30.1",
|
|
65
86
|
"rxjs": "^7.8.1"
|
|
66
87
|
}
|
|
67
88
|
}
|
package/rollup.config.js
ADDED
|
@@ -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
|
-
|
|
88
|
+
const arr = [
|
|
93
89
|
'CHANNEL_DATA_EVENT',
|
|
94
90
|
['CHANNEL_UPDATE_DATA_EVENT', 'onFetchUpdate']
|
|
95
|
-
]
|
|
91
|
+
]
|
|
96
92
|
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
const frozenPayload = ChannelPayload.deepFreeze(payload)
|
|
49
|
-
channelPayloadItemObj
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
75
|
+
{ payload:safeClone(channelPayloadItemObj.payload) },
|
|
82
76
|
channelPayloadItemObj.payload,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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) =>
|
|
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
|
|
104
|
-
get: ()=>ChannelPayload.getLocationData()
|
|
94
|
+
// channelPayloadItemObj['location'] = ChannelPayload.getLocationData();
|
|
95
|
+
channelPayloadItemObjProps.location = {
|
|
96
|
+
get: () => ChannelPayload.getLocationData()
|
|
105
97
|
}
|
|
106
|
-
|
|
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
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
177
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
checkIfChannelIsStillProxy(channelName) {
|
|
38
|
+
const name = channelName
|
|
39
39
|
|
|
40
|
-
const checkIfProxy=()=>{
|
|
41
|
-
|
|
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
|
}
|