@micromag/transforms 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/es/apple-news.js CHANGED
@@ -9,17 +9,15 @@ import hash from 'object-hash';
9
9
 
10
10
  var getArticleComponents = function getArticleComponents(story) {
11
11
  var _ref = story || {},
12
- _ref$title = _ref.title,
13
- title = _ref$title === void 0 ? null : _ref$title,
14
- _ref$metadata = _ref.metadata,
15
- metadata = _ref$metadata === void 0 ? {} : _ref$metadata,
16
- _ref$components = _ref.components,
17
- components = _ref$components === void 0 ? [] : _ref$components;
18
-
12
+ _ref$title = _ref.title,
13
+ title = _ref$title === void 0 ? null : _ref$title,
14
+ _ref$metadata = _ref.metadata,
15
+ metadata = _ref$metadata === void 0 ? {} : _ref$metadata,
16
+ _ref$components = _ref.components,
17
+ components = _ref$components === void 0 ? [] : _ref$components;
19
18
  var _ref2 = metadata || {},
20
- _ref2$description = _ref2.description,
21
- description = _ref2$description === void 0 ? 'Ma description' : _ref2$description;
22
-
19
+ _ref2$description = _ref2.description,
20
+ description = _ref2$description === void 0 ? 'Ma description' : _ref2$description;
23
21
  var heading1 = title ? {
24
22
  role: 'heading1',
25
23
  text: title,
@@ -36,18 +34,15 @@ var getArticleComponents = function getArticleComponents(story) {
36
34
  return next;
37
35
  }
38
36
  }
39
-
40
37
  return comp;
41
38
  }, null);
42
39
  var imageComponent = null;
43
-
44
40
  if (titleScreen !== null) {
45
41
  var _ref3 = titleScreen || {},
46
- _ref3$image = _ref3.image,
47
- image = _ref3$image === void 0 ? null : _ref3$image,
48
- _ref3$background = _ref3.background,
49
- background = _ref3$background === void 0 ? null : _ref3$background;
50
-
42
+ _ref3$image = _ref3.image,
43
+ image = _ref3$image === void 0 ? null : _ref3$image,
44
+ _ref3$background = _ref3.background,
45
+ background = _ref3$background === void 0 ? null : _ref3$background;
51
46
  if (image !== null) {
52
47
  imageComponent = {
53
48
  role: 'image',
@@ -60,7 +55,6 @@ var getArticleComponents = function getArticleComponents(story) {
60
55
  };
61
56
  }
62
57
  }
63
-
64
58
  var headerComponents = [imageComponent, heading1, heading2].filter(function (it) {
65
59
  return it !== null;
66
60
  });
@@ -207,15 +201,14 @@ var TextStyleDefinition = {
207
201
 
208
202
  var TextStyle = function TextStyle() {
209
203
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
210
- _ref$fontFamily = _ref.fontFamily,
211
- fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
212
- _ref$fontSize = _ref.fontSize,
213
- fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
214
- _ref$lineHeight = _ref.lineHeight,
215
- lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
216
- _ref$color = _ref.color,
217
- color = _ref$color === void 0 ? null : _ref$color;
218
-
204
+ _ref$fontFamily = _ref.fontFamily,
205
+ fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
206
+ _ref$fontSize = _ref.fontSize,
207
+ fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
208
+ _ref$lineHeight = _ref.lineHeight,
209
+ lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
210
+ _ref$color = _ref.color,
211
+ color = _ref$color === void 0 ? null : _ref$color;
219
212
  var content = {
220
213
  fontFamily: fontFamily,
221
214
  fontSize: fontSize,
@@ -229,8 +222,10 @@ var getArticleTextStyles = function getArticleTextStyles() {
229
222
  // const { theme = {} } = story || {};
230
223
  // const { textStyle = {} } = theme || {};
231
224
  // const { heading1 = {}, text = {} } = textStyle || {};
225
+
232
226
  // const titleStyles = TextStyle(heading1);
233
227
  // const textStyles = TextStyle(text);
228
+
234
229
  var fontSize = 18;
235
230
  var lineHeight = 1.35;
236
231
  var titleStyles = TextStyle({
@@ -336,15 +331,14 @@ var LayoutDefinition = {
336
331
 
337
332
  var Layout = function Layout() {
338
333
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
339
- _ref$columns = _ref.columns,
340
- columns = _ref$columns === void 0 ? 8 : _ref$columns,
341
- _ref$width = _ref.width,
342
- width = _ref$width === void 0 ? 768 : _ref$width,
343
- _ref$margin = _ref.margin,
344
- margin = _ref$margin === void 0 ? 60 : _ref$margin,
345
- _ref$gutter = _ref.gutter,
346
- gutter = _ref$gutter === void 0 ? 20 : _ref$gutter;
347
-
334
+ _ref$columns = _ref.columns,
335
+ columns = _ref$columns === void 0 ? 8 : _ref$columns,
336
+ _ref$width = _ref.width,
337
+ width = _ref$width === void 0 ? 768 : _ref$width,
338
+ _ref$margin = _ref.margin,
339
+ margin = _ref$margin === void 0 ? 60 : _ref$margin,
340
+ _ref$gutter = _ref.gutter,
341
+ gutter = _ref$gutter === void 0 ? 20 : _ref$gutter;
348
342
  var content = {
349
343
  columns: columns,
350
344
  width: width,
@@ -458,15 +452,14 @@ var ComponentLayoutDefinition = {
458
452
 
459
453
  var ComponentLayout = function ComponentLayout() {
460
454
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
461
- _ref$columnStart = _ref.columnStart,
462
- columnStart = _ref$columnStart === void 0 ? 0 : _ref$columnStart,
463
- _ref$columnSpan = _ref.columnSpan,
464
- columnSpan = _ref$columnSpan === void 0 ? 12 : _ref$columnSpan,
465
- _ref$marginTop = _ref.marginTop,
466
- marginTop = _ref$marginTop === void 0 ? 0 : _ref$marginTop,
467
- _ref$marginBottom = _ref.marginBottom,
468
- marginBottom = _ref$marginBottom === void 0 ? 20 : _ref$marginBottom;
469
-
455
+ _ref$columnStart = _ref.columnStart,
456
+ columnStart = _ref$columnStart === void 0 ? 0 : _ref$columnStart,
457
+ _ref$columnSpan = _ref.columnSpan,
458
+ columnSpan = _ref$columnSpan === void 0 ? 12 : _ref$columnSpan,
459
+ _ref$marginTop = _ref.marginTop,
460
+ marginTop = _ref$marginTop === void 0 ? 0 : _ref$marginTop,
461
+ _ref$marginBottom = _ref.marginBottom,
462
+ marginBottom = _ref$marginBottom === void 0 ? 20 : _ref$marginBottom;
470
463
  var content = {
471
464
  columnStart: columnStart,
472
465
  columnSpan: columnSpan,
@@ -483,6 +476,7 @@ var getArticleLayouts = function getArticleLayouts() {
483
476
  // const { textStyle = {} } = theme || {};
484
477
  // const { heading1 = {}, text = {} } = textStyle || {};
485
478
  // const titleStyles = TextStyle(heading1);
479
+
486
480
  var layoutStyles = Layout();
487
481
  var componentLayoutStyles = ComponentLayout();
488
482
  var defaultMargin = 20;
@@ -598,9 +592,8 @@ var DocumentStyleDefinition = {
598
592
 
599
593
  var DocumentStyle = function DocumentStyle() {
600
594
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
601
- _ref$backgroundColor = _ref.backgroundColor,
602
- backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
603
-
595
+ _ref$backgroundColor = _ref.backgroundColor,
596
+ backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
604
597
  var content = {
605
598
  backgroundColor: backgroundColor
606
599
  };
@@ -728,45 +721,36 @@ var validate = function validate() {
728
721
  var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
729
722
  var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
730
723
  var validated = content ? Object.keys(content).reduce(function (values, name) {
731
- var value = content[name] || null; // Find the reference
732
-
724
+ var value = content[name] || null;
725
+ // Find the reference
733
726
  if (definition && definition.properties) {
734
727
  var property = definition.properties.find(function (prop) {
735
728
  return prop.name === name;
736
729
  }) || null;
737
-
738
730
  if (property !== null) {
739
731
  var isValid = true;
740
-
741
732
  switch (property.type) {
742
733
  case 'string':
743
734
  isValid = isString(value);
744
735
  break;
745
-
746
736
  case 'integer':
747
737
  isValid = isInteger(value);
748
738
  break;
749
-
750
739
  case 'float':
751
740
  isValid = isNumber(value);
752
741
  break;
753
-
754
742
  default:
755
743
  isValid = value !== null;
756
744
  break;
757
- } // Skip the whole thing it cause it aint gonna work
758
-
759
-
745
+ }
746
+ // Skip the whole thing it cause it aint gonna work
760
747
  if (!isValid && property.required) {
761
748
  console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
762
-
763
749
  return null;
764
750
  }
765
-
766
751
  if (values !== null && isValid) {
767
752
  return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
768
753
  }
769
-
770
754
  console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
771
755
  }
772
756
  }
@@ -778,13 +762,12 @@ var validate = function validate() {
778
762
 
779
763
  var Article = function Article(story, settings) {
780
764
  // console.log('ARTICLE', story); // eslint-disable-line
781
- var _story$title = story.title,
782
- title = _story$title === void 0 ? 'Article' : _story$title;
783
765
 
766
+ var _story$title = story.title,
767
+ title = _story$title === void 0 ? 'Article' : _story$title;
784
768
  var _ref = settings || {},
785
- _ref$identifier = _ref.identifier,
786
- identifier = _ref$identifier === void 0 ? 'testArticle' : _ref$identifier;
787
-
769
+ _ref$identifier = _ref.identifier,
770
+ identifier = _ref$identifier === void 0 ? 'testArticle' : _ref$identifier;
788
771
  var content = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
789
772
  title: title,
790
773
  version: "".concat(1, ".0").toString(),
@@ -797,8 +780,9 @@ var Article = function Article(story, settings) {
797
780
  componentStyles: {},
798
781
  componentTextStyles: {},
799
782
  componentLayouts: {}
800
- }, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story)); // console.log('KONTENT', content);
783
+ }, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story));
801
784
 
785
+ // console.log('KONTENT', content);
802
786
 
803
787
  return validate(content, ArticleDefinition);
804
788
  };
@@ -912,11 +896,9 @@ var MediaElement = function MediaElement(story, media) {
912
896
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'audio';
913
897
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
914
898
  var _story$componentLayou = story.componentLayouts,
915
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
916
-
899
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
917
900
  var _ref = media || {},
918
- url = _ref.url;
919
-
901
+ url = _ref.url;
920
902
  var content = _objectSpread(_objectSpread({
921
903
  role: role
922
904
  }, componentLayouts[role] ? {
@@ -924,12 +906,10 @@ var MediaElement = function MediaElement(story, media) {
924
906
  } : {}), {}, {
925
907
  URL: url
926
908
  });
927
-
928
909
  var component = validate$1(content, definition);
929
910
  return {
930
911
  story: story,
931
912
  component: role === 'audio' ? component : component // Figure out HLS for videos
932
-
933
913
  };
934
914
  };
935
915
 
@@ -1047,18 +1027,15 @@ var TextElement = function TextElement(story, text) {
1047
1027
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1048
1028
  var props = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1049
1029
  var _story$componentLayou = story.componentLayouts,
1050
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1051
-
1030
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1052
1031
  var _ref = text || {},
1053
- _ref$body = _ref.body,
1054
- body = _ref$body === void 0 ? null : _ref$body,
1055
- _ref$textStyle = _ref.textStyle,
1056
- textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle;
1057
-
1032
+ _ref$body = _ref.body,
1033
+ body = _ref$body === void 0 ? null : _ref$body,
1034
+ _ref$textStyle = _ref.textStyle,
1035
+ textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle;
1058
1036
  var style = textStyle ? TextStyle(textStyle) : null;
1059
1037
  var styleName = style !== null ? hash(style) : null;
1060
1038
  var hasStyle = style !== null && styleName !== null;
1061
-
1062
1039
  var content = _objectSpread(_objectSpread({
1063
1040
  role: role
1064
1041
  }, componentLayouts[role] ? {
@@ -1067,7 +1044,6 @@ var TextElement = function TextElement(story, text) {
1067
1044
  text: body,
1068
1045
  format: 'html'
1069
1046
  }, props);
1070
-
1071
1047
  var component = definition ? validate$1(content, definition) : null;
1072
1048
  return {
1073
1049
  story: _objectSpread(_objectSpread({}, story), {}, {
@@ -1273,25 +1249,21 @@ var GalleryElement = function GalleryElement(story, gallery) {
1273
1249
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'gallery';
1274
1250
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1275
1251
  var _story$componentLayou = story.componentLayouts,
1276
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1277
-
1252
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1278
1253
  var _ref = gallery || {},
1279
- _ref$images = _ref.images,
1280
- images = _ref$images === void 0 ? [] : _ref$images;
1281
-
1254
+ _ref$images = _ref.images,
1255
+ images = _ref$images === void 0 ? [] : _ref$images;
1282
1256
  var galleryImages = images !== null ? images.map(function (image) {
1283
1257
  if (image == null) {
1284
1258
  return null;
1285
1259
  }
1286
-
1287
1260
  var _ref2 = image || {},
1288
- _ref2$media = _ref2.media,
1289
- media = _ref2$media === void 0 ? null : _ref2$media,
1290
- _ref2$url = _ref2.url,
1291
- url = _ref2$url === void 0 ? null : _ref2$url,
1292
- _ref2$caption = _ref2.caption,
1293
- caption = _ref2$caption === void 0 ? null : _ref2$caption;
1294
-
1261
+ _ref2$media = _ref2.media,
1262
+ media = _ref2$media === void 0 ? null : _ref2$media,
1263
+ _ref2$url = _ref2.url,
1264
+ url = _ref2$url === void 0 ? null : _ref2$url,
1265
+ _ref2$caption = _ref2.caption,
1266
+ caption = _ref2$caption === void 0 ? null : _ref2$caption;
1295
1267
  var mediaUrl = media !== null && media.url ? media.url : null;
1296
1268
  var imageUrl = url !== null ? url : null;
1297
1269
  var hasUrl = imageUrl || mediaUrl;
@@ -1304,7 +1276,6 @@ var GalleryElement = function GalleryElement(story, gallery) {
1304
1276
  }).filter(function (i) {
1305
1277
  return i !== null;
1306
1278
  }) : [];
1307
-
1308
1279
  var content = _objectSpread(_objectSpread({
1309
1280
  role: role
1310
1281
  }, componentLayouts[role] ? {
@@ -1312,7 +1283,6 @@ var GalleryElement = function GalleryElement(story, gallery) {
1312
1283
  } : {}), {}, {
1313
1284
  items: galleryImages
1314
1285
  });
1315
-
1316
1286
  var component = validate$1(content, definition);
1317
1287
  return {
1318
1288
  story: story,
@@ -1548,11 +1518,9 @@ var ImageElement = function ImageElement(story, image) {
1548
1518
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'image';
1549
1519
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1550
1520
  var _story$componentLayou = story.componentLayouts,
1551
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1552
-
1521
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1553
1522
  var _ref = image || {},
1554
- url = _ref.url;
1555
-
1523
+ url = _ref.url;
1556
1524
  var content = _objectSpread(_objectSpread({
1557
1525
  role: role
1558
1526
  }, componentLayouts[role] ? {
@@ -1560,7 +1528,6 @@ var ImageElement = function ImageElement(story, image) {
1560
1528
  } : {}), {}, {
1561
1529
  URL: url
1562
1530
  });
1563
-
1564
1531
  var component = validate$1(content, definition);
1565
1532
  return {
1566
1533
  story: story,
@@ -1695,14 +1662,12 @@ var MapElement = function MapElement(story, map) {
1695
1662
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'map';
1696
1663
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1697
1664
  var _story$componentLayou = story.componentLayouts,
1698
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1699
-
1665
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1700
1666
  var _ref = map || {},
1701
- _ref$latitude = _ref.latitude,
1702
- latitude = _ref$latitude === void 0 ? null : _ref$latitude,
1703
- _ref$longitude = _ref.longitude,
1704
- longitude = _ref$longitude === void 0 ? null : _ref$longitude;
1705
-
1667
+ _ref$latitude = _ref.latitude,
1668
+ latitude = _ref$latitude === void 0 ? null : _ref$latitude,
1669
+ _ref$longitude = _ref.longitude,
1670
+ longitude = _ref$longitude === void 0 ? null : _ref$longitude;
1706
1671
  var content = _objectSpread(_objectSpread({
1707
1672
  role: role
1708
1673
  }, componentLayouts[role] ? {
@@ -1711,7 +1676,6 @@ var MapElement = function MapElement(story, map) {
1711
1676
  latitude: latitude,
1712
1677
  longitude: longitude
1713
1678
  });
1714
-
1715
1679
  var component = validate$1(content, definition);
1716
1680
  return {
1717
1681
  story: story,
package/es/index.js CHANGED
@@ -5,22 +5,19 @@ var transformer = function transformer(story, type, settings) {
5
5
  if (type === 'appleNews') {
6
6
  return Article(story, settings);
7
7
  }
8
-
9
8
  return story;
10
9
  };
11
10
 
12
11
  var postProcessor = function postProcessor(story, type) {
13
12
  if (type === 'appleNews') {
14
13
  var _ref = story || {},
15
- components = _ref.components;
16
-
14
+ components = _ref.components;
17
15
  return _objectSpread(_objectSpread({}, story), {}, {
18
16
  components: components.filter(function (c) {
19
17
  return c !== null;
20
18
  })
21
19
  });
22
20
  }
23
-
24
21
  return story;
25
22
  };
26
23
 
package/es/utils.js CHANGED
@@ -9,45 +9,36 @@ var validate = function validate() {
9
9
  var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
10
  var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
11
11
  var validated = content ? Object.keys(content).reduce(function (values, name) {
12
- var value = content[name] || null; // Find the reference
13
-
12
+ var value = content[name] || null;
13
+ // Find the reference
14
14
  if (definition && definition.properties) {
15
15
  var property = definition.properties.find(function (prop) {
16
16
  return prop.name === name;
17
17
  }) || null;
18
-
19
18
  if (property !== null) {
20
19
  var isValid = true;
21
-
22
20
  switch (property.type) {
23
21
  case 'string':
24
22
  isValid = isString(value);
25
23
  break;
26
-
27
24
  case 'integer':
28
25
  isValid = isInteger(value);
29
26
  break;
30
-
31
27
  case 'float':
32
28
  isValid = isNumber(value);
33
29
  break;
34
-
35
30
  default:
36
31
  isValid = value !== null;
37
32
  break;
38
- } // Skip the whole thing it cause it aint gonna work
39
-
40
-
33
+ }
34
+ // Skip the whole thing it cause it aint gonna work
41
35
  if (!isValid && property.required) {
42
36
  console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
43
-
44
37
  return null;
45
38
  }
46
-
47
39
  if (values !== null && isValid) {
48
40
  return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
49
41
  }
50
-
51
42
  console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
52
43
  }
53
44
  }
@@ -61,7 +52,6 @@ var stripTags = function stripTags(str) {
61
52
  if (!str) {
62
53
  return null;
63
54
  }
64
-
65
55
  return str.replace(/(<([^>]+)>)/gi, '');
66
56
  };
67
57
 
package/lib/apple-news.js CHANGED
@@ -23,17 +23,15 @@ var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
23
23
 
24
24
  var getArticleComponents = function getArticleComponents(story) {
25
25
  var _ref = story || {},
26
- _ref$title = _ref.title,
27
- title = _ref$title === void 0 ? null : _ref$title,
28
- _ref$metadata = _ref.metadata,
29
- metadata = _ref$metadata === void 0 ? {} : _ref$metadata,
30
- _ref$components = _ref.components,
31
- components = _ref$components === void 0 ? [] : _ref$components;
32
-
26
+ _ref$title = _ref.title,
27
+ title = _ref$title === void 0 ? null : _ref$title,
28
+ _ref$metadata = _ref.metadata,
29
+ metadata = _ref$metadata === void 0 ? {} : _ref$metadata,
30
+ _ref$components = _ref.components,
31
+ components = _ref$components === void 0 ? [] : _ref$components;
33
32
  var _ref2 = metadata || {},
34
- _ref2$description = _ref2.description,
35
- description = _ref2$description === void 0 ? 'Ma description' : _ref2$description;
36
-
33
+ _ref2$description = _ref2.description,
34
+ description = _ref2$description === void 0 ? 'Ma description' : _ref2$description;
37
35
  var heading1 = title ? {
38
36
  role: 'heading1',
39
37
  text: title,
@@ -50,18 +48,15 @@ var getArticleComponents = function getArticleComponents(story) {
50
48
  return next;
51
49
  }
52
50
  }
53
-
54
51
  return comp;
55
52
  }, null);
56
53
  var imageComponent = null;
57
-
58
54
  if (titleScreen !== null) {
59
55
  var _ref3 = titleScreen || {},
60
- _ref3$image = _ref3.image,
61
- image = _ref3$image === void 0 ? null : _ref3$image,
62
- _ref3$background = _ref3.background,
63
- background = _ref3$background === void 0 ? null : _ref3$background;
64
-
56
+ _ref3$image = _ref3.image,
57
+ image = _ref3$image === void 0 ? null : _ref3$image,
58
+ _ref3$background = _ref3.background,
59
+ background = _ref3$background === void 0 ? null : _ref3$background;
65
60
  if (image !== null) {
66
61
  imageComponent = {
67
62
  role: 'image',
@@ -74,7 +69,6 @@ var getArticleComponents = function getArticleComponents(story) {
74
69
  };
75
70
  }
76
71
  }
77
-
78
72
  var headerComponents = [imageComponent, heading1, heading2].filter(function (it) {
79
73
  return it !== null;
80
74
  });
@@ -221,15 +215,14 @@ var TextStyleDefinition = {
221
215
 
222
216
  var TextStyle = function TextStyle() {
223
217
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
224
- _ref$fontFamily = _ref.fontFamily,
225
- fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
226
- _ref$fontSize = _ref.fontSize,
227
- fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
228
- _ref$lineHeight = _ref.lineHeight,
229
- lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
230
- _ref$color = _ref.color,
231
- color = _ref$color === void 0 ? null : _ref$color;
232
-
218
+ _ref$fontFamily = _ref.fontFamily,
219
+ fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
220
+ _ref$fontSize = _ref.fontSize,
221
+ fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
222
+ _ref$lineHeight = _ref.lineHeight,
223
+ lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
224
+ _ref$color = _ref.color,
225
+ color = _ref$color === void 0 ? null : _ref$color;
233
226
  var content = {
234
227
  fontFamily: fontFamily,
235
228
  fontSize: fontSize,
@@ -243,8 +236,10 @@ var getArticleTextStyles = function getArticleTextStyles() {
243
236
  // const { theme = {} } = story || {};
244
237
  // const { textStyle = {} } = theme || {};
245
238
  // const { heading1 = {}, text = {} } = textStyle || {};
239
+
246
240
  // const titleStyles = TextStyle(heading1);
247
241
  // const textStyles = TextStyle(text);
242
+
248
243
  var fontSize = 18;
249
244
  var lineHeight = 1.35;
250
245
  var titleStyles = TextStyle({
@@ -350,15 +345,14 @@ var LayoutDefinition = {
350
345
 
351
346
  var Layout = function Layout() {
352
347
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
353
- _ref$columns = _ref.columns,
354
- columns = _ref$columns === void 0 ? 8 : _ref$columns,
355
- _ref$width = _ref.width,
356
- width = _ref$width === void 0 ? 768 : _ref$width,
357
- _ref$margin = _ref.margin,
358
- margin = _ref$margin === void 0 ? 60 : _ref$margin,
359
- _ref$gutter = _ref.gutter,
360
- gutter = _ref$gutter === void 0 ? 20 : _ref$gutter;
361
-
348
+ _ref$columns = _ref.columns,
349
+ columns = _ref$columns === void 0 ? 8 : _ref$columns,
350
+ _ref$width = _ref.width,
351
+ width = _ref$width === void 0 ? 768 : _ref$width,
352
+ _ref$margin = _ref.margin,
353
+ margin = _ref$margin === void 0 ? 60 : _ref$margin,
354
+ _ref$gutter = _ref.gutter,
355
+ gutter = _ref$gutter === void 0 ? 20 : _ref$gutter;
362
356
  var content = {
363
357
  columns: columns,
364
358
  width: width,
@@ -472,15 +466,14 @@ var ComponentLayoutDefinition = {
472
466
 
473
467
  var ComponentLayout = function ComponentLayout() {
474
468
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
475
- _ref$columnStart = _ref.columnStart,
476
- columnStart = _ref$columnStart === void 0 ? 0 : _ref$columnStart,
477
- _ref$columnSpan = _ref.columnSpan,
478
- columnSpan = _ref$columnSpan === void 0 ? 12 : _ref$columnSpan,
479
- _ref$marginTop = _ref.marginTop,
480
- marginTop = _ref$marginTop === void 0 ? 0 : _ref$marginTop,
481
- _ref$marginBottom = _ref.marginBottom,
482
- marginBottom = _ref$marginBottom === void 0 ? 20 : _ref$marginBottom;
483
-
469
+ _ref$columnStart = _ref.columnStart,
470
+ columnStart = _ref$columnStart === void 0 ? 0 : _ref$columnStart,
471
+ _ref$columnSpan = _ref.columnSpan,
472
+ columnSpan = _ref$columnSpan === void 0 ? 12 : _ref$columnSpan,
473
+ _ref$marginTop = _ref.marginTop,
474
+ marginTop = _ref$marginTop === void 0 ? 0 : _ref$marginTop,
475
+ _ref$marginBottom = _ref.marginBottom,
476
+ marginBottom = _ref$marginBottom === void 0 ? 20 : _ref$marginBottom;
484
477
  var content = {
485
478
  columnStart: columnStart,
486
479
  columnSpan: columnSpan,
@@ -497,6 +490,7 @@ var getArticleLayouts = function getArticleLayouts() {
497
490
  // const { textStyle = {} } = theme || {};
498
491
  // const { heading1 = {}, text = {} } = textStyle || {};
499
492
  // const titleStyles = TextStyle(heading1);
493
+
500
494
  var layoutStyles = Layout();
501
495
  var componentLayoutStyles = ComponentLayout();
502
496
  var defaultMargin = 20;
@@ -612,9 +606,8 @@ var DocumentStyleDefinition = {
612
606
 
613
607
  var DocumentStyle = function DocumentStyle() {
614
608
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
615
- _ref$backgroundColor = _ref.backgroundColor,
616
- backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
617
-
609
+ _ref$backgroundColor = _ref.backgroundColor,
610
+ backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
618
611
  var content = {
619
612
  backgroundColor: backgroundColor
620
613
  };
@@ -742,45 +735,36 @@ var validate = function validate() {
742
735
  var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
743
736
  var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
744
737
  var validated = content ? Object.keys(content).reduce(function (values, name) {
745
- var value = content[name] || null; // Find the reference
746
-
738
+ var value = content[name] || null;
739
+ // Find the reference
747
740
  if (definition && definition.properties) {
748
741
  var property = definition.properties.find(function (prop) {
749
742
  return prop.name === name;
750
743
  }) || null;
751
-
752
744
  if (property !== null) {
753
745
  var isValid = true;
754
-
755
746
  switch (property.type) {
756
747
  case 'string':
757
748
  isValid = isString__default["default"](value);
758
749
  break;
759
-
760
750
  case 'integer':
761
751
  isValid = isInteger__default["default"](value);
762
752
  break;
763
-
764
753
  case 'float':
765
754
  isValid = isNumber__default["default"](value);
766
755
  break;
767
-
768
756
  default:
769
757
  isValid = value !== null;
770
758
  break;
771
- } // Skip the whole thing it cause it aint gonna work
772
-
773
-
759
+ }
760
+ // Skip the whole thing it cause it aint gonna work
774
761
  if (!isValid && property.required) {
775
762
  console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
776
-
777
763
  return null;
778
764
  }
779
-
780
765
  if (values !== null && isValid) {
781
766
  return _objectSpread__default["default"](_objectSpread__default["default"]({}, values), {}, _defineProperty__default["default"]({}, name, value));
782
767
  }
783
-
784
768
  console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
785
769
  }
786
770
  }
@@ -792,13 +776,12 @@ var validate = function validate() {
792
776
 
793
777
  var Article = function Article(story, settings) {
794
778
  // console.log('ARTICLE', story); // eslint-disable-line
795
- var _story$title = story.title,
796
- title = _story$title === void 0 ? 'Article' : _story$title;
797
779
 
780
+ var _story$title = story.title,
781
+ title = _story$title === void 0 ? 'Article' : _story$title;
798
782
  var _ref = settings || {},
799
- _ref$identifier = _ref.identifier,
800
- identifier = _ref$identifier === void 0 ? 'testArticle' : _ref$identifier;
801
-
783
+ _ref$identifier = _ref.identifier,
784
+ identifier = _ref$identifier === void 0 ? 'testArticle' : _ref$identifier;
802
785
  var content = _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({
803
786
  title: title,
804
787
  version: "".concat(1, ".0").toString(),
@@ -811,8 +794,9 @@ var Article = function Article(story, settings) {
811
794
  componentStyles: {},
812
795
  componentTextStyles: {},
813
796
  componentLayouts: {}
814
- }, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story)); // console.log('KONTENT', content);
797
+ }, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story));
815
798
 
799
+ // console.log('KONTENT', content);
816
800
 
817
801
  return validate(content, ArticleDefinition);
818
802
  };
@@ -926,11 +910,9 @@ var MediaElement = function MediaElement(story, media) {
926
910
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'audio';
927
911
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
928
912
  var _story$componentLayou = story.componentLayouts,
929
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
930
-
913
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
931
914
  var _ref = media || {},
932
- url = _ref.url;
933
-
915
+ url = _ref.url;
934
916
  var content = _objectSpread__default["default"](_objectSpread__default["default"]({
935
917
  role: role
936
918
  }, componentLayouts[role] ? {
@@ -938,12 +920,10 @@ var MediaElement = function MediaElement(story, media) {
938
920
  } : {}), {}, {
939
921
  URL: url
940
922
  });
941
-
942
923
  var component = utils.validate(content, definition);
943
924
  return {
944
925
  story: story,
945
926
  component: role === 'audio' ? component : component // Figure out HLS for videos
946
-
947
927
  };
948
928
  };
949
929
 
@@ -1061,18 +1041,15 @@ var TextElement = function TextElement(story, text) {
1061
1041
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1062
1042
  var props = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1063
1043
  var _story$componentLayou = story.componentLayouts,
1064
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1065
-
1044
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1066
1045
  var _ref = text || {},
1067
- _ref$body = _ref.body,
1068
- body = _ref$body === void 0 ? null : _ref$body,
1069
- _ref$textStyle = _ref.textStyle,
1070
- textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle;
1071
-
1046
+ _ref$body = _ref.body,
1047
+ body = _ref$body === void 0 ? null : _ref$body,
1048
+ _ref$textStyle = _ref.textStyle,
1049
+ textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle;
1072
1050
  var style = textStyle ? TextStyle(textStyle) : null;
1073
1051
  var styleName = style !== null ? hash__default["default"](style) : null;
1074
1052
  var hasStyle = style !== null && styleName !== null;
1075
-
1076
1053
  var content = _objectSpread__default["default"](_objectSpread__default["default"]({
1077
1054
  role: role
1078
1055
  }, componentLayouts[role] ? {
@@ -1081,7 +1058,6 @@ var TextElement = function TextElement(story, text) {
1081
1058
  text: body,
1082
1059
  format: 'html'
1083
1060
  }, props);
1084
-
1085
1061
  var component = definition ? utils.validate(content, definition) : null;
1086
1062
  return {
1087
1063
  story: _objectSpread__default["default"](_objectSpread__default["default"]({}, story), {}, {
@@ -1287,25 +1263,21 @@ var GalleryElement = function GalleryElement(story, gallery) {
1287
1263
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'gallery';
1288
1264
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1289
1265
  var _story$componentLayou = story.componentLayouts,
1290
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1291
-
1266
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1292
1267
  var _ref = gallery || {},
1293
- _ref$images = _ref.images,
1294
- images = _ref$images === void 0 ? [] : _ref$images;
1295
-
1268
+ _ref$images = _ref.images,
1269
+ images = _ref$images === void 0 ? [] : _ref$images;
1296
1270
  var galleryImages = images !== null ? images.map(function (image) {
1297
1271
  if (image == null) {
1298
1272
  return null;
1299
1273
  }
1300
-
1301
1274
  var _ref2 = image || {},
1302
- _ref2$media = _ref2.media,
1303
- media = _ref2$media === void 0 ? null : _ref2$media,
1304
- _ref2$url = _ref2.url,
1305
- url = _ref2$url === void 0 ? null : _ref2$url,
1306
- _ref2$caption = _ref2.caption,
1307
- caption = _ref2$caption === void 0 ? null : _ref2$caption;
1308
-
1275
+ _ref2$media = _ref2.media,
1276
+ media = _ref2$media === void 0 ? null : _ref2$media,
1277
+ _ref2$url = _ref2.url,
1278
+ url = _ref2$url === void 0 ? null : _ref2$url,
1279
+ _ref2$caption = _ref2.caption,
1280
+ caption = _ref2$caption === void 0 ? null : _ref2$caption;
1309
1281
  var mediaUrl = media !== null && media.url ? media.url : null;
1310
1282
  var imageUrl = url !== null ? url : null;
1311
1283
  var hasUrl = imageUrl || mediaUrl;
@@ -1318,7 +1290,6 @@ var GalleryElement = function GalleryElement(story, gallery) {
1318
1290
  }).filter(function (i) {
1319
1291
  return i !== null;
1320
1292
  }) : [];
1321
-
1322
1293
  var content = _objectSpread__default["default"](_objectSpread__default["default"]({
1323
1294
  role: role
1324
1295
  }, componentLayouts[role] ? {
@@ -1326,7 +1297,6 @@ var GalleryElement = function GalleryElement(story, gallery) {
1326
1297
  } : {}), {}, {
1327
1298
  items: galleryImages
1328
1299
  });
1329
-
1330
1300
  var component = utils.validate(content, definition);
1331
1301
  return {
1332
1302
  story: story,
@@ -1562,11 +1532,9 @@ var ImageElement = function ImageElement(story, image) {
1562
1532
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'image';
1563
1533
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1564
1534
  var _story$componentLayou = story.componentLayouts,
1565
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1566
-
1535
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1567
1536
  var _ref = image || {},
1568
- url = _ref.url;
1569
-
1537
+ url = _ref.url;
1570
1538
  var content = _objectSpread__default["default"](_objectSpread__default["default"]({
1571
1539
  role: role
1572
1540
  }, componentLayouts[role] ? {
@@ -1574,7 +1542,6 @@ var ImageElement = function ImageElement(story, image) {
1574
1542
  } : {}), {}, {
1575
1543
  URL: url
1576
1544
  });
1577
-
1578
1545
  var component = utils.validate(content, definition);
1579
1546
  return {
1580
1547
  story: story,
@@ -1709,14 +1676,12 @@ var MapElement = function MapElement(story, map) {
1709
1676
  var role = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'map';
1710
1677
  var definition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1711
1678
  var _story$componentLayou = story.componentLayouts,
1712
- componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1713
-
1679
+ componentLayouts = _story$componentLayou === void 0 ? {} : _story$componentLayou;
1714
1680
  var _ref = map || {},
1715
- _ref$latitude = _ref.latitude,
1716
- latitude = _ref$latitude === void 0 ? null : _ref$latitude,
1717
- _ref$longitude = _ref.longitude,
1718
- longitude = _ref$longitude === void 0 ? null : _ref$longitude;
1719
-
1681
+ _ref$latitude = _ref.latitude,
1682
+ latitude = _ref$latitude === void 0 ? null : _ref$latitude,
1683
+ _ref$longitude = _ref.longitude,
1684
+ longitude = _ref$longitude === void 0 ? null : _ref$longitude;
1720
1685
  var content = _objectSpread__default["default"](_objectSpread__default["default"]({
1721
1686
  role: role
1722
1687
  }, componentLayouts[role] ? {
@@ -1725,7 +1690,6 @@ var MapElement = function MapElement(story, map) {
1725
1690
  latitude: latitude,
1726
1691
  longitude: longitude
1727
1692
  });
1728
-
1729
1693
  var component = utils.validate(content, definition);
1730
1694
  return {
1731
1695
  story: story,
package/lib/index.js CHANGED
@@ -13,22 +13,19 @@ var transformer = function transformer(story, type, settings) {
13
13
  if (type === 'appleNews') {
14
14
  return appleNews.Article(story, settings);
15
15
  }
16
-
17
16
  return story;
18
17
  };
19
18
 
20
19
  var postProcessor = function postProcessor(story, type) {
21
20
  if (type === 'appleNews') {
22
21
  var _ref = story || {},
23
- components = _ref.components;
24
-
22
+ components = _ref.components;
25
23
  return _objectSpread__default["default"](_objectSpread__default["default"]({}, story), {}, {
26
24
  components: components.filter(function (c) {
27
25
  return c !== null;
28
26
  })
29
27
  });
30
28
  }
31
-
32
29
  return story;
33
30
  };
34
31
 
package/lib/utils.js CHANGED
@@ -22,45 +22,36 @@ var validate = function validate() {
22
22
  var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
23
  var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
24
24
  var validated = content ? Object.keys(content).reduce(function (values, name) {
25
- var value = content[name] || null; // Find the reference
26
-
25
+ var value = content[name] || null;
26
+ // Find the reference
27
27
  if (definition && definition.properties) {
28
28
  var property = definition.properties.find(function (prop) {
29
29
  return prop.name === name;
30
30
  }) || null;
31
-
32
31
  if (property !== null) {
33
32
  var isValid = true;
34
-
35
33
  switch (property.type) {
36
34
  case 'string':
37
35
  isValid = isString__default["default"](value);
38
36
  break;
39
-
40
37
  case 'integer':
41
38
  isValid = isInteger__default["default"](value);
42
39
  break;
43
-
44
40
  case 'float':
45
41
  isValid = isNumber__default["default"](value);
46
42
  break;
47
-
48
43
  default:
49
44
  isValid = value !== null;
50
45
  break;
51
- } // Skip the whole thing it cause it aint gonna work
52
-
53
-
46
+ }
47
+ // Skip the whole thing it cause it aint gonna work
54
48
  if (!isValid && property.required) {
55
49
  console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
56
-
57
50
  return null;
58
51
  }
59
-
60
52
  if (values !== null && isValid) {
61
53
  return _objectSpread__default["default"](_objectSpread__default["default"]({}, values), {}, _defineProperty__default["default"]({}, name, value));
62
54
  }
63
-
64
55
  console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
65
56
  }
66
57
  }
@@ -74,7 +65,6 @@ var stripTags = function stripTags(str) {
74
65
  if (!str) {
75
66
  return null;
76
67
  }
77
-
78
68
  return str.replace(/(<([^>]+)>)/gi, '');
79
69
  };
80
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/transforms",
3
- "version": "0.3.311",
3
+ "version": "0.3.322",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -62,14 +62,14 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@babel/runtime": "^7.13.10",
65
- "@micromag/core": "^0.3.311",
65
+ "@micromag/core": "^0.3.322",
66
66
  "lodash": "^4.17.21",
67
67
  "object-hash": "^2.1.1",
68
68
  "prop-types": "^15.7.2",
69
- "uuid": "^8.3.2"
69
+ "uuid": "^9.0.0"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "fab297a7ad204611597c749b969f14d992d35d47"
74
+ "gitHead": "2dfe09ad5a9ac720e4bfbffcb6371fc31c24fa9f"
75
75
  }