@micromag/core 0.3.311 → 0.3.322
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/assets/css/styles.css +21 -21
- package/assets/css/vendor.css +1 -1
- package/es/components.js +650 -859
- package/es/contexts.js +304 -442
- package/es/hooks.js +448 -694
- package/es/index.js +247 -391
- package/es/utils.js +294 -391
- package/lib/components.js +649 -858
- package/lib/contexts.js +304 -442
- package/lib/hooks.js +448 -694
- package/lib/index.js +247 -391
- package/lib/utils.js +294 -391
- package/package.json +6 -6
package/es/index.js
CHANGED
|
@@ -32,7 +32,6 @@ import { Tracking as Tracking$1 } from '@folklore/tracking';
|
|
|
32
32
|
/**
|
|
33
33
|
* Core
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
35
|
var history = PropTypes$1.shape({
|
|
37
36
|
listen: PropTypes$1.func.isRequired,
|
|
38
37
|
push: PropTypes$1.func.isRequired
|
|
@@ -60,7 +59,6 @@ var label = PropTypes$1.oneOfType([message, PropTypes$1.node]);
|
|
|
60
59
|
var statusCode = PropTypes$1.oneOf([401, 403, 404, 500]);
|
|
61
60
|
var ref = PropTypes$1.oneOfType([PropTypes$1.shape({
|
|
62
61
|
current: PropTypes$1.any // eslint-disable-line react/forbid-prop-types
|
|
63
|
-
|
|
64
62
|
}), PropTypes$1.func]);
|
|
65
63
|
var target = PropTypes$1.oneOf(['_blank', '_self', '_parent']);
|
|
66
64
|
var interaction = PropTypes$1.oneOf(['tap', 'swipe']);
|
|
@@ -70,10 +68,10 @@ var progress = PropTypes$1.shape({
|
|
|
70
68
|
currentTime: PropTypes$1.number,
|
|
71
69
|
duration: PropTypes$1.number
|
|
72
70
|
});
|
|
71
|
+
|
|
73
72
|
/**
|
|
74
73
|
* Site
|
|
75
74
|
*/
|
|
76
|
-
|
|
77
75
|
var user = PropTypes$1.shape({
|
|
78
76
|
id: PropTypes$1.number,
|
|
79
77
|
firstname: PropTypes$1.string,
|
|
@@ -125,10 +123,10 @@ var componentNames = function componentNames(Components) {
|
|
|
125
123
|
};
|
|
126
124
|
var component = PropTypes$1.oneOfType([PropTypes$1.object, PropTypes$1.func]);
|
|
127
125
|
var components = PropTypes$1.objectOf(component);
|
|
126
|
+
|
|
128
127
|
/**
|
|
129
128
|
* Forms
|
|
130
129
|
*/
|
|
131
|
-
|
|
132
130
|
var errors = PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.arrayOf(PropTypes$1.string)]);
|
|
133
131
|
var formErrors = PropTypes$1.objectOf(errors);
|
|
134
132
|
var selectOption = PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.shape({
|
|
@@ -142,10 +140,10 @@ var formField = PropTypes$1.shape({
|
|
|
142
140
|
component: component
|
|
143
141
|
});
|
|
144
142
|
var formFields = PropTypes$1.arrayOf(formField);
|
|
143
|
+
|
|
145
144
|
/**
|
|
146
145
|
* Medias
|
|
147
146
|
*/
|
|
148
|
-
|
|
149
147
|
var mediaMetadataShape = {
|
|
150
148
|
filename: PropTypes$1.string,
|
|
151
149
|
size: PropTypes$1.number,
|
|
@@ -203,15 +201,17 @@ var audioMedias = PropTypes$1.arrayOf(audioMedia);
|
|
|
203
201
|
var closedCaptionsMedia = PropTypes$1.shape(_objectSpread(_objectSpread({}, mediaShape), {}, {
|
|
204
202
|
type: PropTypes$1.oneOf(['closed-captions'])
|
|
205
203
|
}));
|
|
204
|
+
|
|
206
205
|
/**
|
|
207
206
|
* Style
|
|
208
207
|
*/
|
|
209
208
|
|
|
210
|
-
var
|
|
209
|
+
var customFont = PropTypes$1.shape({
|
|
211
210
|
type: PropTypes$1.oneOf(['system', 'google', 'custom']),
|
|
212
211
|
name: PropTypes$1.string,
|
|
213
212
|
media: fontMedia
|
|
214
|
-
})
|
|
213
|
+
});
|
|
214
|
+
var font = PropTypes$1.oneOfType([PropTypes$1.object, PropTypes$1.string]);
|
|
215
215
|
var fonts = PropTypes$1.arrayOf(font);
|
|
216
216
|
var textAlign = PropTypes$1.oneOf(['left', 'right', 'center']);
|
|
217
217
|
var color = PropTypes$1.shape({
|
|
@@ -266,6 +266,7 @@ var objectFit = PropTypes$1.shape({
|
|
|
266
266
|
horizontalPosition: PropTypes$1.oneOf(['left', 'center', 'right']),
|
|
267
267
|
verticalPosition: PropTypes$1.oneOf(['top', 'center', 'bottom'])
|
|
268
268
|
});
|
|
269
|
+
|
|
269
270
|
/**
|
|
270
271
|
* Elements
|
|
271
272
|
*/
|
|
@@ -389,6 +390,7 @@ var conversation = PropTypes$1.shape({
|
|
|
389
390
|
textStyle: textStyle,
|
|
390
391
|
messages: conversationMessages
|
|
391
392
|
});
|
|
393
|
+
|
|
392
394
|
/**
|
|
393
395
|
* Definitions
|
|
394
396
|
*/
|
|
@@ -418,10 +420,10 @@ var fieldDefinition = PropTypes$1.shape({
|
|
|
418
420
|
fields: fields
|
|
419
421
|
});
|
|
420
422
|
var fieldDefinitions = PropTypes$1.arrayOf(fieldDefinition);
|
|
423
|
+
|
|
421
424
|
/**
|
|
422
425
|
* Components
|
|
423
426
|
*/
|
|
424
|
-
|
|
425
427
|
var storyComponentShape = {
|
|
426
428
|
type: PropTypes$1.string.isRequired
|
|
427
429
|
};
|
|
@@ -434,7 +436,6 @@ var screen = screenComponent; // @NOTE should be removed
|
|
|
434
436
|
/**
|
|
435
437
|
* Theme
|
|
436
438
|
*/
|
|
437
|
-
|
|
438
439
|
var theme = PropTypes$1.shape({
|
|
439
440
|
id: PropTypes$1.string,
|
|
440
441
|
textStyles: PropTypes$1.objectOf(textStyle),
|
|
@@ -446,9 +447,11 @@ var theme = PropTypes$1.shape({
|
|
|
446
447
|
var viewerTheme = PropTypes$1.shape(_objectSpread({
|
|
447
448
|
logo: imageMedia
|
|
448
449
|
}, theme));
|
|
450
|
+
|
|
449
451
|
/**
|
|
450
452
|
* Branding
|
|
451
453
|
*/
|
|
454
|
+
|
|
452
455
|
// export const branding = PropTypes.shape({
|
|
453
456
|
// logo: imageMedia,
|
|
454
457
|
// primaryColor: color,
|
|
@@ -460,27 +463,26 @@ var viewerTheme = PropTypes$1.shape(_objectSpread({
|
|
|
460
463
|
/**
|
|
461
464
|
* Metadata
|
|
462
465
|
*/
|
|
463
|
-
|
|
464
466
|
var metadata = PropTypes$1.shape({
|
|
465
467
|
description: PropTypes$1.string,
|
|
466
468
|
shareUrl: PropTypes$1.string,
|
|
467
469
|
shareImage: imageMedia,
|
|
468
470
|
favIcon: imageMedia
|
|
469
471
|
});
|
|
472
|
+
|
|
470
473
|
/**
|
|
471
474
|
* Story
|
|
472
475
|
*/
|
|
473
|
-
|
|
474
476
|
var story = PropTypes$1.shape({
|
|
475
477
|
id: PropTypes$1.string,
|
|
476
478
|
theme: theme,
|
|
477
479
|
components: screenComponents,
|
|
478
480
|
metadata: metadata
|
|
479
481
|
});
|
|
482
|
+
|
|
480
483
|
/**
|
|
481
484
|
* Render
|
|
482
485
|
*/
|
|
483
|
-
|
|
484
486
|
var deviceScreen = PropTypes$1.shape({
|
|
485
487
|
name: PropTypes$1.string.isRequired,
|
|
486
488
|
mediaQuery: PropTypes$1.string
|
|
@@ -494,6 +496,7 @@ var screenSize = PropTypes$1.shape({
|
|
|
494
496
|
landscape: PropTypes$1.bool
|
|
495
497
|
});
|
|
496
498
|
var renderContext = PropTypes$1.oneOf(['view', 'placeholder', 'edit', 'preview', 'static', 'capture']);
|
|
499
|
+
|
|
497
500
|
/**
|
|
498
501
|
* Screens
|
|
499
502
|
*/
|
|
@@ -520,12 +523,15 @@ var slide = PropTypes$1.shape({
|
|
|
520
523
|
image: imageMedia,
|
|
521
524
|
text: PropTypes$1.string
|
|
522
525
|
});
|
|
523
|
-
var slides = PropTypes$1.arrayOf(slide);
|
|
526
|
+
var slides = PropTypes$1.arrayOf(slide);
|
|
527
|
+
|
|
528
|
+
// export const imageStyle = PropTypes.shape({
|
|
524
529
|
// alt: PropTypes.string,
|
|
525
530
|
// fit: PropTypes.object,
|
|
526
531
|
// });
|
|
527
532
|
|
|
528
533
|
var containerStyle = PropTypes$1.shape({});
|
|
534
|
+
|
|
529
535
|
/**
|
|
530
536
|
* Transitions
|
|
531
537
|
*/
|
|
@@ -542,6 +548,7 @@ var transitions = PropTypes$1.shape({
|
|
|
542
548
|
"in": transition,
|
|
543
549
|
out: transition
|
|
544
550
|
});
|
|
551
|
+
|
|
545
552
|
/**
|
|
546
553
|
* Search
|
|
547
554
|
*/
|
|
@@ -551,6 +558,7 @@ var searchFilter = PropTypes$1.shape({
|
|
|
551
558
|
value: PropTypes$1.oneOf([PropTypes$1.string, PropTypes$1.number])
|
|
552
559
|
});
|
|
553
560
|
var searchFilters = PropTypes$1.arrayOf(searchFilter);
|
|
561
|
+
|
|
554
562
|
/**
|
|
555
563
|
* Payments
|
|
556
564
|
*/
|
|
@@ -563,6 +571,7 @@ var paymentItem = PropTypes$1.shape({
|
|
|
563
571
|
amount: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.number])
|
|
564
572
|
});
|
|
565
573
|
var paymentItems = PropTypes$1.arrayOf(paymentItem);
|
|
574
|
+
|
|
566
575
|
/**
|
|
567
576
|
* Page Metadada
|
|
568
577
|
*/
|
|
@@ -649,6 +658,7 @@ var PropTypes = /*#__PURE__*/Object.freeze({
|
|
|
649
658
|
audioMedia: audioMedia,
|
|
650
659
|
audioMedias: audioMedias,
|
|
651
660
|
closedCaptionsMedia: closedCaptionsMedia,
|
|
661
|
+
customFont: customFont,
|
|
652
662
|
font: font,
|
|
653
663
|
fonts: fonts,
|
|
654
664
|
textAlign: textAlign,
|
|
@@ -738,93 +748,77 @@ var PropTypes = /*#__PURE__*/Object.freeze({
|
|
|
738
748
|
var sortedColors = function sortedColors(colors) {
|
|
739
749
|
return sortBy(colors, ['color', 'alpha']);
|
|
740
750
|
};
|
|
741
|
-
|
|
742
751
|
var uniqueColors = function uniqueColors(colors) {
|
|
743
752
|
return uniqWith(colors, function (colorA, colorB) {
|
|
744
753
|
return colorA.alpha === colorB.alpha && colorA.color === colorB.color;
|
|
745
754
|
});
|
|
746
755
|
};
|
|
747
|
-
|
|
748
756
|
var ColorsParser = /*#__PURE__*/function () {
|
|
749
757
|
function ColorsParser(_ref) {
|
|
750
758
|
var fieldsManager = _ref.fieldsManager,
|
|
751
|
-
|
|
752
|
-
|
|
759
|
+
screensManager = _ref.screensManager;
|
|
753
760
|
_classCallCheck(this, ColorsParser);
|
|
754
|
-
|
|
755
761
|
this.fieldsManager = fieldsManager;
|
|
756
762
|
this.screensManager = screensManager;
|
|
757
|
-
}
|
|
758
|
-
|
|
763
|
+
}
|
|
759
764
|
|
|
765
|
+
// Convert medias object to path
|
|
760
766
|
_createClass(ColorsParser, [{
|
|
761
767
|
key: "parse",
|
|
762
768
|
value: function parse(story) {
|
|
763
769
|
var _this = this;
|
|
764
|
-
|
|
765
770
|
if (story === null) {
|
|
766
771
|
return story;
|
|
767
772
|
}
|
|
768
|
-
|
|
769
773
|
var _ref2 = story || {},
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
774
|
+
_ref2$theme = _ref2.theme,
|
|
775
|
+
theme = _ref2$theme === void 0 ? null : _ref2$theme,
|
|
776
|
+
_ref2$components = _ref2.components,
|
|
777
|
+
components = _ref2$components === void 0 ? [] : _ref2$components;
|
|
775
778
|
var _components$reduce = components.reduce(function (_ref3, screen) {
|
|
776
|
-
|
|
779
|
+
var _ref3$colors = _ref3.colors,
|
|
777
780
|
currentColors = _ref3$colors === void 0 ? null : _ref3$colors;
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
var _ref4 = _this.screensManager.getDefinition(type) || {},
|
|
781
|
+
var type = screen.type;
|
|
782
|
+
var _ref4 = _this.screensManager.getDefinition(type) || {},
|
|
781
783
|
_ref4$fields = _ref4.fields,
|
|
782
784
|
fields = _ref4$fields === void 0 ? [] : _ref4$fields;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
var _ColorsParser$getColo = ColorsParser.getColorsFromPath(screen, fieldsPattern),
|
|
785
|
+
var fieldsPattern = _this.getColorFieldPatterns(fields);
|
|
786
|
+
var _ColorsParser$getColo = ColorsParser.getColorsFromPath(screen, fieldsPattern),
|
|
787
787
|
newColors = _ColorsParser$getColo.colors;
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
colors = _components$reduce.colors;
|
|
796
|
-
|
|
788
|
+
return {
|
|
789
|
+
colors: [].concat(_toConsumableArray(currentColors), _toConsumableArray(newColors))
|
|
790
|
+
};
|
|
791
|
+
}, {
|
|
792
|
+
colors: []
|
|
793
|
+
}),
|
|
794
|
+
colors = _components$reduce.colors;
|
|
797
795
|
if (theme !== null) {
|
|
798
796
|
var themeColors = this.parse(theme);
|
|
799
797
|
return colors !== null || themeColors !== null ? uniqueColors([].concat(_toConsumableArray(sortedColors(themeColors || [])), _toConsumableArray(sortedColors(colors || [])))) : [];
|
|
800
798
|
}
|
|
801
|
-
|
|
802
799
|
return colors !== null ? sortedColors(uniqueColors(colors || [])) : [];
|
|
803
800
|
}
|
|
804
801
|
}, {
|
|
805
802
|
key: "getColorFieldPatterns",
|
|
806
803
|
value: function getColorFieldPatterns(fields) {
|
|
807
804
|
var _this2 = this;
|
|
808
|
-
|
|
809
805
|
var namePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
810
806
|
return fields.reduce(function (patterns, field) {
|
|
811
807
|
var _field$name = field.name,
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
808
|
+
name = _field$name === void 0 ? null : _field$name,
|
|
809
|
+
_field$type = field.type,
|
|
810
|
+
type = _field$type === void 0 ? null : _field$type;
|
|
815
811
|
var path = [namePrefix, name].filter(function (it) {
|
|
816
812
|
return it !== null;
|
|
817
813
|
}).join('\\.');
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
814
|
+
var fieldDefinition = _objectSpread(_objectSpread({}, type !== null ? _this2.fieldsManager.getDefinition(type) : null), field);
|
|
815
|
+
// also check settings fields
|
|
822
816
|
var _fieldDefinition$fiel = fieldDefinition.fields,
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
817
|
+
subFields = _fieldDefinition$fiel === void 0 ? [] : _fieldDefinition$fiel,
|
|
818
|
+
_fieldDefinition$item = fieldDefinition.itemsField,
|
|
819
|
+
itemsField = _fieldDefinition$item === void 0 ? null : _fieldDefinition$item,
|
|
820
|
+
_fieldDefinition$sett = fieldDefinition.settings,
|
|
821
|
+
settings = _fieldDefinition$sett === void 0 ? [] : _fieldDefinition$sett;
|
|
828
822
|
return [].concat(_toConsumableArray(patterns), _toConsumableArray(ColorsParser.fieldIsColor(fieldDefinition) ? [new RegExp("^".concat(path, "$"))] : []), _toConsumableArray(_this2.getColorFieldPatterns(subFields, path)), _toConsumableArray(_this2.getColorFieldPatterns(settings, path)), _toConsumableArray(itemsField !== null ? _this2.getColorFieldPatterns([itemsField], "".concat(path, "\\.[0-9]+")) : []));
|
|
829
823
|
}, []);
|
|
830
824
|
}
|
|
@@ -832,7 +826,7 @@ var ColorsParser = /*#__PURE__*/function () {
|
|
|
832
826
|
key: "fieldIsColor",
|
|
833
827
|
value: function fieldIsColor(_ref5) {
|
|
834
828
|
var _ref5$id = _ref5.id,
|
|
835
|
-
|
|
829
|
+
id = _ref5$id === void 0 ? null : _ref5$id;
|
|
836
830
|
return id === 'color';
|
|
837
831
|
}
|
|
838
832
|
}, {
|
|
@@ -844,8 +838,8 @@ var ColorsParser = /*#__PURE__*/function () {
|
|
|
844
838
|
var keys = dataIsArray ? _toConsumableArray(data.keys()) : Object.keys(data);
|
|
845
839
|
return keys.reduce(function (_ref6, key) {
|
|
846
840
|
var currentData = _ref6.data,
|
|
847
|
-
|
|
848
|
-
|
|
841
|
+
_ref6$colors = _ref6.colors,
|
|
842
|
+
currentColors = _ref6$colors === void 0 ? null : _ref6$colors;
|
|
849
843
|
var path = [keyPrefix, key].filter(function (it) {
|
|
850
844
|
return it !== null;
|
|
851
845
|
}).join('.');
|
|
@@ -856,7 +850,6 @@ var ColorsParser = /*#__PURE__*/function () {
|
|
|
856
850
|
var color = null;
|
|
857
851
|
var newValue = null;
|
|
858
852
|
var subColors = null;
|
|
859
|
-
|
|
860
853
|
if (patternMatch && isObject(value)) {
|
|
861
854
|
if (value.color && value.color.length === 4) {
|
|
862
855
|
var innerColor = value.color.split('').map(function (hex, i) {
|
|
@@ -879,7 +872,6 @@ var ColorsParser = /*#__PURE__*/function () {
|
|
|
879
872
|
} else {
|
|
880
873
|
newValue = value;
|
|
881
874
|
}
|
|
882
|
-
|
|
883
875
|
return {
|
|
884
876
|
data: dataIsArray ? [].concat(_toConsumableArray(currentData || []), [newValue]) : _objectSpread(_objectSpread({}, currentData), {}, _defineProperty({}, key, newValue)),
|
|
885
877
|
colors: color !== null ? [].concat(_toConsumableArray(currentColors || []), _toConsumableArray(subColors || []), [color]) : [].concat(_toConsumableArray(currentColors || []), _toConsumableArray(subColors || []))
|
|
@@ -890,7 +882,6 @@ var ColorsParser = /*#__PURE__*/function () {
|
|
|
890
882
|
});
|
|
891
883
|
}
|
|
892
884
|
}]);
|
|
893
|
-
|
|
894
885
|
return ColorsParser;
|
|
895
886
|
}();
|
|
896
887
|
|
|
@@ -898,32 +889,24 @@ var getComponentFromName = function getComponentFromName() {
|
|
|
898
889
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
899
890
|
var components = arguments.length > 1 ? arguments[1] : undefined;
|
|
900
891
|
var defaultComponent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
901
|
-
|
|
902
892
|
if (components === null || name === null) {
|
|
903
893
|
return defaultComponent;
|
|
904
894
|
}
|
|
905
|
-
|
|
906
895
|
var pascalName = pascalCase(name);
|
|
907
896
|
return components[pascalName] || components[name] || defaultComponent;
|
|
908
897
|
};
|
|
909
898
|
|
|
910
899
|
var ComponentsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
911
900
|
_inherits(ComponentsManager, _EventEmitter);
|
|
912
|
-
|
|
913
901
|
var _super = _createSuper(ComponentsManager);
|
|
914
|
-
|
|
915
902
|
function ComponentsManager() {
|
|
916
903
|
var _this;
|
|
917
|
-
|
|
918
904
|
var components = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
919
|
-
|
|
920
905
|
_classCallCheck(this, ComponentsManager);
|
|
921
|
-
|
|
922
906
|
_this = _super.call(this);
|
|
923
907
|
_this.components = components;
|
|
924
908
|
return _this;
|
|
925
909
|
}
|
|
926
|
-
|
|
927
910
|
_createClass(ComponentsManager, [{
|
|
928
911
|
key: "addComponent",
|
|
929
912
|
value: function addComponent(name, component) {
|
|
@@ -951,11 +934,9 @@ var ComponentsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
951
934
|
key: "addNamespace",
|
|
952
935
|
value: function addNamespace(namespace) {
|
|
953
936
|
var _this2 = this;
|
|
954
|
-
|
|
955
937
|
if (namespace === null) {
|
|
956
938
|
return this;
|
|
957
939
|
}
|
|
958
|
-
|
|
959
940
|
this.components = Object.keys(this.components).reduce(function (componentsMap, name) {
|
|
960
941
|
return _objectSpread(_objectSpread({}, componentsMap), {}, _defineProperty({}, "".concat(namespace, ".").concat(name), _this2.components[name]));
|
|
961
942
|
}, {});
|
|
@@ -972,7 +953,6 @@ var ComponentsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
972
953
|
key: "getComponents",
|
|
973
954
|
value: function getComponents() {
|
|
974
955
|
var _this3 = this;
|
|
975
|
-
|
|
976
956
|
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
977
957
|
return namespace !== null ? Object.keys(this.components || {}).reduce(function (componentsMap, name) {
|
|
978
958
|
var pattern = new RegExp("^".concat(namespace, "\\.(.*)$"));
|
|
@@ -987,27 +967,20 @@ var ComponentsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
987
967
|
return this.components !== null && typeof this.components[namespace !== null ? "".concat(namespace, ".").concat(name) : name] !== 'undefined';
|
|
988
968
|
}
|
|
989
969
|
}]);
|
|
990
|
-
|
|
991
970
|
return ComponentsManager;
|
|
992
971
|
}(EventEmitter);
|
|
993
972
|
|
|
994
973
|
var DefinitionsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
995
974
|
_inherits(DefinitionsManager, _EventEmitter);
|
|
996
|
-
|
|
997
975
|
var _super = _createSuper(DefinitionsManager);
|
|
998
|
-
|
|
999
976
|
function DefinitionsManager() {
|
|
1000
977
|
var _this;
|
|
1001
|
-
|
|
1002
978
|
var definitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1003
|
-
|
|
1004
979
|
_classCallCheck(this, DefinitionsManager);
|
|
1005
|
-
|
|
1006
980
|
_this = _super.call(this);
|
|
1007
981
|
_this.definitions = definitions || [];
|
|
1008
982
|
return _this;
|
|
1009
983
|
}
|
|
1010
|
-
|
|
1011
984
|
_createClass(DefinitionsManager, [{
|
|
1012
985
|
key: "addDefinition",
|
|
1013
986
|
value: function addDefinition(definition) {
|
|
@@ -1041,7 +1014,6 @@ var DefinitionsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1041
1014
|
if (id === null) {
|
|
1042
1015
|
return null;
|
|
1043
1016
|
}
|
|
1044
|
-
|
|
1045
1017
|
return this.definitions.find(function (it) {
|
|
1046
1018
|
return it.id === id;
|
|
1047
1019
|
}) || null;
|
|
@@ -1060,9 +1032,8 @@ var DefinitionsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1060
1032
|
key: "getComponent",
|
|
1061
1033
|
value: function getComponent(id) {
|
|
1062
1034
|
var _ref = this.getDefinition(id) || {},
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1035
|
+
_ref$component = _ref.component,
|
|
1036
|
+
component = _ref$component === void 0 ? null : _ref$component;
|
|
1066
1037
|
return component;
|
|
1067
1038
|
}
|
|
1068
1039
|
}, {
|
|
@@ -1070,39 +1041,32 @@ var DefinitionsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1070
1041
|
value: function getComponents() {
|
|
1071
1042
|
return this.definitions.reduce(function (allComponents, _ref2) {
|
|
1072
1043
|
var id = _ref2.id,
|
|
1073
|
-
|
|
1074
|
-
|
|
1044
|
+
_ref2$component = _ref2.component,
|
|
1045
|
+
component = _ref2$component === void 0 ? null : _ref2$component;
|
|
1075
1046
|
return component !== null ? _objectSpread(_objectSpread({}, allComponents), {}, _defineProperty({}, id, component)) : allComponents;
|
|
1076
1047
|
}, {});
|
|
1077
1048
|
}
|
|
1078
1049
|
}]);
|
|
1079
|
-
|
|
1080
1050
|
return DefinitionsManager;
|
|
1081
1051
|
}(EventEmitter);
|
|
1082
1052
|
|
|
1083
1053
|
var EventsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
1084
1054
|
_inherits(EventsManager, _EventEmitter);
|
|
1085
|
-
|
|
1086
1055
|
var _super = _createSuper(EventsManager);
|
|
1087
|
-
|
|
1088
1056
|
function EventsManager(element) {
|
|
1089
1057
|
var _this;
|
|
1090
|
-
|
|
1091
1058
|
_classCallCheck(this, EventsManager);
|
|
1092
|
-
|
|
1093
1059
|
_this = _super.call(this);
|
|
1094
1060
|
_this.element = element;
|
|
1095
1061
|
_this.events = {};
|
|
1096
1062
|
_this.listeners = {};
|
|
1097
1063
|
return _this;
|
|
1098
1064
|
}
|
|
1099
|
-
|
|
1100
1065
|
_createClass(EventsManager, [{
|
|
1101
1066
|
key: "subscribe",
|
|
1102
1067
|
value: function subscribe(event, callback) {
|
|
1103
1068
|
this.on(event, callback);
|
|
1104
1069
|
this.events = _objectSpread(_objectSpread({}, this.events), {}, _defineProperty({}, event, [].concat(_toConsumableArray(this.events[event] || []), [callback])));
|
|
1105
|
-
|
|
1106
1070
|
if (this.events[event].length === 1) {
|
|
1107
1071
|
this.addEventListener(event);
|
|
1108
1072
|
}
|
|
@@ -1111,20 +1075,16 @@ var EventsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1111
1075
|
key: "unsubscribe",
|
|
1112
1076
|
value: function unsubscribe(event, callback) {
|
|
1113
1077
|
var _this2 = this;
|
|
1114
|
-
|
|
1115
1078
|
this.off(event, callback);
|
|
1116
1079
|
this.events = Object.keys(this.events).reduce(function (newEvents, eventName) {
|
|
1117
1080
|
if (eventName !== event) {
|
|
1118
1081
|
return _objectSpread(_objectSpread({}, newEvents), {}, _defineProperty({}, eventName, _this2.events[eventName]));
|
|
1119
1082
|
}
|
|
1120
|
-
|
|
1121
1083
|
var newListeners = _this2.events[eventName].filter(function (listener) {
|
|
1122
1084
|
return listener !== callback;
|
|
1123
1085
|
});
|
|
1124
|
-
|
|
1125
1086
|
return newListeners.length > 0 ? _objectSpread(_objectSpread({}, newEvents), {}, _defineProperty({}, eventName, newListeners)) : newEvents;
|
|
1126
1087
|
}, {});
|
|
1127
|
-
|
|
1128
1088
|
if (typeof this.events[event] === 'undefined') {
|
|
1129
1089
|
this.removeEventListener(event);
|
|
1130
1090
|
}
|
|
@@ -1133,17 +1093,14 @@ var EventsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1133
1093
|
key: "addEventListener",
|
|
1134
1094
|
value: function addEventListener(event) {
|
|
1135
1095
|
var _this3 = this;
|
|
1136
|
-
|
|
1137
1096
|
if (typeof this.listeners[event] === 'undefined') {
|
|
1138
1097
|
this.listeners[event] = function () {
|
|
1139
1098
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1140
1099
|
args[_key] = arguments[_key];
|
|
1141
1100
|
}
|
|
1142
|
-
|
|
1143
1101
|
return _this3.emit.apply(_this3, [event].concat(args));
|
|
1144
1102
|
};
|
|
1145
1103
|
}
|
|
1146
|
-
|
|
1147
1104
|
this.element.addEventListener(event, this.listeners[event]);
|
|
1148
1105
|
}
|
|
1149
1106
|
}, {
|
|
@@ -1152,135 +1109,116 @@ var EventsManager = /*#__PURE__*/function (_EventEmitter) {
|
|
|
1152
1109
|
this.element.removeEventListener(event, this.listeners[event]);
|
|
1153
1110
|
}
|
|
1154
1111
|
}]);
|
|
1155
|
-
|
|
1156
1112
|
return EventsManager;
|
|
1157
1113
|
}(EventEmitter);
|
|
1158
1114
|
|
|
1159
1115
|
var FieldsManager = /*#__PURE__*/function (_DefinitionsManager) {
|
|
1160
1116
|
_inherits(FieldsManager, _DefinitionsManager);
|
|
1161
|
-
|
|
1162
1117
|
var _super = _createSuper(FieldsManager);
|
|
1163
|
-
|
|
1164
1118
|
function FieldsManager() {
|
|
1165
1119
|
_classCallCheck(this, FieldsManager);
|
|
1166
|
-
|
|
1167
1120
|
return _super.apply(this, arguments);
|
|
1168
1121
|
}
|
|
1169
|
-
|
|
1170
1122
|
_createClass(FieldsManager, [{
|
|
1171
1123
|
key: "filter",
|
|
1172
1124
|
value: function filter(_filter) {
|
|
1173
|
-
return new FieldsManager(this.definitions.filter(_filter));
|
|
1125
|
+
return new FieldsManager(this.definitions.filter(_filter));
|
|
1126
|
+
// this.definitions = this.definitions.filter(filter);
|
|
1174
1127
|
// return this;
|
|
1175
1128
|
}
|
|
1176
1129
|
}]);
|
|
1177
|
-
|
|
1178
1130
|
return FieldsManager;
|
|
1179
1131
|
}(DefinitionsManager);
|
|
1180
1132
|
|
|
1181
1133
|
var _excluded$3 = ["medias"];
|
|
1182
|
-
|
|
1183
1134
|
var MediasParser = /*#__PURE__*/function () {
|
|
1184
1135
|
function MediasParser(_ref) {
|
|
1185
1136
|
var fieldsManager = _ref.fieldsManager,
|
|
1186
|
-
|
|
1187
|
-
|
|
1137
|
+
screensManager = _ref.screensManager;
|
|
1188
1138
|
_classCallCheck(this, MediasParser);
|
|
1189
|
-
|
|
1190
1139
|
this.fieldsManager = fieldsManager;
|
|
1191
1140
|
this.screensManager = screensManager;
|
|
1192
1141
|
this.fieldsPatternCache = {};
|
|
1193
1142
|
}
|
|
1194
|
-
|
|
1195
1143
|
_createClass(MediasParser, [{
|
|
1196
1144
|
key: "getFieldsPatternByScreen",
|
|
1197
1145
|
value: function getFieldsPatternByScreen(type) {
|
|
1198
1146
|
if (typeof this.fieldsPatternCache[type] === 'undefined') {
|
|
1199
1147
|
var _ref2 = this.screensManager.getDefinition(type) || {},
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1148
|
+
_ref2$fields = _ref2.fields,
|
|
1149
|
+
fields = _ref2$fields === void 0 ? [] : _ref2$fields;
|
|
1203
1150
|
this.fieldsPatternCache[type] = this.getMediaFieldsPattern(fields);
|
|
1204
1151
|
}
|
|
1205
|
-
|
|
1206
1152
|
return this.fieldsPatternCache[type];
|
|
1207
|
-
}
|
|
1153
|
+
}
|
|
1208
1154
|
|
|
1155
|
+
// Convert medias object to path
|
|
1209
1156
|
}, {
|
|
1210
1157
|
key: "toPath",
|
|
1211
1158
|
value: function toPath(story) {
|
|
1212
1159
|
var _this = this;
|
|
1213
|
-
|
|
1214
1160
|
if (story === null) {
|
|
1215
1161
|
return story;
|
|
1216
1162
|
}
|
|
1217
|
-
|
|
1218
1163
|
var _ref3 = story || {},
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1164
|
+
_ref3$theme = _ref3.theme,
|
|
1165
|
+
theme = _ref3$theme === void 0 ? null : _ref3$theme,
|
|
1166
|
+
_ref3$components = _ref3.components,
|
|
1167
|
+
components = _ref3$components === void 0 ? [] : _ref3$components;
|
|
1224
1168
|
var _components$reduce = components.reduce(function (_ref4, screen) {
|
|
1225
|
-
|
|
1169
|
+
var previousComponents = _ref4.components,
|
|
1226
1170
|
currentMedias = _ref4.medias;
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
var _MediasParser$replace = MediasParser.replaceMediasWithPaths(screen, fieldsPattern),
|
|
1171
|
+
var type = screen.type;
|
|
1172
|
+
var fieldsPattern = _this.getFieldsPatternByScreen(type);
|
|
1173
|
+
var _MediasParser$replace = MediasParser.replaceMediasWithPaths(screen, fieldsPattern),
|
|
1232
1174
|
newScreen = _MediasParser$replace.data,
|
|
1233
1175
|
newMedias = _MediasParser$replace.medias;
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
medias = _components$reduce.medias;
|
|
1245
|
-
|
|
1176
|
+
return {
|
|
1177
|
+
components: [].concat(_toConsumableArray(previousComponents), [newScreen]),
|
|
1178
|
+
medias: _objectSpread(_objectSpread({}, currentMedias), newMedias)
|
|
1179
|
+
};
|
|
1180
|
+
}, {
|
|
1181
|
+
components: [],
|
|
1182
|
+
medias: null
|
|
1183
|
+
}),
|
|
1184
|
+
newComponents = _components$reduce.components,
|
|
1185
|
+
medias = _components$reduce.medias;
|
|
1246
1186
|
if (theme !== null) {
|
|
1247
1187
|
var _this$toPath = this.toPath(theme),
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1188
|
+
themeMedias = _this$toPath.medias,
|
|
1189
|
+
newTheme = _objectWithoutProperties(_this$toPath, _excluded$3);
|
|
1251
1190
|
return medias !== null || themeMedias !== null ? _objectSpread(_objectSpread({}, story), {}, {
|
|
1252
1191
|
theme: newTheme,
|
|
1253
1192
|
components: newComponents,
|
|
1254
1193
|
medias: _objectSpread(_objectSpread({}, themeMedias), medias)
|
|
1255
1194
|
}) : story;
|
|
1256
1195
|
}
|
|
1257
|
-
|
|
1258
1196
|
return medias !== null ? _objectSpread(_objectSpread({}, story), {}, {
|
|
1259
1197
|
components: newComponents,
|
|
1260
1198
|
medias: medias
|
|
1261
1199
|
}) : story;
|
|
1262
|
-
}
|
|
1200
|
+
}
|
|
1263
1201
|
|
|
1202
|
+
// Convert path to medias object
|
|
1264
1203
|
}, {
|
|
1265
1204
|
key: "fromPath",
|
|
1266
1205
|
value: function fromPath(story) {
|
|
1267
1206
|
var defaultMedias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1268
|
-
|
|
1269
1207
|
if (story === null) {
|
|
1270
1208
|
return story;
|
|
1271
1209
|
}
|
|
1272
|
-
|
|
1273
1210
|
var _ref5 = story || {},
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1211
|
+
_ref5$theme = _ref5.theme,
|
|
1212
|
+
theme = _ref5$theme === void 0 ? null : _ref5$theme,
|
|
1213
|
+
_ref5$components = _ref5.components,
|
|
1214
|
+
components = _ref5$components === void 0 ? [] : _ref5$components,
|
|
1215
|
+
_ref5$medias = _ref5.medias,
|
|
1216
|
+
medias = _ref5$medias === void 0 ? defaultMedias : _ref5$medias;
|
|
1281
1217
|
if (medias === null && theme === null) {
|
|
1282
1218
|
return story;
|
|
1283
|
-
}
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// Replace path with medias objects
|
|
1284
1222
|
// const newComponents =
|
|
1285
1223
|
// medias !== null
|
|
1286
1224
|
// ? components.map((screen) => {
|
|
@@ -1289,12 +1227,12 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1289
1227
|
// return MediasParser.replacePathsWithMedias(screen, medias, fieldsPattern);
|
|
1290
1228
|
// })
|
|
1291
1229
|
// : components;
|
|
1292
|
-
// Faster parsing with data only
|
|
1293
|
-
|
|
1294
1230
|
|
|
1231
|
+
// Faster parsing with data only
|
|
1295
1232
|
var componentsPattern = MediasParser.getMediaPatternsFromData(components);
|
|
1296
|
-
var newComponents = medias !== null && componentsPattern.length > 0 ? MediasParser.replacePathsWithMedias(components, medias, componentsPattern) : components;
|
|
1233
|
+
var newComponents = medias !== null && componentsPattern.length > 0 ? MediasParser.replacePathsWithMedias(components, medias, componentsPattern) : components;
|
|
1297
1234
|
|
|
1235
|
+
// Replace path with medias object in theme
|
|
1298
1236
|
if (theme !== null) {
|
|
1299
1237
|
var newTheme = this.fromPath(theme, medias);
|
|
1300
1238
|
return newTheme !== theme || newComponents !== components ? _objectSpread(_objectSpread({}, story), {}, {
|
|
@@ -1302,7 +1240,6 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1302
1240
|
components: newComponents
|
|
1303
1241
|
}) : story;
|
|
1304
1242
|
}
|
|
1305
|
-
|
|
1306
1243
|
return newComponents !== components ? _objectSpread(_objectSpread({}, story), {}, {
|
|
1307
1244
|
components: newComponents
|
|
1308
1245
|
}) : story;
|
|
@@ -1311,26 +1248,24 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1311
1248
|
key: "getMediaFieldsPattern",
|
|
1312
1249
|
value: function getMediaFieldsPattern(fields) {
|
|
1313
1250
|
var _this2 = this;
|
|
1314
|
-
|
|
1315
1251
|
var namePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1316
1252
|
return fields.reduce(function (patterns, field) {
|
|
1317
1253
|
var _field$name = field.name,
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1254
|
+
name = _field$name === void 0 ? null : _field$name,
|
|
1255
|
+
_field$type = field.type,
|
|
1256
|
+
type = _field$type === void 0 ? null : _field$type;
|
|
1321
1257
|
var path = [namePrefix, name].filter(function (it) {
|
|
1322
1258
|
return it !== null;
|
|
1323
1259
|
}).join('\\.');
|
|
1260
|
+
var fieldDefinition = _objectSpread(_objectSpread({}, type !== null ? _this2.fieldsManager.getDefinition(type) : null), field);
|
|
1324
1261
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1262
|
+
// also check settings fields
|
|
1328
1263
|
var _fieldDefinition$fiel = fieldDefinition.fields,
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1264
|
+
subFields = _fieldDefinition$fiel === void 0 ? [] : _fieldDefinition$fiel,
|
|
1265
|
+
_fieldDefinition$item = fieldDefinition.itemsField,
|
|
1266
|
+
itemsField = _fieldDefinition$item === void 0 ? null : _fieldDefinition$item,
|
|
1267
|
+
_fieldDefinition$sett = fieldDefinition.settings,
|
|
1268
|
+
settings = _fieldDefinition$sett === void 0 ? [] : _fieldDefinition$sett;
|
|
1334
1269
|
return [].concat(_toConsumableArray(patterns), _toConsumableArray(MediasParser.fieldIsMedia(fieldDefinition) ? [new RegExp("^".concat(path, "$"))] : []), _toConsumableArray(MediasParser.fieldIsFontFamily(fieldDefinition) ? [new RegExp("^".concat(path, "\\.media$")), new RegExp("^".concat(path, "\\.variants\\.[0-9]+\\.media$"))] : []), _toConsumableArray(_this2.getMediaFieldsPattern(subFields, path)), _toConsumableArray(_this2.getMediaFieldsPattern(settings, path)), _toConsumableArray(itemsField !== null ? _this2.getMediaFieldsPattern([itemsField], "".concat(path, "\\.[0-9]+")) : []));
|
|
1335
1270
|
}, []);
|
|
1336
1271
|
}
|
|
@@ -1338,14 +1273,14 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1338
1273
|
key: "fieldIsMedia",
|
|
1339
1274
|
value: function fieldIsMedia(_ref6) {
|
|
1340
1275
|
var _ref6$media = _ref6.media,
|
|
1341
|
-
|
|
1276
|
+
media = _ref6$media === void 0 ? false : _ref6$media;
|
|
1342
1277
|
return media;
|
|
1343
1278
|
}
|
|
1344
1279
|
}, {
|
|
1345
1280
|
key: "fieldIsFontFamily",
|
|
1346
1281
|
value: function fieldIsFontFamily(_ref7) {
|
|
1347
1282
|
var _ref7$id = _ref7.id,
|
|
1348
|
-
|
|
1283
|
+
id = _ref7$id === void 0 ? null : _ref7$id;
|
|
1349
1284
|
return id === 'font-family';
|
|
1350
1285
|
}
|
|
1351
1286
|
}, {
|
|
@@ -1362,13 +1297,11 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1362
1297
|
}, false);
|
|
1363
1298
|
var value = data[key];
|
|
1364
1299
|
var newValue;
|
|
1365
|
-
|
|
1366
1300
|
if (patternMatch) {
|
|
1367
1301
|
newValue = isObject(value) ? value : medias[value] || value;
|
|
1368
1302
|
} else {
|
|
1369
1303
|
newValue = isObject(value) || isArray(value) ? MediasParser.replacePathsWithMedias(value, medias, patterns, path) : value;
|
|
1370
1304
|
}
|
|
1371
|
-
|
|
1372
1305
|
return dataIsArray ? [].concat(_toConsumableArray(newData), [newValue]) : _objectSpread(_objectSpread({}, newData), {}, _defineProperty({}, key, newValue));
|
|
1373
1306
|
}, dataIsArray ? [] : {});
|
|
1374
1307
|
}
|
|
@@ -1376,7 +1309,7 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1376
1309
|
key: "getMediaPath",
|
|
1377
1310
|
value: function getMediaPath(_ref8) {
|
|
1378
1311
|
var _ref8$id = _ref8.id,
|
|
1379
|
-
|
|
1312
|
+
id = _ref8$id === void 0 ? null : _ref8$id;
|
|
1380
1313
|
return id !== null ? "media://".concat(id) : null;
|
|
1381
1314
|
}
|
|
1382
1315
|
}, {
|
|
@@ -1388,7 +1321,7 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1388
1321
|
var dataKeys = MediasParser.keys(data);
|
|
1389
1322
|
return dataKeys.reduce(function (_ref9, key) {
|
|
1390
1323
|
var currentData = _ref9.data,
|
|
1391
|
-
|
|
1324
|
+
currentMedias = _ref9.medias;
|
|
1392
1325
|
var path = [keyPrefix, key].filter(function (it) {
|
|
1393
1326
|
return it !== null;
|
|
1394
1327
|
}).join('.');
|
|
@@ -1399,7 +1332,6 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1399
1332
|
var newValue;
|
|
1400
1333
|
var media = null;
|
|
1401
1334
|
var subMedias = null;
|
|
1402
|
-
|
|
1403
1335
|
if (patternMatch && isObject(value)) {
|
|
1404
1336
|
var mediaPath = MediasParser.getMediaPath(value);
|
|
1405
1337
|
newValue = mediaPath !== null ? mediaPath : value;
|
|
@@ -1411,7 +1343,6 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1411
1343
|
} else {
|
|
1412
1344
|
newValue = value;
|
|
1413
1345
|
}
|
|
1414
|
-
|
|
1415
1346
|
return {
|
|
1416
1347
|
data: dataIsArray ? [].concat(_toConsumableArray(currentData || []), [newValue]) : _objectSpread(_objectSpread({}, currentData), {}, _defineProperty({}, key, newValue)),
|
|
1417
1348
|
medias: media !== null ? _objectSpread(_objectSpread(_objectSpread({}, currentMedias), subMedias), {}, _defineProperty({}, newValue, media)) : _objectSpread(_objectSpread({}, currentMedias), subMedias)
|
|
@@ -1438,7 +1369,6 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1438
1369
|
if (_typeof(obj[key]) !== 'object' || !obj[key]) {
|
|
1439
1370
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, obj[key]));
|
|
1440
1371
|
}
|
|
1441
|
-
|
|
1442
1372
|
var flattenedChild = MediasParser.dot(obj[key]);
|
|
1443
1373
|
return _objectSpread(_objectSpread({}, acc), MediasParser.keys(flattenedChild).reduce(function (childAcc, childKey) {
|
|
1444
1374
|
return _objectSpread(_objectSpread({}, childAcc), {}, _defineProperty({}, "".concat(key, ".").concat(childKey), flattenedChild[childKey]));
|
|
@@ -1451,62 +1381,51 @@ var MediasParser = /*#__PURE__*/function () {
|
|
|
1451
1381
|
return isArray(obj) ? _toConsumableArray(obj.keys()) : Object.keys(obj);
|
|
1452
1382
|
}
|
|
1453
1383
|
}]);
|
|
1454
|
-
|
|
1455
1384
|
return MediasParser;
|
|
1456
1385
|
}();
|
|
1457
1386
|
|
|
1458
1387
|
var ScreensManager = /*#__PURE__*/function (_DefinitionsManager) {
|
|
1459
1388
|
_inherits(ScreensManager, _DefinitionsManager);
|
|
1460
|
-
|
|
1461
1389
|
var _super = _createSuper(ScreensManager);
|
|
1462
|
-
|
|
1463
1390
|
function ScreensManager() {
|
|
1464
1391
|
_classCallCheck(this, ScreensManager);
|
|
1465
|
-
|
|
1466
1392
|
return _super.apply(this, arguments);
|
|
1467
1393
|
}
|
|
1468
|
-
|
|
1469
1394
|
_createClass(ScreensManager, [{
|
|
1470
1395
|
key: "getFields",
|
|
1471
1396
|
value: function getFields(id) {
|
|
1472
1397
|
var _ref = this.getDefinition(id) || {},
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1398
|
+
_ref$fields = _ref.fields,
|
|
1399
|
+
fields = _ref$fields === void 0 ? null : _ref$fields;
|
|
1476
1400
|
return fields;
|
|
1477
1401
|
}
|
|
1478
1402
|
}, {
|
|
1479
1403
|
key: "getLayouts",
|
|
1480
1404
|
value: function getLayouts(id) {
|
|
1481
1405
|
var _ref2 = this.getDefinition(id) || {},
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1406
|
+
_ref2$layouts = _ref2.layouts,
|
|
1407
|
+
layouts = _ref2$layouts === void 0 ? null : _ref2$layouts;
|
|
1485
1408
|
return layouts;
|
|
1486
1409
|
}
|
|
1487
1410
|
}, {
|
|
1488
1411
|
key: "filter",
|
|
1489
1412
|
value: function filter(_filter) {
|
|
1490
|
-
return new ScreensManager(this.definitions.filter(_filter));
|
|
1413
|
+
return new ScreensManager(this.definitions.filter(_filter));
|
|
1414
|
+
// this.definitions = this.definitions.filter(filter);
|
|
1491
1415
|
// return this;
|
|
1492
1416
|
}
|
|
1493
1417
|
}]);
|
|
1494
|
-
|
|
1495
1418
|
return ScreensManager;
|
|
1496
1419
|
}(DefinitionsManager);
|
|
1497
1420
|
|
|
1498
1421
|
var _excluded$2 = ["textStyle", "color", "boxStyle"];
|
|
1499
|
-
|
|
1500
1422
|
var ThemeParser = /*#__PURE__*/function () {
|
|
1501
1423
|
function ThemeParser(_ref) {
|
|
1502
1424
|
var screensManager = _ref.screensManager;
|
|
1503
|
-
|
|
1504
1425
|
_classCallCheck(this, ThemeParser);
|
|
1505
|
-
|
|
1506
1426
|
this.screensManager = screensManager;
|
|
1507
1427
|
this.definitionCache = {};
|
|
1508
1428
|
}
|
|
1509
|
-
|
|
1510
1429
|
_createClass(ThemeParser, [{
|
|
1511
1430
|
key: "getDefinitionByScreen",
|
|
1512
1431
|
value: function getDefinitionByScreen(type, themeComponents) {
|
|
@@ -1520,48 +1439,41 @@ var ThemeParser = /*#__PURE__*/function () {
|
|
|
1520
1439
|
themeScreen: themeScreen
|
|
1521
1440
|
};
|
|
1522
1441
|
}
|
|
1523
|
-
|
|
1524
1442
|
return this.definitionCache[type];
|
|
1525
1443
|
}
|
|
1526
1444
|
}, {
|
|
1527
1445
|
key: "parse",
|
|
1528
1446
|
value: function parse(story) {
|
|
1529
1447
|
var _this = this;
|
|
1530
|
-
|
|
1531
1448
|
if (story === null) {
|
|
1532
1449
|
return story;
|
|
1533
1450
|
}
|
|
1534
|
-
|
|
1535
1451
|
var _ref2 = story || {},
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1452
|
+
_ref2$theme = _ref2.theme,
|
|
1453
|
+
theme = _ref2$theme === void 0 ? null : _ref2$theme,
|
|
1454
|
+
_ref2$components = _ref2.components,
|
|
1455
|
+
components = _ref2$components === void 0 ? null : _ref2$components;
|
|
1541
1456
|
if (theme === null || components === null) {
|
|
1542
1457
|
return story;
|
|
1543
1458
|
}
|
|
1544
|
-
|
|
1545
1459
|
var _theme$components = theme.components,
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1460
|
+
themeComponents = _theme$components === void 0 ? [] : _theme$components,
|
|
1461
|
+
_theme$background = theme.background,
|
|
1462
|
+
themeBackground = _theme$background === void 0 ? null : _theme$background,
|
|
1463
|
+
_theme$colors = theme.colors,
|
|
1464
|
+
themeColors = _theme$colors === void 0 ? {} : _theme$colors,
|
|
1465
|
+
_theme$textStyles = theme.textStyles,
|
|
1466
|
+
themeTextStyles = _theme$textStyles === void 0 ? null : _theme$textStyles,
|
|
1467
|
+
_theme$boxStyles = theme.boxStyles,
|
|
1468
|
+
themeBoxStyles = _theme$boxStyles === void 0 ? null : _theme$boxStyles;
|
|
1555
1469
|
var newComponents = components.reduce(function (currentComponents, screen, index) {
|
|
1556
1470
|
var type = screen.type;
|
|
1557
|
-
|
|
1558
1471
|
var _this$getDefinitionBy = _this.getDefinitionByScreen(type, themeComponents),
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles, themeBoxStyles); // Only switch screen if it has changed
|
|
1563
|
-
|
|
1472
|
+
definition = _this$getDefinitionBy.definition,
|
|
1473
|
+
themeScreen = _this$getDefinitionBy.themeScreen;
|
|
1474
|
+
var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles, themeBoxStyles);
|
|
1564
1475
|
|
|
1476
|
+
// Only switch screen if it has changed
|
|
1565
1477
|
return newScreen !== screen || themeScreen !== null ? [].concat(_toConsumableArray(currentComponents.slice(0, index)), [_objectSpread(_objectSpread({}, themeScreen), newScreen)], _toConsumableArray(currentComponents.slice(index + 1))) : currentComponents;
|
|
1566
1478
|
}, components);
|
|
1567
1479
|
return newComponents !== components ? _objectSpread(_objectSpread({}, story), {}, {
|
|
@@ -1572,43 +1484,41 @@ var ThemeParser = /*#__PURE__*/function () {
|
|
|
1572
1484
|
key: "parseScreen",
|
|
1573
1485
|
value: function parseScreen(definition, value, themeValue, themeBackground, themeColors, themeTextStyles, themeBoxStyles) {
|
|
1574
1486
|
var _this2 = this;
|
|
1575
|
-
|
|
1576
1487
|
var _definition$fields = definition.fields,
|
|
1577
|
-
|
|
1488
|
+
fields = _definition$fields === void 0 ? [] : _definition$fields;
|
|
1578
1489
|
var newThemeValue = themeValue === null && themeBackground !== null ? {} : themeValue;
|
|
1579
|
-
|
|
1580
1490
|
if (themeBackground !== null && typeof newThemeValue.background !== 'undefined') {
|
|
1581
1491
|
newThemeValue.background = _objectSpread(_objectSpread({}, themeBackground), newThemeValue.background);
|
|
1582
1492
|
} else if (themeBackground !== null) {
|
|
1583
1493
|
newThemeValue.background = themeBackground;
|
|
1584
1494
|
}
|
|
1585
|
-
|
|
1586
1495
|
var newScreenValue = Object.keys(value).reduce(function (currentValue, key) {
|
|
1587
1496
|
var fieldDefinition = fields.find(function (it) {
|
|
1588
1497
|
return it.name === key;
|
|
1589
1498
|
}) || {};
|
|
1590
1499
|
var fieldValue = value[key];
|
|
1591
1500
|
var fieldThemeValue = newThemeValue !== null ? newThemeValue[key] || null : null;
|
|
1501
|
+
var newFieldValue = _this2.parseField(key, fieldDefinition, fieldValue, fieldThemeValue, themeColors, themeTextStyles, themeBoxStyles);
|
|
1592
1502
|
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1503
|
+
// Only switch field if it has changed
|
|
1596
1504
|
return newFieldValue !== fieldValue ? _objectSpread(_objectSpread({}, currentValue), {}, _defineProperty({}, key, newFieldValue)) : currentValue;
|
|
1597
1505
|
}, value);
|
|
1598
1506
|
return newThemeValue !== null ? _objectSpread(_objectSpread({}, newThemeValue), newScreenValue) : newScreenValue;
|
|
1599
|
-
}
|
|
1507
|
+
}
|
|
1600
1508
|
|
|
1509
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1601
1510
|
}, {
|
|
1602
1511
|
key: "parseField",
|
|
1603
1512
|
value: function parseField(key, definition, value, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
|
|
1604
1513
|
var _definition$theme = definition.theme,
|
|
1605
|
-
|
|
1514
|
+
fieldTheme = _definition$theme === void 0 ? null : _definition$theme;
|
|
1606
1515
|
|
|
1516
|
+
// Early return
|
|
1607
1517
|
if (fieldTheme === null || !isObject(fieldTheme)) {
|
|
1608
1518
|
return value;
|
|
1609
|
-
}
|
|
1610
|
-
|
|
1519
|
+
}
|
|
1611
1520
|
|
|
1521
|
+
// @TODO very sloow
|
|
1612
1522
|
if (isArray(value)) {
|
|
1613
1523
|
var newFieldValue = value.map(function (innerField) {
|
|
1614
1524
|
return innerField !== null ? Object.keys(innerField).reduce(function (newInnerField, innerFieldName) {
|
|
@@ -1616,182 +1526,163 @@ var ThemeParser = /*#__PURE__*/function () {
|
|
|
1616
1526
|
if (!isObject(innerField[innerFieldName])) {
|
|
1617
1527
|
return newInnerField;
|
|
1618
1528
|
}
|
|
1619
|
-
|
|
1620
1529
|
var _ref3 = fieldTheme[innerFieldName] || {},
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1530
|
+
_ref3$textStyle = _ref3.textStyle,
|
|
1531
|
+
innerFieldTextStyle = _ref3$textStyle === void 0 ? null : _ref3$textStyle,
|
|
1532
|
+
_ref3$color = _ref3.color,
|
|
1533
|
+
innerFieldColor = _ref3$color === void 0 ? null : _ref3$color,
|
|
1534
|
+
_ref3$boxStyle = _ref3.boxStyle,
|
|
1535
|
+
innerFieldBoxStyle = _ref3$boxStyle === void 0 ? null : _ref3$boxStyle;
|
|
1536
|
+
|
|
1537
|
+
// Early return, no theme
|
|
1629
1538
|
if (innerFieldTextStyle === null && innerFieldColor === null && innerFieldBoxStyle === null) {
|
|
1630
1539
|
return newInnerField;
|
|
1631
|
-
}
|
|
1632
|
-
// Color
|
|
1540
|
+
}
|
|
1633
1541
|
|
|
1542
|
+
// TODO: replace this with the recursive parseValue...
|
|
1634
1543
|
|
|
1544
|
+
// Color
|
|
1635
1545
|
var colorValue = innerFieldColor !== null ? {
|
|
1636
1546
|
color: innerFieldColor !== null && themeColors !== null ? themeColors[innerFieldColor] || null : null
|
|
1637
|
-
} : null;
|
|
1547
|
+
} : null;
|
|
1638
1548
|
|
|
1549
|
+
// Text style
|
|
1639
1550
|
var textStyleValue = innerFieldTextStyle !== null ? {
|
|
1640
1551
|
textStyle: _objectSpread(_objectSpread({}, innerFieldTextStyle !== null && themeTextStyles !== null ? themeTextStyles[innerFieldTextStyle] || null : null), innerField[innerFieldName].textStyle || null)
|
|
1641
1552
|
} : null;
|
|
1642
1553
|
var boxStyleValue = innerFieldBoxStyle !== null ? {
|
|
1643
1554
|
boxStyle: _objectSpread(_objectSpread({}, innerFieldBoxStyle !== null && themeBoxStyles !== null ? themeBoxStyles[innerFieldBoxStyle] || null : null), innerField[innerFieldName].boxStyle || null)
|
|
1644
1555
|
} : null;
|
|
1645
|
-
|
|
1646
1556
|
if (colorValue === null && textStyleValue === null && boxStyleValue === null) {
|
|
1647
1557
|
return newInnerField;
|
|
1648
1558
|
}
|
|
1649
|
-
|
|
1650
1559
|
return _objectSpread(_objectSpread({}, newInnerField), {}, _defineProperty({}, innerFieldName, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colorValue), innerField[innerFieldName]), textStyleValue), boxStyleValue)));
|
|
1651
1560
|
}, innerField) : innerField;
|
|
1652
1561
|
});
|
|
1653
1562
|
return newFieldValue;
|
|
1654
1563
|
}
|
|
1655
|
-
|
|
1656
1564
|
if (isObject(value)) {
|
|
1657
1565
|
return this.parseValue(value, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles);
|
|
1658
1566
|
}
|
|
1659
|
-
|
|
1660
1567
|
return value;
|
|
1661
|
-
}
|
|
1568
|
+
}
|
|
1662
1569
|
|
|
1570
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1663
1571
|
}, {
|
|
1664
1572
|
key: "parseValue",
|
|
1665
1573
|
value: function parseValue(initialValue, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
|
|
1666
1574
|
var _this3 = this;
|
|
1667
|
-
|
|
1668
1575
|
if (isObject(initialValue) || isObject(fieldTheme)) {
|
|
1669
1576
|
var value = initialValue || null;
|
|
1670
|
-
|
|
1671
1577
|
var _ref4 = fieldTheme || {},
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1578
|
+
_ref4$textStyle = _ref4.textStyle,
|
|
1579
|
+
fieldTextStyleName = _ref4$textStyle === void 0 ? null : _ref4$textStyle,
|
|
1580
|
+
_ref4$color = _ref4.color,
|
|
1581
|
+
fieldColorName = _ref4$color === void 0 ? null : _ref4$color,
|
|
1582
|
+
_ref4$boxStyle = _ref4.boxStyle,
|
|
1583
|
+
fieldBoxStyleName = _ref4$boxStyle === void 0 ? null : _ref4$boxStyle,
|
|
1584
|
+
otherProps = _objectWithoutProperties(_ref4, _excluded$2);
|
|
1680
1585
|
if (fieldTextStyleName === null && fieldColorName === null && fieldBoxStyleName === null && isEmpty(otherProps) && !isObject(fieldTheme)) {
|
|
1681
1586
|
return value;
|
|
1682
1587
|
}
|
|
1683
|
-
|
|
1684
1588
|
var complexValue = null;
|
|
1685
|
-
|
|
1686
1589
|
if (!isEmpty(otherProps)) {
|
|
1687
1590
|
complexValue = Object.keys(fieldTheme).reduce(function (newObject, key) {
|
|
1688
1591
|
var innerValue = value !== null ? value[key] || null : null;
|
|
1689
|
-
|
|
1690
1592
|
var newValue = _this3.parseValue(innerValue, fieldTheme[key], themeValue, themeColors, themeTextStyles, themeBoxStyles);
|
|
1691
|
-
|
|
1692
1593
|
return _objectSpread(_objectSpread({}, newObject), newValue !== null ? _defineProperty({}, key, newValue) : null);
|
|
1693
1594
|
}, {});
|
|
1694
1595
|
}
|
|
1695
|
-
|
|
1696
1596
|
var _ref6 = value || {},
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1597
|
+
_ref6$textStyle = _ref6.textStyle,
|
|
1598
|
+
valueTextStyle = _ref6$textStyle === void 0 ? null : _ref6$textStyle,
|
|
1599
|
+
_ref6$boxStyle = _ref6.boxStyle,
|
|
1600
|
+
valueBoxStyle = _ref6$boxStyle === void 0 ? null : _ref6$boxStyle;
|
|
1702
1601
|
|
|
1602
|
+
// Color
|
|
1703
1603
|
var fieldColor = fieldColorName !== null && themeColors !== null ? themeColors[fieldColorName] || null : null;
|
|
1704
1604
|
var colorValue = fieldColor !== null ? {
|
|
1705
1605
|
color: fieldColor
|
|
1706
|
-
} : null;
|
|
1606
|
+
} : null;
|
|
1707
1607
|
|
|
1608
|
+
// Text style
|
|
1708
1609
|
var fieldTextStyle = fieldTextStyleName !== null && themeTextStyles !== null ? themeTextStyles[fieldTextStyleName] || null : null;
|
|
1709
1610
|
var fieldThemeComponentTextStyle = themeValue !== null ? themeValue.textStyle || null : null;
|
|
1710
1611
|
var textStyleValue = fieldTextStyle !== null || fieldThemeComponentTextStyle !== null ? {
|
|
1711
1612
|
textStyle: _objectSpread(_objectSpread(_objectSpread({}, fieldTextStyle), fieldThemeComponentTextStyle), valueTextStyle || null)
|
|
1712
|
-
} : null;
|
|
1613
|
+
} : null;
|
|
1713
1614
|
|
|
1615
|
+
// Box style
|
|
1714
1616
|
var fieldBoxStyle = fieldBoxStyleName !== null && themeBoxStyles !== null ? themeBoxStyles[fieldBoxStyleName] || null : null;
|
|
1715
1617
|
var fieldThemeComponentBoxStyle = themeValue !== null ? themeValue.boxStyle || null : null;
|
|
1716
1618
|
var boxStyleValue = fieldBoxStyle !== null || fieldThemeComponentBoxStyle !== null ? {
|
|
1717
1619
|
boxStyle: _objectSpread(_objectSpread(_objectSpread({}, fieldBoxStyle), fieldThemeComponentBoxStyle), valueBoxStyle || null)
|
|
1718
|
-
} : null;
|
|
1620
|
+
} : null;
|
|
1719
1621
|
|
|
1622
|
+
// Only change value if something is overrided
|
|
1720
1623
|
return colorValue !== null || themeValue !== null || textStyleValue !== null || boxStyleValue !== null || complexValue !== null ? _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colorValue), themeValue), value), boxStyleValue), textStyleValue), complexValue) : value;
|
|
1721
1624
|
}
|
|
1722
|
-
|
|
1723
1625
|
return initialValue;
|
|
1724
1626
|
}
|
|
1725
1627
|
}]);
|
|
1726
|
-
|
|
1727
1628
|
return ThemeParser;
|
|
1728
1629
|
}();
|
|
1729
1630
|
|
|
1730
1631
|
var _excluded$1 = ["fonts"];
|
|
1731
|
-
|
|
1732
1632
|
var FontsParser = /*#__PURE__*/function () {
|
|
1733
1633
|
function FontsParser(_ref) {
|
|
1734
1634
|
var fieldsManager = _ref.fieldsManager,
|
|
1735
|
-
|
|
1736
|
-
|
|
1635
|
+
screensManager = _ref.screensManager;
|
|
1737
1636
|
_classCallCheck(this, FontsParser);
|
|
1738
|
-
|
|
1739
1637
|
this.fieldsManager = fieldsManager;
|
|
1740
1638
|
this.screensManager = screensManager;
|
|
1741
1639
|
this.fieldsPatternCache = {};
|
|
1742
1640
|
}
|
|
1743
|
-
|
|
1744
1641
|
_createClass(FontsParser, [{
|
|
1745
1642
|
key: "getFieldsPatternByScreen",
|
|
1746
1643
|
value: function getFieldsPatternByScreen(type) {
|
|
1747
1644
|
if (typeof this.fieldsPatternCache[type] === 'undefined') {
|
|
1748
1645
|
var _ref2 = this.screensManager.getDefinition(type) || {},
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1646
|
+
_ref2$fields = _ref2.fields,
|
|
1647
|
+
fields = _ref2$fields === void 0 ? [] : _ref2$fields;
|
|
1752
1648
|
this.fieldsPatternCache[type] = this.getFieldsPattern(fields);
|
|
1753
1649
|
}
|
|
1754
|
-
|
|
1755
1650
|
return this.fieldsPatternCache[type];
|
|
1756
|
-
}
|
|
1651
|
+
}
|
|
1757
1652
|
|
|
1653
|
+
// Extract fonts
|
|
1758
1654
|
}, {
|
|
1759
1655
|
key: "parse",
|
|
1760
1656
|
value: function parse(story) {
|
|
1761
1657
|
var _this = this;
|
|
1762
|
-
|
|
1763
1658
|
if (story === null) {
|
|
1764
1659
|
return story;
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1660
|
+
}
|
|
1767
1661
|
|
|
1662
|
+
// Extract fonts from screen
|
|
1768
1663
|
var _ref3 = story || {},
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1664
|
+
_ref3$theme = _ref3.theme,
|
|
1665
|
+
theme = _ref3$theme === void 0 ? null : _ref3$theme,
|
|
1666
|
+
_ref3$components = _ref3.components,
|
|
1667
|
+
components = _ref3$components === void 0 ? [] : _ref3$components;
|
|
1774
1668
|
var fonts = uniq(components.reduce(function (currentFonts, screen) {
|
|
1775
1669
|
var type = screen.type;
|
|
1776
|
-
|
|
1777
1670
|
var fieldsPattern = _this.getFieldsPatternByScreen(type);
|
|
1778
|
-
|
|
1779
1671
|
var newFonts = FontsParser.extractFontsWithPaths(screen, fieldsPattern);
|
|
1780
1672
|
return newFonts.length > 0 ? [].concat(_toConsumableArray(currentFonts), _toConsumableArray(newFonts)) : currentFonts;
|
|
1781
|
-
}, []), 'name');
|
|
1673
|
+
}, []), 'name');
|
|
1782
1674
|
|
|
1675
|
+
// Extract fonts from theme
|
|
1783
1676
|
if (theme !== null) {
|
|
1784
1677
|
var _this$parse = this.parse(theme),
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1678
|
+
_this$parse$fonts = _this$parse.fonts,
|
|
1679
|
+
themeFonts = _this$parse$fonts === void 0 ? [] : _this$parse$fonts,
|
|
1680
|
+
newTheme = _objectWithoutProperties(_this$parse, _excluded$1);
|
|
1789
1681
|
return fonts.length > 0 || themeFonts.length > 0 ? _objectSpread(_objectSpread({}, story), {}, {
|
|
1790
1682
|
theme: newTheme,
|
|
1791
1683
|
fonts: uniq([].concat(_toConsumableArray(themeFonts), _toConsumableArray(fonts)), 'name')
|
|
1792
1684
|
}) : story;
|
|
1793
1685
|
}
|
|
1794
|
-
|
|
1795
1686
|
return fonts.length > 0 ? _objectSpread(_objectSpread({}, story), {}, {
|
|
1796
1687
|
fonts: fonts
|
|
1797
1688
|
}) : story;
|
|
@@ -1800,26 +1691,24 @@ var FontsParser = /*#__PURE__*/function () {
|
|
|
1800
1691
|
key: "getFieldsPattern",
|
|
1801
1692
|
value: function getFieldsPattern(fields) {
|
|
1802
1693
|
var _this2 = this;
|
|
1803
|
-
|
|
1804
1694
|
var namePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1805
1695
|
return fields.reduce(function (patterns, field) {
|
|
1806
1696
|
var _field$name = field.name,
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1697
|
+
name = _field$name === void 0 ? null : _field$name,
|
|
1698
|
+
_field$type = field.type,
|
|
1699
|
+
type = _field$type === void 0 ? null : _field$type;
|
|
1810
1700
|
var path = [namePrefix, name].filter(function (it) {
|
|
1811
1701
|
return it !== null;
|
|
1812
1702
|
}).join('\\.');
|
|
1703
|
+
var fieldDefinition = _objectSpread(_objectSpread({}, type !== null ? _this2.fieldsManager.getDefinition(type) : null), field);
|
|
1813
1704
|
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1705
|
+
// also check settings fields
|
|
1817
1706
|
var _fieldDefinition$fiel = fieldDefinition.fields,
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1707
|
+
subFields = _fieldDefinition$fiel === void 0 ? [] : _fieldDefinition$fiel,
|
|
1708
|
+
_fieldDefinition$item = fieldDefinition.itemsField,
|
|
1709
|
+
itemsField = _fieldDefinition$item === void 0 ? null : _fieldDefinition$item,
|
|
1710
|
+
_fieldDefinition$sett = fieldDefinition.settings,
|
|
1711
|
+
settings = _fieldDefinition$sett === void 0 ? [] : _fieldDefinition$sett;
|
|
1823
1712
|
return [].concat(_toConsumableArray(patterns), _toConsumableArray(FontsParser.fieldIsFontFamily(fieldDefinition) ? [new RegExp("^".concat(path, "$"))] : []), _toConsumableArray(_this2.getFieldsPattern(subFields, path)), _toConsumableArray(_this2.getFieldsPattern(settings, path)), _toConsumableArray(itemsField !== null ? _this2.getFieldsPattern([itemsField], "".concat(path, "\\.[0-9]+")) : []));
|
|
1824
1713
|
}, []);
|
|
1825
1714
|
}
|
|
@@ -1827,14 +1716,14 @@ var FontsParser = /*#__PURE__*/function () {
|
|
|
1827
1716
|
key: "fieldIsFontFamily",
|
|
1828
1717
|
value: function fieldIsFontFamily(_ref4) {
|
|
1829
1718
|
var _ref4$id = _ref4.id,
|
|
1830
|
-
|
|
1719
|
+
id = _ref4$id === void 0 ? null : _ref4$id;
|
|
1831
1720
|
return id === 'font-family';
|
|
1832
1721
|
}
|
|
1833
1722
|
}, {
|
|
1834
1723
|
key: "valueIsFont",
|
|
1835
1724
|
value: function valueIsFont(_ref5) {
|
|
1836
1725
|
var _ref5$type = _ref5.type,
|
|
1837
|
-
|
|
1726
|
+
type = _ref5$type === void 0 ? null : _ref5$type;
|
|
1838
1727
|
return type === 'custom' || type === 'google';
|
|
1839
1728
|
}
|
|
1840
1729
|
}, {
|
|
@@ -1853,28 +1742,23 @@ var FontsParser = /*#__PURE__*/function () {
|
|
|
1853
1742
|
var value = data[key];
|
|
1854
1743
|
var font = null;
|
|
1855
1744
|
var subFonts = null;
|
|
1856
|
-
|
|
1857
1745
|
if (patternMatch && isObject(value) && FontsParser.valueIsFont(value)) {
|
|
1858
1746
|
font = value;
|
|
1859
1747
|
} else if (isObject(value) || isArray(value)) {
|
|
1860
1748
|
subFonts = FontsParser.extractFontsWithPaths(value, patterns, path);
|
|
1861
1749
|
}
|
|
1862
|
-
|
|
1863
1750
|
return subFonts !== null || font !== null ? [].concat(_toConsumableArray(currentFonts), _toConsumableArray(subFonts || []), _toConsumableArray(font !== null ? [font] : [])) : currentFonts;
|
|
1864
1751
|
}, []);
|
|
1865
1752
|
}
|
|
1866
1753
|
}]);
|
|
1867
|
-
|
|
1868
1754
|
return FontsParser;
|
|
1869
1755
|
}();
|
|
1870
1756
|
|
|
1871
1757
|
var StoryParser = /*#__PURE__*/function () {
|
|
1872
1758
|
function StoryParser(_ref) {
|
|
1873
1759
|
var screensManager = _ref.screensManager,
|
|
1874
|
-
|
|
1875
|
-
|
|
1760
|
+
fieldsManager = _ref.fieldsManager;
|
|
1876
1761
|
_classCallCheck(this, StoryParser);
|
|
1877
|
-
|
|
1878
1762
|
this.themeParser = new ThemeParser({
|
|
1879
1763
|
screensManager: screensManager
|
|
1880
1764
|
});
|
|
@@ -1887,24 +1771,20 @@ var StoryParser = /*#__PURE__*/function () {
|
|
|
1887
1771
|
fieldsManager: fieldsManager
|
|
1888
1772
|
});
|
|
1889
1773
|
}
|
|
1890
|
-
|
|
1891
1774
|
_createClass(StoryParser, [{
|
|
1892
1775
|
key: "parse",
|
|
1893
1776
|
value: function parse(story) {
|
|
1894
1777
|
var _this = this;
|
|
1895
|
-
|
|
1896
1778
|
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1779
|
+
_ref2$withTheme = _ref2.withTheme,
|
|
1780
|
+
withTheme = _ref2$withTheme === void 0 ? true : _ref2$withTheme,
|
|
1781
|
+
_ref2$withMedias = _ref2.withMedias,
|
|
1782
|
+
withMedias = _ref2$withMedias === void 0 ? true : _ref2$withMedias,
|
|
1783
|
+
_ref2$withFonts = _ref2.withFonts,
|
|
1784
|
+
withFonts = _ref2$withFonts === void 0 ? true : _ref2$withFonts;
|
|
1904
1785
|
if (story === null) {
|
|
1905
1786
|
return story;
|
|
1906
1787
|
}
|
|
1907
|
-
|
|
1908
1788
|
var parsers = [[withMedias, function (newStory) {
|
|
1909
1789
|
return _this.mediasParser.fromPath(newStory);
|
|
1910
1790
|
}], [withTheme, function (newStory) {
|
|
@@ -1914,50 +1794,38 @@ var StoryParser = /*#__PURE__*/function () {
|
|
|
1914
1794
|
}]];
|
|
1915
1795
|
return parsers.reduce(function (parsedStory, _ref3) {
|
|
1916
1796
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1797
|
+
enabled = _ref4[0],
|
|
1798
|
+
parse = _ref4[1];
|
|
1920
1799
|
return enabled ? parse(parsedStory) : parsedStory;
|
|
1921
1800
|
}, story);
|
|
1922
1801
|
}
|
|
1923
1802
|
}]);
|
|
1924
|
-
|
|
1925
1803
|
return StoryParser;
|
|
1926
1804
|
}();
|
|
1927
1805
|
|
|
1928
1806
|
var _excluded = ["value"],
|
|
1929
|
-
|
|
1930
|
-
|
|
1807
|
+
_excluded2 = ["value", "currentTime"];
|
|
1931
1808
|
var Tracking = /*#__PURE__*/function (_BaseTracking) {
|
|
1932
1809
|
_inherits(Tracking, _BaseTracking);
|
|
1933
|
-
|
|
1934
1810
|
var _super = _createSuper(Tracking);
|
|
1935
|
-
|
|
1936
1811
|
function Tracking() {
|
|
1937
1812
|
var _this;
|
|
1938
|
-
|
|
1939
1813
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1940
|
-
|
|
1941
1814
|
_classCallCheck(this, Tracking);
|
|
1942
|
-
|
|
1943
1815
|
_this = _super.call(this, opts);
|
|
1944
1816
|
var _this$options$variabl = _this.options.variables,
|
|
1945
|
-
|
|
1817
|
+
variables = _this$options$variabl === void 0 ? null : _this$options$variabl;
|
|
1946
1818
|
_this.variables = null;
|
|
1947
1819
|
_this.screensViewed = [];
|
|
1948
|
-
|
|
1949
1820
|
if (variables !== null) {
|
|
1950
1821
|
_this.setVariables(variables);
|
|
1951
1822
|
}
|
|
1952
|
-
|
|
1953
1823
|
return _this;
|
|
1954
1824
|
}
|
|
1955
|
-
|
|
1956
1825
|
_createClass(Tracking, [{
|
|
1957
1826
|
key: "setVariables",
|
|
1958
1827
|
value: function setVariables(variables) {
|
|
1959
1828
|
this.variables = variables;
|
|
1960
|
-
|
|
1961
1829
|
if (variables !== null) {
|
|
1962
1830
|
this.push(variables);
|
|
1963
1831
|
}
|
|
@@ -1971,24 +1839,20 @@ var Tracking = /*#__PURE__*/function (_BaseTracking) {
|
|
|
1971
1839
|
key: "trackScreenView",
|
|
1972
1840
|
value: function trackScreenView(screen, screenIndex) {
|
|
1973
1841
|
var _ref = this.variables || {},
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1842
|
+
_ref$screensCount = _ref.screensCount,
|
|
1843
|
+
screensCount = _ref$screensCount === void 0 ? null : _ref$screensCount;
|
|
1977
1844
|
var _ref2 = screen || {},
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1845
|
+
_ref2$id = _ref2.id,
|
|
1846
|
+
screenId = _ref2$id === void 0 ? null : _ref2$id,
|
|
1847
|
+
_ref2$type = _ref2.type,
|
|
1848
|
+
screenType = _ref2$type === void 0 ? null : _ref2$type,
|
|
1849
|
+
_ref2$metadata = _ref2.metadata,
|
|
1850
|
+
metadata = _ref2$metadata === void 0 ? {} : _ref2$metadata;
|
|
1985
1851
|
var _ref3 = metadata || {},
|
|
1986
|
-
|
|
1987
|
-
|
|
1852
|
+
screenTitle = _ref3.title;
|
|
1988
1853
|
if (this.screensViewed.indexOf(screenId || screenIndex) !== -1) {
|
|
1989
1854
|
this.screensViewed = [].concat(_toConsumableArray(this.screensViewed), [screenId || screenIndex]);
|
|
1990
1855
|
}
|
|
1991
|
-
|
|
1992
1856
|
var data = {
|
|
1993
1857
|
event: 'screenView',
|
|
1994
1858
|
screenId: screenId,
|
|
@@ -2005,10 +1869,9 @@ var Tracking = /*#__PURE__*/function (_BaseTracking) {
|
|
|
2005
1869
|
key: "trackEvent",
|
|
2006
1870
|
value: function trackEvent(category, action, label) {
|
|
2007
1871
|
var _ref4 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1872
|
+
_ref4$value = _ref4.value,
|
|
1873
|
+
value = _ref4$value === void 0 ? null : _ref4$value,
|
|
1874
|
+
opts = _objectWithoutProperties(_ref4, _excluded);
|
|
2012
1875
|
var data = _objectSpread(_objectSpread({}, opts), {}, {
|
|
2013
1876
|
event: 'eventInteraction',
|
|
2014
1877
|
eventCategory: category,
|
|
@@ -2016,37 +1879,32 @@ var Tracking = /*#__PURE__*/function (_BaseTracking) {
|
|
|
2016
1879
|
eventLabel: label,
|
|
2017
1880
|
eventValue: value
|
|
2018
1881
|
});
|
|
2019
|
-
|
|
2020
1882
|
this.push(data);
|
|
2021
1883
|
}
|
|
2022
1884
|
}, {
|
|
2023
1885
|
key: "trackMedia",
|
|
2024
1886
|
value: function trackMedia(type, media, action) {
|
|
2025
1887
|
var _ref5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
1888
|
+
_ref5$value = _ref5.value,
|
|
1889
|
+
value = _ref5$value === void 0 ? null : _ref5$value,
|
|
1890
|
+
_ref5$currentTime = _ref5.currentTime,
|
|
1891
|
+
optsCurrentTime = _ref5$currentTime === void 0 ? null : _ref5$currentTime,
|
|
1892
|
+
opts = _objectWithoutProperties(_ref5, _excluded2);
|
|
2032
1893
|
var _ref6 = media || {},
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
1894
|
+
_ref6$id = _ref6.id,
|
|
1895
|
+
mediaId = _ref6$id === void 0 ? null : _ref6$id,
|
|
1896
|
+
_ref6$name = _ref6.name,
|
|
1897
|
+
name = _ref6$name === void 0 ? null : _ref6$name,
|
|
1898
|
+
_ref6$duration = _ref6.duration,
|
|
1899
|
+
rootDuration = _ref6$duration === void 0 ? null : _ref6$duration,
|
|
1900
|
+
_ref6$currentTime = _ref6.currentTime,
|
|
1901
|
+
currentTime = _ref6$currentTime === void 0 ? optsCurrentTime : _ref6$currentTime,
|
|
1902
|
+
_ref6$metadata = _ref6.metadata,
|
|
1903
|
+
metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata;
|
|
2044
1904
|
var _ref7 = metadata || {},
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
1905
|
+
_ref7$duration = _ref7.duration,
|
|
1906
|
+
duration = _ref7$duration === void 0 ? rootDuration : _ref7$duration;
|
|
2048
1907
|
var label = name;
|
|
2049
|
-
|
|
2050
1908
|
var data = _objectSpread(_objectSpread({}, opts), {}, {
|
|
2051
1909
|
event: 'eventInteraction',
|
|
2052
1910
|
eventCategory: type,
|
|
@@ -2057,11 +1915,9 @@ var Tracking = /*#__PURE__*/function (_BaseTracking) {
|
|
|
2057
1915
|
mediaCurrentTime: currentTime !== null ? Math.round(currentTime) : null,
|
|
2058
1916
|
mediaProgress: currentTime !== null && duration !== null && duration > 0 ? Math.round(currentTime / duration * 100) : null
|
|
2059
1917
|
});
|
|
2060
|
-
|
|
2061
1918
|
this.push(data);
|
|
2062
1919
|
}
|
|
2063
1920
|
}]);
|
|
2064
|
-
|
|
2065
1921
|
return Tracking;
|
|
2066
1922
|
}(Tracking$1);
|
|
2067
1923
|
|