gatsby-plugin-image 2.9.0 → 2.10.0-next.2
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 +247 -247
- package/dist/components/gatsby-image.server.js +112 -112
- package/dist/components/hooks.js +399 -399
- package/dist/components/intersection-observer.js +55 -55
- package/dist/components/layout-wrapper.js +94 -94
- package/dist/components/lazy-hydrate.js +75 -75
- package/dist/components/main-image.js +43 -43
- package/dist/components/picture.js +96 -96
- package/dist/components/placeholder.js +74 -74
- package/dist/components/static-image.server.js +111 -111
- package/dist/gatsby-node.js +54 -54
- package/dist/image-utils.js +449 -449
- package/dist/index.js +27 -27
- 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 +119 -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/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 +4 -4
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.createIntersectionObserver = void 0;
|
|
4
|
-
var intersectionObserver;
|
|
5
|
-
var ioEntryMap = new WeakMap();
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
-
var connection = navigator.connection ||
|
|
8
|
-
navigator.mozConnection ||
|
|
9
|
-
navigator.webkitConnection;
|
|
10
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
11
|
-
// These match the thresholds used in Chrome's native lazy loading
|
|
12
|
-
// @see https://web.dev/browser-level-image-lazy-loading/#distance-from-viewport-thresholds
|
|
13
|
-
var FAST_CONNECTION_THRESHOLD = "1250px";
|
|
14
|
-
var SLOW_CONNECTION_THRESHOLD = "2500px";
|
|
15
|
-
function createIntersectionObserver(callback) {
|
|
16
|
-
var connectionType = connection === null || connection === void 0 ? void 0 : connection.effectiveType;
|
|
17
|
-
// if we don't support intersectionObserver we don't lazy load (Sorry IE 11).
|
|
18
|
-
if (!("IntersectionObserver" in window)) {
|
|
19
|
-
return function observe() {
|
|
20
|
-
callback();
|
|
21
|
-
return function unobserve() { };
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if (!intersectionObserver) {
|
|
25
|
-
intersectionObserver = new IntersectionObserver(function (entries) {
|
|
26
|
-
entries.forEach(function (entry) {
|
|
27
|
-
var _a;
|
|
28
|
-
if (entry.isIntersecting) {
|
|
29
|
-
// Get the matching entry's callback and call it
|
|
30
|
-
(_a = ioEntryMap.get(entry.target)) === null || _a === void 0 ? void 0 : _a();
|
|
31
|
-
// We only need to call it once
|
|
32
|
-
ioEntryMap["delete"](entry.target);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}, {
|
|
36
|
-
rootMargin: connectionType === "4g" && !(connection === null || connection === void 0 ? void 0 : connection.saveData)
|
|
37
|
-
? FAST_CONNECTION_THRESHOLD
|
|
38
|
-
: SLOW_CONNECTION_THRESHOLD
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return function observe(element) {
|
|
42
|
-
if (element.current) {
|
|
43
|
-
// Store a reference to the callback mapped to the element being watched
|
|
44
|
-
ioEntryMap.set(element.current, callback);
|
|
45
|
-
intersectionObserver.observe(element.current);
|
|
46
|
-
}
|
|
47
|
-
return function unobserve() {
|
|
48
|
-
if (intersectionObserver && element.current) {
|
|
49
|
-
ioEntryMap["delete"](element.current);
|
|
50
|
-
intersectionObserver.unobserve(element.current);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.createIntersectionObserver = createIntersectionObserver;
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.createIntersectionObserver = void 0;
|
|
4
|
+
var intersectionObserver;
|
|
5
|
+
var ioEntryMap = new WeakMap();
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
var connection = navigator.connection ||
|
|
8
|
+
navigator.mozConnection ||
|
|
9
|
+
navigator.webkitConnection;
|
|
10
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
11
|
+
// These match the thresholds used in Chrome's native lazy loading
|
|
12
|
+
// @see https://web.dev/browser-level-image-lazy-loading/#distance-from-viewport-thresholds
|
|
13
|
+
var FAST_CONNECTION_THRESHOLD = "1250px";
|
|
14
|
+
var SLOW_CONNECTION_THRESHOLD = "2500px";
|
|
15
|
+
function createIntersectionObserver(callback) {
|
|
16
|
+
var connectionType = connection === null || connection === void 0 ? void 0 : connection.effectiveType;
|
|
17
|
+
// if we don't support intersectionObserver we don't lazy load (Sorry IE 11).
|
|
18
|
+
if (!("IntersectionObserver" in window)) {
|
|
19
|
+
return function observe() {
|
|
20
|
+
callback();
|
|
21
|
+
return function unobserve() { };
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!intersectionObserver) {
|
|
25
|
+
intersectionObserver = new IntersectionObserver(function (entries) {
|
|
26
|
+
entries.forEach(function (entry) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (entry.isIntersecting) {
|
|
29
|
+
// Get the matching entry's callback and call it
|
|
30
|
+
(_a = ioEntryMap.get(entry.target)) === null || _a === void 0 ? void 0 : _a();
|
|
31
|
+
// We only need to call it once
|
|
32
|
+
ioEntryMap["delete"](entry.target);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}, {
|
|
36
|
+
rootMargin: connectionType === "4g" && !(connection === null || connection === void 0 ? void 0 : connection.saveData)
|
|
37
|
+
? FAST_CONNECTION_THRESHOLD
|
|
38
|
+
: SLOW_CONNECTION_THRESHOLD
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return function observe(element) {
|
|
42
|
+
if (element.current) {
|
|
43
|
+
// Store a reference to the callback mapped to the element being watched
|
|
44
|
+
ioEntryMap.set(element.current, callback);
|
|
45
|
+
intersectionObserver.observe(element.current);
|
|
46
|
+
}
|
|
47
|
+
return function unobserve() {
|
|
48
|
+
if (intersectionObserver && element.current) {
|
|
49
|
+
ioEntryMap["delete"](element.current);
|
|
50
|
+
intersectionObserver.unobserve(element.current);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.createIntersectionObserver = createIntersectionObserver;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
3
|
-
/// <reference path="../global.d.ts" />
|
|
4
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
5
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
6
|
-
return cooked;
|
|
7
|
-
};
|
|
8
|
-
var __assign = (this && this.__assign) || function () {
|
|
9
|
-
__assign = Object.assign || function(t) {
|
|
10
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11
|
-
s = arguments[i];
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
};
|
|
17
|
-
return __assign.apply(this, arguments);
|
|
18
|
-
};
|
|
19
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
-
if (k2 === undefined) k2 = k;
|
|
21
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
22
|
-
}) : (function(o, m, k, k2) {
|
|
23
|
-
if (k2 === undefined) k2 = k;
|
|
24
|
-
o[k2] = m[k];
|
|
25
|
-
}));
|
|
26
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
-
}) : function(o, v) {
|
|
29
|
-
o["default"] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
|
-
var t = {};
|
|
40
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
41
|
-
t[p] = s[p];
|
|
42
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
43
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
44
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
45
|
-
t[p[i]] = s[p[i]];
|
|
46
|
-
}
|
|
47
|
-
return t;
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
exports.__esModule = true;
|
|
53
|
-
exports.LayoutWrapper = exports.getSizer = void 0;
|
|
54
|
-
var react_1 = __importStar(require("react"));
|
|
55
|
-
var terser_macro_1 = __importDefault(require("../../macros/terser.macro"));
|
|
56
|
-
var NativeScriptLoading = function () { return (react_1["default"].createElement("script", { type: "module", dangerouslySetInnerHTML: {
|
|
57
|
-
__html: (0, terser_macro_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nconst hasNativeLazyLoadSupport = typeof HTMLImageElement !== \"undefined\" && \"loading\" in HTMLImageElement.prototype;\nif (hasNativeLazyLoadSupport) {\n const gatsbyImages = document.querySelectorAll('img[data-main-image]');\n for (let mainImage of gatsbyImages) {\n if (mainImage.dataset.src) {\n mainImage.setAttribute('src', mainImage.dataset.src)\n mainImage.removeAttribute('data-src')\n }\n if (mainImage.dataset.srcset) {\n mainImage.setAttribute('srcset', mainImage.dataset.srcset)\n mainImage.removeAttribute('data-srcset')\n }\n\n const sources = mainImage.parentNode.querySelectorAll('source[data-srcset]');\n for (let source of sources) {\n source.setAttribute('srcset', source.dataset.srcset)\n source.removeAttribute('data-srcset')\n }\n\n if (mainImage.complete) {\n mainImage.style.opacity = 1;\n }\n }\n}\n"], ["\nconst hasNativeLazyLoadSupport = typeof HTMLImageElement !== \"undefined\" && \"loading\" in HTMLImageElement.prototype;\nif (hasNativeLazyLoadSupport) {\n const gatsbyImages = document.querySelectorAll('img[data-main-image]');\n for (let mainImage of gatsbyImages) {\n if (mainImage.dataset.src) {\n mainImage.setAttribute('src', mainImage.dataset.src)\n mainImage.removeAttribute('data-src')\n }\n if (mainImage.dataset.srcset) {\n mainImage.setAttribute('srcset', mainImage.dataset.srcset)\n mainImage.removeAttribute('data-srcset')\n }\n\n const sources = mainImage.parentNode.querySelectorAll('source[data-srcset]');\n for (let source of sources) {\n source.setAttribute('srcset', source.dataset.srcset)\n source.removeAttribute('data-srcset')\n }\n\n if (mainImage.complete) {\n mainImage.style.opacity = 1;\n }\n }\n}\n"])))
|
|
58
|
-
} })); };
|
|
59
|
-
function getSizer(layout, width, height) {
|
|
60
|
-
var sizer = null;
|
|
61
|
-
if (layout === "fullWidth") {
|
|
62
|
-
sizer = "<div aria-hidden=\"true\" style=\"padding-top: ".concat((height / width) * 100, "%;\"></div>");
|
|
63
|
-
}
|
|
64
|
-
if (layout === "constrained") {
|
|
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
|
-
}
|
|
67
|
-
return sizer;
|
|
68
|
-
}
|
|
69
|
-
exports.getSizer = getSizer;
|
|
70
|
-
var Sizer = function Sizer(_a) {
|
|
71
|
-
var layout = _a.layout, width = _a.width, height = _a.height;
|
|
72
|
-
if (layout === "fullWidth") {
|
|
73
|
-
return (react_1["default"].createElement("div", { "aria-hidden": true, style: { paddingTop: "".concat((height / width) * 100, "%") } }));
|
|
74
|
-
}
|
|
75
|
-
if (layout === "constrained") {
|
|
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='".concat(height, "' width='").concat(width, "' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E"), style: {
|
|
78
|
-
maxWidth: "100%",
|
|
79
|
-
display: "block",
|
|
80
|
-
position: "static"
|
|
81
|
-
} })));
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
};
|
|
85
|
-
var LayoutWrapper = function LayoutWrapper(_a) {
|
|
86
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
87
|
-
return (react_1["default"].createElement(react_1.Fragment, null,
|
|
88
|
-
react_1["default"].createElement(Sizer, __assign({}, props)),
|
|
89
|
-
children,
|
|
90
|
-
// eslint-disable-next-line no-undef
|
|
91
|
-
SERVER && react_1["default"].createElement(NativeScriptLoading, null)));
|
|
92
|
-
};
|
|
93
|
-
exports.LayoutWrapper = LayoutWrapper;
|
|
94
|
-
var templateObject_1;
|
|
1
|
+
"use strict";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
3
|
+
/// <reference path="../global.d.ts" />
|
|
4
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
5
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
6
|
+
return cooked;
|
|
7
|
+
};
|
|
8
|
+
var __assign = (this && this.__assign) || function () {
|
|
9
|
+
__assign = Object.assign || function(t) {
|
|
10
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11
|
+
s = arguments[i];
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
return __assign.apply(this, arguments);
|
|
18
|
+
};
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
|
+
var t = {};
|
|
40
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
41
|
+
t[p] = s[p];
|
|
42
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
43
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
44
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
45
|
+
t[p[i]] = s[p[i]];
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.LayoutWrapper = exports.getSizer = void 0;
|
|
54
|
+
var react_1 = __importStar(require("react"));
|
|
55
|
+
var terser_macro_1 = __importDefault(require("../../macros/terser.macro"));
|
|
56
|
+
var NativeScriptLoading = function () { return (react_1["default"].createElement("script", { type: "module", dangerouslySetInnerHTML: {
|
|
57
|
+
__html: (0, terser_macro_1["default"])(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nconst hasNativeLazyLoadSupport = typeof HTMLImageElement !== \"undefined\" && \"loading\" in HTMLImageElement.prototype;\nif (hasNativeLazyLoadSupport) {\n const gatsbyImages = document.querySelectorAll('img[data-main-image]');\n for (let mainImage of gatsbyImages) {\n if (mainImage.dataset.src) {\n mainImage.setAttribute('src', mainImage.dataset.src)\n mainImage.removeAttribute('data-src')\n }\n if (mainImage.dataset.srcset) {\n mainImage.setAttribute('srcset', mainImage.dataset.srcset)\n mainImage.removeAttribute('data-srcset')\n }\n\n const sources = mainImage.parentNode.querySelectorAll('source[data-srcset]');\n for (let source of sources) {\n source.setAttribute('srcset', source.dataset.srcset)\n source.removeAttribute('data-srcset')\n }\n\n if (mainImage.complete) {\n mainImage.style.opacity = 1;\n }\n }\n}\n"], ["\nconst hasNativeLazyLoadSupport = typeof HTMLImageElement !== \"undefined\" && \"loading\" in HTMLImageElement.prototype;\nif (hasNativeLazyLoadSupport) {\n const gatsbyImages = document.querySelectorAll('img[data-main-image]');\n for (let mainImage of gatsbyImages) {\n if (mainImage.dataset.src) {\n mainImage.setAttribute('src', mainImage.dataset.src)\n mainImage.removeAttribute('data-src')\n }\n if (mainImage.dataset.srcset) {\n mainImage.setAttribute('srcset', mainImage.dataset.srcset)\n mainImage.removeAttribute('data-srcset')\n }\n\n const sources = mainImage.parentNode.querySelectorAll('source[data-srcset]');\n for (let source of sources) {\n source.setAttribute('srcset', source.dataset.srcset)\n source.removeAttribute('data-srcset')\n }\n\n if (mainImage.complete) {\n mainImage.style.opacity = 1;\n }\n }\n}\n"])))
|
|
58
|
+
} })); };
|
|
59
|
+
function getSizer(layout, width, height) {
|
|
60
|
+
var sizer = null;
|
|
61
|
+
if (layout === "fullWidth") {
|
|
62
|
+
sizer = "<div aria-hidden=\"true\" style=\"padding-top: ".concat((height / width) * 100, "%;\"></div>");
|
|
63
|
+
}
|
|
64
|
+
if (layout === "constrained") {
|
|
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
|
+
}
|
|
67
|
+
return sizer;
|
|
68
|
+
}
|
|
69
|
+
exports.getSizer = getSizer;
|
|
70
|
+
var Sizer = function Sizer(_a) {
|
|
71
|
+
var layout = _a.layout, width = _a.width, height = _a.height;
|
|
72
|
+
if (layout === "fullWidth") {
|
|
73
|
+
return (react_1["default"].createElement("div", { "aria-hidden": true, style: { paddingTop: "".concat((height / width) * 100, "%") } }));
|
|
74
|
+
}
|
|
75
|
+
if (layout === "constrained") {
|
|
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='".concat(height, "' width='").concat(width, "' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E"), style: {
|
|
78
|
+
maxWidth: "100%",
|
|
79
|
+
display: "block",
|
|
80
|
+
position: "static"
|
|
81
|
+
} })));
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
};
|
|
85
|
+
var LayoutWrapper = function LayoutWrapper(_a) {
|
|
86
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
87
|
+
return (react_1["default"].createElement(react_1.Fragment, null,
|
|
88
|
+
react_1["default"].createElement(Sizer, __assign({}, props)),
|
|
89
|
+
children,
|
|
90
|
+
// eslint-disable-next-line no-undef
|
|
91
|
+
SERVER && react_1["default"].createElement(NativeScriptLoading, null)));
|
|
92
|
+
};
|
|
93
|
+
exports.LayoutWrapper = LayoutWrapper;
|
|
94
|
+
var templateObject_1;
|
|
@@ -1,75 +1,75 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
exports.__esModule = true;
|
|
28
|
-
exports.lazyHydrate = void 0;
|
|
29
|
-
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var react_dom_1 = __importDefault(require("react-dom"));
|
|
31
|
-
var layout_wrapper_1 = require("./layout-wrapper");
|
|
32
|
-
var placeholder_1 = require("./placeholder");
|
|
33
|
-
var main_image_1 = require("./main-image");
|
|
34
|
-
var hooks_1 = require("./hooks");
|
|
35
|
-
function lazyHydrate(_a, root, hydrated, forceHydrate) {
|
|
36
|
-
var image = _a.image, loading = _a.loading, isLoading = _a.isLoading, isLoaded = _a.isLoaded, toggleIsLoaded = _a.toggleIsLoaded, ref = _a.ref, imgClassName = _a.imgClassName, _b = _a.imgStyle, imgStyle = _b === void 0 ? {} : _b, objectPosition = _a.objectPosition, backgroundColor = _a.backgroundColor, _c = _a.objectFit, objectFit = _c === void 0 ? "cover" : _c, props = __rest(_a, ["image", "loading", "isLoading", "isLoaded", "toggleIsLoaded", "ref", "imgClassName", "imgStyle", "objectPosition", "backgroundColor", "objectFit"]);
|
|
37
|
-
var width = image.width, height = image.height, layout = image.layout, images = image.images, placeholder = image.placeholder, wrapperBackgroundColor = image.backgroundColor;
|
|
38
|
-
var cacheKey = JSON.stringify(images);
|
|
39
|
-
imgStyle = __assign({ objectFit: objectFit, objectPosition: objectPosition, backgroundColor: backgroundColor }, imgStyle);
|
|
40
|
-
var component = (react_1["default"].createElement(layout_wrapper_1.LayoutWrapper, { layout: layout, width: width, height: height },
|
|
41
|
-
react_1["default"].createElement(placeholder_1.Placeholder, __assign({}, (0, hooks_1.getPlaceholderProps)(placeholder, isLoaded, layout, width, height, wrapperBackgroundColor, objectFit, objectPosition))),
|
|
42
|
-
react_1["default"].createElement(main_image_1.MainImage, __assign({}, props, { width: width, height: height, className: imgClassName }, (0, hooks_1.getMainProps)(isLoading, isLoaded, images, loading, toggleIsLoaded, cacheKey, ref, imgStyle)))));
|
|
43
|
-
if (root.current) {
|
|
44
|
-
// Force render to mitigate "Expected server HTML to contain a matching" in develop
|
|
45
|
-
// @ts-ignore react 18 typings
|
|
46
|
-
if (react_dom_1["default"].createRoot) {
|
|
47
|
-
if (!hydrated.current) {
|
|
48
|
-
// @ts-ignore react 18 typings
|
|
49
|
-
hydrated.current = react_dom_1["default"].createRoot(root.current);
|
|
50
|
-
}
|
|
51
|
-
// @ts-ignore react 18 typings
|
|
52
|
-
hydrated.current.render(component);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
var doRender = hydrated.current || forceHydrate.current
|
|
56
|
-
? react_dom_1["default"].render
|
|
57
|
-
: react_dom_1["default"].hydrate;
|
|
58
|
-
doRender(component, root.current);
|
|
59
|
-
hydrated.current = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return function () {
|
|
63
|
-
if (root.current) {
|
|
64
|
-
// @ts-ignore react 18 typings
|
|
65
|
-
if (react_dom_1["default"].createRoot) {
|
|
66
|
-
// @ts-ignore react 18 typings
|
|
67
|
-
hydrated.current.render(null);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
react_dom_1["default"].render(null, root.current);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
exports.lazyHydrate = lazyHydrate;
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
exports.__esModule = true;
|
|
28
|
+
exports.lazyHydrate = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var react_dom_1 = __importDefault(require("react-dom"));
|
|
31
|
+
var layout_wrapper_1 = require("./layout-wrapper");
|
|
32
|
+
var placeholder_1 = require("./placeholder");
|
|
33
|
+
var main_image_1 = require("./main-image");
|
|
34
|
+
var hooks_1 = require("./hooks");
|
|
35
|
+
function lazyHydrate(_a, root, hydrated, forceHydrate) {
|
|
36
|
+
var image = _a.image, loading = _a.loading, isLoading = _a.isLoading, isLoaded = _a.isLoaded, toggleIsLoaded = _a.toggleIsLoaded, ref = _a.ref, imgClassName = _a.imgClassName, _b = _a.imgStyle, imgStyle = _b === void 0 ? {} : _b, objectPosition = _a.objectPosition, backgroundColor = _a.backgroundColor, _c = _a.objectFit, objectFit = _c === void 0 ? "cover" : _c, props = __rest(_a, ["image", "loading", "isLoading", "isLoaded", "toggleIsLoaded", "ref", "imgClassName", "imgStyle", "objectPosition", "backgroundColor", "objectFit"]);
|
|
37
|
+
var width = image.width, height = image.height, layout = image.layout, images = image.images, placeholder = image.placeholder, wrapperBackgroundColor = image.backgroundColor;
|
|
38
|
+
var cacheKey = JSON.stringify(images);
|
|
39
|
+
imgStyle = __assign({ objectFit: objectFit, objectPosition: objectPosition, backgroundColor: backgroundColor }, imgStyle);
|
|
40
|
+
var component = (react_1["default"].createElement(layout_wrapper_1.LayoutWrapper, { layout: layout, width: width, height: height },
|
|
41
|
+
react_1["default"].createElement(placeholder_1.Placeholder, __assign({}, (0, hooks_1.getPlaceholderProps)(placeholder, isLoaded, layout, width, height, wrapperBackgroundColor, objectFit, objectPosition))),
|
|
42
|
+
react_1["default"].createElement(main_image_1.MainImage, __assign({}, props, { width: width, height: height, className: imgClassName }, (0, hooks_1.getMainProps)(isLoading, isLoaded, images, loading, toggleIsLoaded, cacheKey, ref, imgStyle)))));
|
|
43
|
+
if (root.current) {
|
|
44
|
+
// Force render to mitigate "Expected server HTML to contain a matching" in develop
|
|
45
|
+
// @ts-ignore react 18 typings
|
|
46
|
+
if (react_dom_1["default"].createRoot) {
|
|
47
|
+
if (!hydrated.current) {
|
|
48
|
+
// @ts-ignore react 18 typings
|
|
49
|
+
hydrated.current = react_dom_1["default"].createRoot(root.current);
|
|
50
|
+
}
|
|
51
|
+
// @ts-ignore react 18 typings
|
|
52
|
+
hydrated.current.render(component);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
var doRender = hydrated.current || forceHydrate.current
|
|
56
|
+
? react_dom_1["default"].render
|
|
57
|
+
: react_dom_1["default"].hydrate;
|
|
58
|
+
doRender(component, root.current);
|
|
59
|
+
hydrated.current = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return function () {
|
|
63
|
+
if (root.current) {
|
|
64
|
+
// @ts-ignore react 18 typings
|
|
65
|
+
if (react_dom_1["default"].createRoot) {
|
|
66
|
+
// @ts-ignore react 18 typings
|
|
67
|
+
hydrated.current.render(null);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
react_dom_1["default"].render(null, root.current);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
exports.lazyHydrate = lazyHydrate;
|
|
@@ -1,43 +1,43 @@
|
|
|
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
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
exports.__esModule = true;
|
|
33
|
-
exports.MainImage = void 0;
|
|
34
|
-
var react_1 = __importStar(require("react"));
|
|
35
|
-
var picture_1 = require("./picture");
|
|
36
|
-
exports.MainImage = (0, react_1.forwardRef)(function MainImage(props, ref) {
|
|
37
|
-
return (react_1["default"].createElement(react_1["default"].Fragment, null,
|
|
38
|
-
react_1["default"].createElement(picture_1.Picture, __assign({ ref: ref }, props)),
|
|
39
|
-
react_1["default"].createElement("noscript", null,
|
|
40
|
-
react_1["default"].createElement(picture_1.Picture, __assign({}, props, { shouldLoad: true })))));
|
|
41
|
-
});
|
|
42
|
-
exports.MainImage.displayName = "MainImage";
|
|
43
|
-
exports.MainImage.propTypes = picture_1.Picture.propTypes;
|
|
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
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
exports.__esModule = true;
|
|
33
|
+
exports.MainImage = void 0;
|
|
34
|
+
var react_1 = __importStar(require("react"));
|
|
35
|
+
var picture_1 = require("./picture");
|
|
36
|
+
exports.MainImage = (0, react_1.forwardRef)(function MainImage(props, ref) {
|
|
37
|
+
return (react_1["default"].createElement(react_1["default"].Fragment, null,
|
|
38
|
+
react_1["default"].createElement(picture_1.Picture, __assign({ ref: ref }, props)),
|
|
39
|
+
react_1["default"].createElement("noscript", null,
|
|
40
|
+
react_1["default"].createElement(picture_1.Picture, __assign({}, props, { shouldLoad: true })))));
|
|
41
|
+
});
|
|
42
|
+
exports.MainImage.displayName = "MainImage";
|
|
43
|
+
exports.MainImage.propTypes = picture_1.Picture.propTypes;
|