sygnal 2.6.2 → 2.6.4
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/README.md +16 -0
- package/dist/index.cjs.js +73 -87
- package/dist/index.esm.js +62 -66
- package/dist/jsx.cjs.js +2 -15
- package/dist/jsx.esm.js +0 -7
- package/dist/sygnal.min.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -123,6 +123,22 @@ Alternatively, you can use any other bundler of your choice (Webpack, Babel, Rol
|
|
|
123
123
|
}
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
NOTE: Some minifiers will cause JSX fragments to fail by renaming the Fragment pragma function. This can be fixed by preventing renaming of 'Fragment'. For Vite this is done by installing terser, and adding the following to your vite.config.js file:
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
{
|
|
130
|
+
...,
|
|
131
|
+
build: {
|
|
132
|
+
minify: 'terser',
|
|
133
|
+
terserOptions: {
|
|
134
|
+
mangle: {
|
|
135
|
+
reserved: ['Fragment'],
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
126
142
|
|
|
127
143
|
## Initialization
|
|
128
144
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var isolate = require('@cycle/isolate');
|
|
6
4
|
var state = require('@cycle/state');
|
|
7
|
-
var
|
|
5
|
+
var xs$1 = require('xstream');
|
|
8
6
|
var run$1 = require('@cycle/run');
|
|
9
7
|
var dom = require('@cycle/dom');
|
|
10
8
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var isolate__default = /*#__PURE__*/_interopDefaultLegacy(isolate);
|
|
14
|
-
var xstream__default = /*#__PURE__*/_interopDefaultLegacy(xstream$1);
|
|
15
|
-
|
|
16
9
|
function collection(component, stateLense, opts={}) {
|
|
17
10
|
const {
|
|
18
11
|
combineList = ['DOM'],
|
|
@@ -70,7 +63,7 @@ function collection(component, stateLense, opts={}) {
|
|
|
70
63
|
* @return {Object} collection of component sinks
|
|
71
64
|
*/
|
|
72
65
|
function makeIsolatedCollection (collectionOpts, isolateOpts, sources) {
|
|
73
|
-
return
|
|
66
|
+
return isolate(state.makeCollection(collectionOpts), isolateOpts)(sources)
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -79,9 +72,7 @@ var dropRepeats$1 = {};
|
|
|
79
72
|
|
|
80
73
|
var xstream = {};
|
|
81
74
|
|
|
82
|
-
var ponyfill$1 = {
|
|
83
|
-
|
|
84
|
-
var ponyfill = {};
|
|
75
|
+
var ponyfill$1 = {};
|
|
85
76
|
|
|
86
77
|
(function (exports) {
|
|
87
78
|
|
|
@@ -115,11 +106,9 @@ var ponyfill = {};
|
|
|
115
106
|
}
|
|
116
107
|
|
|
117
108
|
return result;
|
|
118
|
-
}} (ponyfill));
|
|
109
|
+
}} (ponyfill$1));
|
|
119
110
|
|
|
120
|
-
|
|
121
|
-
module.exports = ponyfill;
|
|
122
|
-
} (ponyfill$1));
|
|
111
|
+
var ponyfill = ponyfill$1;
|
|
123
112
|
|
|
124
113
|
var toStr$2 = Object.prototype.toString;
|
|
125
114
|
|
|
@@ -919,7 +908,7 @@ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
|
919
908
|
})();
|
|
920
909
|
Object.defineProperty(xstream, "__esModule", { value: true });
|
|
921
910
|
xstream.NO_IL = xstream.NO = xstream.MemoryStream = xstream.Stream = void 0;
|
|
922
|
-
var ponyfill_1 = ponyfill
|
|
911
|
+
var ponyfill_1 = ponyfill;
|
|
923
912
|
var globalthis_1 = globalthis;
|
|
924
913
|
var $$observable = ponyfill_1.default(globalthis_1.getPolyfill());
|
|
925
914
|
var NO$1 = {};
|
|
@@ -2777,11 +2766,11 @@ function switchable(factories, name$, initial, opts={}) {
|
|
|
2777
2766
|
const nameType = typeof name$;
|
|
2778
2767
|
|
|
2779
2768
|
if (!name$) throw new Error(`Missing 'name$' parameter for switchable()`)
|
|
2780
|
-
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof
|
|
2769
|
+
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof xs$1.Stream)) {
|
|
2781
2770
|
throw new Error(`Invalid 'name$' parameter for switchable(): expects Stream, String, or Function`)
|
|
2782
2771
|
}
|
|
2783
2772
|
|
|
2784
|
-
if (name$ instanceof
|
|
2773
|
+
if (name$ instanceof xs$1.Stream) {
|
|
2785
2774
|
const withInitial$ = name$
|
|
2786
2775
|
.compose(_default$5())
|
|
2787
2776
|
.startWith(initial)
|
|
@@ -2791,7 +2780,7 @@ function switchable(factories, name$, initial, opts={}) {
|
|
|
2791
2780
|
const mapFunction = (nameType === 'function' && name$) || (state => state[name$]);
|
|
2792
2781
|
return sources => {
|
|
2793
2782
|
const state$ = sources && ((typeof stateSourceName === 'string' && sources[stateSourceName]) || sources.STATE || sources.state).stream;
|
|
2794
|
-
if (!state$ instanceof
|
|
2783
|
+
if (!state$ instanceof xs$1.Stream) throw new Error(`Could not find the state source: ${ stateSourceName }`)
|
|
2795
2784
|
const _name$ = state$
|
|
2796
2785
|
.map(mapFunction)
|
|
2797
2786
|
.filter(name => typeof name === 'string')
|
|
@@ -2823,7 +2812,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2823
2812
|
.map(([name, factory]) => {
|
|
2824
2813
|
if (sources[stateSourceName]) {
|
|
2825
2814
|
const state$ = sources[stateSourceName].stream;
|
|
2826
|
-
const switched =
|
|
2815
|
+
const switched = xs$1.combine(name$, state$)
|
|
2827
2816
|
.filter(([newComponentName, _]) => newComponentName == name)
|
|
2828
2817
|
.map(([_, state]) => state)
|
|
2829
2818
|
.remember();
|
|
@@ -2840,7 +2829,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2840
2829
|
obj[sinkName] = name$
|
|
2841
2830
|
.map( newComponentName => {
|
|
2842
2831
|
const sink = sinks.find(([componentName, _]) => componentName === newComponentName);
|
|
2843
|
-
return (sink && sink[1][sinkName]) ||
|
|
2832
|
+
return (sink && sink[1][sinkName]) || xs$1.never()
|
|
2844
2833
|
})
|
|
2845
2834
|
.flatten()
|
|
2846
2835
|
.remember()
|
|
@@ -2848,7 +2837,7 @@ function _switchable (factories, sources, name$, switched=['DOM'], stateSourceNa
|
|
|
2848
2837
|
} else {
|
|
2849
2838
|
const definedSinks = sinks.filter(([_,sink]) => sink[sinkName] !== undefined)
|
|
2850
2839
|
.map(([_,sink]) => sink[sinkName]);
|
|
2851
|
-
obj[sinkName] =
|
|
2840
|
+
obj[sinkName] = xs$1.merge(...definedSinks);
|
|
2852
2841
|
}
|
|
2853
2842
|
return obj
|
|
2854
2843
|
}, {});
|
|
@@ -3152,17 +3141,6 @@ function debounce(period) {
|
|
|
3152
3141
|
}
|
|
3153
3142
|
var _default$2 = debounce$1.default = debounce;
|
|
3154
3143
|
|
|
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
3144
|
const ENVIRONMENT = ((typeof window != 'undefined' && window) || (process && process.env)) || {};
|
|
3167
3145
|
|
|
3168
3146
|
|
|
@@ -3202,7 +3180,7 @@ function component (opts) {
|
|
|
3202
3180
|
const fixedOpts = { ...opts, sources };
|
|
3203
3181
|
return (new Component(fixedOpts)).sinks
|
|
3204
3182
|
};
|
|
3205
|
-
return currySources ?
|
|
3183
|
+
return currySources ? isolate(wrapped, fixedIsolateOpts) : isolate(wrapped, fixedIsolateOpts)(sources)
|
|
3206
3184
|
} else {
|
|
3207
3185
|
return currySources ? (sources) => (new Component({ ...opts, sources })).sinks : (new Component(opts)).sinks
|
|
3208
3186
|
}
|
|
@@ -3222,6 +3200,7 @@ class Component {
|
|
|
3222
3200
|
// response
|
|
3223
3201
|
// view
|
|
3224
3202
|
// children
|
|
3203
|
+
// components
|
|
3225
3204
|
// initialState
|
|
3226
3205
|
// calculated
|
|
3227
3206
|
// storeCalculatedInState
|
|
@@ -3278,9 +3257,11 @@ class Component {
|
|
|
3278
3257
|
}));
|
|
3279
3258
|
}
|
|
3280
3259
|
|
|
3260
|
+
// TODO: this is a hack to allow the root component to be created without an intent or model
|
|
3261
|
+
// refactor to avoid using a global variable
|
|
3281
3262
|
if (IS_ROOT_COMPONENT && typeof this.intent === 'undefined' && typeof this.model === 'undefined') {
|
|
3282
3263
|
this.initialState = initialState || true;
|
|
3283
|
-
this.intent = _ => ({__NOOP_ACTION__:
|
|
3264
|
+
this.intent = _ => ({__NOOP_ACTION__:xs$1.never()});
|
|
3284
3265
|
this.model = {
|
|
3285
3266
|
__NOOP_ACTION__: state => state
|
|
3286
3267
|
};
|
|
@@ -3312,7 +3293,7 @@ class Component {
|
|
|
3312
3293
|
|
|
3313
3294
|
this.intent$ = this.intent(this.sources);
|
|
3314
3295
|
|
|
3315
|
-
if (!(this.intent$ instanceof
|
|
3296
|
+
if (!(this.intent$ instanceof xs$1.Stream) && (typeof this.intent$ != 'object')) {
|
|
3316
3297
|
throw new Error('Intent must return either an action$ stream or map of event streams')
|
|
3317
3298
|
}
|
|
3318
3299
|
}
|
|
@@ -3321,21 +3302,21 @@ class Component {
|
|
|
3321
3302
|
const requestSource = (this.sources && this.sources[this.requestSourceName]) || null;
|
|
3322
3303
|
|
|
3323
3304
|
if (!this.intent$) {
|
|
3324
|
-
this.action$ =
|
|
3305
|
+
this.action$ = xs$1.never();
|
|
3325
3306
|
return
|
|
3326
3307
|
}
|
|
3327
3308
|
|
|
3328
3309
|
let runner;
|
|
3329
|
-
if (this.intent$ instanceof
|
|
3310
|
+
if (this.intent$ instanceof xs$1.Stream) {
|
|
3330
3311
|
runner = this.intent$;
|
|
3331
3312
|
} else {
|
|
3332
3313
|
const mapped = Object.entries(this.intent$)
|
|
3333
3314
|
.map(([type, data$]) => data$.map(data => ({type, data})));
|
|
3334
|
-
runner =
|
|
3315
|
+
runner = xs$1.merge(xs$1.never(), ...mapped);
|
|
3335
3316
|
}
|
|
3336
3317
|
|
|
3337
|
-
const action$ = ((runner instanceof
|
|
3338
|
-
const wrapped$ = _default$3(
|
|
3318
|
+
const action$ = ((runner instanceof xs$1.Stream) ? runner : (runner.apply && runner(this.sources) || xs$1.never()));
|
|
3319
|
+
const wrapped$ = _default$3(xs$1.of({ type: BOOTSTRAP_ACTION }), action$)
|
|
3339
3320
|
.compose(_default$4(10));
|
|
3340
3321
|
|
|
3341
3322
|
let initialApiData;
|
|
@@ -3343,12 +3324,12 @@ class Component {
|
|
|
3343
3324
|
initialApiData = requestSource.select('initial')
|
|
3344
3325
|
.flatten();
|
|
3345
3326
|
} else {
|
|
3346
|
-
initialApiData =
|
|
3327
|
+
initialApiData = xs$1.never();
|
|
3347
3328
|
}
|
|
3348
3329
|
|
|
3349
3330
|
const hydrate$ = initialApiData.map(data => ({ type: HYDRATE_ACTION, data }));
|
|
3350
3331
|
|
|
3351
|
-
this.action$ =
|
|
3332
|
+
this.action$ = xs$1.merge(wrapped$, hydrate$)
|
|
3352
3333
|
.compose(this.log(({ type }) => `Action triggered: <${ type }>`));
|
|
3353
3334
|
}
|
|
3354
3335
|
|
|
@@ -3405,7 +3386,7 @@ class Component {
|
|
|
3405
3386
|
if (actionType === 'function') {
|
|
3406
3387
|
const enhancedState = this.addCalculated(this.currentState);
|
|
3407
3388
|
const result = action(enhancedState, req);
|
|
3408
|
-
return
|
|
3389
|
+
return xs$1.of({ ...obj, data: result })
|
|
3409
3390
|
} else {
|
|
3410
3391
|
this.action$.shamefullySendNext(obj);
|
|
3411
3392
|
|
|
@@ -3415,7 +3396,7 @@ class Component {
|
|
|
3415
3396
|
const selected$ = source[REQUEST_SELECTOR_METHOD](_reqId);
|
|
3416
3397
|
return [ ...acc, selected$ ]
|
|
3417
3398
|
}, []);
|
|
3418
|
-
return
|
|
3399
|
+
return xs$1.merge(...responses)
|
|
3419
3400
|
}
|
|
3420
3401
|
} catch(err) {
|
|
3421
3402
|
console.error(err);
|
|
@@ -3423,11 +3404,11 @@ class Component {
|
|
|
3423
3404
|
}).flatten();
|
|
3424
3405
|
return [ ...acc, route$ ]
|
|
3425
3406
|
}, []);
|
|
3426
|
-
const mapped$ =
|
|
3407
|
+
const mapped$ = xs$1.merge(...mapped);
|
|
3427
3408
|
return [ ...acc, mapped$ ]
|
|
3428
3409
|
}, []);
|
|
3429
3410
|
|
|
3430
|
-
this.response$ =
|
|
3411
|
+
this.response$ = xs$1.merge(...wrapped)
|
|
3431
3412
|
.compose(this.log(res => {
|
|
3432
3413
|
if (res._action) return `[${ this.requestSourceName }] response data received for Action: <${ res._action }>`
|
|
3433
3414
|
return `[${ this.requestSourceName }] response data received from FUNCTION`
|
|
@@ -3458,14 +3439,14 @@ class Component {
|
|
|
3458
3439
|
initModel$() {
|
|
3459
3440
|
if (typeof this.model == 'undefined') {
|
|
3460
3441
|
this.model$ = this.sourceNames.reduce((a,s) => {
|
|
3461
|
-
a[s] =
|
|
3442
|
+
a[s] = xs$1.never();
|
|
3462
3443
|
return a
|
|
3463
3444
|
}, {});
|
|
3464
3445
|
return
|
|
3465
3446
|
}
|
|
3466
3447
|
|
|
3467
3448
|
const initial = { type: INITIALIZE_ACTION, data: this.initialState };
|
|
3468
|
-
const shimmed$ = this.initialState ? _default$3(
|
|
3449
|
+
const shimmed$ = this.initialState ? _default$3(xs$1.of(initial), this.action$).compose(_default$4(0)) : this.action$;
|
|
3469
3450
|
const onState = this.makeOnAction(shimmed$, true, this.action$);
|
|
3470
3451
|
const onNormal = this.makeOnAction(this.action$, false, this.action$);
|
|
3471
3452
|
|
|
@@ -3514,7 +3495,7 @@ class Component {
|
|
|
3514
3495
|
|
|
3515
3496
|
const model$ = Object.entries(reducers).reduce((acc, entry) => {
|
|
3516
3497
|
const [sink, streams] = entry;
|
|
3517
|
-
acc[sink] =
|
|
3498
|
+
acc[sink] = xs$1.merge(xs$1.never(), ...streams);
|
|
3518
3499
|
return acc
|
|
3519
3500
|
}, {});
|
|
3520
3501
|
|
|
@@ -3533,7 +3514,7 @@ class Component {
|
|
|
3533
3514
|
next: this.log(({ _reqId, _action }) => `Unhandled response for request: ${ _action } ${ _reqId }`)
|
|
3534
3515
|
});
|
|
3535
3516
|
}
|
|
3536
|
-
this.sendResponse$ =
|
|
3517
|
+
this.sendResponse$ = xs$1.never();
|
|
3537
3518
|
return
|
|
3538
3519
|
}
|
|
3539
3520
|
|
|
@@ -3561,7 +3542,7 @@ class Component {
|
|
|
3561
3542
|
return [ ...acc, mapped$ ]
|
|
3562
3543
|
}, []);
|
|
3563
3544
|
|
|
3564
|
-
this.sendResponse$ =
|
|
3545
|
+
this.sendResponse$ = xs$1.merge(...out$)
|
|
3565
3546
|
.compose(this.log(({ _reqId, _action }) => `[${ this.requestSourceName }] response sent for: <${ _action }>`));
|
|
3566
3547
|
}
|
|
3567
3548
|
|
|
@@ -3589,7 +3570,7 @@ class Component {
|
|
|
3589
3570
|
}
|
|
3590
3571
|
|
|
3591
3572
|
initSubComponentSink$() {
|
|
3592
|
-
const subComponentSink$ =
|
|
3573
|
+
const subComponentSink$ = xs$1.create({
|
|
3593
3574
|
start: listener => {
|
|
3594
3575
|
this.newSubComponentSinks = listener.next.bind(listener);
|
|
3595
3576
|
},
|
|
@@ -3602,7 +3583,7 @@ class Component {
|
|
|
3602
3583
|
}
|
|
3603
3584
|
|
|
3604
3585
|
initSubComponentsRendered$() {
|
|
3605
|
-
const stream =
|
|
3586
|
+
const stream = xs$1.create({
|
|
3606
3587
|
start: (listener) => {
|
|
3607
3588
|
this.subComponentsRendered = listener.next.bind(listener);
|
|
3608
3589
|
},
|
|
@@ -3615,7 +3596,7 @@ class Component {
|
|
|
3615
3596
|
|
|
3616
3597
|
initVdom$() {
|
|
3617
3598
|
if (typeof this.view != 'function') {
|
|
3618
|
-
this.vdom$ =
|
|
3599
|
+
this.vdom$ = xs$1.of(null);
|
|
3619
3600
|
return
|
|
3620
3601
|
}
|
|
3621
3602
|
|
|
@@ -3633,17 +3614,17 @@ class Component {
|
|
|
3633
3614
|
initSinks() {
|
|
3634
3615
|
this.sinks = this.sourceNames.reduce((acc, name) => {
|
|
3635
3616
|
if (name == this.DOMSourceName) return acc
|
|
3636
|
-
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() :
|
|
3617
|
+
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() : xs$1.never();
|
|
3637
3618
|
if (name === this.stateSourceName) {
|
|
3638
|
-
acc[name] =
|
|
3619
|
+
acc[name] = xs$1.merge((this.model$[name] || xs$1.never()), subComponentSink$, this.sources[this.stateSourceName].stream.filter(_ => false), ...this.children$[name]);
|
|
3639
3620
|
} else {
|
|
3640
|
-
acc[name] =
|
|
3621
|
+
acc[name] = xs$1.merge((this.model$[name] || xs$1.never()), subComponentSink$, ...this.children$[name]);
|
|
3641
3622
|
}
|
|
3642
3623
|
return acc
|
|
3643
3624
|
}, {});
|
|
3644
3625
|
|
|
3645
3626
|
this.sinks[this.DOMSourceName] = this.vdom$;
|
|
3646
|
-
this.sinks[this.requestSourceName] =
|
|
3627
|
+
this.sinks[this.requestSourceName] = xs$1.merge(this.sendResponse$ ,this.sinks[this.requestSourceName]);
|
|
3647
3628
|
}
|
|
3648
3629
|
|
|
3649
3630
|
makeOnAction(action$, isStateSink=true, rootAction$) {
|
|
@@ -3737,7 +3718,7 @@ class Component {
|
|
|
3737
3718
|
const renderParams = { ...this.children$[this.DOMSourceName] };
|
|
3738
3719
|
|
|
3739
3720
|
const enhancedState = state && state.isolateSource(state, { get: state => this.addCalculated(state) });
|
|
3740
|
-
const stateStream = (enhancedState && enhancedState.stream) ||
|
|
3721
|
+
const stateStream = (enhancedState && enhancedState.stream) || xs$1.never();
|
|
3741
3722
|
|
|
3742
3723
|
renderParams.state = stateStream;
|
|
3743
3724
|
renderParams[this.stateSourceName] = stateStream;
|
|
@@ -3758,7 +3739,7 @@ class Component {
|
|
|
3758
3739
|
streams.push(stream);
|
|
3759
3740
|
});
|
|
3760
3741
|
|
|
3761
|
-
const combined =
|
|
3742
|
+
const combined = xs$1.combine(...streams)
|
|
3762
3743
|
// map the streams from an array back to an object with the render parameter names as the keys
|
|
3763
3744
|
.map(arr => {
|
|
3764
3745
|
return names.reduce((acc, name, index) => {
|
|
@@ -3800,8 +3781,8 @@ class Component {
|
|
|
3800
3781
|
return acc
|
|
3801
3782
|
}
|
|
3802
3783
|
|
|
3803
|
-
const props$ =
|
|
3804
|
-
const children$ =
|
|
3784
|
+
const props$ = xs$1.create().startWith(props);
|
|
3785
|
+
const children$ = xs$1.create().startWith(children);
|
|
3805
3786
|
|
|
3806
3787
|
let instantiator;
|
|
3807
3788
|
|
|
@@ -3815,7 +3796,7 @@ class Component {
|
|
|
3815
3796
|
|
|
3816
3797
|
const sink$ = instantiator(el, props$, children$);
|
|
3817
3798
|
|
|
3818
|
-
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) :
|
|
3799
|
+
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) : xs$1.never();
|
|
3819
3800
|
|
|
3820
3801
|
acc[id] = { sink$, props$, children$ };
|
|
3821
3802
|
|
|
@@ -3829,7 +3810,7 @@ class Component {
|
|
|
3829
3810
|
|
|
3830
3811
|
const mergedSinksByType = Object.entries(sinkArrsByType).reduce((acc, [name, streamArr]) => {
|
|
3831
3812
|
if (streamArr.length === 0) return acc
|
|
3832
|
-
acc[name] = streamArr.length === 1 ? streamArr[0] :
|
|
3813
|
+
acc[name] = streamArr.length === 1 ? streamArr[0] : xs$1.merge(...streamArr);
|
|
3833
3814
|
return acc
|
|
3834
3815
|
}, {});
|
|
3835
3816
|
|
|
@@ -3859,7 +3840,7 @@ class Component {
|
|
|
3859
3840
|
const props = data.props || {};
|
|
3860
3841
|
el.children || [];
|
|
3861
3842
|
|
|
3862
|
-
const combined$ =
|
|
3843
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3863
3844
|
.map(([state, __props, __children]) => {
|
|
3864
3845
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3865
3846
|
});
|
|
@@ -3903,7 +3884,6 @@ class Component {
|
|
|
3903
3884
|
return state
|
|
3904
3885
|
},
|
|
3905
3886
|
set: (oldState, newState) => {
|
|
3906
|
-
console.log('COLL SET', newState);
|
|
3907
3887
|
return newState
|
|
3908
3888
|
}
|
|
3909
3889
|
};
|
|
@@ -3931,7 +3911,17 @@ class Component {
|
|
|
3931
3911
|
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
3912
|
lense = undefined;
|
|
3933
3913
|
} else {
|
|
3934
|
-
lense = {
|
|
3914
|
+
lense = {
|
|
3915
|
+
get: (state) => {
|
|
3916
|
+
const newState = stateField.get(state);
|
|
3917
|
+
if (!Array.isArray(newState)) {
|
|
3918
|
+
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);
|
|
3919
|
+
return []
|
|
3920
|
+
}
|
|
3921
|
+
return newState
|
|
3922
|
+
},
|
|
3923
|
+
set: stateField.set
|
|
3924
|
+
};
|
|
3935
3925
|
}
|
|
3936
3926
|
} else {
|
|
3937
3927
|
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 +3941,7 @@ class Component {
|
|
|
3951
3941
|
const props = data.props || {};
|
|
3952
3942
|
el.children || [];
|
|
3953
3943
|
|
|
3954
|
-
const combined$ =
|
|
3944
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3955
3945
|
.map(([state, __props, __children]) => {
|
|
3956
3946
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3957
3947
|
});
|
|
@@ -3970,7 +3960,6 @@ class Component {
|
|
|
3970
3960
|
console.warn(`Switchable sub-component of ${ this.name } attempted to update state on a calculated field '${ stateField }': Update ignored`);
|
|
3971
3961
|
return oldState
|
|
3972
3962
|
}
|
|
3973
|
-
console.log('SWITCH SET', newState);
|
|
3974
3963
|
if (typeof newState !== 'object' || newState instanceof Array) return { ...oldState, [stateField]: newState }
|
|
3975
3964
|
const { __props, __children, ...sanitized } = newState;
|
|
3976
3965
|
return { ...oldState, [stateField]: sanitized }
|
|
@@ -4005,7 +3994,7 @@ class Component {
|
|
|
4005
3994
|
const switchableComponents = props.of;
|
|
4006
3995
|
const sources = { ...this.sources, [this.stateSourceName]: stateSource, props$, children$ };
|
|
4007
3996
|
|
|
4008
|
-
const sink$ =
|
|
3997
|
+
const sink$ = isolate(switchable(switchableComponents, props$.map(props => props.current)), { [this.stateSourceName]: lense })(sources);
|
|
4009
3998
|
|
|
4010
3999
|
if (typeof sink$ !== 'object') {
|
|
4011
4000
|
throw new Error('Invalid sinks returned from component factory of switchable element')
|
|
@@ -4020,7 +4009,7 @@ class Component {
|
|
|
4020
4009
|
const props = data.props || {};
|
|
4021
4010
|
el.children || [];
|
|
4022
4011
|
|
|
4023
|
-
const combined$ =
|
|
4012
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
4024
4013
|
.map(([state, __props, __children]) => {
|
|
4025
4014
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
4026
4015
|
});
|
|
@@ -4076,7 +4065,7 @@ class Component {
|
|
|
4076
4065
|
}
|
|
4077
4066
|
|
|
4078
4067
|
const sources = { ...this.sources, [this.stateSourceName]: stateSource, props$, children$ };
|
|
4079
|
-
const sink$ =
|
|
4068
|
+
const sink$ = isolate(factory, { [this.stateSourceName]: lense })(sources);
|
|
4080
4069
|
|
|
4081
4070
|
if (typeof sink$ !== 'object') {
|
|
4082
4071
|
const name = componentName === 'sygnal-factory' ? 'custom element' : componentName;
|
|
@@ -4087,7 +4076,7 @@ class Component {
|
|
|
4087
4076
|
}
|
|
4088
4077
|
|
|
4089
4078
|
renderVdom(componentInstances$) {
|
|
4090
|
-
return
|
|
4079
|
+
return xs$1.combine(this.subComponentsRendered$, componentInstances$)
|
|
4091
4080
|
.compose(_default$2(5))
|
|
4092
4081
|
.map(([_, components]) => {
|
|
4093
4082
|
const componentNames = Object.keys(this.components);
|
|
@@ -4096,7 +4085,7 @@ class Component {
|
|
|
4096
4085
|
const entries = Object.entries(components).filter(([id]) => id !== '::ROOT::');
|
|
4097
4086
|
|
|
4098
4087
|
if (entries.length === 0) {
|
|
4099
|
-
return
|
|
4088
|
+
return xs$1.of(root)
|
|
4100
4089
|
}
|
|
4101
4090
|
|
|
4102
4091
|
const ids = [];
|
|
@@ -4106,9 +4095,9 @@ class Component {
|
|
|
4106
4095
|
return val.sink$[this.DOMSourceName].startWith(undefined)
|
|
4107
4096
|
});
|
|
4108
4097
|
|
|
4109
|
-
if (vdom$.length === 0) return
|
|
4098
|
+
if (vdom$.length === 0) return xs$1.of(root)
|
|
4110
4099
|
|
|
4111
|
-
return
|
|
4100
|
+
return xs$1.combine(...vdom$)
|
|
4112
4101
|
.compose(_default$2(10))
|
|
4113
4102
|
.map(vdoms => {
|
|
4114
4103
|
const withIds = vdoms.reduce((acc, vdom, index) => {
|
|
@@ -4183,12 +4172,12 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4183
4172
|
if (!props.of) throw new Error(`Collection element missing required 'component' property`)
|
|
4184
4173
|
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
4174
|
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
|
|
4175
|
+
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
4176
|
currentElement.data.isCollection = true;
|
|
4188
4177
|
currentElement.data.props ||= {};
|
|
4189
4178
|
} else if (isSwitchable) {
|
|
4190
4179
|
if (!props.of) throw new Error(`Switchable element missing required 'of' property`)
|
|
4191
|
-
if (typeof props.of !== 'object') throw new Error(`Invalid '
|
|
4180
|
+
if (typeof props.of !== 'object') throw new Error(`Invalid 'of' property of switchable element: found ${ typeof props.of } requires object mapping names to component factories`)
|
|
4192
4181
|
const switchableComponents = Object.values(props.of);
|
|
4193
4182
|
if (!switchableComponents.every(comp => typeof comp === 'function')) throw new Error(`One or more components provided to switchable element is not a valid component factory`)
|
|
4194
4183
|
if (!props.current || (typeof props.current !== 'string' && typeof props.current !== 'function')) throw new Error(`Missing or invalid 'current' property for switchable element: found '${ typeof props.current }' requires string or function`)
|
|
@@ -4272,7 +4261,7 @@ function processForm(form, options={}) {
|
|
|
4272
4261
|
|
|
4273
4262
|
const eventStream$ = events.map(event => form.events(event));
|
|
4274
4263
|
|
|
4275
|
-
const merged$ =
|
|
4264
|
+
const merged$ = xs$1.merge(...eventStream$);
|
|
4276
4265
|
|
|
4277
4266
|
return merged$.map((e) => {
|
|
4278
4267
|
if (preventDefault) e.preventDefault();
|
|
@@ -4333,7 +4322,7 @@ function eventBusDriver(out$) {
|
|
|
4333
4322
|
const all = !type;
|
|
4334
4323
|
const _type = (Array.isArray(type)) ? type : [type];
|
|
4335
4324
|
let cb;
|
|
4336
|
-
const in$ =
|
|
4325
|
+
const in$ = xs$1.create({
|
|
4337
4326
|
start: (listener) => {
|
|
4338
4327
|
cb = ({detail: event}) => {
|
|
4339
4328
|
const data = (event && event.data) || null;
|
|
@@ -4738,10 +4727,7 @@ sampleCombine = function sampleCombine() {
|
|
|
4738
4727
|
};
|
|
4739
4728
|
var _default = sampleCombine$1.default = sampleCombine;
|
|
4740
4729
|
|
|
4741
|
-
|
|
4742
|
-
enumerable: true,
|
|
4743
|
-
get: function () { return xstream__default["default"]; }
|
|
4744
|
-
});
|
|
4730
|
+
exports.xs = xs$1;
|
|
4745
4731
|
exports.ABORT = ABORT;
|
|
4746
4732
|
exports.classes = classes;
|
|
4747
4733
|
exports.collection = collection;
|
|
@@ -4755,7 +4741,7 @@ exports.sampleCombine = _default;
|
|
|
4755
4741
|
exports.switchable = switchable;
|
|
4756
4742
|
exports.throttle = _default$1;
|
|
4757
4743
|
Object.keys(dom).forEach(function (k) {
|
|
4758
|
-
if (k !== 'default' && !
|
|
4744
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4759
4745
|
enumerable: true,
|
|
4760
4746
|
get: function () { return dom[k]; }
|
|
4761
4747
|
});
|