gatsby-plugin-image 2.15.0-next.2 → 2.15.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/CHANGELOG.md +14 -0
- package/dist/babel-helpers.js +66 -66
- package/dist/babel-plugin-parse-static-images.js +80 -80
- package/dist/components/gatsby-image.browser.js +170 -170
- 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-image.js +1 -1
- package/dist/gatsby-image.js.map +1 -1
- package/dist/gatsby-image.module.js +1 -1
- package/dist/gatsby-image.module.js.map +1 -1
- package/dist/gatsby-node.js +58 -58
- package/dist/global.js +2 -2
- package/dist/image-utils.js +442 -442
- package/dist/index.browser-bd6b0c0c.js.map +1 -1
- package/dist/index.browser-cdba1a30.js.map +1 -1
- package/dist/index.js +32 -32
- package/dist/node-apis/image-processing.js +278 -278
- package/dist/node-apis/node-utils.js +11 -11
- package/dist/node-apis/parser.js +98 -98
- package/dist/node-apis/preprocess-source.js +118 -118
- package/dist/node-apis/watcher.js +129 -129
- package/dist/resolver-utils.js +120 -119
- package/dist/src/babel-helpers.d.ts +6 -6
- package/dist/src/babel-plugin-parse-static-images.d.ts +10 -10
- package/dist/src/components/layout-wrapper.d.ts.map +1 -1
- package/dist/src/gatsby-node.d.ts +5 -5
- package/dist/src/node-apis/image-processing.d.ts +30 -30
- 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 +6 -5
|
@@ -1,170 +1,170 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
-
var t = {};
|
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
-
t[p] = s[p];
|
|
40
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
-
t[p[i]] = s[p[i]];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
|
-
exports.__esModule = true;
|
|
48
|
-
exports.GatsbyImage = void 0;
|
|
49
|
-
var react_1 = require("react");
|
|
50
|
-
var hooks_1 = require("./hooks");
|
|
51
|
-
var layout_wrapper_1 = require("./layout-wrapper");
|
|
52
|
-
var gatsby_image_server_1 = require("./gatsby-image.server");
|
|
53
|
-
var imageCache = new Set();
|
|
54
|
-
var renderImageToStringPromise;
|
|
55
|
-
var renderImage;
|
|
56
|
-
var GatsbyImageHydrator = function GatsbyImageHydrator(_a) {
|
|
57
|
-
var _b = _a.as, as = _b === void 0 ? "div" : _b, image = _a.image, style = _a.style, backgroundColor = _a.backgroundColor, className = _a.className, preactClass = _a["class"], onStartLoad = _a.onStartLoad, onLoad = _a.onLoad, onError = _a.onError, props = __rest(_a, ["as", "image", "style", "backgroundColor", "className", "class", "onStartLoad", "onLoad", "onError"]);
|
|
58
|
-
var width = image.width, height = image.height, layout = image.layout;
|
|
59
|
-
var _c = (0, hooks_1.getWrapperProps)(width, height, layout), wStyle = _c.style, wClass = _c.className, wrapperProps = __rest(_c, ["style", "className"]);
|
|
60
|
-
var root = (0, react_1.useRef)();
|
|
61
|
-
var cacheKey = (0, react_1.useMemo)(function () { return JSON.stringify(image.images); }, [image.images]);
|
|
62
|
-
// Preact uses class instead of className so we need to check for both
|
|
63
|
-
if (preactClass) {
|
|
64
|
-
className = preactClass;
|
|
65
|
-
}
|
|
66
|
-
var sizer = (0, layout_wrapper_1.getSizer)(layout, width, height);
|
|
67
|
-
(0, react_1.useEffect)(function () {
|
|
68
|
-
if (!renderImageToStringPromise) {
|
|
69
|
-
renderImageToStringPromise = Promise.resolve().then(function () { return __importStar(require("./lazy-hydrate")); }).then(function (_a) {
|
|
70
|
-
var renderImageToString = _a.renderImageToString, swapPlaceholderImage = _a.swapPlaceholderImage;
|
|
71
|
-
renderImage = renderImageToString;
|
|
72
|
-
return {
|
|
73
|
-
renderImageToString: renderImageToString,
|
|
74
|
-
swapPlaceholderImage: swapPlaceholderImage
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
// The plugin image component is a bit special where if it's server-side rendered, we add extra script tags to support lazy-loading without
|
|
79
|
-
// In this case we stop hydration but fire the correct events.
|
|
80
|
-
var ssrImage = root.current.querySelector("[data-gatsby-image-ssr]");
|
|
81
|
-
if (ssrImage && (0, hooks_1.hasNativeLazyLoadSupport)()) {
|
|
82
|
-
if (ssrImage.complete) {
|
|
83
|
-
// Trigger onStartload and onLoad events
|
|
84
|
-
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
85
|
-
wasCached: true
|
|
86
|
-
});
|
|
87
|
-
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
88
|
-
wasCached: true
|
|
89
|
-
});
|
|
90
|
-
// remove ssr key for state updates but add delay to not fight with native code snippt of gatsby-ssr
|
|
91
|
-
setTimeout(function () {
|
|
92
|
-
ssrImage.removeAttribute("data-gatsby-image-ssr");
|
|
93
|
-
}, 0);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
document.addEventListener("load", function onLoadListener() {
|
|
97
|
-
document.removeEventListener("load", onLoadListener);
|
|
98
|
-
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
99
|
-
wasCached: true
|
|
100
|
-
});
|
|
101
|
-
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
102
|
-
wasCached: true
|
|
103
|
-
});
|
|
104
|
-
// remove ssr key for state updates but add delay to not fight with native code snippt of gatsby-ssr
|
|
105
|
-
setTimeout(function () {
|
|
106
|
-
ssrImage.removeAttribute("data-gatsby-image-ssr");
|
|
107
|
-
}, 0);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
imageCache.add(cacheKey);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (renderImage && imageCache.has(cacheKey)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
var animationFrame;
|
|
117
|
-
var cleanupCallback;
|
|
118
|
-
renderImageToStringPromise.then(function (_a) {
|
|
119
|
-
var renderImageToString = _a.renderImageToString, swapPlaceholderImage = _a.swapPlaceholderImage;
|
|
120
|
-
root.current.innerHTML = renderImageToString(__assign({ isLoading: true, isLoaded: imageCache.has(cacheKey), image: image }, props));
|
|
121
|
-
if (!imageCache.has(cacheKey)) {
|
|
122
|
-
animationFrame = requestAnimationFrame(function () {
|
|
123
|
-
if (root.current) {
|
|
124
|
-
cleanupCallback = swapPlaceholderImage(root.current, cacheKey, imageCache, style, onStartLoad, onLoad, onError);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
// eslint-disable-next-line consistent-return
|
|
130
|
-
return function () {
|
|
131
|
-
if (animationFrame) {
|
|
132
|
-
cancelAnimationFrame(animationFrame);
|
|
133
|
-
}
|
|
134
|
-
if (cleanupCallback) {
|
|
135
|
-
cleanupCallback();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}, [image]);
|
|
139
|
-
// useLayoutEffect is ran before React commits to the DOM. This allows us to make sure our HTML is using our cached image version
|
|
140
|
-
(0, react_1.useLayoutEffect)(function () {
|
|
141
|
-
if (imageCache.has(cacheKey) && renderImage) {
|
|
142
|
-
root.current.innerHTML = renderImage(__assign({ isLoading: imageCache.has(cacheKey), isLoaded: imageCache.has(cacheKey), image: image }, props));
|
|
143
|
-
// Trigger onStartload and onLoad events
|
|
144
|
-
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
145
|
-
wasCached: true
|
|
146
|
-
});
|
|
147
|
-
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
148
|
-
wasCached: true
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}, [image]);
|
|
152
|
-
// By keeping all props equal React will keep the component in the DOM
|
|
153
|
-
return (0, react_1.createElement)(as, __assign(__assign({}, wrapperProps), { style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : ""), ref: root, dangerouslySetInnerHTML: {
|
|
154
|
-
__html: sizer
|
|
155
|
-
}, suppressHydrationWarning: true }));
|
|
156
|
-
};
|
|
157
|
-
exports.GatsbyImage = (0, react_1.memo)(function GatsbyImage(props) {
|
|
158
|
-
if (!props.image) {
|
|
159
|
-
if (process.env.NODE_ENV === "development") {
|
|
160
|
-
console.warn("[gatsby-plugin-image] Missing image prop");
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
if (!(0, hooks_1.gatsbyImageIsInstalled)() && process.env.NODE_ENV === "development") {
|
|
165
|
-
console.warn("[gatsby-plugin-image] You're missing out on some cool performance features. Please add \"gatsby-plugin-image\" to your gatsby-config.js");
|
|
166
|
-
}
|
|
167
|
-
return (0, react_1.createElement)(GatsbyImageHydrator, props);
|
|
168
|
-
});
|
|
169
|
-
exports.GatsbyImage.propTypes = gatsby_image_server_1.propTypes;
|
|
170
|
-
exports.GatsbyImage.displayName = "GatsbyImage";
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
exports.__esModule = true;
|
|
48
|
+
exports.GatsbyImage = void 0;
|
|
49
|
+
var react_1 = require("react");
|
|
50
|
+
var hooks_1 = require("./hooks");
|
|
51
|
+
var layout_wrapper_1 = require("./layout-wrapper");
|
|
52
|
+
var gatsby_image_server_1 = require("./gatsby-image.server");
|
|
53
|
+
var imageCache = new Set();
|
|
54
|
+
var renderImageToStringPromise;
|
|
55
|
+
var renderImage;
|
|
56
|
+
var GatsbyImageHydrator = function GatsbyImageHydrator(_a) {
|
|
57
|
+
var _b = _a.as, as = _b === void 0 ? "div" : _b, image = _a.image, style = _a.style, backgroundColor = _a.backgroundColor, className = _a.className, preactClass = _a["class"], onStartLoad = _a.onStartLoad, onLoad = _a.onLoad, onError = _a.onError, props = __rest(_a, ["as", "image", "style", "backgroundColor", "className", "class", "onStartLoad", "onLoad", "onError"]);
|
|
58
|
+
var width = image.width, height = image.height, layout = image.layout;
|
|
59
|
+
var _c = (0, hooks_1.getWrapperProps)(width, height, layout), wStyle = _c.style, wClass = _c.className, wrapperProps = __rest(_c, ["style", "className"]);
|
|
60
|
+
var root = (0, react_1.useRef)();
|
|
61
|
+
var cacheKey = (0, react_1.useMemo)(function () { return JSON.stringify(image.images); }, [image.images]);
|
|
62
|
+
// Preact uses class instead of className so we need to check for both
|
|
63
|
+
if (preactClass) {
|
|
64
|
+
className = preactClass;
|
|
65
|
+
}
|
|
66
|
+
var sizer = (0, layout_wrapper_1.getSizer)(layout, width, height);
|
|
67
|
+
(0, react_1.useEffect)(function () {
|
|
68
|
+
if (!renderImageToStringPromise) {
|
|
69
|
+
renderImageToStringPromise = Promise.resolve().then(function () { return __importStar(require("./lazy-hydrate")); }).then(function (_a) {
|
|
70
|
+
var renderImageToString = _a.renderImageToString, swapPlaceholderImage = _a.swapPlaceholderImage;
|
|
71
|
+
renderImage = renderImageToString;
|
|
72
|
+
return {
|
|
73
|
+
renderImageToString: renderImageToString,
|
|
74
|
+
swapPlaceholderImage: swapPlaceholderImage
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// The plugin image component is a bit special where if it's server-side rendered, we add extra script tags to support lazy-loading without
|
|
79
|
+
// In this case we stop hydration but fire the correct events.
|
|
80
|
+
var ssrImage = root.current.querySelector("[data-gatsby-image-ssr]");
|
|
81
|
+
if (ssrImage && (0, hooks_1.hasNativeLazyLoadSupport)()) {
|
|
82
|
+
if (ssrImage.complete) {
|
|
83
|
+
// Trigger onStartload and onLoad events
|
|
84
|
+
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
85
|
+
wasCached: true
|
|
86
|
+
});
|
|
87
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
88
|
+
wasCached: true
|
|
89
|
+
});
|
|
90
|
+
// remove ssr key for state updates but add delay to not fight with native code snippt of gatsby-ssr
|
|
91
|
+
setTimeout(function () {
|
|
92
|
+
ssrImage.removeAttribute("data-gatsby-image-ssr");
|
|
93
|
+
}, 0);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
document.addEventListener("load", function onLoadListener() {
|
|
97
|
+
document.removeEventListener("load", onLoadListener);
|
|
98
|
+
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
99
|
+
wasCached: true
|
|
100
|
+
});
|
|
101
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
102
|
+
wasCached: true
|
|
103
|
+
});
|
|
104
|
+
// remove ssr key for state updates but add delay to not fight with native code snippt of gatsby-ssr
|
|
105
|
+
setTimeout(function () {
|
|
106
|
+
ssrImage.removeAttribute("data-gatsby-image-ssr");
|
|
107
|
+
}, 0);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
imageCache.add(cacheKey);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (renderImage && imageCache.has(cacheKey)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
var animationFrame;
|
|
117
|
+
var cleanupCallback;
|
|
118
|
+
renderImageToStringPromise.then(function (_a) {
|
|
119
|
+
var renderImageToString = _a.renderImageToString, swapPlaceholderImage = _a.swapPlaceholderImage;
|
|
120
|
+
root.current.innerHTML = renderImageToString(__assign({ isLoading: true, isLoaded: imageCache.has(cacheKey), image: image }, props));
|
|
121
|
+
if (!imageCache.has(cacheKey)) {
|
|
122
|
+
animationFrame = requestAnimationFrame(function () {
|
|
123
|
+
if (root.current) {
|
|
124
|
+
cleanupCallback = swapPlaceholderImage(root.current, cacheKey, imageCache, style, onStartLoad, onLoad, onError);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
// eslint-disable-next-line consistent-return
|
|
130
|
+
return function () {
|
|
131
|
+
if (animationFrame) {
|
|
132
|
+
cancelAnimationFrame(animationFrame);
|
|
133
|
+
}
|
|
134
|
+
if (cleanupCallback) {
|
|
135
|
+
cleanupCallback();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}, [image]);
|
|
139
|
+
// useLayoutEffect is ran before React commits to the DOM. This allows us to make sure our HTML is using our cached image version
|
|
140
|
+
(0, react_1.useLayoutEffect)(function () {
|
|
141
|
+
if (imageCache.has(cacheKey) && renderImage) {
|
|
142
|
+
root.current.innerHTML = renderImage(__assign({ isLoading: imageCache.has(cacheKey), isLoaded: imageCache.has(cacheKey), image: image }, props));
|
|
143
|
+
// Trigger onStartload and onLoad events
|
|
144
|
+
onStartLoad === null || onStartLoad === void 0 ? void 0 : onStartLoad({
|
|
145
|
+
wasCached: true
|
|
146
|
+
});
|
|
147
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad({
|
|
148
|
+
wasCached: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, [image]);
|
|
152
|
+
// By keeping all props equal React will keep the component in the DOM
|
|
153
|
+
return (0, react_1.createElement)(as, __assign(__assign({}, wrapperProps), { style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : ""), ref: root, dangerouslySetInnerHTML: {
|
|
154
|
+
__html: sizer
|
|
155
|
+
}, suppressHydrationWarning: true }));
|
|
156
|
+
};
|
|
157
|
+
exports.GatsbyImage = (0, react_1.memo)(function GatsbyImage(props) {
|
|
158
|
+
if (!props.image) {
|
|
159
|
+
if (process.env.NODE_ENV === "development") {
|
|
160
|
+
console.warn("[gatsby-plugin-image] Missing image prop");
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
if (!(0, hooks_1.gatsbyImageIsInstalled)() && process.env.NODE_ENV === "development") {
|
|
165
|
+
console.warn("[gatsby-plugin-image] You're missing out on some cool performance features. Please add \"gatsby-plugin-image\" to your gatsby-config.js");
|
|
166
|
+
}
|
|
167
|
+
return (0, react_1.createElement)(GatsbyImageHydrator, props);
|
|
168
|
+
});
|
|
169
|
+
exports.GatsbyImage.propTypes = gatsby_image_server_1.propTypes;
|
|
170
|
+
exports.GatsbyImage.displayName = "GatsbyImage";
|
|
@@ -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
|
+
};
|