spyne 0.20.5 → 0.20.7
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/lib/spyne.esm.js +3 -3
- package/lib/spyne.esm.js.map +1 -1
- package/lib/spyne.umd.js +2 -2
- package/lib/spyne.umd.js.LICENSE.txt +2 -2
- package/package.json +1 -1
- package/src/spyne/channels/channel-fetch-class.js +15 -12
- package/src/spyne/channels/channel-payload-class.js +2 -2
- package/src/spyne/channels/channel-proxy.js +3 -3
- package/src/spyne/channels/channel.js +60 -33
- package/src/spyne/channels/channels-config.js +1 -1
- package/src/spyne/channels/channels-map.js +5 -5
- package/src/spyne/channels/spyne-channel-lifecycle.js +1 -1
- package/src/spyne/channels/spyne-channel-route.js +43 -6
- package/src/spyne/channels/spyne-channel-ui.js +17 -1
- package/src/spyne/channels/spyne-channel-window.js +5 -5
- package/src/spyne/spyne-app.js +9 -7
- package/src/spyne/spyne-plugins.js +17 -2
- package/src/spyne/spyne.js +19 -19
- package/src/spyne/utils/channel-fetch-util.js +2 -0
- package/src/spyne/utils/channel-payload-filter.js +1 -1
- package/src/spyne/utils/mixins/base-streams-mixins.js +1 -1
- package/src/spyne/utils/route-channel-updater.js +1 -1
- package/src/spyne/utils/safe-clone.js +1 -1
- package/src/spyne/utils/spyne-app-properties.js +73 -7
- package/src/spyne/utils/spyne-trait.js +1 -1
- package/src/spyne/utils/spyne-utils-channel-route-url.js +16 -2
- package/src/spyne/utils/spyne-utils-channel-route.js +1 -1
- package/src/spyne/views/dom-element-template.js +5 -2
- package/src/spyne/views/dom-element.js +3 -3
- package/src/spyne/views/view-stream-broadcaster.js +3 -3
- package/src/spyne/views/view-stream-element.js +12 -7
- package/src/spyne/views/view-stream-payload.js +3 -3
- package/src/spyne/views/view-stream-selector.js +1 -1
- package/src/spyne/views/view-stream.js +22 -18
- package/src/tests/utils/channel-data-packet-generator.unused.js +1 -1
- package/src/spyne/utils/channel-config-validator.js +0 -14
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import { SpynePluginsMethods } from './spyne-plugins-methods'
|
|
3
|
-
import { deepMerge } from './deep-merge'
|
|
4
|
-
import { path } from 'ramda'
|
|
1
|
+
import { SpyneUtilsChannelRoute } from './spyne-utils-channel-route.js'
|
|
2
|
+
import { SpynePluginsMethods } from './spyne-plugins-methods.js'
|
|
3
|
+
import { deepMerge } from './deep-merge.js'
|
|
5
4
|
|
|
6
5
|
let _config
|
|
7
6
|
let _channels
|
|
8
7
|
let _channelsMap
|
|
9
8
|
let _initialized
|
|
10
9
|
let _debug = true
|
|
10
|
+
const _excludeChannelsFromConsole = []
|
|
11
|
+
/* eslint-disable */
|
|
12
|
+
let _linksData
|
|
13
|
+
let _navLinks
|
|
11
14
|
let _IMG_PATH
|
|
12
15
|
const _doNotTrackChannelsArr = []
|
|
13
16
|
const _proxiesMap = new Map()
|
|
14
17
|
|
|
18
|
+
function random6Chars() {
|
|
19
|
+
// For simplicity: slice(2, 8) gets 6 random chars from the substring
|
|
20
|
+
return Math.random().toString(36).slice(2, 8);
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
const _spynePluginMethods = new SpynePluginsMethods()
|
|
16
24
|
|
|
17
25
|
class SpyneAppPropertiesClass {
|
|
@@ -95,14 +103,32 @@ class SpyneAppPropertiesClass {
|
|
|
95
103
|
_channelsMap = { getStream, testStream, getProxySubject }
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
setProp(key, val) {
|
|
99
|
-
|
|
106
|
+
setProp(key, val, isTemp = false) {
|
|
107
|
+
if (isTemp) {
|
|
108
|
+
_config.ephemeralProps[key] = val;
|
|
109
|
+
return val;
|
|
110
|
+
} else {
|
|
111
|
+
_config.tmpProps[key] = val;
|
|
112
|
+
}
|
|
113
|
+
return key;
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
getProp(key) {
|
|
103
|
-
|
|
117
|
+
if (_config.ephemeralProps.hasOwnProperty(key)) {
|
|
118
|
+
const tempVal = _config.ephemeralProps[key];
|
|
119
|
+
delete _config.ephemeralProps[key];
|
|
120
|
+
return tempVal;
|
|
121
|
+
}
|
|
122
|
+
return _config?.tmpProps?.[key];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
createTempProp(value) {
|
|
126
|
+
const key = random6Chars();
|
|
127
|
+
this.setProp(key, value, true); // isTemp = true
|
|
128
|
+
return key;
|
|
104
129
|
}
|
|
105
130
|
|
|
131
|
+
|
|
106
132
|
setChannelConfig(channelName, config) {
|
|
107
133
|
_config.channels[channelName] = config
|
|
108
134
|
return _config.channels[channelName]
|
|
@@ -201,6 +227,46 @@ class SpyneAppPropertiesClass {
|
|
|
201
227
|
return _IMG_PATH
|
|
202
228
|
}
|
|
203
229
|
|
|
230
|
+
get excludeChannelsFromConsole() {
|
|
231
|
+
return _excludeChannelsFromConsole
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Setter for _excludeChannelsFromConsole
|
|
235
|
+
set excludeChannelsFromConsole(value) {
|
|
236
|
+
if (typeof value === 'string') {
|
|
237
|
+
// Push a single string into the array if not already present
|
|
238
|
+
if (!_excludeChannelsFromConsole.includes(value)) {
|
|
239
|
+
_excludeChannelsFromConsole.push(value)
|
|
240
|
+
}
|
|
241
|
+
} else if (Array.isArray(value)) {
|
|
242
|
+
// Merge an array into the existing array, avoiding duplicates
|
|
243
|
+
value.forEach(item => {
|
|
244
|
+
if (typeof item === 'string' && !_excludeChannelsFromConsole.includes(item)) {
|
|
245
|
+
_excludeChannelsFromConsole.push(item)
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
} else {
|
|
249
|
+
console.warn('Invalid value provided to excludeChannelsFromConsole. Only strings or arrays are allowed.')
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
get linksData() {
|
|
254
|
+
console.warn('get links data in SpyneAppProperties is deprecated, use navLinks')
|
|
255
|
+
return _navLinks
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
set linksData(arr) {
|
|
259
|
+
console.warn('set links data in SpyneAppProperties is deprecated, use navLinks')
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
get navLinks() {
|
|
263
|
+
return _navLinks
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
set navLinks(arr) {
|
|
267
|
+
_navLinks = arr
|
|
268
|
+
}
|
|
269
|
+
|
|
204
270
|
tempGetChannelsInstance() {
|
|
205
271
|
|
|
206
272
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmpty, head, values, compose, prop, complement, isNil, allPass, reduce, filter, equals, toPairs, replace, either, propEq, __, invert, path, zipObj, reject, keys, find, assoc, is, has, when, split, always, concat, join, flatten, map, ifElse, test, findLastIndex, last, defaultTo, fromPairs } from 'ramda'
|
|
2
|
-
import { SpyneAppProperties } from './spyne-app-properties'
|
|
2
|
+
import { SpyneAppProperties } from './spyne-app-properties.js'
|
|
3
3
|
|
|
4
4
|
export class SpyneUtilsChannelRouteUrl {
|
|
5
5
|
constructor() {
|
|
@@ -254,9 +254,23 @@ export class SpyneUtilsChannelRouteUrl {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
static findIndexOfMatchedStringOrRegex(mainStr, paramsArr) {
|
|
257
|
+
const is404 = paramsArr.includes('.+')
|
|
258
|
+
|
|
259
|
+
const reFn = (s) => {
|
|
260
|
+
if (is404) {
|
|
261
|
+
if (!s.startsWith('^')) {
|
|
262
|
+
s = '^' + s
|
|
263
|
+
}
|
|
264
|
+
if (!s.endsWith('$')) {
|
|
265
|
+
s = s + '$'
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return new RegExp(s)
|
|
270
|
+
}
|
|
271
|
+
|
|
257
272
|
const checkForEmpty = replace(/^$/, '^$')
|
|
258
273
|
const createStrRegexTest = (str) => {
|
|
259
|
-
const reFn = s => new RegExp(s)
|
|
260
274
|
return {
|
|
261
275
|
str,
|
|
262
276
|
re: reFn(str)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromEventPattern } from 'rxjs'
|
|
2
2
|
import { last, flatten, clone, pick, prop, pickAll, path, equals, compose, keys, filter, propEq, uniq, map, __, chain, is, includes, fromPairs, reject, mergeDeepRight, mergeRight, test, toPairs, values } from 'ramda'
|
|
3
|
-
import { SpyneUtilsChannelRouteUrl } from './spyne-utils-channel-route-url'
|
|
3
|
+
import { SpyneUtilsChannelRouteUrl } from './spyne-utils-channel-route-url.js'
|
|
4
4
|
|
|
5
5
|
export class SpyneUtilsChannelRoute {
|
|
6
6
|
constructor() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { includes, __, ifElse, path, prop, reject, is, isNil, isEmpty } from 'ramda'
|
|
2
|
-
import sanitizeHTML from '../utils/sanitize-html'
|
|
3
|
-
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
2
|
+
import sanitizeHTML from '../utils/sanitize-html.js'
|
|
3
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @module DomElTemplate
|
|
@@ -349,6 +349,9 @@ export class DomElementTemplate {
|
|
|
349
349
|
elData = [elData]
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
// convert to array if is string
|
|
353
|
+
elData = Array.isArray(elData) ? elData : [elData]
|
|
354
|
+
|
|
352
355
|
return elData.map(mapStringData).join('')
|
|
353
356
|
}
|
|
354
357
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { baseCoreMixins } from '../utils/mixins/base-core-mixins'
|
|
2
|
-
import { DomElementTemplate } from './dom-element-template'
|
|
3
|
-
import { deepMerge } from '../utils/deep-merge'
|
|
1
|
+
import { baseCoreMixins } from '../utils/mixins/base-core-mixins.js'
|
|
2
|
+
import { DomElementTemplate } from './dom-element-template.js'
|
|
3
|
+
import { deepMerge } from '../utils/deep-merge.js'
|
|
4
4
|
import { is, defaultTo, pick, mapObjIndexed, forEachObjIndexed, pipe } from 'ramda'
|
|
5
5
|
|
|
6
6
|
class DomElement {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins'
|
|
2
|
-
import { convertDomStringMapToObj } from '../utils/frp-tools'
|
|
3
|
-
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
1
|
+
import { baseStreamsMixins } from '../utils/mixins/base-streams-mixins.js'
|
|
2
|
+
import { convertDomStringMapToObj } from '../utils/frp-tools.js'
|
|
3
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties.js'
|
|
4
4
|
import { fromEvent } from 'rxjs'
|
|
5
5
|
import { map } from 'rxjs/operators'
|
|
6
6
|
import { clone, omit } from 'ramda'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DomElement } from './dom-element'
|
|
2
|
-
import { fadein, fadeout } from '../utils/viewstream-animations'
|
|
3
|
-
import { ViewStreamObservable } from '../utils/viewstream-observables'
|
|
4
|
-
import { deepMerge } from '../utils/deep-merge'
|
|
1
|
+
import { DomElement } from './dom-element.js'
|
|
2
|
+
import { fadein, fadeout } from '../utils/viewstream-animations.js'
|
|
3
|
+
import { ViewStreamObservable } from '../utils/viewstream-observables.js'
|
|
4
|
+
import { deepMerge } from '../utils/deep-merge.js'
|
|
5
5
|
import { Subject, bindCallback } from 'rxjs'
|
|
6
6
|
import { filter, isNil, pick, props, defaultTo } from 'ramda'
|
|
7
7
|
|
|
@@ -23,6 +23,7 @@ export class ViewStreamElement {
|
|
|
23
23
|
this.addMixins()
|
|
24
24
|
this._state = 'INIT'
|
|
25
25
|
this.vsid = vsid
|
|
26
|
+
this.el = viewProps.el
|
|
26
27
|
this.vsName = vsName
|
|
27
28
|
this.defaults = {
|
|
28
29
|
debug:false,
|
|
@@ -152,6 +153,10 @@ export class ViewStreamElement {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
combineDomItems(d) {
|
|
156
|
+
if (this.el !== undefined) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
|
|
155
160
|
const container = isNil(d.query) ? d.node : d.query
|
|
156
161
|
const prepend = (node, item) => node.insertBefore(item, node.firstChild)
|
|
157
162
|
const append = (node, item) => node.appendChild(item)
|
|
@@ -195,7 +200,7 @@ export class ViewStreamElement {
|
|
|
195
200
|
this.combineDomItems(d)
|
|
196
201
|
return {
|
|
197
202
|
action: 'VS_SPAWNED_AND_ATTACHED_TO_PARENT',
|
|
198
|
-
el: this.domItem.el,
|
|
203
|
+
el: this.el || this.domItem.el,
|
|
199
204
|
$dir: this.$dirs.PI
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -208,7 +213,7 @@ export class ViewStreamElement {
|
|
|
208
213
|
|
|
209
214
|
onRender(d) {
|
|
210
215
|
const getEl = (data) => this.renderDomItem(data)
|
|
211
|
-
const el =
|
|
216
|
+
const el = this.el || getEl(props(['tagName', 'domAttributes', 'data', 'template'], d))
|
|
212
217
|
return {
|
|
213
218
|
action: 'VS_SPAWNED',
|
|
214
219
|
el,
|
|
@@ -231,7 +236,7 @@ export class ViewStreamElement {
|
|
|
231
236
|
this.combineDomItems(d.attachData)
|
|
232
237
|
return {
|
|
233
238
|
action: 'VS_SPAWNED_AND_ATTACHED_TO_DOM',
|
|
234
|
-
el:
|
|
239
|
+
el: this.el || d.attachData.el.el,
|
|
235
240
|
$dir: this.$dirs.CI
|
|
236
241
|
}
|
|
237
242
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
2
|
-
import { safeClone } from '../utils/safe-clone'
|
|
3
|
-
import { gc } from '../utils/gc'
|
|
1
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties.js'
|
|
2
|
+
import { safeClone } from '../utils/safe-clone.js'
|
|
3
|
+
import { gc } from '../utils/gc.js'
|
|
4
4
|
import {
|
|
5
5
|
compose,
|
|
6
6
|
clone,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { head, compose, reject, split, isEmpty, lte, defaultTo, prop } from 'ramda'
|
|
2
|
-
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
2
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties.js'
|
|
3
3
|
|
|
4
4
|
function generateSpyneSelectorId(el) {
|
|
5
5
|
const num = () => Math.random().toString(36).replace(/\d/gm, '').substring(1, 8)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { baseCoreMixins } from '../utils/mixins/base-core-mixins'
|
|
2
|
-
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
3
|
-
import { deepMerge } from '../utils/deep-merge'
|
|
4
|
-
import { safeClone } from '../utils/safe-clone'
|
|
1
|
+
import { baseCoreMixins } from '../utils/mixins/base-core-mixins.js'
|
|
2
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties.js'
|
|
3
|
+
import { deepMerge } from '../utils/deep-merge.js'
|
|
4
|
+
import { safeClone } from '../utils/safe-clone.js'
|
|
5
5
|
import {
|
|
6
6
|
findStrOrRegexMatchStr,
|
|
7
7
|
getConstructorName
|
|
8
|
-
} from '../utils/frp-tools'
|
|
9
|
-
import { ViewStreamElement } from './view-stream-element'
|
|
10
|
-
import { registeredStreamNames } from '../channels/channels-config'
|
|
11
|
-
import { ViewStreamBroadcaster } from './view-stream-broadcaster'
|
|
12
|
-
import { ViewStreamPayload } from './view-stream-payload'
|
|
13
|
-
import { ChannelPayloadFilter } from '../utils/channel-payload-filter'
|
|
14
|
-
import { ViewStreamObservable } from '../utils/viewstream-observables'
|
|
15
|
-
import { ViewStreamSelector } from './view-stream-selector'
|
|
8
|
+
} from '../utils/frp-tools.js'
|
|
9
|
+
import { ViewStreamElement } from './view-stream-element.js'
|
|
10
|
+
import { registeredStreamNames } from '../channels/channels-config.js'
|
|
11
|
+
import { ViewStreamBroadcaster } from './view-stream-broadcaster.js'
|
|
12
|
+
import { ViewStreamPayload } from './view-stream-payload.js'
|
|
13
|
+
import { ChannelPayloadFilter } from '../utils/channel-payload-filter.js'
|
|
14
|
+
import { ViewStreamObservable } from '../utils/viewstream-observables.js'
|
|
15
|
+
import { ViewStreamSelector } from './view-stream-selector.js'
|
|
16
16
|
import { Subject, of } from 'rxjs'
|
|
17
17
|
import { mergeMap, map, takeWhile, filter, tap, skip, finalize } from 'rxjs/operators'
|
|
18
18
|
import {
|
|
@@ -99,9 +99,9 @@ export class ViewStream {
|
|
|
99
99
|
this.loadAllMethods()
|
|
100
100
|
this.props.action = 'LOADED'
|
|
101
101
|
this.sink$ = new Subject()
|
|
102
|
+
this.props.elIsAlreadyRenderedBool = this.elAlreadyExistsFn(this.props)
|
|
102
103
|
const ViewClass = this.props.viewClass
|
|
103
|
-
this.view = new ViewClass(this.sink$, {}, this.props.vsid,
|
|
104
|
-
this.props.id)// new this.props.viewClass(this.sink$);
|
|
104
|
+
this.view = new ViewClass(this.sink$, { el:this.props.el }, this.props.vsid, this.props.id)// new this.props.viewClass(this.sink$);
|
|
105
105
|
this.sourceStreams = this.view.sourceStreams
|
|
106
106
|
this._rawSource$ = this.view.getSourceStream()
|
|
107
107
|
this._rawSource$.viewName = this.props.name
|
|
@@ -216,12 +216,14 @@ export class ViewStream {
|
|
|
216
216
|
|
|
217
217
|
// =====================================================================
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
elAlreadyExistsFn(props) {
|
|
220
220
|
const elIsDomElement = compose(lte(0), defaultTo(-1), prop('nodeType'))
|
|
221
221
|
const elIsRendered = el => document.body.contains(el)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
return propSatisfies(allPass([elIsRendered, elIsDomElement]), 'el')(props)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
checkIfElementAlreadyExists() {
|
|
226
|
+
if (this.props.elIsAlreadyRenderedBool === true) {
|
|
225
227
|
this.updatePropsToMatchEl()
|
|
226
228
|
this.postRender()
|
|
227
229
|
} else if (this.props.el === null) {
|
|
@@ -972,6 +974,8 @@ export class ViewStream {
|
|
|
972
974
|
}
|
|
973
975
|
if (Array.isArray(this?.props?.channels)) {
|
|
974
976
|
this?.props?.channels?.forEach(addChannel)
|
|
977
|
+
} else if (Array.isArray(this?.props?.channel)) {
|
|
978
|
+
console.warn('props.channel is not a ViewStream property. Do you mean props.channels?')
|
|
975
979
|
}
|
|
976
980
|
}
|
|
977
981
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChannelPayloadToTestFilters } from '../mocks/channel-payload-data'
|
|
1
|
+
import { ChannelPayloadToTestFilters } from '../mocks/channel-payload-data.js'
|
|
2
2
|
import { ChannelDataPacketGenerator } from '../../spyne/utils/channel-data-packet-generator'
|
|
3
3
|
import { ChannelDataPacket } from '../../spyne/utils/channel-data-packet'
|
|
4
4
|
const { expect, assert } = require('chai')
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Validation from 'data.validation'
|
|
2
|
-
import { curry, curryN, length, always, reduce } from 'ramda'
|
|
3
|
-
const success = Validation.Success
|
|
4
|
-
const failure = Validation.Failure
|
|
5
|
-
let validate = () => {}
|
|
6
|
-
if (curry !== undefined) {
|
|
7
|
-
validate = curry((validations, thing) => {
|
|
8
|
-
const initial = success(curryN(length(validations), always(thing)))
|
|
9
|
-
const run = (acc, v) =>
|
|
10
|
-
acc.ap(v.predicate(thing) ? success(thing) : failure([v.error]))
|
|
11
|
-
return reduce(run, initial, validations)
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
export { validate }
|