sygnal 2.6.2 → 2.6.3
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/dist/index.cjs.js +64 -64
- package/dist/index.esm.js +57 -57
- package/dist/sygnal.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var isolate = require('@cycle/isolate');
|
|
6
6
|
var state = require('@cycle/state');
|
|
7
|
-
var
|
|
7
|
+
var xs$1 = require('xstream');
|
|
8
8
|
var run$1 = require('@cycle/run');
|
|
9
9
|
var dom = require('@cycle/dom');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
13
13
|
var isolate__default = /*#__PURE__*/_interopDefaultLegacy(isolate);
|
|
14
|
-
var
|
|
14
|
+
var xs__default = /*#__PURE__*/_interopDefaultLegacy(xs$1);
|
|
15
15
|
|
|
16
16
|
function collection(component, stateLense, opts={}) {
|
|
17
17
|
const {
|
|
@@ -2777,11 +2777,11 @@ function switchable(factories, name$, initial, opts={}) {
|
|
|
2777
2777
|
const nameType = typeof name$;
|
|
2778
2778
|
|
|
2779
2779
|
if (!name$) throw new Error(`Missing 'name$' parameter for switchable()`)
|
|
2780
|
-
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof
|
|
2780
|
+
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof xs$1.Stream)) {
|
|
2781
2781
|
throw new Error(`Invalid 'name$' parameter for switchable(): expects Stream, String, or Function`)
|
|
2782
2782
|
}
|
|
2783
2783
|
|
|
2784
|
-
if (name$ instanceof
|
|
2784
|
+
if (name$ instanceof xs$1.Stream) {
|
|
2785
2785
|
const withInitial$ = name$
|
|
2786
2786
|
.compose(_default$5())
|
|
2787
2787
|
.startWith(initial)
|
|
@@ -2791,7 +2791,7 @@ function switchable(factories, name$, initial, opts={}) {
|
|
|
2791
2791
|
const mapFunction = (nameType === 'function' && name$) || (state => state[name$]);
|
|
2792
2792
|
return sources => {
|
|
2793
2793
|
const state$ = sources && ((typeof stateSourceName === 'string' && sources[stateSourceName]) || sources.STATE || sources.state).stream;
|
|
2794
|
-
if (!state$ instanceof
|
|
2794
|
+
if (!state$ instanceof xs$1.Stream) throw new Error(`Could not find the state source: ${ stateSourceName }`)
|
|
2795
2795
|
const _name$ = state$
|
|
2796
2796
|
.map(mapFunction)
|
|
2797
2797
|
.filter(name => typeof name === 'string')
|
|
@@ -2823,7 +2823,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2823
2823
|
.map(([name, factory]) => {
|
|
2824
2824
|
if (sources[stateSourceName]) {
|
|
2825
2825
|
const state$ = sources[stateSourceName].stream;
|
|
2826
|
-
const switched =
|
|
2826
|
+
const switched = xs__default["default"].combine(name$, state$)
|
|
2827
2827
|
.filter(([newComponentName, _]) => newComponentName == name)
|
|
2828
2828
|
.map(([_, state]) => state)
|
|
2829
2829
|
.remember();
|
|
@@ -2840,7 +2840,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2840
2840
|
obj[sinkName] = name$
|
|
2841
2841
|
.map( newComponentName => {
|
|
2842
2842
|
const sink = sinks.find(([componentName, _]) => componentName === newComponentName);
|
|
2843
|
-
return (sink && sink[1][sinkName]) ||
|
|
2843
|
+
return (sink && sink[1][sinkName]) || xs__default["default"].never()
|
|
2844
2844
|
})
|
|
2845
2845
|
.flatten()
|
|
2846
2846
|
.remember()
|
|
@@ -2848,7 +2848,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2848
2848
|
} else {
|
|
2849
2849
|
const definedSinks = sinks.filter(([_,sink]) => sink[sinkName] !== undefined)
|
|
2850
2850
|
.map(([_,sink]) => sink[sinkName]);
|
|
2851
|
-
obj[sinkName] =
|
|
2851
|
+
obj[sinkName] = xs__default["default"].merge(...definedSinks);
|
|
2852
2852
|
}
|
|
2853
2853
|
return obj
|
|
2854
2854
|
}, {});
|
|
@@ -3152,17 +3152,6 @@ function debounce(period) {
|
|
|
3152
3152
|
}
|
|
3153
3153
|
var _default$2 = debounce$1.default = debounce;
|
|
3154
3154
|
|
|
3155
|
-
// import syntax has bugs for xstream in Node context
|
|
3156
|
-
// this attempts to normalize to work in both Node and browser
|
|
3157
|
-
// if (!xs.never && xs.default && xs.default.never) {
|
|
3158
|
-
// xs.never = xs.default.never
|
|
3159
|
-
// xs.merge = xs.default.merge
|
|
3160
|
-
// xs.of = xs.default.of
|
|
3161
|
-
// }
|
|
3162
|
-
// const concat = (Concat && Concat.default) ? Concat.default : Concat
|
|
3163
|
-
// const delay = (Delay && Delay.default) ? Delay.default : Delay
|
|
3164
|
-
// const dropRepeats = (DropRepeats && DropRepeats.default) ? DropRepeats.default : DropRepeats
|
|
3165
|
-
|
|
3166
3155
|
const ENVIRONMENT = ((typeof window != 'undefined' && window) || (process && process.env)) || {};
|
|
3167
3156
|
|
|
3168
3157
|
|
|
@@ -3222,6 +3211,7 @@ class Component {
|
|
|
3222
3211
|
// response
|
|
3223
3212
|
// view
|
|
3224
3213
|
// children
|
|
3214
|
+
// components
|
|
3225
3215
|
// initialState
|
|
3226
3216
|
// calculated
|
|
3227
3217
|
// storeCalculatedInState
|
|
@@ -3278,9 +3268,11 @@ class Component {
|
|
|
3278
3268
|
}));
|
|
3279
3269
|
}
|
|
3280
3270
|
|
|
3271
|
+
// TODO: this is a hack to allow the root component to be created without an intent or model
|
|
3272
|
+
// refactor to avoid using a global variable
|
|
3281
3273
|
if (IS_ROOT_COMPONENT && typeof this.intent === 'undefined' && typeof this.model === 'undefined') {
|
|
3282
3274
|
this.initialState = initialState || true;
|
|
3283
|
-
this.intent = _ => ({__NOOP_ACTION__:
|
|
3275
|
+
this.intent = _ => ({__NOOP_ACTION__:xs__default["default"].never()});
|
|
3284
3276
|
this.model = {
|
|
3285
3277
|
__NOOP_ACTION__: state => state
|
|
3286
3278
|
};
|
|
@@ -3312,7 +3304,7 @@ class Component {
|
|
|
3312
3304
|
|
|
3313
3305
|
this.intent$ = this.intent(this.sources);
|
|
3314
3306
|
|
|
3315
|
-
if (!(this.intent$ instanceof
|
|
3307
|
+
if (!(this.intent$ instanceof xs$1.Stream) && (typeof this.intent$ != 'object')) {
|
|
3316
3308
|
throw new Error('Intent must return either an action$ stream or map of event streams')
|
|
3317
3309
|
}
|
|
3318
3310
|
}
|
|
@@ -3321,21 +3313,21 @@ class Component {
|
|
|
3321
3313
|
const requestSource = (this.sources && this.sources[this.requestSourceName]) || null;
|
|
3322
3314
|
|
|
3323
3315
|
if (!this.intent$) {
|
|
3324
|
-
this.action$ =
|
|
3316
|
+
this.action$ = xs__default["default"].never();
|
|
3325
3317
|
return
|
|
3326
3318
|
}
|
|
3327
3319
|
|
|
3328
3320
|
let runner;
|
|
3329
|
-
if (this.intent$ instanceof
|
|
3321
|
+
if (this.intent$ instanceof xs$1.Stream) {
|
|
3330
3322
|
runner = this.intent$;
|
|
3331
3323
|
} else {
|
|
3332
3324
|
const mapped = Object.entries(this.intent$)
|
|
3333
3325
|
.map(([type, data$]) => data$.map(data => ({type, data})));
|
|
3334
|
-
runner =
|
|
3326
|
+
runner = xs__default["default"].merge(xs__default["default"].never(), ...mapped);
|
|
3335
3327
|
}
|
|
3336
3328
|
|
|
3337
|
-
const action$ = ((runner instanceof
|
|
3338
|
-
const wrapped$ = _default$3(
|
|
3329
|
+
const action$ = ((runner instanceof xs$1.Stream) ? runner : (runner.apply && runner(this.sources) || xs__default["default"].never()));
|
|
3330
|
+
const wrapped$ = _default$3(xs__default["default"].of({ type: BOOTSTRAP_ACTION }), action$)
|
|
3339
3331
|
.compose(_default$4(10));
|
|
3340
3332
|
|
|
3341
3333
|
let initialApiData;
|
|
@@ -3343,12 +3335,12 @@ class Component {
|
|
|
3343
3335
|
initialApiData = requestSource.select('initial')
|
|
3344
3336
|
.flatten();
|
|
3345
3337
|
} else {
|
|
3346
|
-
initialApiData =
|
|
3338
|
+
initialApiData = xs__default["default"].never();
|
|
3347
3339
|
}
|
|
3348
3340
|
|
|
3349
3341
|
const hydrate$ = initialApiData.map(data => ({ type: HYDRATE_ACTION, data }));
|
|
3350
3342
|
|
|
3351
|
-
this.action$ =
|
|
3343
|
+
this.action$ = xs__default["default"].merge(wrapped$, hydrate$)
|
|
3352
3344
|
.compose(this.log(({ type }) => `Action triggered: <${ type }>`));
|
|
3353
3345
|
}
|
|
3354
3346
|
|
|
@@ -3405,7 +3397,7 @@ class Component {
|
|
|
3405
3397
|
if (actionType === 'function') {
|
|
3406
3398
|
const enhancedState = this.addCalculated(this.currentState);
|
|
3407
3399
|
const result = action(enhancedState, req);
|
|
3408
|
-
return
|
|
3400
|
+
return xs__default["default"].of({ ...obj, data: result })
|
|
3409
3401
|
} else {
|
|
3410
3402
|
this.action$.shamefullySendNext(obj);
|
|
3411
3403
|
|
|
@@ -3415,7 +3407,7 @@ class Component {
|
|
|
3415
3407
|
const selected$ = source[REQUEST_SELECTOR_METHOD](_reqId);
|
|
3416
3408
|
return [ ...acc, selected$ ]
|
|
3417
3409
|
}, []);
|
|
3418
|
-
return
|
|
3410
|
+
return xs__default["default"].merge(...responses)
|
|
3419
3411
|
}
|
|
3420
3412
|
} catch(err) {
|
|
3421
3413
|
console.error(err);
|
|
@@ -3423,11 +3415,11 @@ class Component {
|
|
|
3423
3415
|
}).flatten();
|
|
3424
3416
|
return [ ...acc, route$ ]
|
|
3425
3417
|
}, []);
|
|
3426
|
-
const mapped$ =
|
|
3418
|
+
const mapped$ = xs__default["default"].merge(...mapped);
|
|
3427
3419
|
return [ ...acc, mapped$ ]
|
|
3428
3420
|
}, []);
|
|
3429
3421
|
|
|
3430
|
-
this.response$ =
|
|
3422
|
+
this.response$ = xs__default["default"].merge(...wrapped)
|
|
3431
3423
|
.compose(this.log(res => {
|
|
3432
3424
|
if (res._action) return `[${ this.requestSourceName }] response data received for Action: <${ res._action }>`
|
|
3433
3425
|
return `[${ this.requestSourceName }] response data received from FUNCTION`
|
|
@@ -3458,14 +3450,14 @@ class Component {
|
|
|
3458
3450
|
initModel$() {
|
|
3459
3451
|
if (typeof this.model == 'undefined') {
|
|
3460
3452
|
this.model$ = this.sourceNames.reduce((a,s) => {
|
|
3461
|
-
a[s] =
|
|
3453
|
+
a[s] = xs__default["default"].never();
|
|
3462
3454
|
return a
|
|
3463
3455
|
}, {});
|
|
3464
3456
|
return
|
|
3465
3457
|
}
|
|
3466
3458
|
|
|
3467
3459
|
const initial = { type: INITIALIZE_ACTION, data: this.initialState };
|
|
3468
|
-
const shimmed$ = this.initialState ? _default$3(
|
|
3460
|
+
const shimmed$ = this.initialState ? _default$3(xs__default["default"].of(initial), this.action$).compose(_default$4(0)) : this.action$;
|
|
3469
3461
|
const onState = this.makeOnAction(shimmed$, true, this.action$);
|
|
3470
3462
|
const onNormal = this.makeOnAction(this.action$, false, this.action$);
|
|
3471
3463
|
|
|
@@ -3514,7 +3506,7 @@ class Component {
|
|
|
3514
3506
|
|
|
3515
3507
|
const model$ = Object.entries(reducers).reduce((acc, entry) => {
|
|
3516
3508
|
const [sink, streams] = entry;
|
|
3517
|
-
acc[sink] =
|
|
3509
|
+
acc[sink] = xs__default["default"].merge(xs__default["default"].never(), ...streams);
|
|
3518
3510
|
return acc
|
|
3519
3511
|
}, {});
|
|
3520
3512
|
|
|
@@ -3533,7 +3525,7 @@ class Component {
|
|
|
3533
3525
|
next: this.log(({ _reqId, _action }) => `Unhandled response for request: ${ _action } ${ _reqId }`)
|
|
3534
3526
|
});
|
|
3535
3527
|
}
|
|
3536
|
-
this.sendResponse$ =
|
|
3528
|
+
this.sendResponse$ = xs__default["default"].never();
|
|
3537
3529
|
return
|
|
3538
3530
|
}
|
|
3539
3531
|
|
|
@@ -3561,7 +3553,7 @@ class Component {
|
|
|
3561
3553
|
return [ ...acc, mapped$ ]
|
|
3562
3554
|
}, []);
|
|
3563
3555
|
|
|
3564
|
-
this.sendResponse$ =
|
|
3556
|
+
this.sendResponse$ = xs__default["default"].merge(...out$)
|
|
3565
3557
|
.compose(this.log(({ _reqId, _action }) => `[${ this.requestSourceName }] response sent for: <${ _action }>`));
|
|
3566
3558
|
}
|
|
3567
3559
|
|
|
@@ -3589,7 +3581,7 @@ class Component {
|
|
|
3589
3581
|
}
|
|
3590
3582
|
|
|
3591
3583
|
initSubComponentSink$() {
|
|
3592
|
-
const subComponentSink$ =
|
|
3584
|
+
const subComponentSink$ = xs__default["default"].create({
|
|
3593
3585
|
start: listener => {
|
|
3594
3586
|
this.newSubComponentSinks = listener.next.bind(listener);
|
|
3595
3587
|
},
|
|
@@ -3602,7 +3594,7 @@ class Component {
|
|
|
3602
3594
|
}
|
|
3603
3595
|
|
|
3604
3596
|
initSubComponentsRendered$() {
|
|
3605
|
-
const stream =
|
|
3597
|
+
const stream = xs__default["default"].create({
|
|
3606
3598
|
start: (listener) => {
|
|
3607
3599
|
this.subComponentsRendered = listener.next.bind(listener);
|
|
3608
3600
|
},
|
|
@@ -3615,7 +3607,7 @@ class Component {
|
|
|
3615
3607
|
|
|
3616
3608
|
initVdom$() {
|
|
3617
3609
|
if (typeof this.view != 'function') {
|
|
3618
|
-
this.vdom$ =
|
|
3610
|
+
this.vdom$ = xs__default["default"].of(null);
|
|
3619
3611
|
return
|
|
3620
3612
|
}
|
|
3621
3613
|
|
|
@@ -3633,17 +3625,17 @@ class Component {
|
|
|
3633
3625
|
initSinks() {
|
|
3634
3626
|
this.sinks = this.sourceNames.reduce((acc, name) => {
|
|
3635
3627
|
if (name == this.DOMSourceName) return acc
|
|
3636
|
-
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() :
|
|
3628
|
+
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() : xs__default["default"].never();
|
|
3637
3629
|
if (name === this.stateSourceName) {
|
|
3638
|
-
acc[name] =
|
|
3630
|
+
acc[name] = xs__default["default"].merge((this.model$[name] || xs__default["default"].never()), subComponentSink$, this.sources[this.stateSourceName].stream.filter(_ => false), ...this.children$[name]);
|
|
3639
3631
|
} else {
|
|
3640
|
-
acc[name] =
|
|
3632
|
+
acc[name] = xs__default["default"].merge((this.model$[name] || xs__default["default"].never()), subComponentSink$, ...this.children$[name]);
|
|
3641
3633
|
}
|
|
3642
3634
|
return acc
|
|
3643
3635
|
}, {});
|
|
3644
3636
|
|
|
3645
3637
|
this.sinks[this.DOMSourceName] = this.vdom$;
|
|
3646
|
-
this.sinks[this.requestSourceName] =
|
|
3638
|
+
this.sinks[this.requestSourceName] = xs__default["default"].merge(this.sendResponse$ ,this.sinks[this.requestSourceName]);
|
|
3647
3639
|
}
|
|
3648
3640
|
|
|
3649
3641
|
makeOnAction(action$, isStateSink=true, rootAction$) {
|
|
@@ -3737,7 +3729,7 @@ class Component {
|
|
|
3737
3729
|
const renderParams = { ...this.children$[this.DOMSourceName] };
|
|
3738
3730
|
|
|
3739
3731
|
const enhancedState = state && state.isolateSource(state, { get: state => this.addCalculated(state) });
|
|
3740
|
-
const stateStream = (enhancedState && enhancedState.stream) ||
|
|
3732
|
+
const stateStream = (enhancedState && enhancedState.stream) || xs__default["default"].never();
|
|
3741
3733
|
|
|
3742
3734
|
renderParams.state = stateStream;
|
|
3743
3735
|
renderParams[this.stateSourceName] = stateStream;
|
|
@@ -3758,7 +3750,7 @@ class Component {
|
|
|
3758
3750
|
streams.push(stream);
|
|
3759
3751
|
});
|
|
3760
3752
|
|
|
3761
|
-
const combined =
|
|
3753
|
+
const combined = xs__default["default"].combine(...streams)
|
|
3762
3754
|
// map the streams from an array back to an object with the render parameter names as the keys
|
|
3763
3755
|
.map(arr => {
|
|
3764
3756
|
return names.reduce((acc, name, index) => {
|
|
@@ -3800,8 +3792,8 @@ class Component {
|
|
|
3800
3792
|
return acc
|
|
3801
3793
|
}
|
|
3802
3794
|
|
|
3803
|
-
const props$ =
|
|
3804
|
-
const children$ =
|
|
3795
|
+
const props$ = xs__default["default"].create().startWith(props);
|
|
3796
|
+
const children$ = xs__default["default"].create().startWith(children);
|
|
3805
3797
|
|
|
3806
3798
|
let instantiator;
|
|
3807
3799
|
|
|
@@ -3815,7 +3807,7 @@ class Component {
|
|
|
3815
3807
|
|
|
3816
3808
|
const sink$ = instantiator(el, props$, children$);
|
|
3817
3809
|
|
|
3818
|
-
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) :
|
|
3810
|
+
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) : xs__default["default"].never();
|
|
3819
3811
|
|
|
3820
3812
|
acc[id] = { sink$, props$, children$ };
|
|
3821
3813
|
|
|
@@ -3829,7 +3821,7 @@ class Component {
|
|
|
3829
3821
|
|
|
3830
3822
|
const mergedSinksByType = Object.entries(sinkArrsByType).reduce((acc, [name, streamArr]) => {
|
|
3831
3823
|
if (streamArr.length === 0) return acc
|
|
3832
|
-
acc[name] = streamArr.length === 1 ? streamArr[0] :
|
|
3824
|
+
acc[name] = streamArr.length === 1 ? streamArr[0] : xs__default["default"].merge(...streamArr);
|
|
3833
3825
|
return acc
|
|
3834
3826
|
}, {});
|
|
3835
3827
|
|
|
@@ -3859,7 +3851,7 @@ class Component {
|
|
|
3859
3851
|
const props = data.props || {};
|
|
3860
3852
|
el.children || [];
|
|
3861
3853
|
|
|
3862
|
-
const combined$ =
|
|
3854
|
+
const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3863
3855
|
.map(([state, __props, __children]) => {
|
|
3864
3856
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3865
3857
|
});
|
|
@@ -3903,7 +3895,6 @@ class Component {
|
|
|
3903
3895
|
return state
|
|
3904
3896
|
},
|
|
3905
3897
|
set: (oldState, newState) => {
|
|
3906
|
-
console.log('COLL SET', newState);
|
|
3907
3898
|
return newState
|
|
3908
3899
|
}
|
|
3909
3900
|
};
|
|
@@ -3931,7 +3922,17 @@ class Component {
|
|
|
3931
3922
|
console.error(`Collection component in ${ this.name } has an invalid 'from' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting child state from the current state. Attempting to use parent component state.`);
|
|
3932
3923
|
lense = undefined;
|
|
3933
3924
|
} else {
|
|
3934
|
-
lense = {
|
|
3925
|
+
lense = {
|
|
3926
|
+
get: (state) => {
|
|
3927
|
+
const newState = stateField.get(state);
|
|
3928
|
+
if (!Array.isArray(newState)) {
|
|
3929
|
+
console.warn(`State getter function in collection component of ${ this.name } did not return an array: No components will be instantiated in the collection. Returned value:`, newState);
|
|
3930
|
+
return []
|
|
3931
|
+
}
|
|
3932
|
+
return newState
|
|
3933
|
+
},
|
|
3934
|
+
set: stateField.set
|
|
3935
|
+
};
|
|
3935
3936
|
}
|
|
3936
3937
|
} else {
|
|
3937
3938
|
console.error(`Collection component in ${ this.name } has an invalid 'from' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting child state from the current state. Attempting to use parent component state.`);
|
|
@@ -3951,7 +3952,7 @@ class Component {
|
|
|
3951
3952
|
const props = data.props || {};
|
|
3952
3953
|
el.children || [];
|
|
3953
3954
|
|
|
3954
|
-
const combined$ =
|
|
3955
|
+
const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3955
3956
|
.map(([state, __props, __children]) => {
|
|
3956
3957
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3957
3958
|
});
|
|
@@ -3970,7 +3971,6 @@ class Component {
|
|
|
3970
3971
|
console.warn(`Switchable sub-component of ${ this.name } attempted to update state on a calculated field '${ stateField }': Update ignored`);
|
|
3971
3972
|
return oldState
|
|
3972
3973
|
}
|
|
3973
|
-
console.log('SWITCH SET', newState);
|
|
3974
3974
|
if (typeof newState !== 'object' || newState instanceof Array) return { ...oldState, [stateField]: newState }
|
|
3975
3975
|
const { __props, __children, ...sanitized } = newState;
|
|
3976
3976
|
return { ...oldState, [stateField]: sanitized }
|
|
@@ -4020,7 +4020,7 @@ class Component {
|
|
|
4020
4020
|
const props = data.props || {};
|
|
4021
4021
|
el.children || [];
|
|
4022
4022
|
|
|
4023
|
-
const combined$ =
|
|
4023
|
+
const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
4024
4024
|
.map(([state, __props, __children]) => {
|
|
4025
4025
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
4026
4026
|
});
|
|
@@ -4087,7 +4087,7 @@ class Component {
|
|
|
4087
4087
|
}
|
|
4088
4088
|
|
|
4089
4089
|
renderVdom(componentInstances$) {
|
|
4090
|
-
return
|
|
4090
|
+
return xs__default["default"].combine(this.subComponentsRendered$, componentInstances$)
|
|
4091
4091
|
.compose(_default$2(5))
|
|
4092
4092
|
.map(([_, components]) => {
|
|
4093
4093
|
const componentNames = Object.keys(this.components);
|
|
@@ -4096,7 +4096,7 @@ class Component {
|
|
|
4096
4096
|
const entries = Object.entries(components).filter(([id]) => id !== '::ROOT::');
|
|
4097
4097
|
|
|
4098
4098
|
if (entries.length === 0) {
|
|
4099
|
-
return
|
|
4099
|
+
return xs__default["default"].of(root)
|
|
4100
4100
|
}
|
|
4101
4101
|
|
|
4102
4102
|
const ids = [];
|
|
@@ -4106,9 +4106,9 @@ class Component {
|
|
|
4106
4106
|
return val.sink$[this.DOMSourceName].startWith(undefined)
|
|
4107
4107
|
});
|
|
4108
4108
|
|
|
4109
|
-
if (vdom$.length === 0) return
|
|
4109
|
+
if (vdom$.length === 0) return xs__default["default"].of(root)
|
|
4110
4110
|
|
|
4111
|
-
return
|
|
4111
|
+
return xs__default["default"].combine(...vdom$)
|
|
4112
4112
|
.compose(_default$2(10))
|
|
4113
4113
|
.map(vdoms => {
|
|
4114
4114
|
const withIds = vdoms.reduce((acc, vdom, index) => {
|
|
@@ -4183,7 +4183,7 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4183
4183
|
if (!props.of) throw new Error(`Collection element missing required 'component' property`)
|
|
4184
4184
|
if (typeof props.of !== 'string' && typeof props.of !== 'function') throw new Error(`Invalid 'component' property of collection element: found ${ typeof props.of } requires string or component factory function`)
|
|
4185
4185
|
if (typeof props.of !== 'function' && !componentNames.includes(props.of)) throw new Error(`Specified component for collection not found: ${ props.of }`)
|
|
4186
|
-
if (typeof props.from !== 'undefined' && !(typeof props.from === 'string' || Array.isArray(props.from))) console.warn(`No valid array found
|
|
4186
|
+
if (typeof props.from !== 'undefined' && !(typeof props.from === 'string' || Array.isArray(props.from) || typeof props.from.get === 'function')) console.warn(`No valid array found for collection ${ typeof props.of === 'string' ? props.of : 'function component' }: no collection components will be created`, props.from);
|
|
4187
4187
|
currentElement.data.isCollection = true;
|
|
4188
4188
|
currentElement.data.props ||= {};
|
|
4189
4189
|
} else if (isSwitchable) {
|
|
@@ -4272,7 +4272,7 @@ function processForm(form, options={}) {
|
|
|
4272
4272
|
|
|
4273
4273
|
const eventStream$ = events.map(event => form.events(event));
|
|
4274
4274
|
|
|
4275
|
-
const merged$ =
|
|
4275
|
+
const merged$ = xs__default["default"].merge(...eventStream$);
|
|
4276
4276
|
|
|
4277
4277
|
return merged$.map((e) => {
|
|
4278
4278
|
if (preventDefault) e.preventDefault();
|
|
@@ -4333,7 +4333,7 @@ function eventBusDriver(out$) {
|
|
|
4333
4333
|
const all = !type;
|
|
4334
4334
|
const _type = (Array.isArray(type)) ? type : [type];
|
|
4335
4335
|
let cb;
|
|
4336
|
-
const in$ =
|
|
4336
|
+
const in$ = xs__default["default"].create({
|
|
4337
4337
|
start: (listener) => {
|
|
4338
4338
|
cb = ({detail: event}) => {
|
|
4339
4339
|
const data = (event && event.data) || null;
|
|
@@ -4740,7 +4740,7 @@ var _default = sampleCombine$1.default = sampleCombine;
|
|
|
4740
4740
|
|
|
4741
4741
|
Object.defineProperty(exports, 'xs', {
|
|
4742
4742
|
enumerable: true,
|
|
4743
|
-
get: function () { return
|
|
4743
|
+
get: function () { return xs__default["default"]; }
|
|
4744
4744
|
});
|
|
4745
4745
|
exports.ABORT = ABORT;
|
|
4746
4746
|
exports.classes = classes;
|