sygnal 2.6.1 → 2.6.2

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 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 xs$1 = require('xstream');
7
+ var xstream$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 xs__default = /*#__PURE__*/_interopDefaultLegacy(xs$1);
14
+ var xstream__default = /*#__PURE__*/_interopDefaultLegacy(xstream$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 xs$1.Stream)) {
2780
+ if (!(nameType === 'string' || nameType === 'function' || name$ instanceof xstream$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 xs$1.Stream) {
2784
+ if (name$ instanceof xstream$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 xs$1.Stream) throw new Error(`Could not find the state source: ${ stateSourceName }`)
2794
+ if (!state$ instanceof xstream$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 = xs__default["default"].combine(name$, state$)
2826
+ const switched = xstream__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]) || xs__default["default"].never()
2843
+ return (sink && sink[1][sinkName]) || xstream__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] = xs__default["default"].merge(...definedSinks);
2851
+ obj[sinkName] = xstream__default["default"].merge(...definedSinks);
2852
2852
  }
2853
2853
  return obj
2854
2854
  }, {});
@@ -3280,7 +3280,7 @@ class Component {
3280
3280
 
3281
3281
  if (IS_ROOT_COMPONENT && typeof this.intent === 'undefined' && typeof this.model === 'undefined') {
3282
3282
  this.initialState = initialState || true;
3283
- this.intent = _ => ({__NOOP_ACTION__:xs__default["default"].never()});
3283
+ this.intent = _ => ({__NOOP_ACTION__:xstream__default["default"].never()});
3284
3284
  this.model = {
3285
3285
  __NOOP_ACTION__: state => state
3286
3286
  };
@@ -3312,7 +3312,7 @@ class Component {
3312
3312
 
3313
3313
  this.intent$ = this.intent(this.sources);
3314
3314
 
3315
- if (!(this.intent$ instanceof xs$1.Stream) && (typeof this.intent$ != 'object')) {
3315
+ if (!(this.intent$ instanceof xstream$1.Stream) && (typeof this.intent$ != 'object')) {
3316
3316
  throw new Error('Intent must return either an action$ stream or map of event streams')
3317
3317
  }
3318
3318
  }
@@ -3321,21 +3321,21 @@ class Component {
3321
3321
  const requestSource = (this.sources && this.sources[this.requestSourceName]) || null;
3322
3322
 
3323
3323
  if (!this.intent$) {
3324
- this.action$ = xs__default["default"].never();
3324
+ this.action$ = xstream__default["default"].never();
3325
3325
  return
3326
3326
  }
3327
3327
 
3328
3328
  let runner;
3329
- if (this.intent$ instanceof xs$1.Stream) {
3329
+ if (this.intent$ instanceof xstream$1.Stream) {
3330
3330
  runner = this.intent$;
3331
3331
  } else {
3332
3332
  const mapped = Object.entries(this.intent$)
3333
3333
  .map(([type, data$]) => data$.map(data => ({type, data})));
3334
- runner = xs__default["default"].merge(xs__default["default"].never(), ...mapped);
3334
+ runner = xstream__default["default"].merge(xstream__default["default"].never(), ...mapped);
3335
3335
  }
3336
3336
 
3337
- const action$ = ((runner instanceof xs$1.Stream) ? runner : (runner.apply && runner(this.sources) || xs__default["default"].never()));
3338
- const wrapped$ = _default$3(xs__default["default"].of({ type: BOOTSTRAP_ACTION }), action$)
3337
+ const action$ = ((runner instanceof xstream$1.Stream) ? runner : (runner.apply && runner(this.sources) || xstream__default["default"].never()));
3338
+ const wrapped$ = _default$3(xstream__default["default"].of({ type: BOOTSTRAP_ACTION }), action$)
3339
3339
  .compose(_default$4(10));
3340
3340
 
3341
3341
  let initialApiData;
@@ -3343,12 +3343,12 @@ class Component {
3343
3343
  initialApiData = requestSource.select('initial')
3344
3344
  .flatten();
3345
3345
  } else {
3346
- initialApiData = xs__default["default"].never();
3346
+ initialApiData = xstream__default["default"].never();
3347
3347
  }
3348
3348
 
3349
3349
  const hydrate$ = initialApiData.map(data => ({ type: HYDRATE_ACTION, data }));
3350
3350
 
3351
- this.action$ = xs__default["default"].merge(wrapped$, hydrate$)
3351
+ this.action$ = xstream__default["default"].merge(wrapped$, hydrate$)
3352
3352
  .compose(this.log(({ type }) => `Action triggered: <${ type }>`));
3353
3353
  }
3354
3354
 
@@ -3405,7 +3405,7 @@ class Component {
3405
3405
  if (actionType === 'function') {
3406
3406
  const enhancedState = this.addCalculated(this.currentState);
3407
3407
  const result = action(enhancedState, req);
3408
- return xs__default["default"].of({ ...obj, data: result })
3408
+ return xstream__default["default"].of({ ...obj, data: result })
3409
3409
  } else {
3410
3410
  this.action$.shamefullySendNext(obj);
3411
3411
 
@@ -3415,7 +3415,7 @@ class Component {
3415
3415
  const selected$ = source[REQUEST_SELECTOR_METHOD](_reqId);
3416
3416
  return [ ...acc, selected$ ]
3417
3417
  }, []);
3418
- return xs__default["default"].merge(...responses)
3418
+ return xstream__default["default"].merge(...responses)
3419
3419
  }
3420
3420
  } catch(err) {
3421
3421
  console.error(err);
@@ -3423,11 +3423,11 @@ class Component {
3423
3423
  }).flatten();
3424
3424
  return [ ...acc, route$ ]
3425
3425
  }, []);
3426
- const mapped$ = xs__default["default"].merge(...mapped);
3426
+ const mapped$ = xstream__default["default"].merge(...mapped);
3427
3427
  return [ ...acc, mapped$ ]
3428
3428
  }, []);
3429
3429
 
3430
- this.response$ = xs__default["default"].merge(...wrapped)
3430
+ this.response$ = xstream__default["default"].merge(...wrapped)
3431
3431
  .compose(this.log(res => {
3432
3432
  if (res._action) return `[${ this.requestSourceName }] response data received for Action: <${ res._action }>`
3433
3433
  return `[${ this.requestSourceName }] response data received from FUNCTION`
@@ -3458,14 +3458,14 @@ class Component {
3458
3458
  initModel$() {
3459
3459
  if (typeof this.model == 'undefined') {
3460
3460
  this.model$ = this.sourceNames.reduce((a,s) => {
3461
- a[s] = xs__default["default"].never();
3461
+ a[s] = xstream__default["default"].never();
3462
3462
  return a
3463
3463
  }, {});
3464
3464
  return
3465
3465
  }
3466
3466
 
3467
3467
  const initial = { type: INITIALIZE_ACTION, data: this.initialState };
3468
- const shimmed$ = this.initialState ? _default$3(xs__default["default"].of(initial), this.action$).compose(_default$4(0)) : this.action$;
3468
+ const shimmed$ = this.initialState ? _default$3(xstream__default["default"].of(initial), this.action$).compose(_default$4(0)) : this.action$;
3469
3469
  const onState = this.makeOnAction(shimmed$, true, this.action$);
3470
3470
  const onNormal = this.makeOnAction(this.action$, false, this.action$);
3471
3471
 
@@ -3514,7 +3514,7 @@ class Component {
3514
3514
 
3515
3515
  const model$ = Object.entries(reducers).reduce((acc, entry) => {
3516
3516
  const [sink, streams] = entry;
3517
- acc[sink] = xs__default["default"].merge(xs__default["default"].never(), ...streams);
3517
+ acc[sink] = xstream__default["default"].merge(xstream__default["default"].never(), ...streams);
3518
3518
  return acc
3519
3519
  }, {});
3520
3520
 
@@ -3533,7 +3533,7 @@ class Component {
3533
3533
  next: this.log(({ _reqId, _action }) => `Unhandled response for request: ${ _action } ${ _reqId }`)
3534
3534
  });
3535
3535
  }
3536
- this.sendResponse$ = xs__default["default"].never();
3536
+ this.sendResponse$ = xstream__default["default"].never();
3537
3537
  return
3538
3538
  }
3539
3539
 
@@ -3561,7 +3561,7 @@ class Component {
3561
3561
  return [ ...acc, mapped$ ]
3562
3562
  }, []);
3563
3563
 
3564
- this.sendResponse$ = xs__default["default"].merge(...out$)
3564
+ this.sendResponse$ = xstream__default["default"].merge(...out$)
3565
3565
  .compose(this.log(({ _reqId, _action }) => `[${ this.requestSourceName }] response sent for: <${ _action }>`));
3566
3566
  }
3567
3567
 
@@ -3589,7 +3589,7 @@ class Component {
3589
3589
  }
3590
3590
 
3591
3591
  initSubComponentSink$() {
3592
- const subComponentSink$ = xs__default["default"].create({
3592
+ const subComponentSink$ = xstream__default["default"].create({
3593
3593
  start: listener => {
3594
3594
  this.newSubComponentSinks = listener.next.bind(listener);
3595
3595
  },
@@ -3602,7 +3602,7 @@ class Component {
3602
3602
  }
3603
3603
 
3604
3604
  initSubComponentsRendered$() {
3605
- const stream = xs__default["default"].create({
3605
+ const stream = xstream__default["default"].create({
3606
3606
  start: (listener) => {
3607
3607
  this.subComponentsRendered = listener.next.bind(listener);
3608
3608
  },
@@ -3615,7 +3615,7 @@ class Component {
3615
3615
 
3616
3616
  initVdom$() {
3617
3617
  if (typeof this.view != 'function') {
3618
- this.vdom$ = xs__default["default"].of(null);
3618
+ this.vdom$ = xstream__default["default"].of(null);
3619
3619
  return
3620
3620
  }
3621
3621
 
@@ -3633,17 +3633,17 @@ class Component {
3633
3633
  initSinks() {
3634
3634
  this.sinks = this.sourceNames.reduce((acc, name) => {
3635
3635
  if (name == this.DOMSourceName) return acc
3636
- const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() : xs__default["default"].never();
3636
+ const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() : xstream__default["default"].never();
3637
3637
  if (name === this.stateSourceName) {
3638
- acc[name] = xs__default["default"].merge((this.model$[name] || xs__default["default"].never()), subComponentSink$, this.sources[this.stateSourceName].stream.filter(_ => false), ...this.children$[name]);
3638
+ acc[name] = xstream__default["default"].merge((this.model$[name] || xstream__default["default"].never()), subComponentSink$, this.sources[this.stateSourceName].stream.filter(_ => false), ...this.children$[name]);
3639
3639
  } else {
3640
- acc[name] = xs__default["default"].merge((this.model$[name] || xs__default["default"].never()), subComponentSink$, ...this.children$[name]);
3640
+ acc[name] = xstream__default["default"].merge((this.model$[name] || xstream__default["default"].never()), subComponentSink$, ...this.children$[name]);
3641
3641
  }
3642
3642
  return acc
3643
3643
  }, {});
3644
3644
 
3645
3645
  this.sinks[this.DOMSourceName] = this.vdom$;
3646
- this.sinks[this.requestSourceName] = xs__default["default"].merge(this.sendResponse$ ,this.sinks[this.requestSourceName]);
3646
+ this.sinks[this.requestSourceName] = xstream__default["default"].merge(this.sendResponse$ ,this.sinks[this.requestSourceName]);
3647
3647
  }
3648
3648
 
3649
3649
  makeOnAction(action$, isStateSink=true, rootAction$) {
@@ -3737,7 +3737,7 @@ class Component {
3737
3737
  const renderParams = { ...this.children$[this.DOMSourceName] };
3738
3738
 
3739
3739
  const enhancedState = state && state.isolateSource(state, { get: state => this.addCalculated(state) });
3740
- const stateStream = (enhancedState && enhancedState.stream) || xs__default["default"].never();
3740
+ const stateStream = (enhancedState && enhancedState.stream) || xstream__default["default"].never();
3741
3741
 
3742
3742
  renderParams.state = stateStream;
3743
3743
  renderParams[this.stateSourceName] = stateStream;
@@ -3758,7 +3758,7 @@ class Component {
3758
3758
  streams.push(stream);
3759
3759
  });
3760
3760
 
3761
- const combined = xs__default["default"].combine(...streams)
3761
+ const combined = xstream__default["default"].combine(...streams)
3762
3762
  // map the streams from an array back to an object with the render parameter names as the keys
3763
3763
  .map(arr => {
3764
3764
  return names.reduce((acc, name, index) => {
@@ -3800,8 +3800,8 @@ class Component {
3800
3800
  return acc
3801
3801
  }
3802
3802
 
3803
- const props$ = xs__default["default"].create().startWith(props);
3804
- const children$ = xs__default["default"].create().startWith(children);
3803
+ const props$ = xstream__default["default"].create().startWith(props);
3804
+ const children$ = xstream__default["default"].create().startWith(children);
3805
3805
 
3806
3806
  let instantiator;
3807
3807
 
@@ -3815,7 +3815,7 @@ class Component {
3815
3815
 
3816
3816
  const sink$ = instantiator(el, props$, children$);
3817
3817
 
3818
- sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) : xs__default["default"].never();
3818
+ sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) : xstream__default["default"].never();
3819
3819
 
3820
3820
  acc[id] = { sink$, props$, children$ };
3821
3821
 
@@ -3829,7 +3829,7 @@ class Component {
3829
3829
 
3830
3830
  const mergedSinksByType = Object.entries(sinkArrsByType).reduce((acc, [name, streamArr]) => {
3831
3831
  if (streamArr.length === 0) return acc
3832
- acc[name] = streamArr.length === 1 ? streamArr[0] : xs__default["default"].merge(...streamArr);
3832
+ acc[name] = streamArr.length === 1 ? streamArr[0] : xstream__default["default"].merge(...streamArr);
3833
3833
  return acc
3834
3834
  }, {});
3835
3835
 
@@ -3859,7 +3859,7 @@ class Component {
3859
3859
  const props = data.props || {};
3860
3860
  el.children || [];
3861
3861
 
3862
- const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
3862
+ const combined$ = xstream__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
3863
3863
  .map(([state, __props, __children]) => {
3864
3864
  return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
3865
3865
  });
@@ -3909,7 +3909,7 @@ class Component {
3909
3909
  };
3910
3910
  } else if (typeof stateField === 'string') {
3911
3911
  if (typeof this.currentState === 'object') {
3912
- if(!(stateField in this.currentState)) {
3912
+ if(!(stateField in this.currentState) && !(stateField in this.calculated)) {
3913
3913
  console.error(`Collection component in ${ this.name } is attempting to use non-existent state property '${ stateField }': To fix this error, specify a valid array property on the state. Attempting to use parent component state.`);
3914
3914
  lense = undefined;
3915
3915
  } else if (!Array.isArray(this.currentState[stateField])) {
@@ -3920,7 +3920,7 @@ class Component {
3920
3920
  }
3921
3921
  } else {
3922
3922
  if (!Array.isArray(this.currentState[stateField])) {
3923
- console.warn(`State property '${ stateField }' in collection comopnent of ${ this.name } is not an array: No components will be instantiated in the collection.`);
3923
+ console.warn(`State property '${ stateField }' in collection component of ${ this.name } is not an array: No components will be instantiated in the collection.`);
3924
3924
  lense = fieldLense;
3925
3925
  } else {
3926
3926
  lense = fieldLense;
@@ -3951,7 +3951,7 @@ class Component {
3951
3951
  const props = data.props || {};
3952
3952
  el.children || [];
3953
3953
 
3954
- const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
3954
+ const combined$ = xstream__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
3955
3955
  .map(([state, __props, __children]) => {
3956
3956
  return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
3957
3957
  });
@@ -4020,7 +4020,7 @@ class Component {
4020
4020
  const props = data.props || {};
4021
4021
  el.children || [];
4022
4022
 
4023
- const combined$ = xs__default["default"].combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
4023
+ const combined$ = xstream__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 xs__default["default"].combine(this.subComponentsRendered$, componentInstances$)
4090
+ return xstream__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 xs__default["default"].of(root)
4099
+ return xstream__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 xs__default["default"].of(root)
4109
+ if (vdom$.length === 0) return xstream__default["default"].of(root)
4110
4110
 
4111
- return xs__default["default"].combine(...vdom$)
4111
+ return xstream__default["default"].combine(...vdom$)
4112
4112
  .compose(_default$2(10))
4113
4113
  .map(vdoms => {
4114
4114
  const withIds = vdoms.reduce((acc, vdom, index) => {
@@ -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$ = xs__default["default"].merge(...eventStream$);
4275
+ const merged$ = xstream__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$ = xs__default["default"].create({
4336
+ const in$ = xstream__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 xs__default["default"]; }
4743
+ get: function () { return xstream__default["default"]; }
4744
4744
  });
4745
4745
  exports.ABORT = ABORT;
4746
4746
  exports.classes = classes;