sygnal 2.6.3 → 2.6.5
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 +74 -72
- package/dist/index.esm.js +28 -16
- package/dist/jsx.cjs.js +3 -16
- package/dist/jsx.esm.js +1 -8
- 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
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 xs__default = /*#__PURE__*/_interopDefaultLegacy(xs$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 = {};
|
|
@@ -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
|
}, {});
|
|
@@ -3162,6 +3151,7 @@ const HYDRATE_ACTION = 'HYDRATE';
|
|
|
3162
3151
|
|
|
3163
3152
|
|
|
3164
3153
|
let IS_ROOT_COMPONENT = true;
|
|
3154
|
+
let COMPONENT_COUNT = 0;
|
|
3165
3155
|
|
|
3166
3156
|
|
|
3167
3157
|
const ABORT = '~#~#~ABORT~#~#~';
|
|
@@ -3185,16 +3175,19 @@ function component (opts) {
|
|
|
3185
3175
|
}
|
|
3186
3176
|
|
|
3187
3177
|
const currySources = typeof sources === 'undefined';
|
|
3178
|
+
let returnFunction;
|
|
3188
3179
|
|
|
3189
3180
|
if (typeof fixedIsolateOpts == 'object') {
|
|
3190
3181
|
const wrapped = (sources) => {
|
|
3191
3182
|
const fixedOpts = { ...opts, sources };
|
|
3192
3183
|
return (new Component(fixedOpts)).sinks
|
|
3193
3184
|
};
|
|
3194
|
-
|
|
3185
|
+
returnFunction = currySources ? isolate(wrapped, fixedIsolateOpts) : isolate(wrapped, fixedIsolateOpts)(sources);
|
|
3195
3186
|
} else {
|
|
3196
|
-
|
|
3187
|
+
returnFunction = currySources ? (sources) => (new Component({ ...opts, sources })).sinks : (new Component(opts)).sinks;
|
|
3197
3188
|
}
|
|
3189
|
+
|
|
3190
|
+
return returnFunction
|
|
3198
3191
|
}
|
|
3199
3192
|
|
|
3200
3193
|
|
|
@@ -3272,7 +3265,7 @@ class Component {
|
|
|
3272
3265
|
// refactor to avoid using a global variable
|
|
3273
3266
|
if (IS_ROOT_COMPONENT && typeof this.intent === 'undefined' && typeof this.model === 'undefined') {
|
|
3274
3267
|
this.initialState = initialState || true;
|
|
3275
|
-
this.intent = _ => ({__NOOP_ACTION__:
|
|
3268
|
+
this.intent = _ => ({__NOOP_ACTION__:xs$1.never()});
|
|
3276
3269
|
this.model = {
|
|
3277
3270
|
__NOOP_ACTION__: state => state
|
|
3278
3271
|
};
|
|
@@ -3292,6 +3285,12 @@ class Component {
|
|
|
3292
3285
|
this.initSubComponentsRendered$();
|
|
3293
3286
|
this.initVdom$();
|
|
3294
3287
|
this.initSinks();
|
|
3288
|
+
|
|
3289
|
+
this.sinks.__index = COMPONENT_COUNT++;
|
|
3290
|
+
|
|
3291
|
+
if (ENVIRONMENT.DEBUG === true) {
|
|
3292
|
+
console.log(`[${ this.name }] Instantiated (#${ this.sinks.__index })`);
|
|
3293
|
+
}
|
|
3295
3294
|
}
|
|
3296
3295
|
|
|
3297
3296
|
initIntent$() {
|
|
@@ -3313,7 +3312,7 @@ class Component {
|
|
|
3313
3312
|
const requestSource = (this.sources && this.sources[this.requestSourceName]) || null;
|
|
3314
3313
|
|
|
3315
3314
|
if (!this.intent$) {
|
|
3316
|
-
this.action$ =
|
|
3315
|
+
this.action$ = xs$1.never();
|
|
3317
3316
|
return
|
|
3318
3317
|
}
|
|
3319
3318
|
|
|
@@ -3323,11 +3322,11 @@ class Component {
|
|
|
3323
3322
|
} else {
|
|
3324
3323
|
const mapped = Object.entries(this.intent$)
|
|
3325
3324
|
.map(([type, data$]) => data$.map(data => ({type, data})));
|
|
3326
|
-
runner =
|
|
3325
|
+
runner = xs$1.merge(xs$1.never(), ...mapped);
|
|
3327
3326
|
}
|
|
3328
3327
|
|
|
3329
|
-
const action$ = ((runner instanceof xs$1.Stream) ? runner : (runner.apply && runner(this.sources) ||
|
|
3330
|
-
const wrapped$ = _default$3(
|
|
3328
|
+
const action$ = ((runner instanceof xs$1.Stream) ? runner : (runner.apply && runner(this.sources) || xs$1.never()));
|
|
3329
|
+
const wrapped$ = _default$3(xs$1.of({ type: BOOTSTRAP_ACTION }), action$)
|
|
3331
3330
|
.compose(_default$4(10));
|
|
3332
3331
|
|
|
3333
3332
|
let initialApiData;
|
|
@@ -3335,12 +3334,12 @@ class Component {
|
|
|
3335
3334
|
initialApiData = requestSource.select('initial')
|
|
3336
3335
|
.flatten();
|
|
3337
3336
|
} else {
|
|
3338
|
-
initialApiData =
|
|
3337
|
+
initialApiData = xs$1.never();
|
|
3339
3338
|
}
|
|
3340
3339
|
|
|
3341
3340
|
const hydrate$ = initialApiData.map(data => ({ type: HYDRATE_ACTION, data }));
|
|
3342
3341
|
|
|
3343
|
-
this.action$ =
|
|
3342
|
+
this.action$ = xs$1.merge(wrapped$, hydrate$)
|
|
3344
3343
|
.compose(this.log(({ type }) => `Action triggered: <${ type }>`));
|
|
3345
3344
|
}
|
|
3346
3345
|
|
|
@@ -3397,7 +3396,7 @@ class Component {
|
|
|
3397
3396
|
if (actionType === 'function') {
|
|
3398
3397
|
const enhancedState = this.addCalculated(this.currentState);
|
|
3399
3398
|
const result = action(enhancedState, req);
|
|
3400
|
-
return
|
|
3399
|
+
return xs$1.of({ ...obj, data: result })
|
|
3401
3400
|
} else {
|
|
3402
3401
|
this.action$.shamefullySendNext(obj);
|
|
3403
3402
|
|
|
@@ -3407,7 +3406,7 @@ class Component {
|
|
|
3407
3406
|
const selected$ = source[REQUEST_SELECTOR_METHOD](_reqId);
|
|
3408
3407
|
return [ ...acc, selected$ ]
|
|
3409
3408
|
}, []);
|
|
3410
|
-
return
|
|
3409
|
+
return xs$1.merge(...responses)
|
|
3411
3410
|
}
|
|
3412
3411
|
} catch(err) {
|
|
3413
3412
|
console.error(err);
|
|
@@ -3415,11 +3414,11 @@ class Component {
|
|
|
3415
3414
|
}).flatten();
|
|
3416
3415
|
return [ ...acc, route$ ]
|
|
3417
3416
|
}, []);
|
|
3418
|
-
const mapped$ =
|
|
3417
|
+
const mapped$ = xs$1.merge(...mapped);
|
|
3419
3418
|
return [ ...acc, mapped$ ]
|
|
3420
3419
|
}, []);
|
|
3421
3420
|
|
|
3422
|
-
this.response$ =
|
|
3421
|
+
this.response$ = xs$1.merge(...wrapped)
|
|
3423
3422
|
.compose(this.log(res => {
|
|
3424
3423
|
if (res._action) return `[${ this.requestSourceName }] response data received for Action: <${ res._action }>`
|
|
3425
3424
|
return `[${ this.requestSourceName }] response data received from FUNCTION`
|
|
@@ -3450,14 +3449,14 @@ class Component {
|
|
|
3450
3449
|
initModel$() {
|
|
3451
3450
|
if (typeof this.model == 'undefined') {
|
|
3452
3451
|
this.model$ = this.sourceNames.reduce((a,s) => {
|
|
3453
|
-
a[s] =
|
|
3452
|
+
a[s] = xs$1.never();
|
|
3454
3453
|
return a
|
|
3455
3454
|
}, {});
|
|
3456
3455
|
return
|
|
3457
3456
|
}
|
|
3458
3457
|
|
|
3459
3458
|
const initial = { type: INITIALIZE_ACTION, data: this.initialState };
|
|
3460
|
-
const shimmed$ = this.initialState ? _default$3(
|
|
3459
|
+
const shimmed$ = this.initialState ? _default$3(xs$1.of(initial), this.action$).compose(_default$4(0)) : this.action$;
|
|
3461
3460
|
const onState = this.makeOnAction(shimmed$, true, this.action$);
|
|
3462
3461
|
const onNormal = this.makeOnAction(this.action$, false, this.action$);
|
|
3463
3462
|
|
|
@@ -3506,7 +3505,7 @@ class Component {
|
|
|
3506
3505
|
|
|
3507
3506
|
const model$ = Object.entries(reducers).reduce((acc, entry) => {
|
|
3508
3507
|
const [sink, streams] = entry;
|
|
3509
|
-
acc[sink] =
|
|
3508
|
+
acc[sink] = xs$1.merge(xs$1.never(), ...streams);
|
|
3510
3509
|
return acc
|
|
3511
3510
|
}, {});
|
|
3512
3511
|
|
|
@@ -3525,7 +3524,7 @@ class Component {
|
|
|
3525
3524
|
next: this.log(({ _reqId, _action }) => `Unhandled response for request: ${ _action } ${ _reqId }`)
|
|
3526
3525
|
});
|
|
3527
3526
|
}
|
|
3528
|
-
this.sendResponse$ =
|
|
3527
|
+
this.sendResponse$ = xs$1.never();
|
|
3529
3528
|
return
|
|
3530
3529
|
}
|
|
3531
3530
|
|
|
@@ -3553,7 +3552,7 @@ class Component {
|
|
|
3553
3552
|
return [ ...acc, mapped$ ]
|
|
3554
3553
|
}, []);
|
|
3555
3554
|
|
|
3556
|
-
this.sendResponse$ =
|
|
3555
|
+
this.sendResponse$ = xs$1.merge(...out$)
|
|
3557
3556
|
.compose(this.log(({ _reqId, _action }) => `[${ this.requestSourceName }] response sent for: <${ _action }>`));
|
|
3558
3557
|
}
|
|
3559
3558
|
|
|
@@ -3581,7 +3580,7 @@ class Component {
|
|
|
3581
3580
|
}
|
|
3582
3581
|
|
|
3583
3582
|
initSubComponentSink$() {
|
|
3584
|
-
const subComponentSink$ =
|
|
3583
|
+
const subComponentSink$ = xs$1.create({
|
|
3585
3584
|
start: listener => {
|
|
3586
3585
|
this.newSubComponentSinks = listener.next.bind(listener);
|
|
3587
3586
|
},
|
|
@@ -3594,7 +3593,7 @@ class Component {
|
|
|
3594
3593
|
}
|
|
3595
3594
|
|
|
3596
3595
|
initSubComponentsRendered$() {
|
|
3597
|
-
const stream =
|
|
3596
|
+
const stream = xs$1.create({
|
|
3598
3597
|
start: (listener) => {
|
|
3599
3598
|
this.subComponentsRendered = listener.next.bind(listener);
|
|
3600
3599
|
},
|
|
@@ -3607,7 +3606,7 @@ class Component {
|
|
|
3607
3606
|
|
|
3608
3607
|
initVdom$() {
|
|
3609
3608
|
if (typeof this.view != 'function') {
|
|
3610
|
-
this.vdom$ =
|
|
3609
|
+
this.vdom$ = xs$1.of(null);
|
|
3611
3610
|
return
|
|
3612
3611
|
}
|
|
3613
3612
|
|
|
@@ -3625,17 +3624,17 @@ class Component {
|
|
|
3625
3624
|
initSinks() {
|
|
3626
3625
|
this.sinks = this.sourceNames.reduce((acc, name) => {
|
|
3627
3626
|
if (name == this.DOMSourceName) return acc
|
|
3628
|
-
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() :
|
|
3627
|
+
const subComponentSink$ = this.subComponentSink$ ? this.subComponentSink$.map(sinks => sinks[name]).filter(sink => !!sink).flatten() : xs$1.never();
|
|
3629
3628
|
if (name === this.stateSourceName) {
|
|
3630
|
-
acc[name] =
|
|
3629
|
+
acc[name] = xs$1.merge((this.model$[name] || xs$1.never()), subComponentSink$, this.sources[this.stateSourceName].stream.filter(_ => false), ...this.children$[name]);
|
|
3631
3630
|
} else {
|
|
3632
|
-
acc[name] =
|
|
3631
|
+
acc[name] = xs$1.merge((this.model$[name] || xs$1.never()), subComponentSink$, ...this.children$[name]);
|
|
3633
3632
|
}
|
|
3634
3633
|
return acc
|
|
3635
3634
|
}, {});
|
|
3636
3635
|
|
|
3637
3636
|
this.sinks[this.DOMSourceName] = this.vdom$;
|
|
3638
|
-
this.sinks[this.requestSourceName] =
|
|
3637
|
+
this.sinks[this.requestSourceName] = xs$1.merge(this.sendResponse$ ,this.sinks[this.requestSourceName]);
|
|
3639
3638
|
}
|
|
3640
3639
|
|
|
3641
3640
|
makeOnAction(action$, isStateSink=true, rootAction$) {
|
|
@@ -3729,7 +3728,7 @@ class Component {
|
|
|
3729
3728
|
const renderParams = { ...this.children$[this.DOMSourceName] };
|
|
3730
3729
|
|
|
3731
3730
|
const enhancedState = state && state.isolateSource(state, { get: state => this.addCalculated(state) });
|
|
3732
|
-
const stateStream = (enhancedState && enhancedState.stream) ||
|
|
3731
|
+
const stateStream = (enhancedState && enhancedState.stream) || xs$1.never();
|
|
3733
3732
|
|
|
3734
3733
|
renderParams.state = stateStream;
|
|
3735
3734
|
renderParams[this.stateSourceName] = stateStream;
|
|
@@ -3750,7 +3749,7 @@ class Component {
|
|
|
3750
3749
|
streams.push(stream);
|
|
3751
3750
|
});
|
|
3752
3751
|
|
|
3753
|
-
const combined =
|
|
3752
|
+
const combined = xs$1.combine(...streams)
|
|
3754
3753
|
// map the streams from an array back to an object with the render parameter names as the keys
|
|
3755
3754
|
.map(arr => {
|
|
3756
3755
|
return names.reduce((acc, name, index) => {
|
|
@@ -3768,6 +3767,8 @@ class Component {
|
|
|
3768
3767
|
const foundComponents = getComponents(vDom, componentNames);
|
|
3769
3768
|
const entries = Object.entries(foundComponents);
|
|
3770
3769
|
|
|
3770
|
+
if (this.name === 'APP') console.log(`[${ this.name }] FOUND`, foundComponents);
|
|
3771
|
+
|
|
3771
3772
|
const rootEntry = { '::ROOT::': vDom };
|
|
3772
3773
|
|
|
3773
3774
|
if (entries.length === 0) {
|
|
@@ -3792,8 +3793,8 @@ class Component {
|
|
|
3792
3793
|
return acc
|
|
3793
3794
|
}
|
|
3794
3795
|
|
|
3795
|
-
const props$ =
|
|
3796
|
-
const children$ =
|
|
3796
|
+
const props$ = xs$1.create().startWith(props);
|
|
3797
|
+
const children$ = xs$1.create().startWith(children);
|
|
3797
3798
|
|
|
3798
3799
|
let instantiator;
|
|
3799
3800
|
|
|
@@ -3807,7 +3808,7 @@ class Component {
|
|
|
3807
3808
|
|
|
3808
3809
|
const sink$ = instantiator(el, props$, children$);
|
|
3809
3810
|
|
|
3810
|
-
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) :
|
|
3811
|
+
sink$[this.DOMSourceName] = sink$[this.DOMSourceName] ? this.makeCoordinatedSubComponentDomSink(sink$[this.DOMSourceName]) : xs$1.never();
|
|
3811
3812
|
|
|
3812
3813
|
acc[id] = { sink$, props$, children$ };
|
|
3813
3814
|
|
|
@@ -3821,7 +3822,7 @@ class Component {
|
|
|
3821
3822
|
|
|
3822
3823
|
const mergedSinksByType = Object.entries(sinkArrsByType).reduce((acc, [name, streamArr]) => {
|
|
3823
3824
|
if (streamArr.length === 0) return acc
|
|
3824
|
-
acc[name] = streamArr.length === 1 ? streamArr[0] :
|
|
3825
|
+
acc[name] = streamArr.length === 1 ? streamArr[0] : xs$1.merge(...streamArr);
|
|
3825
3826
|
return acc
|
|
3826
3827
|
}, {});
|
|
3827
3828
|
|
|
@@ -3851,7 +3852,7 @@ class Component {
|
|
|
3851
3852
|
const props = data.props || {};
|
|
3852
3853
|
el.children || [];
|
|
3853
3854
|
|
|
3854
|
-
const combined$ =
|
|
3855
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3855
3856
|
.map(([state, __props, __children]) => {
|
|
3856
3857
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3857
3858
|
});
|
|
@@ -3952,7 +3953,7 @@ class Component {
|
|
|
3952
3953
|
const props = data.props || {};
|
|
3953
3954
|
el.children || [];
|
|
3954
3955
|
|
|
3955
|
-
const combined$ =
|
|
3956
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
3956
3957
|
.map(([state, __props, __children]) => {
|
|
3957
3958
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
3958
3959
|
});
|
|
@@ -4005,7 +4006,7 @@ class Component {
|
|
|
4005
4006
|
const switchableComponents = props.of;
|
|
4006
4007
|
const sources = { ...this.sources, [this.stateSourceName]: stateSource, props$, children$ };
|
|
4007
4008
|
|
|
4008
|
-
const sink$ =
|
|
4009
|
+
const sink$ = isolate(switchable(switchableComponents, props$.map(props => props.current)), { [this.stateSourceName]: lense })(sources);
|
|
4009
4010
|
|
|
4010
4011
|
if (typeof sink$ !== 'object') {
|
|
4011
4012
|
throw new Error('Invalid sinks returned from component factory of switchable element')
|
|
@@ -4020,7 +4021,7 @@ class Component {
|
|
|
4020
4021
|
const props = data.props || {};
|
|
4021
4022
|
el.children || [];
|
|
4022
4023
|
|
|
4023
|
-
const combined$ =
|
|
4024
|
+
const combined$ = xs$1.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState), props$, children$)
|
|
4024
4025
|
.map(([state, __props, __children]) => {
|
|
4025
4026
|
return typeof state === 'object' ? { ...this.addCalculated(state), __props, __children } : { value: state, __props, __children }
|
|
4026
4027
|
});
|
|
@@ -4076,7 +4077,7 @@ class Component {
|
|
|
4076
4077
|
}
|
|
4077
4078
|
|
|
4078
4079
|
const sources = { ...this.sources, [this.stateSourceName]: stateSource, props$, children$ };
|
|
4079
|
-
const sink$ =
|
|
4080
|
+
const sink$ = isolate(factory, { [this.stateSourceName]: lense })(sources);
|
|
4080
4081
|
|
|
4081
4082
|
if (typeof sink$ !== 'object') {
|
|
4082
4083
|
const name = componentName === 'sygnal-factory' ? 'custom element' : componentName;
|
|
@@ -4087,7 +4088,7 @@ class Component {
|
|
|
4087
4088
|
}
|
|
4088
4089
|
|
|
4089
4090
|
renderVdom(componentInstances$) {
|
|
4090
|
-
return
|
|
4091
|
+
return xs$1.combine(this.subComponentsRendered$, componentInstances$)
|
|
4091
4092
|
.compose(_default$2(5))
|
|
4092
4093
|
.map(([_, components]) => {
|
|
4093
4094
|
const componentNames = Object.keys(this.components);
|
|
@@ -4096,7 +4097,7 @@ class Component {
|
|
|
4096
4097
|
const entries = Object.entries(components).filter(([id]) => id !== '::ROOT::');
|
|
4097
4098
|
|
|
4098
4099
|
if (entries.length === 0) {
|
|
4099
|
-
return
|
|
4100
|
+
return xs$1.of(root)
|
|
4100
4101
|
}
|
|
4101
4102
|
|
|
4102
4103
|
const ids = [];
|
|
@@ -4106,9 +4107,9 @@ class Component {
|
|
|
4106
4107
|
return val.sink$[this.DOMSourceName].startWith(undefined)
|
|
4107
4108
|
});
|
|
4108
4109
|
|
|
4109
|
-
if (vdom$.length === 0) return
|
|
4110
|
+
if (vdom$.length === 0) return xs$1.of(root)
|
|
4110
4111
|
|
|
4111
|
-
return
|
|
4112
|
+
return xs$1.combine(...vdom$)
|
|
4112
4113
|
.compose(_default$2(10))
|
|
4113
4114
|
.map(vdoms => {
|
|
4114
4115
|
const withIds = vdoms.reduce((acc, vdom, index) => {
|
|
@@ -4179,6 +4180,7 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4179
4180
|
|
|
4180
4181
|
if (isComponent) {
|
|
4181
4182
|
const id = getComponentIdFromElement(currentElement, depth, index);
|
|
4183
|
+
if (found[id]) console.log('DUPLICATE', id);
|
|
4182
4184
|
if (isCollection) {
|
|
4183
4185
|
if (!props.of) throw new Error(`Collection element missing required 'component' property`)
|
|
4184
4186
|
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`)
|
|
@@ -4188,7 +4190,7 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4188
4190
|
currentElement.data.props ||= {};
|
|
4189
4191
|
} else if (isSwitchable) {
|
|
4190
4192
|
if (!props.of) throw new Error(`Switchable element missing required 'of' property`)
|
|
4191
|
-
if (typeof props.of !== 'object') throw new Error(`Invalid '
|
|
4193
|
+
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
4194
|
const switchableComponents = Object.values(props.of);
|
|
4193
4195
|
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
4196
|
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`)
|
|
@@ -4200,16 +4202,19 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4200
4202
|
}
|
|
4201
4203
|
|
|
4202
4204
|
if (children.length > 0) {
|
|
4203
|
-
children.map((child, i) => getComponents(child, componentNames, depth + 1, i))
|
|
4204
|
-
.forEach((child) => {
|
|
4205
|
-
Object.entries(child).forEach(([id, el]) =>
|
|
4205
|
+
children.map((child, i) => getComponents(child, componentNames, depth + 1, index + i))
|
|
4206
|
+
.forEach((child, i) => {
|
|
4207
|
+
Object.entries(child).forEach(([id, el]) => {
|
|
4208
|
+
if (found[id]) console.log('DUPLICATE', id, depth, i);
|
|
4209
|
+
return found[id] = el
|
|
4210
|
+
});
|
|
4206
4211
|
});
|
|
4207
4212
|
}
|
|
4208
4213
|
|
|
4209
4214
|
return found
|
|
4210
4215
|
}
|
|
4211
4216
|
|
|
4212
|
-
function injectComponents(currentElement, components, componentNames, depth=0, index) {
|
|
4217
|
+
function injectComponents(currentElement, components, componentNames, depth=0, index=0) {
|
|
4213
4218
|
if (!currentElement) return
|
|
4214
4219
|
if (currentElement.data?.componentsInjected) return currentElement
|
|
4215
4220
|
if (depth === 0 && currentElement.data) currentElement.data.componentsInjected = true;
|
|
@@ -4235,7 +4240,7 @@ function injectComponents(currentElement, components, componentNames, depth=0, i
|
|
|
4235
4240
|
return component
|
|
4236
4241
|
}
|
|
4237
4242
|
} else if (children.length > 0) {
|
|
4238
|
-
currentElement.children = children.map((child, i) => injectComponents(child, components, componentNames, depth + 1, i)).flat();
|
|
4243
|
+
currentElement.children = children.map((child, i) => injectComponents(child, components, componentNames, depth + 1, index + i)).flat();
|
|
4239
4244
|
return currentElement
|
|
4240
4245
|
} else {
|
|
4241
4246
|
return currentElement
|
|
@@ -4272,7 +4277,7 @@ function processForm(form, options={}) {
|
|
|
4272
4277
|
|
|
4273
4278
|
const eventStream$ = events.map(event => form.events(event));
|
|
4274
4279
|
|
|
4275
|
-
const merged$ =
|
|
4280
|
+
const merged$ = xs$1.merge(...eventStream$);
|
|
4276
4281
|
|
|
4277
4282
|
return merged$.map((e) => {
|
|
4278
4283
|
if (preventDefault) e.preventDefault();
|
|
@@ -4333,7 +4338,7 @@ function eventBusDriver(out$) {
|
|
|
4333
4338
|
const all = !type;
|
|
4334
4339
|
const _type = (Array.isArray(type)) ? type : [type];
|
|
4335
4340
|
let cb;
|
|
4336
|
-
const in$ =
|
|
4341
|
+
const in$ = xs$1.create({
|
|
4337
4342
|
start: (listener) => {
|
|
4338
4343
|
cb = ({detail: event}) => {
|
|
4339
4344
|
const data = (event && event.data) || null;
|
|
@@ -4738,10 +4743,7 @@ sampleCombine = function sampleCombine() {
|
|
|
4738
4743
|
};
|
|
4739
4744
|
var _default = sampleCombine$1.default = sampleCombine;
|
|
4740
4745
|
|
|
4741
|
-
|
|
4742
|
-
enumerable: true,
|
|
4743
|
-
get: function () { return xs__default["default"]; }
|
|
4744
|
-
});
|
|
4746
|
+
exports.xs = xs$1;
|
|
4745
4747
|
exports.ABORT = ABORT;
|
|
4746
4748
|
exports.classes = classes;
|
|
4747
4749
|
exports.collection = collection;
|
|
@@ -4755,7 +4757,7 @@ exports.sampleCombine = _default;
|
|
|
4755
4757
|
exports.switchable = switchable;
|
|
4756
4758
|
exports.throttle = _default$1;
|
|
4757
4759
|
Object.keys(dom).forEach(function (k) {
|
|
4758
|
-
if (k !== 'default' && !
|
|
4760
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4759
4761
|
enumerable: true,
|
|
4760
4762
|
get: function () { return dom[k]; }
|
|
4761
4763
|
});
|
package/dist/index.esm.js
CHANGED
|
@@ -72,9 +72,7 @@ var dropRepeats$1 = {};
|
|
|
72
72
|
|
|
73
73
|
var xstream = {};
|
|
74
74
|
|
|
75
|
-
var ponyfill$1 = {
|
|
76
|
-
|
|
77
|
-
var ponyfill = {};
|
|
75
|
+
var ponyfill$1 = {};
|
|
78
76
|
|
|
79
77
|
(function (exports) {
|
|
80
78
|
|
|
@@ -108,11 +106,9 @@ var ponyfill = {};
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
return result;
|
|
111
|
-
}} (ponyfill));
|
|
109
|
+
}} (ponyfill$1));
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
module.exports = ponyfill;
|
|
115
|
-
} (ponyfill$1));
|
|
111
|
+
var ponyfill = ponyfill$1;
|
|
116
112
|
|
|
117
113
|
var toStr$2 = Object.prototype.toString;
|
|
118
114
|
|
|
@@ -912,7 +908,7 @@ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
|
912
908
|
})();
|
|
913
909
|
Object.defineProperty(xstream, "__esModule", { value: true });
|
|
914
910
|
xstream.NO_IL = xstream.NO = xstream.MemoryStream = xstream.Stream = void 0;
|
|
915
|
-
var ponyfill_1 = ponyfill
|
|
911
|
+
var ponyfill_1 = ponyfill;
|
|
916
912
|
var globalthis_1 = globalthis;
|
|
917
913
|
var $$observable = ponyfill_1.default(globalthis_1.getPolyfill());
|
|
918
914
|
var NO$1 = {};
|
|
@@ -3155,6 +3151,7 @@ const HYDRATE_ACTION = 'HYDRATE';
|
|
|
3155
3151
|
|
|
3156
3152
|
|
|
3157
3153
|
let IS_ROOT_COMPONENT = true;
|
|
3154
|
+
let COMPONENT_COUNT = 0;
|
|
3158
3155
|
|
|
3159
3156
|
|
|
3160
3157
|
const ABORT = '~#~#~ABORT~#~#~';
|
|
@@ -3178,16 +3175,19 @@ function component (opts) {
|
|
|
3178
3175
|
}
|
|
3179
3176
|
|
|
3180
3177
|
const currySources = typeof sources === 'undefined';
|
|
3178
|
+
let returnFunction;
|
|
3181
3179
|
|
|
3182
3180
|
if (typeof fixedIsolateOpts == 'object') {
|
|
3183
3181
|
const wrapped = (sources) => {
|
|
3184
3182
|
const fixedOpts = { ...opts, sources };
|
|
3185
3183
|
return (new Component(fixedOpts)).sinks
|
|
3186
3184
|
};
|
|
3187
|
-
|
|
3185
|
+
returnFunction = currySources ? isolate(wrapped, fixedIsolateOpts) : isolate(wrapped, fixedIsolateOpts)(sources);
|
|
3188
3186
|
} else {
|
|
3189
|
-
|
|
3187
|
+
returnFunction = currySources ? (sources) => (new Component({ ...opts, sources })).sinks : (new Component(opts)).sinks;
|
|
3190
3188
|
}
|
|
3189
|
+
|
|
3190
|
+
return returnFunction
|
|
3191
3191
|
}
|
|
3192
3192
|
|
|
3193
3193
|
|
|
@@ -3285,6 +3285,12 @@ class Component {
|
|
|
3285
3285
|
this.initSubComponentsRendered$();
|
|
3286
3286
|
this.initVdom$();
|
|
3287
3287
|
this.initSinks();
|
|
3288
|
+
|
|
3289
|
+
this.sinks.__index = COMPONENT_COUNT++;
|
|
3290
|
+
|
|
3291
|
+
if (ENVIRONMENT.DEBUG === true) {
|
|
3292
|
+
console.log(`[${ this.name }] Instantiated (#${ this.sinks.__index })`);
|
|
3293
|
+
}
|
|
3288
3294
|
}
|
|
3289
3295
|
|
|
3290
3296
|
initIntent$() {
|
|
@@ -3761,6 +3767,8 @@ class Component {
|
|
|
3761
3767
|
const foundComponents = getComponents(vDom, componentNames);
|
|
3762
3768
|
const entries = Object.entries(foundComponents);
|
|
3763
3769
|
|
|
3770
|
+
if (this.name === 'APP') console.log(`[${ this.name }] FOUND`, foundComponents);
|
|
3771
|
+
|
|
3764
3772
|
const rootEntry = { '::ROOT::': vDom };
|
|
3765
3773
|
|
|
3766
3774
|
if (entries.length === 0) {
|
|
@@ -4172,6 +4180,7 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4172
4180
|
|
|
4173
4181
|
if (isComponent) {
|
|
4174
4182
|
const id = getComponentIdFromElement(currentElement, depth, index);
|
|
4183
|
+
if (found[id]) console.log('DUPLICATE', id);
|
|
4175
4184
|
if (isCollection) {
|
|
4176
4185
|
if (!props.of) throw new Error(`Collection element missing required 'component' property`)
|
|
4177
4186
|
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`)
|
|
@@ -4181,7 +4190,7 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4181
4190
|
currentElement.data.props ||= {};
|
|
4182
4191
|
} else if (isSwitchable) {
|
|
4183
4192
|
if (!props.of) throw new Error(`Switchable element missing required 'of' property`)
|
|
4184
|
-
if (typeof props.of !== 'object') throw new Error(`Invalid '
|
|
4193
|
+
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`)
|
|
4185
4194
|
const switchableComponents = Object.values(props.of);
|
|
4186
4195
|
if (!switchableComponents.every(comp => typeof comp === 'function')) throw new Error(`One or more components provided to switchable element is not a valid component factory`)
|
|
4187
4196
|
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`)
|
|
@@ -4193,16 +4202,19 @@ function getComponents(currentElement, componentNames, depth=0, index=0) {
|
|
|
4193
4202
|
}
|
|
4194
4203
|
|
|
4195
4204
|
if (children.length > 0) {
|
|
4196
|
-
children.map((child, i) => getComponents(child, componentNames, depth + 1, i))
|
|
4197
|
-
.forEach((child) => {
|
|
4198
|
-
Object.entries(child).forEach(([id, el]) =>
|
|
4205
|
+
children.map((child, i) => getComponents(child, componentNames, depth + 1, index + i))
|
|
4206
|
+
.forEach((child, i) => {
|
|
4207
|
+
Object.entries(child).forEach(([id, el]) => {
|
|
4208
|
+
if (found[id]) console.log('DUPLICATE', id, depth, i);
|
|
4209
|
+
return found[id] = el
|
|
4210
|
+
});
|
|
4199
4211
|
});
|
|
4200
4212
|
}
|
|
4201
4213
|
|
|
4202
4214
|
return found
|
|
4203
4215
|
}
|
|
4204
4216
|
|
|
4205
|
-
function injectComponents(currentElement, components, componentNames, depth=0, index) {
|
|
4217
|
+
function injectComponents(currentElement, components, componentNames, depth=0, index=0) {
|
|
4206
4218
|
if (!currentElement) return
|
|
4207
4219
|
if (currentElement.data?.componentsInjected) return currentElement
|
|
4208
4220
|
if (depth === 0 && currentElement.data) currentElement.data.componentsInjected = true;
|
|
@@ -4228,7 +4240,7 @@ function injectComponents(currentElement, components, componentNames, depth=0, i
|
|
|
4228
4240
|
return component
|
|
4229
4241
|
}
|
|
4230
4242
|
} else if (children.length > 0) {
|
|
4231
|
-
currentElement.children = children.map((child, i) => injectComponents(child, components, componentNames, depth + 1, i)).flat();
|
|
4243
|
+
currentElement.children = children.map((child, i) => injectComponents(child, components, componentNames, depth + 1, index + i)).flat();
|
|
4232
4244
|
return currentElement
|
|
4233
4245
|
} else {
|
|
4234
4246
|
return currentElement
|