@micromag/transforms 0.2.286
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/apple-news.js +1 -0
- package/es/apple-news.js +2157 -0
- package/es/index.js +27 -0
- package/es/utils.js +68 -0
- package/lib/apple-news.js +2186 -0
- package/lib/index.js +36 -0
- package/lib/utils.js +82 -0
- package/package.json +75 -0
- package/utils.js +1 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var appleNews = require('@micromag/transforms/apple-news');
|
|
6
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
11
|
+
|
|
12
|
+
var transformer = function transformer(story, type, settings) {
|
|
13
|
+
if (type === 'appleNews') {
|
|
14
|
+
return appleNews.Article(story, settings);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return story;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var postProcessor = function postProcessor(story, type) {
|
|
21
|
+
if (type === 'appleNews') {
|
|
22
|
+
var _ref = story || {},
|
|
23
|
+
components = _ref.components;
|
|
24
|
+
|
|
25
|
+
return _objectSpread__default['default'](_objectSpread__default['default']({}, story), {}, {
|
|
26
|
+
components: components.filter(function (c) {
|
|
27
|
+
return c !== null;
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return story;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.postProcessor = postProcessor;
|
|
36
|
+
exports.transformer = transformer;
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
7
|
+
var isString = require('lodash/isString');
|
|
8
|
+
var isInteger = require('lodash/isInteger');
|
|
9
|
+
var isNumber = require('lodash/isNumber');
|
|
10
|
+
var isEmpty = require('lodash/isEmpty');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
15
|
+
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
16
|
+
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
17
|
+
var isInteger__default = /*#__PURE__*/_interopDefaultLegacy(isInteger);
|
|
18
|
+
var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
|
|
19
|
+
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
20
|
+
|
|
21
|
+
var validate = function validate() {
|
|
22
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
|
+
var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
24
|
+
var validated = content ? Object.keys(content).reduce(function (values, name) {
|
|
25
|
+
var value = content[name] || null; // Find the reference
|
|
26
|
+
|
|
27
|
+
if (definition && definition.properties) {
|
|
28
|
+
var property = definition.properties.find(function (prop) {
|
|
29
|
+
return prop.name === name;
|
|
30
|
+
}) || null;
|
|
31
|
+
|
|
32
|
+
if (property !== null) {
|
|
33
|
+
var isValid = true;
|
|
34
|
+
|
|
35
|
+
switch (property.type) {
|
|
36
|
+
case 'string':
|
|
37
|
+
isValid = isString__default['default'](value);
|
|
38
|
+
break;
|
|
39
|
+
|
|
40
|
+
case 'integer':
|
|
41
|
+
isValid = isInteger__default['default'](value);
|
|
42
|
+
break;
|
|
43
|
+
|
|
44
|
+
case 'float':
|
|
45
|
+
isValid = isNumber__default['default'](value);
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
default:
|
|
49
|
+
isValid = value !== null;
|
|
50
|
+
break;
|
|
51
|
+
} // Skip the whole thing it cause it aint gonna work
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if (!isValid && property.required) {
|
|
55
|
+
console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (values !== null && isValid) {
|
|
61
|
+
return _objectSpread__default['default'](_objectSpread__default['default']({}, values), {}, _defineProperty__default['default']({}, name, value));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return values;
|
|
69
|
+
}, {}) : {};
|
|
70
|
+
return !isEmpty__default['default'](validated) ? validated : null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var stripTags = function stripTags(str) {
|
|
74
|
+
if (!str) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return str.replace(/(<([^>]+)>)/gi, '');
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.stripTags = stripTags;
|
|
82
|
+
exports.validate = validate;
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@micromag/transforms",
|
|
3
|
+
"version": "0.2.286",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"javascript"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/urbania-media/micromag-js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/urbania-media/micromag-js.git"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Folklore",
|
|
15
|
+
"email": "info@folklore.email"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [
|
|
18
|
+
{
|
|
19
|
+
"name": "David Mongeau-Petitpas",
|
|
20
|
+
"email": "dmp@folklore.email"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Nicolas Roy-Bourdages",
|
|
24
|
+
"email": "nrb@folklore.email"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Julien Carignan",
|
|
28
|
+
"email": "jc@folklore.email"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"main": "lib/index.js",
|
|
33
|
+
"module": "es/index.js",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": "./lib/index.js",
|
|
36
|
+
"./apple-news": "./lib/apple-news.js",
|
|
37
|
+
"./utils": "./lib/utils.js"
|
|
38
|
+
},
|
|
39
|
+
"browser": {
|
|
40
|
+
".": "./es/index.js",
|
|
41
|
+
"./apple-news": "./es/apple-news.js",
|
|
42
|
+
"./utils": "./es/utils.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"lib",
|
|
46
|
+
"es",
|
|
47
|
+
"assets",
|
|
48
|
+
"scss",
|
|
49
|
+
"apple-news.js",
|
|
50
|
+
"utils.js"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"prepare": "../../scripts/prepare-package.sh"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"react": "^16.8.0",
|
|
57
|
+
"react-dom": "^16.8.0"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"react": "^16.8.0",
|
|
61
|
+
"react-dom": "^16.8.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@babel/runtime": "^7.13.10",
|
|
65
|
+
"@micromag/core": "^0.2.286",
|
|
66
|
+
"lodash": "^4.17.20",
|
|
67
|
+
"object-hash": "^2.1.1",
|
|
68
|
+
"prop-types": "^15.7.2",
|
|
69
|
+
"uuid": "^8.3.2"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "380a52b4b3f57dc2535014af6241032f09055d40"
|
|
75
|
+
}
|
package/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/utils');
|