spyne 0.19.0 → 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.
- package/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +76 -86
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.umd.js +9565 -0
- package/package.json +46 -26
- 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
package/src/spyne/utils/gc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {forEach} from 'ramda'
|
|
1
|
+
import { forEach } from 'ramda'
|
|
2
2
|
export function gc() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
forEach(loopM, this)
|
|
6
|
-
}
|
|
7
|
-
setTimeout(cleanup, 1)
|
|
3
|
+
const cleanup = () => {
|
|
4
|
+
const loopM = m => undefined
|
|
5
|
+
forEach(loopM, this)
|
|
6
|
+
}
|
|
7
|
+
setTimeout(cleanup, 1)
|
|
8
8
|
}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
export function baseCoreMixins() {
|
|
2
2
|
return {
|
|
3
3
|
createpropsMap: function() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
wm.set(objKey, this.props)
|
|
4
|
+
const wm = new WeakMap()
|
|
5
|
+
const objKey = { vsid: this.props.vsid }
|
|
6
|
+
wm.set(objKey, this.props)
|
|
7
7
|
return {
|
|
8
8
|
key: objKey,
|
|
9
9
|
weakMap: wm
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
},
|
|
12
12
|
gc: function() {
|
|
13
|
-
for (
|
|
14
|
-
delete this[m]
|
|
13
|
+
for (const m in this) {
|
|
14
|
+
delete this[m]
|
|
15
15
|
}
|
|
16
|
-
delete this
|
|
16
|
+
delete this
|
|
17
17
|
},
|
|
18
18
|
createId: function() {
|
|
19
|
-
//let num = Math.floor(Math.random(10000000) * 10000000);
|
|
20
|
-
//const num = () => Math.random().toString(36).substring(2, 8);;
|
|
21
|
-
const num = () => Math.random().toString(36).replace(/\d/gm, '').substring(1,8)
|
|
22
|
-
return num()
|
|
23
|
-
//return `vsid-${num()}`;
|
|
19
|
+
// let num = Math.floor(Math.random(10000000) * 10000000);
|
|
20
|
+
// const num = () => Math.random().toString(36).substring(2, 8);;
|
|
21
|
+
const num = () => Math.random().toString(36).replace(/\d/gm, '').substring(1, 8)
|
|
22
|
+
return num()
|
|
23
|
+
// return `vsid-${num()}`;
|
|
24
24
|
},
|
|
25
25
|
setTraceFunc: function(debug) {
|
|
26
|
-
return debug === true
|
|
27
|
-
|
|
26
|
+
return debug === true
|
|
27
|
+
? console.log
|
|
28
|
+
: () => {
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
|
-
}
|
|
31
|
+
}
|
|
30
32
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ViewStreamPayload } from '../../views/view-stream-payload'
|
|
1
|
+
import { ViewStreamPayload } from '../../views/view-stream-payload'
|
|
2
2
|
|
|
3
3
|
export function baseStreamsMixins() {
|
|
4
4
|
return {
|
|
5
5
|
testFunc: function(str) {
|
|
6
|
-
console.log('stream mixin is ', str)
|
|
6
|
+
console.log('stream mixin is ', str)
|
|
7
7
|
},
|
|
8
8
|
sendRoutePayload: function(obs, data) {
|
|
9
|
-
/**TODO: ADD A CHECK FOR END ROUTE AND TRANSFORM TO EMPTY*/
|
|
10
|
-
return new ViewStreamPayload('CHANNEL_ROUTE', obs, data, 'subscribe')
|
|
9
|
+
/** TODO: ADD A CHECK FOR END ROUTE AND TRANSFORM TO EMPTY */
|
|
10
|
+
return new ViewStreamPayload('CHANNEL_ROUTE', obs, data, 'subscribe')
|
|
11
11
|
},
|
|
12
12
|
sendUIPayload: function(obs, data) {
|
|
13
|
-
return new ViewStreamPayload('CHANNEL_UI', obs, data, 'subscribe')
|
|
14
|
-
}
|
|
13
|
+
return new ViewStreamPayload('CHANNEL_UI', obs, data, 'subscribe')
|
|
14
|
+
}
|
|
15
15
|
/*
|
|
16
16
|
sendInfoToChannel: function(channelName, payload) {
|
|
17
17
|
const getProp = str => prop(str, this.props);
|
|
@@ -28,13 +28,13 @@ export function baseStreamsMixins() {
|
|
|
28
28
|
'subscribe');
|
|
29
29
|
},
|
|
30
30
|
*/
|
|
31
|
-
/* sendLifeStreamPayload: function(obs, data) {
|
|
31
|
+
/* sendLifeStreamPayload: function(obs, data) {
|
|
32
32
|
return new ViewStreamPayload('LIFESTREAM', obs, data, 'subscribe');
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
createLifeStreamPayload: function(STEP, data = {}, type = 'parent') {
|
|
36
36
|
let viewId = `${this.props.name}: ${this.props.vsid}`;
|
|
37
37
|
return new LifestreamPayload('LIFESTREAM', STEP, type, viewId, data).data;
|
|
38
|
-
}*/
|
|
39
|
-
}
|
|
38
|
+
} */
|
|
39
|
+
}
|
|
40
40
|
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
import {ViewStream} from '../views/view-stream'
|
|
2
|
-
import {curry} from 'ramda'
|
|
3
|
-
export class RouteChannelUpdater{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return sendRouteChannelUpdate({id,name});
|
|
1
|
+
import { ViewStream } from '../views/view-stream'
|
|
2
|
+
import { curry } from 'ramda'
|
|
3
|
+
export class RouteChannelUpdater {
|
|
4
|
+
constructor(cxt) {
|
|
5
|
+
const name = String(cxt.props.name)
|
|
6
|
+
const id = `${name}_ROUTE_UPDATER`
|
|
7
|
+
|
|
8
|
+
const sendRouteChannelUpdate = curry(RouteChannelUpdater.createTemporaryViewStreamObj)
|
|
9
|
+
return sendRouteChannelUpdate({ id, name })
|
|
11
10
|
}
|
|
12
11
|
|
|
12
|
+
static createTemporaryViewStreamObj(props, data) {
|
|
13
|
+
const { name, id } = props
|
|
14
|
+
const payload = data
|
|
15
|
+
const vs = new ViewStream({
|
|
16
|
+
id, name, data
|
|
17
|
+
})
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let vs = new ViewStream({
|
|
18
|
-
id, name, data
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
vs.onRendered = ()=>{
|
|
22
|
-
vs.sendInfoToChannel('CHANNEL_ROUTE', payload);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
vs.afterBroadcastEvents = ()=>{
|
|
26
|
-
vs.disposeViewStream();
|
|
27
|
-
};
|
|
19
|
+
vs.onRendered = () => {
|
|
20
|
+
vs.sendInfoToChannel('CHANNEL_ROUTE', payload)
|
|
21
|
+
}
|
|
28
22
|
|
|
29
|
-
vs.
|
|
23
|
+
vs.afterBroadcastEvents = () => {
|
|
24
|
+
vs.disposeViewStream()
|
|
25
|
+
}
|
|
30
26
|
|
|
27
|
+
vs.appendToNull()
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
29
|
+
}
|
|
@@ -1,85 +1,67 @@
|
|
|
1
|
-
import {clone, compose, fromPairs, is, path, toPairs} from 'ramda'
|
|
2
|
-
import {SpyneAppProperties} from './spyne-app-properties'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type = 'primitive';
|
|
11
|
-
} else if (type==='object'){
|
|
12
|
-
if (Array.isArray(prp)){
|
|
1
|
+
import { clone, compose, fromPairs, is, path, toPairs } from 'ramda'
|
|
2
|
+
import { SpyneAppProperties } from './spyne-app-properties'
|
|
3
|
+
|
|
4
|
+
const getPropType = (prp) => {
|
|
5
|
+
let type = typeof prp
|
|
6
|
+
if (['number', 'boolean', 'string'].includes(type)) {
|
|
7
|
+
type = 'primitive'
|
|
8
|
+
} else if (type === 'object') {
|
|
9
|
+
if (Array.isArray(prp)) {
|
|
13
10
|
type = 'array'
|
|
14
|
-
} else if (prp===null){
|
|
15
|
-
type = 'undefined'
|
|
11
|
+
} else if (prp === null) {
|
|
12
|
+
type = 'undefined'
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
return type
|
|
15
|
+
return type
|
|
19
16
|
}
|
|
20
17
|
|
|
18
|
+
const cmsDataReviveNestedProxyObj = (proxyObj, proxyReviverMethod) => {
|
|
19
|
+
const { __proxy__proxyName } = proxyObj
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const {__proxy__proxyName} = proxyObj;
|
|
26
|
-
|
|
27
|
-
if (__proxy__proxyName === undefined){
|
|
28
|
-
console.error('object is not proxy object ',proxyObj);
|
|
21
|
+
if (__proxy__proxyName === undefined) {
|
|
22
|
+
console.error('object is not proxy object ', proxyObj)
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
const cloneNestedProxyObj = (target, pathArr)=>{
|
|
32
|
-
const nestedProxyObj = path(pathArr, proxyObj)
|
|
33
|
-
const {__proxy__isProxy, __proxy__props} = nestedProxyObj
|
|
34
|
-
return __proxy__isProxy ? proxyReviverMethod(target, __proxy__props) : target
|
|
25
|
+
const cloneNestedProxyObj = (target, pathArr) => {
|
|
26
|
+
const nestedProxyObj = path(pathArr, proxyObj)
|
|
27
|
+
const { __proxy__isProxy, __proxy__props } = nestedProxyObj
|
|
28
|
+
return __proxy__isProxy ? proxyReviverMethod(target, __proxy__props) : target
|
|
35
29
|
}
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
const rootObj = cloneNestedProxyObj(clone(proxyObj), []);
|
|
39
|
-
|
|
31
|
+
const rootObj = cloneNestedProxyObj(clone(proxyObj), [])
|
|
40
32
|
|
|
41
33
|
const proxyIterable = (iterObj, iterPath) => {
|
|
42
|
-
|
|
34
|
+
const dataPath = iterPath || []
|
|
43
35
|
const loopObj = ([key, prop]) => {
|
|
44
|
-
const type = getPropType(prop)
|
|
36
|
+
const type = getPropType(prop)
|
|
45
37
|
const clonedPath = [...dataPath]
|
|
46
|
-
clonedPath.push(key)
|
|
47
|
-
if (type === 'object' || type==='array') {
|
|
48
|
-
iterObj[key] = cloneNestedProxyObj(prop, clonedPath)
|
|
38
|
+
clonedPath.push(key)
|
|
39
|
+
if (type === 'object' || type === 'array') {
|
|
40
|
+
iterObj[key] = cloneNestedProxyObj(prop, clonedPath)
|
|
49
41
|
proxyIterable(prop, clonedPath)
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
|
-
Object.entries(iterObj).forEach(loopObj)
|
|
44
|
+
Object.entries(iterObj).forEach(loopObj)
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
proxyIterable(rootObj)
|
|
47
|
+
proxyIterable(rootObj)
|
|
56
48
|
// console.timeEnd('proxify2');
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
return rootObj;
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
return rootObj
|
|
62
51
|
}
|
|
63
52
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const proxyReviverMethod = SpyneAppProperties.getProxyReviver(__proxy__proxyName);
|
|
71
|
-
if (typeof proxyReviverMethod === 'function'){
|
|
72
|
-
return cmsDataReviveNestedProxyObj(o, proxyReviverMethod);
|
|
53
|
+
export const safeClone = function(o) {
|
|
54
|
+
const { __proxy__proxyName } = o
|
|
55
|
+
if (__proxy__proxyName !== undefined) {
|
|
56
|
+
const proxyReviverMethod = SpyneAppProperties.getProxyReviver(__proxy__proxyName)
|
|
57
|
+
if (typeof proxyReviverMethod === 'function') {
|
|
58
|
+
return cmsDataReviveNestedProxyObj(o, proxyReviverMethod)
|
|
73
59
|
}
|
|
74
60
|
}
|
|
75
61
|
|
|
76
|
-
const isArr = is(Array)
|
|
77
|
-
const isObj = is(Object)
|
|
78
|
-
const isIter = ob => isArr(ob)===false && isObj(ob)===true
|
|
79
|
-
const isIterable = isIter(o)
|
|
80
|
-
return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
const isArr = is(Array)
|
|
63
|
+
const isObj = is(Object)
|
|
64
|
+
const isIter = ob => isArr(ob) === false && isObj(ob) === true
|
|
65
|
+
const isIterable = isIter(o)
|
|
66
|
+
return isIterable ? compose(fromPairs, toPairs, clone)(o) : clone(o)
|
|
85
67
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify'
|
|
2
|
+
|
|
3
|
+
let _sanitizeHTML
|
|
4
|
+
let isConfigured = false
|
|
5
|
+
|
|
6
|
+
const sanitizeHTMLConfigure = (config) => {
|
|
7
|
+
if (!isConfigured) {
|
|
8
|
+
if (config.strict) {
|
|
9
|
+
if (window.trustedTypes) {
|
|
10
|
+
const policy = window.trustedTypes.createPolicy('default', {
|
|
11
|
+
createHTML: (to_escape) => DOMPurify.sanitize(to_escape, { RETURN_TRUSTED_TYPE: false })
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
_sanitizeHTML = (html) => policy.createHTML(html)
|
|
15
|
+
} else {
|
|
16
|
+
_sanitizeHTML = (html) => DOMPurify.sanitize(html)
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
_sanitizeHTML = (html) => html // No sanitization if not required
|
|
20
|
+
}
|
|
21
|
+
isConfigured = true
|
|
22
|
+
} else {
|
|
23
|
+
console.warn('sanitizeHTML is already configured. Reconfiguration is not allowed.')
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const sanitizeHTML = (html) => {
|
|
28
|
+
if (!isConfigured) {
|
|
29
|
+
throw new Error('sanitizeHTML is not configured. Call sanitizeHTMLConfigure() with appropriate config.')
|
|
30
|
+
}
|
|
31
|
+
return _sanitizeHTML(html)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { sanitizeHTMLConfigure }
|
|
35
|
+
export default sanitizeHTML
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import {SpyneUtilsChannelRoute} from './spyne-utils-channel-route'
|
|
2
|
-
import {SpynePluginsMethods} from './spyne-plugins-methods'
|
|
3
|
-
import {deepMerge} from './deep-merge'
|
|
4
|
-
import {path} from 'ramda'
|
|
5
|
-
|
|
6
|
-
let _config
|
|
7
|
-
let _channels
|
|
8
|
-
let _channelsMap
|
|
9
|
-
let _initialized
|
|
10
|
-
let _debug = true
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class SpyneAppPropertiesClass{
|
|
18
|
-
|
|
1
|
+
// import { SpyneUtilsChannelRoute } from './spyne-utils-channel-route'
|
|
2
|
+
import { SpynePluginsMethods } from './spyne-plugins-methods'
|
|
3
|
+
import { deepMerge } from './deep-merge'
|
|
4
|
+
import { path } from 'ramda'
|
|
5
|
+
|
|
6
|
+
let _config
|
|
7
|
+
let _channels
|
|
8
|
+
let _channelsMap
|
|
9
|
+
let _initialized
|
|
10
|
+
let _debug = true
|
|
11
|
+
let _IMG_PATH
|
|
12
|
+
const _doNotTrackChannelsArr = []
|
|
13
|
+
const _proxiesMap = new Map()
|
|
14
|
+
|
|
15
|
+
const _spynePluginMethods = new SpynePluginsMethods()
|
|
16
|
+
|
|
17
|
+
class SpyneAppPropertiesClass {
|
|
19
18
|
constructor() {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
_initialized = false
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
get channelsMap(){
|
|
25
|
-
return _channelsMap
|
|
22
|
+
get channelsMap() {
|
|
23
|
+
return _channelsMap
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
get initialized(){
|
|
29
|
-
return _initialized
|
|
26
|
+
get initialized() {
|
|
27
|
+
return _initialized
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
get config(){
|
|
33
|
-
return _config
|
|
30
|
+
get config() {
|
|
31
|
+
return _config
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
get debug(){
|
|
37
|
-
return _debug
|
|
34
|
+
get debug() {
|
|
35
|
+
return _debug
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
/**
|
|
@@ -47,56 +45,66 @@ class SpyneAppPropertiesClass{
|
|
|
47
45
|
* @returns A list of all registered channels
|
|
48
46
|
*/
|
|
49
47
|
static listChannels() {
|
|
50
|
-
return Array.from(_channels.map.keys())
|
|
48
|
+
return Array.from(_channels.map.keys())
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
initialize(defaultConfig={}, config={}, channelsMap){
|
|
54
|
-
_channels = channelsMap
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
initialize(defaultConfig = {}, config = {}, channelsMap, routeUtils) {
|
|
52
|
+
_channels = channelsMap
|
|
53
|
+
_config = deepMerge(defaultConfig, config)
|
|
54
|
+
// console.log("config is ", { defaultConfig,config });
|
|
55
|
+
if (_config.channels && _config.channels.ROUTE) {
|
|
56
|
+
// _config = SpyneUtilsChannelRoute.conformRouteObject(_config)
|
|
57
|
+
_config = routeUtils.conformRouteObject(_config)
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
_debug = _config.debug!== undefined ? _config.debug : _debug
|
|
61
|
-
this.getChannelActions = _channels.getChannelActions.bind(_channels)
|
|
62
|
-
this.listRegisteredChannels = _channels.listRegisteredChannels.bind(_channels)
|
|
63
|
-
_initialized = true
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
_IMG_PATH = _config?.IMG_PATH
|
|
60
|
+
_debug = _config.debug !== undefined ? _config.debug : _debug
|
|
61
|
+
this.getChannelActions = _channels.getChannelActions.bind(_channels)
|
|
62
|
+
this.listRegisteredChannels = _channels.listRegisteredChannels.bind(_channels)
|
|
63
|
+
_initialized = true
|
|
64
|
+
this.setChannelsMap()
|
|
65
|
+
if (config?.baseHref) {
|
|
66
|
+
this.setHeadBaseHref(config.baseHref)
|
|
67
|
+
}
|
|
68
|
+
return _config
|
|
69
|
+
}
|
|
68
70
|
|
|
71
|
+
setHeadBaseHref(str) {
|
|
72
|
+
// Create a new base element
|
|
73
|
+
const baseTag = document.createElement('base')
|
|
74
|
+
// Set the href attribute to the desired base URL
|
|
75
|
+
baseTag.href = str // You can set this to any base URL
|
|
76
|
+
// Append the base element to the head section of the document
|
|
77
|
+
document.head.appendChild(baseTag)
|
|
69
78
|
}
|
|
70
79
|
|
|
71
|
-
conformRouteConfig(add404Props=false){
|
|
80
|
+
conformRouteConfig(add404Props = false) {
|
|
72
81
|
/**
|
|
73
82
|
* THIS METHOD IS PRIMARILY USED FOR SPA GEN SITE GENERATION
|
|
74
83
|
*/
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
// eslint-disable-next-line no-undef
|
|
86
|
+
_config = SpyneUtilsChannelRoute.conformRouteObject(_config, add404Props)
|
|
78
87
|
}
|
|
79
88
|
|
|
80
|
-
setChannelsMap(){
|
|
81
|
-
const getStream = _channels.getStream.bind(_channels)
|
|
82
|
-
const testStream = _channels.testStream.bind(_channels)
|
|
83
|
-
const getProxySubject = _channels.getProxySubject.bind(_channels)
|
|
84
|
-
|
|
85
|
-
_channelsMap = {getStream, testStream, getProxySubject}
|
|
89
|
+
setChannelsMap() {
|
|
90
|
+
const getStream = _channels.getStream.bind(_channels)
|
|
91
|
+
const testStream = _channels.testStream.bind(_channels)
|
|
92
|
+
const getProxySubject = _channels.getProxySubject.bind(_channels)
|
|
86
93
|
|
|
94
|
+
_channelsMap = { getStream, testStream, getProxySubject }
|
|
87
95
|
}
|
|
88
96
|
|
|
89
|
-
setProp(key, val){
|
|
90
|
-
_config.tmp[key]=val
|
|
97
|
+
setProp(key, val) {
|
|
98
|
+
_config.tmp[key] = val
|
|
91
99
|
}
|
|
92
100
|
|
|
93
|
-
getProp(key){
|
|
94
|
-
return path(['tmp', key], _config)
|
|
101
|
+
getProp(key) {
|
|
102
|
+
return path(['tmp', key], _config)
|
|
95
103
|
}
|
|
96
104
|
|
|
97
|
-
setChannelConfig(channelName, config){
|
|
98
|
-
_config.channels[channelName] = config
|
|
99
|
-
return _config.channels[channelName]
|
|
105
|
+
setChannelConfig(channelName, config) {
|
|
106
|
+
_config.channels[channelName] = config
|
|
107
|
+
return _config.channels[channelName]
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
/**
|
|
@@ -104,103 +112,91 @@ class SpyneAppPropertiesClass{
|
|
|
104
112
|
* @param {String} channelName
|
|
105
113
|
* @returns {Array} An array of Actions that can be listened to
|
|
106
114
|
*/
|
|
107
|
-
/* getChannelActions(channelName) {
|
|
115
|
+
/* getChannelActions(channelName) {
|
|
108
116
|
return _channels.getChannelActions(channelName);
|
|
109
|
-
}*/
|
|
117
|
+
} */
|
|
110
118
|
|
|
111
|
-
getChannelConfig(channelName, config=_config){
|
|
112
|
-
if (channelName === 'CHANNEL_ROUTE'){
|
|
113
|
-
channelName =
|
|
114
|
-
} else if (channelName === 'CHANNEL_WINDOW'){
|
|
115
|
-
channelName =
|
|
119
|
+
getChannelConfig(channelName, config = _config) {
|
|
120
|
+
if (channelName === 'CHANNEL_ROUTE') {
|
|
121
|
+
channelName = 'ROUTE'
|
|
122
|
+
} else if (channelName === 'CHANNEL_WINDOW') {
|
|
123
|
+
channelName = 'WINDOW'
|
|
116
124
|
}
|
|
117
125
|
|
|
118
|
-
if (config === undefined || _config.channels === undefined){
|
|
126
|
+
if (config === undefined || _config.channels === undefined) {
|
|
119
127
|
console.warn('Spyne warning: Spyne config object is empty!')
|
|
120
|
-
return
|
|
128
|
+
return
|
|
121
129
|
}
|
|
122
130
|
|
|
123
|
-
const channelConfig = _config.channels[channelName]
|
|
131
|
+
const channelConfig = _config.channels[channelName]
|
|
124
132
|
|
|
125
|
-
if (channelConfig === undefined){
|
|
133
|
+
if (channelConfig === undefined) {
|
|
126
134
|
console.warn(`Spyne warning: Spyne configuration for channel, ${channelName} is empty!`)
|
|
127
|
-
return
|
|
135
|
+
return
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
return channelConfig
|
|
138
|
+
return channelConfig
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
registerChannel(){
|
|
134
|
-
|
|
141
|
+
registerChannel() {
|
|
135
142
|
|
|
136
143
|
}
|
|
137
144
|
|
|
138
|
-
addPluginConfig(pluginName, pluginConfig={}){
|
|
139
|
-
if (_config
|
|
140
|
-
_config
|
|
145
|
+
addPluginConfig(pluginName, pluginConfig = {}) {
|
|
146
|
+
if (_config.plugins === undefined) {
|
|
147
|
+
_config.plugins = {}
|
|
141
148
|
}
|
|
142
|
-
this.addPluginMethods(pluginConfig
|
|
143
|
-
|
|
144
|
-
_config.plugins[pluginName]=pluginConfig;
|
|
149
|
+
this.addPluginMethods(pluginConfig.pluginMethods)
|
|
145
150
|
|
|
151
|
+
_config.plugins[pluginName] = pluginConfig
|
|
146
152
|
}
|
|
147
153
|
|
|
148
|
-
getPluginsMethodObj(pluginMethodsObj){
|
|
149
|
-
if(pluginMethodsObj){
|
|
150
|
-
this.addPluginMethods(pluginMethodsObj)
|
|
154
|
+
getPluginsMethodObj(pluginMethodsObj) {
|
|
155
|
+
if (pluginMethodsObj) {
|
|
156
|
+
this.addPluginMethods(pluginMethodsObj)
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
return _spynePluginMethods.pluginMethodsObj
|
|
159
|
+
return _spynePluginMethods.pluginMethodsObj
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
addPluginMethods(pluginMethods){
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
_spynePluginMethods.addMethods(pluginMethods);
|
|
161
|
-
|
|
162
|
+
addPluginMethods(pluginMethods) {
|
|
163
|
+
if (pluginMethods) {
|
|
164
|
+
_spynePluginMethods.addMethods(pluginMethods)
|
|
162
165
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
doNotTrackChannel(channelName){
|
|
170
|
-
_doNotTrackChannelsArr.push(channelName);
|
|
168
|
+
doNotTrackChannel(channelName) {
|
|
169
|
+
_doNotTrackChannelsArr.push(channelName)
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
getUntrackedChannelsList(){
|
|
174
|
-
return _doNotTrackChannelsArr
|
|
172
|
+
getUntrackedChannelsList() {
|
|
173
|
+
return _doNotTrackChannelsArr
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
_proxiesMap.
|
|
180
|
-
//console.log("REGISTERD PROXY REVIVER",_proxiesMap, _proxiesMap.get(name));
|
|
181
|
-
|
|
176
|
+
registerProxyReviver(name, method) {
|
|
177
|
+
_proxiesMap.set(name, method)
|
|
178
|
+
// console.log("REGISTERD PROXY REVIVER",_proxiesMap, _proxiesMap.get(name));
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
getProxyReviver(proxyName){
|
|
185
|
-
return _proxiesMap.get(proxyName)
|
|
181
|
+
getProxyReviver(proxyName) {
|
|
182
|
+
return _proxiesMap.get(proxyName)
|
|
186
183
|
}
|
|
187
184
|
|
|
188
|
-
getPluginConfigByPluginName(pluginName){
|
|
189
|
-
return _config.plugins[pluginName]
|
|
185
|
+
getPluginConfigByPluginName(pluginName) {
|
|
186
|
+
return _config.plugins[pluginName]
|
|
190
187
|
}
|
|
191
188
|
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
get IMG_PATH() {
|
|
190
|
+
return _IMG_PATH
|
|
194
191
|
}
|
|
195
192
|
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
tempGetChannelsInstance() {
|
|
198
194
|
|
|
199
195
|
}
|
|
200
196
|
|
|
197
|
+
tempGetConfig() {
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
}
|
|
204
200
|
}
|
|
205
201
|
|
|
206
|
-
export
|
|
202
|
+
export const SpyneAppProperties = new SpyneAppPropertiesClass()
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
class SpyneLoggerClass{
|
|
2
|
-
|
|
1
|
+
class SpyneLoggerClass {
|
|
3
2
|
constructor(props) {
|
|
4
|
-
|
|
5
|
-
this._warnings = [];
|
|
3
|
+
this._warnings = []
|
|
6
4
|
}
|
|
7
5
|
|
|
8
|
-
static warn(){
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
static warn() {
|
|
11
7
|
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
9
|
}
|
|
17
10
|
|
|
18
|
-
export
|
|
11
|
+
export const SpyneLogger = new SpyneLoggerClass()
|