gatsby-plugin-image 2.19.0-next.2 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel-helpers.js +66 -66
- package/dist/babel-plugin-parse-static-images.js +80 -80
- package/dist/components/gatsby-image.browser.js +173 -173
- package/dist/components/gatsby-image.server.js +106 -106
- package/dist/components/hooks.js +250 -250
- package/dist/components/intersection-observer.js +53 -53
- package/dist/components/layout-wrapper.js +95 -95
- package/dist/components/lazy-hydrate.js +218 -218
- package/dist/components/main-image.js +28 -28
- package/dist/components/picture.js +103 -103
- package/dist/components/placeholder.js +78 -78
- package/dist/components/static-image.server.js +111 -111
- package/dist/gatsby-node.js +58 -58
- package/dist/global.js +2 -2
- package/dist/image-utils.js +442 -442
- package/dist/index.js +32 -32
- package/dist/node-apis/image-processing.js +276 -276
- package/dist/node-apis/node-utils.js +11 -11
- package/dist/node-apis/parser.js +98 -98
- package/dist/node-apis/preprocess-source.js +117 -117
- package/dist/node-apis/watcher.js +129 -129
- package/dist/resolver-utils.js +120 -120
- package/dist/src/babel-helpers.d.ts +6 -6
- package/dist/src/babel-plugin-parse-static-images.d.ts +10 -10
- package/dist/src/gatsby-node.d.ts +5 -5
- package/dist/src/node-apis/image-processing.d.ts +29 -29
- package/dist/src/node-apis/node-utils.d.ts +1 -1
- package/dist/src/node-apis/parser.d.ts +11 -11
- package/dist/src/node-apis/preprocess-source.d.ts +2 -2
- package/dist/src/node-apis/watcher.d.ts +12 -12
- package/dist/src/resolver-utils.d.ts +21 -21
- package/package.json +5 -5
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
-
if (!m) return o;
|
|
27
|
-
var i = m.call(o), r, ar = [], e;
|
|
28
|
-
try {
|
|
29
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
-
}
|
|
31
|
-
catch (error) { e = { error: error }; }
|
|
32
|
-
finally {
|
|
33
|
-
try {
|
|
34
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
-
}
|
|
36
|
-
finally { if (e) throw e.error; }
|
|
37
|
-
}
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
41
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42
|
-
if (ar || !(i in from)) {
|
|
43
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
44
|
-
ar[i] = from[i];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
exports.__esModule = true;
|
|
53
|
-
exports.propTypes = exports.altValidator = exports.GatsbyImage = void 0;
|
|
54
|
-
var react_1 = __importDefault(require("react"));
|
|
55
|
-
var hooks_1 = require("./hooks");
|
|
56
|
-
var placeholder_1 = require("./placeholder");
|
|
57
|
-
var main_image_1 = require("./main-image");
|
|
58
|
-
var layout_wrapper_1 = require("./layout-wrapper");
|
|
59
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
60
|
-
var removeNewLines = function (str) { return str.replace(/\n/g, ""); };
|
|
61
|
-
var GatsbyImage = function GatsbyImage(_a) {
|
|
62
|
-
var _b = _a.as, as = _b === void 0 ? "div" : _b, className = _a.className, preactClass = _a["class"], style = _a.style, image = _a.image, _c = _a.loading, loading = _c === void 0 ? "lazy" : _c, imgClassName = _a.imgClassName, imgStyle = _a.imgStyle, backgroundColor = _a.backgroundColor, objectFit = _a.objectFit, objectPosition = _a.objectPosition, props = __rest(_a, ["as", "className", "class", "style", "image", "loading", "imgClassName", "imgStyle", "backgroundColor", "objectFit", "objectPosition"]);
|
|
63
|
-
if (!image) {
|
|
64
|
-
console.warn("[gatsby-plugin-image] Missing image prop");
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
if (preactClass) {
|
|
68
|
-
className = preactClass;
|
|
69
|
-
}
|
|
70
|
-
imgStyle = __assign({ objectFit: objectFit, objectPosition: objectPosition, backgroundColor: backgroundColor }, imgStyle);
|
|
71
|
-
var width = image.width, height = image.height, layout = image.layout, images = image.images, placeholder = image.placeholder, placeholderBackgroundColor = image.backgroundColor;
|
|
72
|
-
var _d = (0, hooks_1.getWrapperProps)(width, height, layout), wStyle = _d.style, wClass = _d.className, wrapperProps = __rest(_d, ["style", "className"]);
|
|
73
|
-
var cleanedImages = {
|
|
74
|
-
fallback: undefined,
|
|
75
|
-
sources: []
|
|
76
|
-
};
|
|
77
|
-
if (images.fallback) {
|
|
78
|
-
cleanedImages.fallback = __assign(__assign({}, images.fallback), { srcSet: images.fallback.srcSet
|
|
79
|
-
? removeNewLines(images.fallback.srcSet)
|
|
80
|
-
: undefined });
|
|
81
|
-
}
|
|
82
|
-
if (images.sources) {
|
|
83
|
-
cleanedImages.sources = images.sources.map(function (source) {
|
|
84
|
-
return __assign(__assign({}, source), { srcSet: removeNewLines(source.srcSet) });
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return react_1["default"].createElement(as, __assign(__assign({}, wrapperProps), { style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : "") }), react_1["default"].createElement(layout_wrapper_1.LayoutWrapper, { layout: layout, width: width, height: height },
|
|
88
|
-
react_1["default"].createElement(placeholder_1.Placeholder, __assign({}, (0, hooks_1.getPlaceholderProps)(placeholder, false, layout, width, height, placeholderBackgroundColor, objectFit, objectPosition))),
|
|
89
|
-
react_1["default"].createElement(main_image_1.MainImage, __assign({ "data-gatsby-image-ssr": "", className: imgClassName }, props, (0, hooks_1.getMainProps)(loading === "eager", false, cleanedImages, loading, imgStyle)))));
|
|
90
|
-
};
|
|
91
|
-
exports.GatsbyImage = GatsbyImage;
|
|
92
|
-
var altValidator = function (props, propName, componentName) {
|
|
93
|
-
var rest = [];
|
|
94
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
95
|
-
rest[_i - 3] = arguments[_i];
|
|
96
|
-
}
|
|
97
|
-
if (!props.alt && props.alt !== "") {
|
|
98
|
-
return new Error("The \"alt\" prop is required in ".concat(componentName, ". If the image is purely presentational then pass an empty string: e.g. alt=\"\". Learn more: https://a11y-style-guide.com/style-guide/section-media.html"));
|
|
99
|
-
}
|
|
100
|
-
return prop_types_1["default"].string.apply(prop_types_1["default"], __spreadArray([props, propName, componentName], __read(rest), false));
|
|
101
|
-
};
|
|
102
|
-
exports.altValidator = altValidator;
|
|
103
|
-
exports.propTypes = {
|
|
104
|
-
image: prop_types_1["default"].object.isRequired,
|
|
105
|
-
alt: exports.altValidator
|
|
106
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
+
if (!m) return o;
|
|
27
|
+
var i = m.call(o), r, ar = [], e;
|
|
28
|
+
try {
|
|
29
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) { e = { error: error }; }
|
|
32
|
+
finally {
|
|
33
|
+
try {
|
|
34
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
+
}
|
|
36
|
+
finally { if (e) throw e.error; }
|
|
37
|
+
}
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
41
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
42
|
+
if (ar || !(i in from)) {
|
|
43
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
44
|
+
ar[i] = from[i];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.propTypes = exports.altValidator = exports.GatsbyImage = void 0;
|
|
54
|
+
var react_1 = __importDefault(require("react"));
|
|
55
|
+
var hooks_1 = require("./hooks");
|
|
56
|
+
var placeholder_1 = require("./placeholder");
|
|
57
|
+
var main_image_1 = require("./main-image");
|
|
58
|
+
var layout_wrapper_1 = require("./layout-wrapper");
|
|
59
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
|
60
|
+
var removeNewLines = function (str) { return str.replace(/\n/g, ""); };
|
|
61
|
+
var GatsbyImage = function GatsbyImage(_a) {
|
|
62
|
+
var _b = _a.as, as = _b === void 0 ? "div" : _b, className = _a.className, preactClass = _a["class"], style = _a.style, image = _a.image, _c = _a.loading, loading = _c === void 0 ? "lazy" : _c, imgClassName = _a.imgClassName, imgStyle = _a.imgStyle, backgroundColor = _a.backgroundColor, objectFit = _a.objectFit, objectPosition = _a.objectPosition, props = __rest(_a, ["as", "className", "class", "style", "image", "loading", "imgClassName", "imgStyle", "backgroundColor", "objectFit", "objectPosition"]);
|
|
63
|
+
if (!image) {
|
|
64
|
+
console.warn("[gatsby-plugin-image] Missing image prop");
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (preactClass) {
|
|
68
|
+
className = preactClass;
|
|
69
|
+
}
|
|
70
|
+
imgStyle = __assign({ objectFit: objectFit, objectPosition: objectPosition, backgroundColor: backgroundColor }, imgStyle);
|
|
71
|
+
var width = image.width, height = image.height, layout = image.layout, images = image.images, placeholder = image.placeholder, placeholderBackgroundColor = image.backgroundColor;
|
|
72
|
+
var _d = (0, hooks_1.getWrapperProps)(width, height, layout), wStyle = _d.style, wClass = _d.className, wrapperProps = __rest(_d, ["style", "className"]);
|
|
73
|
+
var cleanedImages = {
|
|
74
|
+
fallback: undefined,
|
|
75
|
+
sources: []
|
|
76
|
+
};
|
|
77
|
+
if (images.fallback) {
|
|
78
|
+
cleanedImages.fallback = __assign(__assign({}, images.fallback), { srcSet: images.fallback.srcSet
|
|
79
|
+
? removeNewLines(images.fallback.srcSet)
|
|
80
|
+
: undefined });
|
|
81
|
+
}
|
|
82
|
+
if (images.sources) {
|
|
83
|
+
cleanedImages.sources = images.sources.map(function (source) {
|
|
84
|
+
return __assign(__assign({}, source), { srcSet: removeNewLines(source.srcSet) });
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return react_1["default"].createElement(as, __assign(__assign({}, wrapperProps), { style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : "") }), react_1["default"].createElement(layout_wrapper_1.LayoutWrapper, { layout: layout, width: width, height: height },
|
|
88
|
+
react_1["default"].createElement(placeholder_1.Placeholder, __assign({}, (0, hooks_1.getPlaceholderProps)(placeholder, false, layout, width, height, placeholderBackgroundColor, objectFit, objectPosition))),
|
|
89
|
+
react_1["default"].createElement(main_image_1.MainImage, __assign({ "data-gatsby-image-ssr": "", className: imgClassName }, props, (0, hooks_1.getMainProps)(loading === "eager", false, cleanedImages, loading, imgStyle)))));
|
|
90
|
+
};
|
|
91
|
+
exports.GatsbyImage = GatsbyImage;
|
|
92
|
+
var altValidator = function (props, propName, componentName) {
|
|
93
|
+
var rest = [];
|
|
94
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
95
|
+
rest[_i - 3] = arguments[_i];
|
|
96
|
+
}
|
|
97
|
+
if (!props.alt && props.alt !== "") {
|
|
98
|
+
return new Error("The \"alt\" prop is required in ".concat(componentName, ". If the image is purely presentational then pass an empty string: e.g. alt=\"\". Learn more: https://a11y-style-guide.com/style-guide/section-media.html"));
|
|
99
|
+
}
|
|
100
|
+
return prop_types_1["default"].string.apply(prop_types_1["default"], __spreadArray([props, propName, componentName], __read(rest), false));
|
|
101
|
+
};
|
|
102
|
+
exports.altValidator = altValidator;
|
|
103
|
+
exports.propTypes = {
|
|
104
|
+
image: prop_types_1["default"].object.isRequired,
|
|
105
|
+
alt: exports.altValidator
|
|
106
|
+
};
|