sygnal 1.2.1 → 2.1.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/dist/collection.js +2 -2
- package/dist/component.js +37 -15
- package/dist/extra/run.js +12 -1
- package/dist/index.js +47 -2
- package/dist/jsx.js +9 -1
- package/dist/pragma/index.js +15 -4
- package/package.json +2 -1
- package/sygnal-1.2.1.tgz +0 -0
- package/sygnal-2.0.0.tgz +0 -0
- package/sygnal-2.0.1.tgz +0 -0
- package/sygnal-1.2.0.tgz +0 -0
package/dist/collection.js
CHANGED
|
@@ -32,8 +32,8 @@ function collection(component, stateLense) {
|
|
|
32
32
|
return function (sources) {
|
|
33
33
|
var collectionOpts = {
|
|
34
34
|
item: component,
|
|
35
|
-
itemKey: function itemKey(state) {
|
|
36
|
-
return state.id;
|
|
35
|
+
itemKey: function itemKey(state, ind) {
|
|
36
|
+
return typeof state.id !== 'undefined' ? state.id : ind;
|
|
37
37
|
},
|
|
38
38
|
itemScope: function itemScope(key) {
|
|
39
39
|
return key;
|
package/dist/component.js
CHANGED
|
@@ -738,7 +738,12 @@ var Component = /*#__PURE__*/function () {
|
|
|
738
738
|
return acc;
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
-
var factory = _this8.components[componentName];
|
|
741
|
+
var factory = componentName === 'sygnal-factory' ? props.sygnalFactory : _this8.components[componentName] || props.sygnalFactory;
|
|
742
|
+
|
|
743
|
+
if (!factory && !isCollection && !isSwitchable) {
|
|
744
|
+
if (componentName === 'sygnal-factory') throw new Error("Component not found on element with Capitalized selector and nameless function: JSX transpilation replaces selectors starting with upper case letters with functions in-scope with the same name, Sygnal cannot see the name of the resulting component.");
|
|
745
|
+
throw new Error("Component not found: ".concat(componentName));
|
|
746
|
+
}
|
|
742
747
|
|
|
743
748
|
var props$ = _xstream["default"].create().startWith(props);
|
|
744
749
|
|
|
@@ -750,13 +755,30 @@ var Component = /*#__PURE__*/function () {
|
|
|
750
755
|
if (isCollection) {
|
|
751
756
|
var _objectSpread2;
|
|
752
757
|
|
|
753
|
-
|
|
754
|
-
|
|
758
|
+
var stream, field;
|
|
759
|
+
|
|
760
|
+
if (typeof data.props["for"] === 'string') {
|
|
761
|
+
field = data.props["for"];
|
|
762
|
+
stream = _this8.sources[_this8.stateSourceName].stream;
|
|
763
|
+
} else {
|
|
764
|
+
field = 'for';
|
|
765
|
+
stream = props$;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
propState = new _state2.StateSource(stream.map(function (val) {
|
|
769
|
+
var arr = val[field];
|
|
770
|
+
|
|
771
|
+
if (!Array.isArray(arr)) {
|
|
772
|
+
console.warn("Collection of ".concat(data.props.of, " does not have a valid array in the 'for' property: expects either an array or a string of the name of an array property on the state"));
|
|
773
|
+
return [];
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return arr;
|
|
755
777
|
}).remember());
|
|
756
778
|
|
|
757
779
|
var sources = _objectSpread(_objectSpread({}, _this8.sources), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, _this8.stateSourceName, propState), _defineProperty(_objectSpread2, "props$", props$), _defineProperty(_objectSpread2, "children$", children$), _objectSpread2));
|
|
758
780
|
|
|
759
|
-
var _factory = _this8.components[data.
|
|
781
|
+
var _factory = _this8.components[data.props.of];
|
|
760
782
|
var lense = {
|
|
761
783
|
get: function get(state) {
|
|
762
784
|
return state;
|
|
@@ -1049,7 +1071,7 @@ function makeLog(context) {
|
|
|
1049
1071
|
}
|
|
1050
1072
|
|
|
1051
1073
|
function getComponents(currentElement, componentNames) {
|
|
1052
|
-
var _currentElement$data;
|
|
1074
|
+
var _currentElement$data, _currentElement$data2, _currentElement$data3;
|
|
1053
1075
|
|
|
1054
1076
|
var isNestedElement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1055
1077
|
if (!currentElement) return {};
|
|
@@ -1058,7 +1080,7 @@ function getComponents(currentElement, componentNames) {
|
|
|
1058
1080
|
var sel = currentElement.sel;
|
|
1059
1081
|
var isCollection = sel && sel.toLowerCase() === 'collection';
|
|
1060
1082
|
var isSwitchable = sel && sel.toLowerCase() === 'switchable';
|
|
1061
|
-
var isComponent = sel && ['collection', 'swtichable'].concat(_toConsumableArray(componentNames)).includes(currentElement.sel);
|
|
1083
|
+
var isComponent = sel && ['collection', 'swtichable', 'sygnal-factory'].concat(_toConsumableArray(componentNames)).includes(currentElement.sel) || typeof ((_currentElement$data2 = currentElement.data) === null || _currentElement$data2 === void 0 ? void 0 : (_currentElement$data3 = _currentElement$data2.props) === null || _currentElement$data3 === void 0 ? void 0 : _currentElement$data3.sygnalFactory) === 'function';
|
|
1062
1084
|
var props = currentElement.data && currentElement.data.props || {};
|
|
1063
1085
|
var children = currentElement.children || [];
|
|
1064
1086
|
var found = {};
|
|
@@ -1067,10 +1089,10 @@ function getComponents(currentElement, componentNames) {
|
|
|
1067
1089
|
var id = getComponentIdFromElement(currentElement);
|
|
1068
1090
|
|
|
1069
1091
|
if (isCollection) {
|
|
1070
|
-
if (!props.
|
|
1071
|
-
if (typeof props.
|
|
1072
|
-
if (!componentNames.includes(props.
|
|
1073
|
-
if (!props
|
|
1092
|
+
if (!props.of) throw new Error("Collection element missing required 'component' property");
|
|
1093
|
+
if (typeof props.of !== 'string') throw new Error("Invalid 'component' property of collection element: found ".concat(_typeof(props.of), " requires string"));
|
|
1094
|
+
if (!componentNames.includes(props.of)) throw new Error("Specified component for collection not found: ".concat(props.of));
|
|
1095
|
+
if (!props["for"] || !(typeof props["for"] === 'string' || Array.isArray(props["for"]))) console.warn("No valid array found in the 'value' property of collection ".concat(props.of, ": no collection components will be created"));
|
|
1074
1096
|
currentElement.data.isCollection = true;
|
|
1075
1097
|
currentElement.data.component = props.component; // currentElement.data.componentArray = props.value
|
|
1076
1098
|
} else if (isSwitchable) {
|
|
@@ -1109,16 +1131,16 @@ function getComponents(currentElement, componentNames) {
|
|
|
1109
1131
|
}
|
|
1110
1132
|
|
|
1111
1133
|
function injectComponents(currentElement, components, componentNames) {
|
|
1112
|
-
var _currentElement$
|
|
1134
|
+
var _currentElement$data4, _currentElement$data5, _currentElement$data6, _currentElement$data7, _currentElement$data8;
|
|
1113
1135
|
|
|
1114
1136
|
var isNestedElement = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
1115
1137
|
if (!currentElement) return;
|
|
1116
|
-
if ((_currentElement$
|
|
1138
|
+
if ((_currentElement$data4 = currentElement.data) !== null && _currentElement$data4 !== void 0 && _currentElement$data4.componentsInjected) return currentElement;
|
|
1117
1139
|
if (!isNestedElement && currentElement.data) currentElement.data.componentsInjected = true;
|
|
1118
1140
|
var sel = currentElement.sel || 'NO SELECTOR';
|
|
1119
|
-
var isComponent = ['collection', 'swtichable'].concat(_toConsumableArray(componentNames)).includes(sel);
|
|
1120
|
-
var isCollection = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement$
|
|
1121
|
-
var isSwitchable = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement$
|
|
1141
|
+
var isComponent = ['collection', 'swtichable', 'sygnal-factory'].concat(_toConsumableArray(componentNames)).includes(sel) || typeof ((_currentElement$data5 = currentElement.data) === null || _currentElement$data5 === void 0 ? void 0 : (_currentElement$data6 = _currentElement$data5.props) === null || _currentElement$data6 === void 0 ? void 0 : _currentElement$data6.sygnalFactory) === 'function';
|
|
1142
|
+
var isCollection = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement$data7 = currentElement.data) === null || _currentElement$data7 === void 0 ? void 0 : _currentElement$data7.isCollection;
|
|
1143
|
+
var isSwitchable = currentElement === null || currentElement === void 0 ? void 0 : (_currentElement$data8 = currentElement.data) === null || _currentElement$data8 === void 0 ? void 0 : _currentElement$data8.isSwitchable;
|
|
1122
1144
|
var props = currentElement.data && currentElement.data.props || {};
|
|
1123
1145
|
var children = currentElement.children || [];
|
|
1124
1146
|
|
package/dist/extra/run.js
CHANGED
|
@@ -25,10 +25,21 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
25
25
|
|
|
26
26
|
function run(app) {
|
|
27
27
|
var drivers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
29
|
+
var _options$mountPoint = options.mountPoint,
|
|
30
|
+
mountPoint = _options$mountPoint === void 0 ? '#root' : _options$mountPoint,
|
|
31
|
+
_options$fragments = options.fragments,
|
|
32
|
+
fragments = _options$fragments === void 0 ? true : _options$fragments;
|
|
28
33
|
var wrapped = (0, _state.withState)(app, 'STATE');
|
|
29
34
|
var baseDrivers = {
|
|
30
35
|
EVENTS: _eventDriver["default"],
|
|
31
|
-
DOM: (0, _dom.makeDOMDriver)(
|
|
36
|
+
DOM: (0, _dom.makeDOMDriver)(mountPoint, {
|
|
37
|
+
snabbdomOptions: {
|
|
38
|
+
experimental: {
|
|
39
|
+
fragments: fragments
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
32
43
|
LOG: _logDriver["default"]
|
|
33
44
|
};
|
|
34
45
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict'; // export sygnal core functions
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
@@ -13,7 +13,12 @@ var _exportNames = {
|
|
|
13
13
|
processForm: true,
|
|
14
14
|
run: true,
|
|
15
15
|
classes: true,
|
|
16
|
-
xs: true
|
|
16
|
+
xs: true,
|
|
17
|
+
debounce: true,
|
|
18
|
+
throttle: true,
|
|
19
|
+
delay: true,
|
|
20
|
+
dropRepeats: true,
|
|
21
|
+
sampleCombine: true
|
|
17
22
|
};
|
|
18
23
|
Object.defineProperty(exports, "ABORT", {
|
|
19
24
|
enumerable: true,
|
|
@@ -39,6 +44,24 @@ Object.defineProperty(exports, "component", {
|
|
|
39
44
|
return _component["default"];
|
|
40
45
|
}
|
|
41
46
|
});
|
|
47
|
+
Object.defineProperty(exports, "debounce", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function get() {
|
|
50
|
+
return _debounce["default"];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "delay", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function get() {
|
|
56
|
+
return _delay["default"];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "dropRepeats", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return _dropRepeats["default"];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
42
65
|
Object.defineProperty(exports, "processForm", {
|
|
43
66
|
enumerable: true,
|
|
44
67
|
get: function get() {
|
|
@@ -51,12 +74,24 @@ Object.defineProperty(exports, "run", {
|
|
|
51
74
|
return _run["default"];
|
|
52
75
|
}
|
|
53
76
|
});
|
|
77
|
+
Object.defineProperty(exports, "sampleCombine", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return _sampleCombine["default"];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
54
83
|
Object.defineProperty(exports, "switchable", {
|
|
55
84
|
enumerable: true,
|
|
56
85
|
get: function get() {
|
|
57
86
|
return _switchable["default"];
|
|
58
87
|
}
|
|
59
88
|
});
|
|
89
|
+
Object.defineProperty(exports, "throttle", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function get() {
|
|
92
|
+
return _throttle["default"];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
60
95
|
Object.defineProperty(exports, "xs", {
|
|
61
96
|
enumerable: true,
|
|
62
97
|
get: function get() {
|
|
@@ -92,6 +127,16 @@ Object.keys(_dom).forEach(function (key) {
|
|
|
92
127
|
|
|
93
128
|
var _xstream = _interopRequireDefault(require("xstream"));
|
|
94
129
|
|
|
130
|
+
var _debounce = _interopRequireDefault(require("xstream/extra/debounce"));
|
|
131
|
+
|
|
132
|
+
var _throttle = _interopRequireDefault(require("xstream/extra/throttle"));
|
|
133
|
+
|
|
134
|
+
var _delay = _interopRequireDefault(require("xstream/extra/delay"));
|
|
135
|
+
|
|
136
|
+
var _dropRepeats = _interopRequireDefault(require("xstream/extra/dropRepeats"));
|
|
137
|
+
|
|
138
|
+
var _sampleCombine = _interopRequireDefault(require("xstream/extra/sampleCombine"));
|
|
139
|
+
|
|
95
140
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
96
141
|
|
|
97
142
|
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); }
|
package/dist/jsx.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "Fragment", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _snabbdom.Fragment;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "jsx", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -10,4 +16,6 @@ Object.defineProperty(exports, "jsx", {
|
|
|
10
16
|
}
|
|
11
17
|
});
|
|
12
18
|
|
|
13
|
-
var _index = require("./pragma/index");
|
|
19
|
+
var _index = require("./pragma/index");
|
|
20
|
+
|
|
21
|
+
var _snabbdom = require("snabbdom");
|
package/dist/pragma/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var considerSvg = function considerSvg(vnode) {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
var rewrites = {
|
|
48
|
-
|
|
48
|
+
// for: 'attrs',
|
|
49
49
|
role: 'attrs',
|
|
50
50
|
tabindex: 'attrs',
|
|
51
51
|
'aria-*': 'attrs',
|
|
@@ -116,15 +116,26 @@ var defaultModules = {
|
|
|
116
116
|
|
|
117
117
|
var createElementWithModules = function createElementWithModules(modules) {
|
|
118
118
|
return function (sel, data) {
|
|
119
|
-
if (
|
|
120
|
-
sel =
|
|
121
|
-
|
|
119
|
+
if (typeof sel === 'undefined') {
|
|
120
|
+
sel = 'UNDEFINED';
|
|
121
|
+
cnosole.error('JSX Error: Capitalized HTML element without corresponding Sygnal factory. Components with names where the first letter is capital MUST be defined or included at the parent component\'s file scope.');
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
125
125
|
children[_key - 2] = arguments[_key];
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
if (is.fun(sel)) {
|
|
129
|
+
if (sel.name === 'Fragment') {
|
|
130
|
+
return sel(data || {}, children);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var factory = sel;
|
|
134
|
+
sel = sel.name || 'sygnal-factory';
|
|
135
|
+
data || (data = {});
|
|
136
|
+
data.sygnalFactory = factory;
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
var text = sanitizeText(children, modules);
|
|
129
140
|
return considerSvg({
|
|
130
141
|
sel: sel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sygnal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@cycle/run": "^5.7.0",
|
|
37
37
|
"@cycle/state": "^1.7.0",
|
|
38
38
|
"extend": "^3.0.2",
|
|
39
|
+
"snabbdom": "^3.5.0",
|
|
39
40
|
"xstream": "^11.14.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
package/sygnal-1.2.1.tgz
ADDED
|
Binary file
|
package/sygnal-2.0.0.tgz
ADDED
|
Binary file
|
package/sygnal-2.0.1.tgz
ADDED
|
Binary file
|
package/sygnal-1.2.0.tgz
DELETED
|
Binary file
|