sygnal 2.3.0 → 2.4.0
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/.babelrc +4 -1
- package/dist/collection.js +4 -14
- package/dist/component.js +257 -166
- package/dist/extra/classes.js +1 -7
- package/dist/extra/eventDriver.js +5 -16
- package/dist/extra/logDriver.js +1 -6
- package/dist/extra/processForm.js +3 -13
- package/dist/extra/run.js +11 -25
- package/dist/index.js +15 -142
- package/dist/jsx.js +2 -21
- package/dist/pragma/fn.js +13 -49
- package/dist/pragma/index.js +7 -27
- package/dist/pragma/is.js +11 -47
- package/dist/switchable.js +17 -28
- package/package.json +1 -1
package/dist/switchable.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = switchable;
|
|
7
|
-
|
|
8
|
-
var _xstream = _interopRequireWildcard(require("xstream"));
|
|
9
|
-
|
|
10
|
-
var _dropRepeats = _interopRequireDefault(require("xstream/extra/dropRepeats"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
19
4
|
|
|
20
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -43,20 +28,25 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
43
28
|
|
|
44
29
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
45
30
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
import { default as xs, Stream } from 'xstream';
|
|
32
|
+
import dropRepeats from 'xstream/extra/dropRepeats';
|
|
33
|
+
export default function switchable(factories, name$, initial) {
|
|
34
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
35
|
+
var _opts$switched = opts.switched,
|
|
36
|
+
switched = _opts$switched === void 0 ? ['DOM'] : _opts$switched,
|
|
37
|
+
_opts$stateSourceName = opts.stateSourceName,
|
|
38
|
+
stateSourceName = _opts$stateSourceName === void 0 ? 'STATE' : _opts$stateSourceName;
|
|
49
39
|
|
|
50
40
|
var nameType = _typeof(name$);
|
|
51
41
|
|
|
52
42
|
if (!name$) throw new Error("Missing 'name$' parameter for switchable()");
|
|
53
43
|
|
|
54
|
-
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof
|
|
44
|
+
if (!(nameType === 'string' || nameType === 'function' || name$ instanceof Stream)) {
|
|
55
45
|
throw new Error("Invalid 'name$' parameter for switchable(): expects Stream, String, or Function");
|
|
56
46
|
}
|
|
57
47
|
|
|
58
|
-
if (name$ instanceof
|
|
59
|
-
var withInitial$ = name$.compose((
|
|
48
|
+
if (name$ instanceof Stream) {
|
|
49
|
+
var withInitial$ = name$.compose(dropRepeats()).startWith(initial).remember();
|
|
60
50
|
return function (sources) {
|
|
61
51
|
return _switchable(factories, sources, withInitial$, switched);
|
|
62
52
|
};
|
|
@@ -67,11 +57,11 @@ function switchable(factories, name$, initial) {
|
|
|
67
57
|
|
|
68
58
|
return function (sources) {
|
|
69
59
|
var state$ = sources && (typeof stateSourceName === 'string' && sources[stateSourceName] || sources.STATE || sources.state).stream;
|
|
70
|
-
if (!state$ instanceof
|
|
60
|
+
if (!state$ instanceof Stream) throw new Error("Could not find the state source: ".concat(stateSourceName));
|
|
71
61
|
|
|
72
62
|
var _name$ = state$.map(mapFunction).filter(function (name) {
|
|
73
63
|
return typeof name === 'string';
|
|
74
|
-
}).compose((
|
|
64
|
+
}).compose(dropRepeats()).startWith(initial).remember();
|
|
75
65
|
|
|
76
66
|
return _switchable(factories, sources, _name$, switched, stateSourceName);
|
|
77
67
|
};
|
|
@@ -89,7 +79,6 @@ function switchable(factories, name$, initial) {
|
|
|
89
79
|
* any component sinks not dsignated in `switched` will be merged across all components
|
|
90
80
|
*/
|
|
91
81
|
|
|
92
|
-
|
|
93
82
|
function _switchable(factories, sources, name$) {
|
|
94
83
|
var switched = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ['DOM'];
|
|
95
84
|
var stateSourceName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'STATE';
|
|
@@ -102,7 +91,7 @@ function _switchable(factories, sources, name$) {
|
|
|
102
91
|
if (sources[stateSourceName]) {
|
|
103
92
|
var state$ = sources[stateSourceName].stream;
|
|
104
93
|
|
|
105
|
-
var _switched =
|
|
94
|
+
var _switched = xs.combine(name$, state$).filter(function (_ref3) {
|
|
106
95
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
107
96
|
newComponentName = _ref4[0],
|
|
108
97
|
_ = _ref4[1];
|
|
@@ -134,8 +123,8 @@ function _switchable(factories, sources, name$) {
|
|
|
134
123
|
|
|
135
124
|
return componentName === newComponentName;
|
|
136
125
|
});
|
|
137
|
-
return sink && sink[1][sinkName] ||
|
|
138
|
-
}).flatten().remember().startWith(
|
|
126
|
+
return sink && sink[1][sinkName] || xs.never();
|
|
127
|
+
}).flatten().remember().startWith(undefined);
|
|
139
128
|
} else {
|
|
140
129
|
var definedSinks = sinks.filter(function (_ref9) {
|
|
141
130
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
@@ -150,7 +139,7 @@ function _switchable(factories, sources, name$) {
|
|
|
150
139
|
|
|
151
140
|
return sink[sinkName];
|
|
152
141
|
});
|
|
153
|
-
obj[sinkName] =
|
|
142
|
+
obj[sinkName] = xs.merge.apply(xs, _toConsumableArray(definedSinks));
|
|
154
143
|
}
|
|
155
144
|
|
|
156
145
|
return obj;
|