gatsby-plugin-image 2.3.0-next.0 → 2.4.0-next.1
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 +19 -0
- package/dist/babel-helpers.js +1 -1
- package/dist/babel-plugin-parse-static-images.js +7 -7
- package/dist/components/gatsby-image.browser.js +1 -1
- package/dist/components/gatsby-image.server.js +2 -2
- package/dist/components/hooks.js +2 -2
- package/dist/components/layout-wrapper.js +4 -4
- package/dist/components/picture.js +1 -1
- package/dist/components/placeholder.js +1 -1
- package/dist/components/static-image.server.js +2 -2
- package/dist/image-utils.js +9 -9
- package/dist/node-apis/image-processing.js +9 -9
- package/dist/node-apis/watcher.js +3 -3
- package/dist/resolver-utils.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.3.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-image@2.3.0/packages/gatsby-plugin-image) (2021-12-01)
|
|
7
|
+
|
|
8
|
+
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.3)
|
|
9
|
+
|
|
10
|
+
**Note:** Version bump only for package gatsby-plugin-image
|
|
11
|
+
|
|
12
|
+
## [2.2.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-image@2.2.0/packages/gatsby-plugin-image) (2021-11-16)
|
|
13
|
+
|
|
14
|
+
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.2)
|
|
15
|
+
|
|
16
|
+
#### Chores
|
|
17
|
+
|
|
18
|
+
- update dependency @types/fs-extra to ^9.0.13 [#33350](https://github.com/gatsbyjs/gatsby/issues/33350) ([2574cce](https://github.com/gatsbyjs/gatsby/commit/2574cce054bf00718de40f6c7d789faeb871c710))
|
|
19
|
+
- update dependency typescript to ^4.4.4 [#33757](https://github.com/gatsbyjs/gatsby/issues/33757) ([7743561](https://github.com/gatsbyjs/gatsby/commit/7743561bbbe0a621d22030fecbba97dfc3e566d1))
|
|
20
|
+
|
|
21
|
+
### [2.1.3](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-image@2.1.3/packages/gatsby-plugin-image) (2021-11-15)
|
|
22
|
+
|
|
23
|
+
**Note:** Version bump only for package gatsby-plugin-image
|
|
24
|
+
|
|
6
25
|
### [2.1.2](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-image@2.1.2/packages/gatsby-plugin-image) (2021-11-11)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package gatsby-plugin-image
|
package/dist/babel-helpers.js
CHANGED
|
@@ -61,6 +61,6 @@ function evaluateImageAttributes(nodePath, onError) {
|
|
|
61
61
|
}
|
|
62
62
|
exports.evaluateImageAttributes = evaluateImageAttributes;
|
|
63
63
|
function hashOptions(options) {
|
|
64
|
-
return ""
|
|
64
|
+
return "".concat((0, murmur_1.murmurhash)(JSON.stringify(options)));
|
|
65
65
|
}
|
|
66
66
|
exports.hashOptions = hashOptions;
|
|
@@ -34,15 +34,15 @@ function attrs(_a) {
|
|
|
34
34
|
var error;
|
|
35
35
|
if (unresolvedProps.length) {
|
|
36
36
|
// TODO: Add a shortlink to docs on the plugin
|
|
37
|
-
error = "Could not find values for the following props at build time: "
|
|
38
|
-
console.warn("[gatsby-plugin-image] "
|
|
37
|
+
error = "Could not find values for the following props at build time: ".concat(unresolvedProps.join(", "));
|
|
38
|
+
console.warn("[gatsby-plugin-image] ".concat(error));
|
|
39
39
|
}
|
|
40
40
|
var hash = (0, babel_helpers_1.hashOptions)(props);
|
|
41
41
|
var cacheDir = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.cacheDir;
|
|
42
42
|
if (!cacheDir) {
|
|
43
43
|
console.warn("[gatsby-plugin-image] Couldn't find image data cache file");
|
|
44
44
|
}
|
|
45
|
-
var filename = path_1["default"].join(cacheDir, hash
|
|
45
|
+
var filename = path_1["default"].join(cacheDir, "".concat(hash, ".json"));
|
|
46
46
|
var data;
|
|
47
47
|
// If there's no src prop there's no point in checking if it exists
|
|
48
48
|
if (!unresolvedProps.includes("src")) {
|
|
@@ -53,13 +53,13 @@ function attrs(_a) {
|
|
|
53
53
|
// TODO add info about minimum Gatsby version once this is merged
|
|
54
54
|
var msg = (0, common_tags_1.stripIndent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Could not read image data file \"", "\". \n This may mean that the images in \"", "\" were not processed.\n Please ensure that your gatsby version is at least 2.24.78."], ["\n Could not read image data file \"", "\". \n This may mean that the images in \"", "\" were not processed.\n Please ensure that your gatsby version is at least 2.24.78."])), filename, this.filename);
|
|
55
55
|
error += msg;
|
|
56
|
-
console.warn("[gatsby-plugin-image] "
|
|
56
|
+
console.warn("[gatsby-plugin-image] ".concat(msg));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
if (!data) {
|
|
60
|
-
console.warn("[gatsby-plugin-image] No data found for image \""
|
|
60
|
+
console.warn("[gatsby-plugin-image] No data found for image \"".concat(props.src, "\""));
|
|
61
61
|
// Add the error message to the component so we can show it in the browser
|
|
62
|
-
var newProp_1 = t.jsxAttribute(t.jsxIdentifier("__error"), t.jsxExpressionContainer(t.stringLiteral("No data found for image \""
|
|
62
|
+
var newProp_1 = t.jsxAttribute(t.jsxIdentifier("__error"), t.jsxExpressionContainer(t.stringLiteral("No data found for image \"".concat(props.src, "\"\n ").concat(error || ""))));
|
|
63
63
|
nodePath.node.attributes.push(newProp_1);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
@@ -69,7 +69,7 @@ function attrs(_a) {
|
|
|
69
69
|
nodePath.node.attributes.push(newProp_2);
|
|
70
70
|
}
|
|
71
71
|
// `require()` the image data into a component prop
|
|
72
|
-
var makeRequire = template.expression("require(\""
|
|
72
|
+
var makeRequire = template.expression("require(\"".concat((0, gatsby_core_utils_1.slash)(filename), "\")"));
|
|
73
73
|
var newProp = t.jsxAttribute(t.jsxIdentifier("__imageData"), t.jsxExpressionContainer(makeRequire()));
|
|
74
74
|
nodePath.node.attributes.push(newProp);
|
|
75
75
|
}
|
|
@@ -214,7 +214,7 @@ var GatsbyImageHydrator = /** @class */ (function (_super) {
|
|
|
214
214
|
className = this.props["class"];
|
|
215
215
|
}
|
|
216
216
|
var sizer = (0, layout_wrapper_1.getSizer)(layout, width, height);
|
|
217
|
-
return (react_1["default"].createElement(Type, __assign({}, wrapperProps, { style: __assign(__assign(__assign({}, wStyle), this.props.style), { backgroundColor: this.props.backgroundColor }), className: ""
|
|
217
|
+
return (react_1["default"].createElement(Type, __assign({}, wrapperProps, { style: __assign(__assign(__assign({}, wStyle), this.props.style), { backgroundColor: this.props.backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : ""), ref: this.root, dangerouslySetInnerHTML: {
|
|
218
218
|
__html: sizer
|
|
219
219
|
}, suppressHydrationWarning: true })));
|
|
220
220
|
};
|
|
@@ -89,7 +89,7 @@ var GatsbyImage = function GatsbyImage(_a) {
|
|
|
89
89
|
return __assign(__assign({}, source), { srcSet: removeNewLines(source.srcSet) });
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
return (react_1["default"].createElement(exports.GatsbyImageHydrator, __assign({}, wrapperProps, { as: as, style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: ""
|
|
92
|
+
return (react_1["default"].createElement(exports.GatsbyImageHydrator, __assign({}, wrapperProps, { as: as, style: __assign(__assign(__assign({}, wStyle), style), { backgroundColor: backgroundColor }), className: "".concat(wClass).concat(className ? " ".concat(className) : "") }),
|
|
93
93
|
react_1["default"].createElement(layout_wrapper_1.LayoutWrapper, { layout: layout, width: width, height: height },
|
|
94
94
|
react_1["default"].createElement(placeholder_1.Placeholder, __assign({}, (0, hooks_1.getPlaceholderProps)(placeholder, false, layout, width, height, placeholderBackgroundColor, objectFit, objectPosition))),
|
|
95
95
|
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, undefined, undefined, undefined, imgStyle))))));
|
|
@@ -101,7 +101,7 @@ var altValidator = function (props, propName, componentName) {
|
|
|
101
101
|
rest[_i - 3] = arguments[_i];
|
|
102
102
|
}
|
|
103
103
|
if (!props.alt && props.alt !== "") {
|
|
104
|
-
return new Error("The \"alt\" prop is required in "
|
|
104
|
+
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"));
|
|
105
105
|
}
|
|
106
106
|
return prop_types_1["default"].string.apply(prop_types_1["default"], __spreadArray([props, propName, componentName], __read(rest), false));
|
|
107
107
|
};
|
package/dist/components/hooks.js
CHANGED
|
@@ -251,7 +251,7 @@ function getMainProps(isLoading, isLoaded, images, loading, toggleLoaded, cacheK
|
|
|
251
251
|
// Polyfill "object-fit" if unsupported (mostly IE)
|
|
252
252
|
if ((ref === null || ref === void 0 ? void 0 : ref.current) && !("objectFit" in document.documentElement.style)) {
|
|
253
253
|
ref.current.dataset.objectFit = (_a = style.objectFit) !== null && _a !== void 0 ? _a : "cover";
|
|
254
|
-
ref.current.dataset.objectPosition = ""
|
|
254
|
+
ref.current.dataset.objectPosition = "".concat((_b = style.objectPosition) !== null && _b !== void 0 ? _b : "50% 50%");
|
|
255
255
|
applyPolyfill(ref);
|
|
256
256
|
}
|
|
257
257
|
// fallback when it's not configured in gatsby-config.
|
|
@@ -374,7 +374,7 @@ function withArtDirection(defaultImage, artDirected) {
|
|
|
374
374
|
}
|
|
375
375
|
if (image.layout !== defaultImage.layout &&
|
|
376
376
|
process.env.NODE_ENV === "development") {
|
|
377
|
-
console.warn("[gatsby-plugin-image] Mismatched image layout: expected \""
|
|
377
|
+
console.warn("[gatsby-plugin-image] Mismatched image layout: expected \"".concat(defaultImage.layout, "\" but received \"").concat(image.layout, "\". All art-directed images use the same layout as the default image"));
|
|
378
378
|
}
|
|
379
379
|
(_b = output.images.sources).push.apply(_b, __spreadArray(__spreadArray([], __read(image.images.sources.map(function (source) {
|
|
380
380
|
return __assign(__assign({}, source), { media: media });
|
|
@@ -59,10 +59,10 @@ var NativeScriptLoading = function () { return (react_1["default"].createElement
|
|
|
59
59
|
function getSizer(layout, width, height) {
|
|
60
60
|
var sizer = null;
|
|
61
61
|
if (layout === "fullWidth") {
|
|
62
|
-
sizer = "<div aria-hidden=\"true\" style=\"padding-top: "
|
|
62
|
+
sizer = "<div aria-hidden=\"true\" style=\"padding-top: ".concat((height / width) * 100, "%;\"></div>");
|
|
63
63
|
}
|
|
64
64
|
if (layout === "constrained") {
|
|
65
|
-
sizer = "<div style=\"max-width: "
|
|
65
|
+
sizer = "<div style=\"max-width: ".concat(width, "px; display: block;\"><img alt=\"\" role=\"presentation\" aria-hidden=\"true\" src=\"data:image/svg+xml;charset=utf-8,%3Csvg height='").concat(height, "' width='").concat(width, "' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E\" style=\"max-width: 100%; display: block; position: static;\"></div>");
|
|
66
66
|
}
|
|
67
67
|
return sizer;
|
|
68
68
|
}
|
|
@@ -70,11 +70,11 @@ exports.getSizer = getSizer;
|
|
|
70
70
|
var Sizer = function Sizer(_a) {
|
|
71
71
|
var layout = _a.layout, width = _a.width, height = _a.height;
|
|
72
72
|
if (layout === "fullWidth") {
|
|
73
|
-
return (react_1["default"].createElement("div", { "aria-hidden": true, style: { paddingTop: (height / width) * 100
|
|
73
|
+
return (react_1["default"].createElement("div", { "aria-hidden": true, style: { paddingTop: "".concat((height / width) * 100, "%") } }));
|
|
74
74
|
}
|
|
75
75
|
if (layout === "constrained") {
|
|
76
76
|
return (react_1["default"].createElement("div", { style: { maxWidth: width, display: "block" } },
|
|
77
|
-
react_1["default"].createElement("img", { alt: "", role: "presentation", "aria-hidden": "true", src: "data:image/svg+xml;charset=utf-8,%3Csvg height='"
|
|
77
|
+
react_1["default"].createElement("img", { alt: "", role: "presentation", "aria-hidden": "true", src: "data:image/svg+xml;charset=utf-8,%3Csvg height='".concat(height, "' width='").concat(width, "' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E"), style: {
|
|
78
78
|
maxWidth: "100%",
|
|
79
79
|
display: "block",
|
|
80
80
|
position: "static"
|
|
@@ -59,7 +59,7 @@ exports.Picture = (0, react_1.forwardRef)(function Picture(_a, ref) {
|
|
|
59
59
|
return (react_1["default"].createElement("picture", null,
|
|
60
60
|
sources.map(function (_a) {
|
|
61
61
|
var media = _a.media, srcSet = _a.srcSet, type = _a.type;
|
|
62
|
-
return (react_1["default"].createElement("source", { key: media
|
|
62
|
+
return (react_1["default"].createElement("source", { key: "".concat(media, "-").concat(type, "-").concat(srcSet), type: type, media: media, srcSet: shouldLoad ? srcSet : undefined, "data-srcset": !shouldLoad ? srcSet : undefined, sizes: sizes }));
|
|
63
63
|
}),
|
|
64
64
|
fallbackImage));
|
|
65
65
|
});
|
|
@@ -69,6 +69,6 @@ exports.Placeholder.propTypes = {
|
|
|
69
69
|
if (!props[propName]) {
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
return new Error("Invalid prop `"
|
|
72
|
+
return new Error("Invalid prop `".concat(propName, "` supplied to `").concat(componentName, "`. Validation failed."));
|
|
73
73
|
}
|
|
74
74
|
};
|
|
@@ -86,7 +86,7 @@ var checkDimensionProps = function (props, propName) {
|
|
|
86
86
|
if (props.layout === "fullWidth" &&
|
|
87
87
|
(propName === "width" || propName === "height") &&
|
|
88
88
|
props[propName]) {
|
|
89
|
-
return new Error("\""
|
|
89
|
+
return new Error("\"".concat(propName, "\" ").concat(props[propName], " may not be passed when layout is fullWidth."));
|
|
90
90
|
}
|
|
91
91
|
return prop_types_1["default"].number.apply(prop_types_1["default"], __spreadArray([props, propName], __read(rest), false));
|
|
92
92
|
};
|
|
@@ -104,7 +104,7 @@ exports.propTypes = {
|
|
|
104
104
|
if (validLayouts.has(props.layout)) {
|
|
105
105
|
return undefined;
|
|
106
106
|
}
|
|
107
|
-
return new Error("Invalid value "
|
|
107
|
+
return new Error("Invalid value ".concat(props.layout, "\" provided for prop \"layout\". Defaulting to \"constrained\". Valid values are \"fixed\", \"fullWidth\" or \"constrained\"."));
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
StaticImage.displayName = "StaticImage";
|
package/dist/image-utils.js
CHANGED
|
@@ -62,10 +62,10 @@ var getSizes = function (width, layout) {
|
|
|
62
62
|
// If screen is wider than the max size, image width is the max size,
|
|
63
63
|
// otherwise it's the width of the screen
|
|
64
64
|
case "constrained":
|
|
65
|
-
return "(min-width: "
|
|
65
|
+
return "(min-width: ".concat(width, "px) ").concat(width, "px, 100vw");
|
|
66
66
|
// Image is always the same width, whatever the size of the screen
|
|
67
67
|
case "fixed":
|
|
68
|
-
return width
|
|
68
|
+
return "".concat(width, "px");
|
|
69
69
|
// Image is always the width of the screen
|
|
70
70
|
case "fullWidth":
|
|
71
71
|
return "100vw";
|
|
@@ -75,7 +75,7 @@ var getSizes = function (width, layout) {
|
|
|
75
75
|
};
|
|
76
76
|
exports.getSizes = getSizes;
|
|
77
77
|
var getSrcSet = function (images) {
|
|
78
|
-
return images.map(function (image) { return image.src
|
|
78
|
+
return images.map(function (image) { return "".concat(image.src, " ").concat(image.width, "w"); }).join(",\n");
|
|
79
79
|
};
|
|
80
80
|
exports.getSrcSet = getSrcSet;
|
|
81
81
|
function formatFromFilename(filename) {
|
|
@@ -170,7 +170,7 @@ function generateImageData(args) {
|
|
|
170
170
|
formats.add(sourceMetadata.format);
|
|
171
171
|
}
|
|
172
172
|
if (formats.has("jpg") && formats.has("png")) {
|
|
173
|
-
reporter.warn("["
|
|
173
|
+
reporter.warn("[".concat(pluginName, "] Specifying both 'jpg' and 'png' formats is not supported. Using 'auto' instead"));
|
|
174
174
|
if (sourceMetadata.format === "jpg") {
|
|
175
175
|
formats["delete"]("png");
|
|
176
176
|
}
|
|
@@ -195,7 +195,7 @@ function generateImageData(args) {
|
|
|
195
195
|
!imageSrc.height ||
|
|
196
196
|
!imageSrc.src ||
|
|
197
197
|
!imageSrc.format) {
|
|
198
|
-
reporter.warn("["
|
|
198
|
+
reporter.warn("[".concat(pluginName, "] The resolver for image ").concat(filename, " returned an invalid value."));
|
|
199
199
|
return undefined;
|
|
200
200
|
}
|
|
201
201
|
return imageSrc;
|
|
@@ -215,7 +215,7 @@ function generateImageData(args) {
|
|
|
215
215
|
(_a = result.sources) === null || _a === void 0 ? void 0 : _a.push({
|
|
216
216
|
srcSet: (0, exports.getSrcSet)(images),
|
|
217
217
|
sizes: sizes,
|
|
218
|
-
type: "image/"
|
|
218
|
+
type: "image/".concat(format)
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
});
|
|
@@ -255,9 +255,9 @@ function calculateImageSizes(args) {
|
|
|
255
255
|
return typeof size === "number" && size < 1;
|
|
256
256
|
});
|
|
257
257
|
if (erroneousUserDimensions.length) {
|
|
258
|
-
throw new Error("Specified dimensions for images must be positive numbers (> 0). Problem dimensions you have are "
|
|
258
|
+
throw new Error("Specified dimensions for images must be positive numbers (> 0). Problem dimensions you have are ".concat(erroneousUserDimensions
|
|
259
259
|
.map(function (dim) { return dim.join(": "); })
|
|
260
|
-
.join(", "));
|
|
260
|
+
.join(", ")));
|
|
261
261
|
}
|
|
262
262
|
if (layout === "fixed") {
|
|
263
263
|
return fixedImageSizes(args);
|
|
@@ -269,7 +269,7 @@ function calculateImageSizes(args) {
|
|
|
269
269
|
return responsiveImageSizes(__assign({ breakpoints: breakpoints }, args));
|
|
270
270
|
}
|
|
271
271
|
else {
|
|
272
|
-
reporter.warn("No valid layout was provided for the image at "
|
|
272
|
+
reporter.warn("No valid layout was provided for the image at ".concat(filename, ". Valid image layouts are fixed, fullWidth, and constrained. Found ").concat(layout));
|
|
273
273
|
return {
|
|
274
274
|
sizes: [imgDimensions.width],
|
|
275
275
|
presentationWidth: imgDimensions.width,
|
|
@@ -132,7 +132,7 @@ function writeImages(_a) {
|
|
|
132
132
|
case 0:
|
|
133
133
|
_d = _a, _e = __read(_d, 2), hash = _e[0], _c = _e[1], src = _c.src, args = __rest(_c, ["src"]);
|
|
134
134
|
if (!src) {
|
|
135
|
-
reporter.warn("Missing StaticImage \"src\" in "
|
|
135
|
+
reporter.warn("Missing StaticImage \"src\" in ".concat(filename, "."));
|
|
136
136
|
return [2 /*return*/];
|
|
137
137
|
}
|
|
138
138
|
if (!(0, exports.isRemoteURL)(src)) return [3 /*break*/, 5];
|
|
@@ -160,19 +160,19 @@ function writeImages(_a) {
|
|
|
160
160
|
return [3 /*break*/, 4];
|
|
161
161
|
case 3:
|
|
162
162
|
err_1 = _f.sent();
|
|
163
|
-
reporter.error("Error loading image "
|
|
163
|
+
reporter.error("Error loading image ".concat(src), err_1);
|
|
164
164
|
return [2 /*return*/];
|
|
165
165
|
case 4:
|
|
166
166
|
if (!(file === null || file === void 0 ? void 0 : file.internal.mediaType) ||
|
|
167
167
|
!supportedTypes.has(file.internal.mediaType)) {
|
|
168
|
-
reporter.error("The file loaded from "
|
|
168
|
+
reporter.error("The file loaded from ".concat(src, " is not a valid image type. Found \"").concat((file === null || file === void 0 ? void 0 : file.internal.mediaType) || "unknown", "\""));
|
|
169
169
|
return [2 /*return*/];
|
|
170
170
|
}
|
|
171
171
|
return [3 /*break*/, 9];
|
|
172
172
|
case 5:
|
|
173
173
|
fullPath = path_1["default"].resolve(sourceDir, src);
|
|
174
174
|
if (!fs_extra_1["default"].existsSync(fullPath)) {
|
|
175
|
-
reporter.warn("Could not find image \""
|
|
175
|
+
reporter.warn("Could not find image \"".concat(src, "\" in \"").concat(filename, "\". Looked for ").concat(fullPath, "."));
|
|
176
176
|
return [2 /*return*/];
|
|
177
177
|
}
|
|
178
178
|
_f.label = 6;
|
|
@@ -189,18 +189,18 @@ function writeImages(_a) {
|
|
|
189
189
|
return [3 /*break*/, 9];
|
|
190
190
|
case 9:
|
|
191
191
|
if (!file) {
|
|
192
|
-
reporter.warn("Could not create node for image "
|
|
192
|
+
reporter.warn("Could not create node for image ".concat(src));
|
|
193
193
|
return [2 /*return*/];
|
|
194
194
|
}
|
|
195
195
|
// We need our own type, because `File` belongs to the filesystem plugin
|
|
196
196
|
file.internal.type = "StaticImage";
|
|
197
197
|
delete file.internal.owner;
|
|
198
198
|
createNode(file);
|
|
199
|
-
cacheKey = "ref-"
|
|
199
|
+
cacheKey = "ref-".concat(file.id);
|
|
200
200
|
return [4 /*yield*/, cache.get(cacheKey)];
|
|
201
201
|
case 10:
|
|
202
202
|
imageRefs = (_f.sent()) || {};
|
|
203
|
-
cacheFilename = path_1["default"].join(cacheDir, hash
|
|
203
|
+
cacheFilename = path_1["default"].join(cacheDir, "".concat(hash, ".json"));
|
|
204
204
|
imageRefs[hash] = {
|
|
205
205
|
contentDigest: (_b = file.internal) === null || _b === void 0 ? void 0 : _b.contentDigest,
|
|
206
206
|
args: args,
|
|
@@ -263,12 +263,12 @@ function writeImage(file, args, pathPrefix, reporter, cache, filename) {
|
|
|
263
263
|
_a.sent();
|
|
264
264
|
return [3 /*break*/, 5];
|
|
265
265
|
case 4:
|
|
266
|
-
reporter.warn("Could not process image "
|
|
266
|
+
reporter.warn("Could not process image ".concat(file.relativePath));
|
|
267
267
|
_a.label = 5;
|
|
268
268
|
case 5: return [3 /*break*/, 7];
|
|
269
269
|
case 6:
|
|
270
270
|
e_3 = _a.sent();
|
|
271
|
-
reporter.warn("Error processing image "
|
|
271
|
+
reporter.warn("Error processing image ".concat(file.relativePath, ". \n").concat(e_3.message));
|
|
272
272
|
return [3 /*break*/, 7];
|
|
273
273
|
case 7: return [2 /*return*/];
|
|
274
274
|
}
|
|
@@ -57,7 +57,7 @@ function watchImage(_a) {
|
|
|
57
57
|
return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
59
|
case 0:
|
|
60
|
-
reporter.verbose("Image changed: "
|
|
60
|
+
reporter.verbose("Image changed: ".concat(path));
|
|
61
61
|
return [4 /*yield*/, (0, image_processing_1.createImageNode)({
|
|
62
62
|
fullPath: path,
|
|
63
63
|
createNodeId: createNodeId,
|
|
@@ -67,7 +67,7 @@ function watchImage(_a) {
|
|
|
67
67
|
case 1:
|
|
68
68
|
node = _a.sent();
|
|
69
69
|
if (!node) {
|
|
70
|
-
reporter.warn("Could not process image "
|
|
70
|
+
reporter.warn("Could not process image ".concat(path));
|
|
71
71
|
return [2 /*return*/];
|
|
72
72
|
}
|
|
73
73
|
return [4 /*yield*/, updateImages({ node: node, cache: cache, pathPrefix: pathPrefix, reporter: reporter })];
|
|
@@ -94,7 +94,7 @@ function updateImages(_a) {
|
|
|
94
94
|
var _this = this;
|
|
95
95
|
return __generator(this, function (_b) {
|
|
96
96
|
switch (_b.label) {
|
|
97
|
-
case 0: return [4 /*yield*/, cache.get("ref-"
|
|
97
|
+
case 0: return [4 /*yield*/, cache.get("ref-".concat(node.id))];
|
|
98
98
|
case 1:
|
|
99
99
|
imageRefs = _b.sent();
|
|
100
100
|
if (!imageRefs) {
|
package/dist/resolver-utils.js
CHANGED
|
@@ -96,7 +96,7 @@ function getGatsbyImageFieldConfig(resolve, extraArgs) {
|
|
|
96
96
|
type: exports.ImagePlaceholderType.name,
|
|
97
97
|
description: (0, common_tags_1.stripIndent)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n Format of generated placeholder image, displayed while the main image loads.\n BLURRED: a blurred, low resolution image, encoded as a base64 data URI (default)\n DOMINANT_COLOR: a solid color, calculated from the dominant color of the image.\n TRACED_SVG: a low-resolution traced SVG of the image.\n NONE: no placeholder. Set the argument \"backgroundColor\" to use a fixed background color."], ["\n Format of generated placeholder image, displayed while the main image loads.\n BLURRED: a blurred, low resolution image, encoded as a base64 data URI (default)\n DOMINANT_COLOR: a solid color, calculated from the dominant color of the image.\n TRACED_SVG: a low-resolution traced SVG of the image.\n NONE: no placeholder. Set the argument \"backgroundColor\" to use a fixed background color."])))
|
|
98
98
|
}, formats: {
|
|
99
|
-
type: "["
|
|
99
|
+
type: "[".concat(exports.ImageFormatType.name, "]"),
|
|
100
100
|
description: (0, common_tags_1.stripIndent)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n The image formats to generate. Valid values are AUTO (meaning the same format as the source image), JPG, PNG, WEBP and AVIF.\n The default value is [AUTO, WEBP], and you should rarely need to change this. Take care if you specify JPG or PNG when you do\n not know the formats of the source images, as this could lead to unwanted results such as converting JPEGs to PNGs. Specifying\n both PNG and JPG is not supported and will be ignored.\n "], ["\n The image formats to generate. Valid values are AUTO (meaning the same format as the source image), JPG, PNG, WEBP and AVIF.\n The default value is [AUTO, WEBP], and you should rarely need to change this. Take care if you specify JPG or PNG when you do\n not know the formats of the source images, as this could lead to unwanted results such as converting JPEGs to PNGs. Specifying\n both PNG and JPG is not supported and will be ignored.\n "]))),
|
|
101
101
|
defaultValue: ["", "webp"]
|
|
102
102
|
}, outputPixelDensities: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-plugin-image",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-next.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "npm-run-all -s clean -p build:*",
|
|
6
6
|
"build:gatsby-node": "tsc --jsx react --downlevelIteration true --skipLibCheck true --esModuleInterop true --outDir dist/ src/gatsby-node.ts src/babel-plugin-parse-static-images.ts src/resolver-utils.ts src/types.d.ts -d --declarationDir dist/src",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"npm-run-all": "^4.1.5",
|
|
62
62
|
"postcss": "^8.2.9",
|
|
63
63
|
"terser": "^5.3.8",
|
|
64
|
-
"typescript": "^4.
|
|
64
|
+
"typescript": "^4.5.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@babel/core": "^7.12.3",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"@babel/runtime": "^7.15.4",
|
|
78
78
|
"@babel/traverse": "^7.15.4",
|
|
79
79
|
"babel-jsx-utils": "^1.1.0",
|
|
80
|
-
"babel-plugin-remove-graphql-queries": "^4.
|
|
80
|
+
"babel-plugin-remove-graphql-queries": "^4.4.0-next.1",
|
|
81
81
|
"camelcase": "^5.3.1",
|
|
82
82
|
"chokidar": "^3.5.2",
|
|
83
|
-
"common-tags": "^1.8.
|
|
83
|
+
"common-tags": "^1.8.2",
|
|
84
84
|
"fs-extra": "^10.0.0",
|
|
85
|
-
"gatsby-core-utils": "^3.
|
|
85
|
+
"gatsby-core-utils": "^3.4.0-next.1",
|
|
86
86
|
"objectFitPolyfill": "^2.3.5",
|
|
87
87
|
"prop-types": "^15.7.2"
|
|
88
88
|
},
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
},
|
|
94
94
|
"author": "Matt Kane <matt@gatsbyjs.com>",
|
|
95
95
|
"license": "MIT",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "6b28b69d8383ccdb951c81283a77e19d2f14ddb9"
|
|
97
97
|
}
|