@alpaca-headless/alpaca-headless-nextjs 1.0.2807 → 1.0.2808
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/cjs/components/Picture.js +40 -61
- package/dist/cjs/index.js +0 -14
- package/dist/cjs/loadRouteData.js +0 -2
- package/dist/esm/components/Picture.js +41 -62
- package/dist/esm/index.js +0 -1
- package/dist/esm/loadRouteData.js +0 -2
- package/package.json +1 -1
- package/types/alpacaContext.d.ts +0 -1
- package/types/components/Picture.d.ts +0 -1
- package/types/fieldTypes.d.ts +2 -14
- package/types/index.d.ts +0 -1
- package/types/loadRouteData.d.ts +0 -9
- package/dist/cjs/graphQLTypes.js +0 -2
- package/dist/cjs/mediaProtection.js +0 -53
- package/dist/esm/graphQLTypes.js +0 -1
- package/dist/esm/mediaProtection.js +0 -46
- package/types/graphQLTypes.d.ts +0 -24
- package/types/mediaProtection.d.ts +0 -2
|
@@ -13,7 +13,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Picture = void 0;
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
const mediaProtection_1 = require("../mediaProtection");
|
|
17
16
|
// const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
18
17
|
// if (otherAttrs.class) {
|
|
19
18
|
// // if any classes are defined properly already
|
|
@@ -28,83 +27,63 @@ const mediaProtection_1 = require("../mediaProtection");
|
|
|
28
27
|
// }
|
|
29
28
|
// };
|
|
30
29
|
const Picture = (_a) => {
|
|
31
|
-
var _b, _c, _d, _e
|
|
32
|
-
var { field, imageParams, sources, defaultVariant
|
|
30
|
+
var _b, _c, _d, _e;
|
|
31
|
+
var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
|
|
33
32
|
if (!field)
|
|
34
|
-
return
|
|
35
|
-
const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
36
|
-
const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
37
|
-
const attrs = Object.assign({
|
|
38
|
-
const video = img === null || img === void 0 ? void 0 : img.videoUrl;
|
|
39
|
-
const videoAttr = Object.assign({ src: video }, otherProps);
|
|
33
|
+
return;
|
|
34
|
+
const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
35
|
+
const img = (_d = (_c = field === null || field === void 0 ? void 0 : field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field === null || field === void 0 ? void 0 : field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
36
|
+
const attrs = Object.assign(Object.assign({}, img), otherProps);
|
|
40
37
|
if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
|
|
41
|
-
return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt:
|
|
38
|
+
return (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: "" }));
|
|
42
39
|
}
|
|
43
40
|
else {
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
42
|
+
const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
|
|
43
|
+
if (!variant)
|
|
44
|
+
return;
|
|
45
|
+
let srcSet = variant.src;
|
|
46
|
+
if (source.widths && source.widths.length) {
|
|
47
|
+
const getScaledImage = (variant, width) => {
|
|
48
|
+
if (width > variant.width)
|
|
49
|
+
return { src: variant.src, width: 0 };
|
|
50
|
+
else
|
|
51
|
+
return { src: variant.src + "&mw=" + width, width: width };
|
|
52
|
+
};
|
|
53
|
+
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
54
|
+
srcSet = "";
|
|
55
|
+
for (let w = 0; w < scaledImages.length; w++) {
|
|
56
|
+
if (srcSet.length)
|
|
57
|
+
srcSet = srcSet + ", ";
|
|
58
|
+
srcSet += scaledImages[w].src + " " + source.widths[w] + "w";
|
|
59
|
+
if (scaledImages[w].width === 0)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
if (source.width) {
|
|
49
65
|
const getScaledImage = (variant, width) => {
|
|
50
66
|
if (width > variant.width)
|
|
51
67
|
return { src: variant.src, width: 0 };
|
|
52
68
|
else
|
|
53
|
-
return { src: variant.src +
|
|
69
|
+
return { src: variant.src + "&mw=" + width, width: width };
|
|
54
70
|
};
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
srcSet = getScaledImage(variant, source.width).src;
|
|
72
|
+
if (source.scales) {
|
|
73
|
+
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
57
74
|
srcSet = "";
|
|
58
75
|
for (let w = 0; w < scaledImages.length; w++) {
|
|
59
76
|
if (srcSet.length)
|
|
60
77
|
srcSet = srcSet + ", ";
|
|
61
|
-
srcSet +=
|
|
62
|
-
(0, mediaProtection_1.hashImageUrl)(scaledImages[w].src) +
|
|
63
|
-
" " +
|
|
64
|
-
source.widths[w] +
|
|
65
|
-
"w";
|
|
78
|
+
srcSet += scaledImages[w].src + " " + source.scales[w] + "x";
|
|
66
79
|
if (scaledImages[w].width === 0)
|
|
67
80
|
break;
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
75
|
-
srcSet = "";
|
|
76
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
77
|
-
if (srcSet.length)
|
|
78
|
-
srcSet = srcSet + ", ";
|
|
79
|
-
srcSet +=
|
|
80
|
-
(0, mediaProtection_1.hashImageUrl)(scaledImages[w].src) +
|
|
81
|
-
" " +
|
|
82
|
-
source.scales[w] +
|
|
83
|
-
"x";
|
|
84
|
-
if (scaledImages[w].width === 0)
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return ((0, jsx_runtime_1.jsx)("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
91
|
-
}), (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), renderJsonLinkedData && !video ? (0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
92
|
-
__html: JSON.stringify({
|
|
93
|
-
"@context": "http://schema.org",
|
|
94
|
-
"@type": "ImageObject",
|
|
95
|
-
"image": img === null || img === void 0 ? void 0 : img.src,
|
|
96
|
-
"description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
|
|
97
|
-
"name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
|
|
98
|
-
})
|
|
99
|
-
} }) : null, video && (0, jsx_runtime_1.jsx)("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? (0, jsx_runtime_1.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
100
|
-
__html: JSON.stringify({
|
|
101
|
-
"@context": "http://schema.org",
|
|
102
|
-
"@type": "VideoObject",
|
|
103
|
-
"contentUrl": img === null || img === void 0 ? void 0 : img.src,
|
|
104
|
-
"description": (_k = field.value) === null || _k === void 0 ? void 0 : _k.alt,
|
|
105
|
-
"name": (_l = field.value) === null || _l === void 0 ? void 0 : _l.name
|
|
106
|
-
})
|
|
107
|
-
} }) : null] }));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
86
|
+
}), (0, jsx_runtime_1.jsx)("img", Object.assign({}, attrs, { alt: "" }))] }));
|
|
108
87
|
}
|
|
109
88
|
};
|
|
110
89
|
exports.Picture = Picture;
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,26 +10,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
15
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.GraphQLTypes = void 0;
|
|
30
17
|
__exportStar(require("./layoutData"), exports);
|
|
31
18
|
__exportStar(require("./loadRouteData"), exports);
|
|
32
19
|
__exportStar(require("./components"), exports);
|
|
33
20
|
__exportStar(require("./alpacaContext"), exports);
|
|
34
21
|
__exportStar(require("./fieldTypes"), exports);
|
|
35
|
-
exports.GraphQLTypes = __importStar(require("./graphQLTypes"));
|
|
@@ -30,7 +30,6 @@ const fetchRouteData = (0, react_1.cache)((path, host, mode, itemId, language) =
|
|
|
30
30
|
headers: {
|
|
31
31
|
"Content-Type": "application/json",
|
|
32
32
|
Cookie: (0, headers_1.cookies)().toString(),
|
|
33
|
-
"x-api-key": process.env.API_KEY,
|
|
34
33
|
},
|
|
35
34
|
next: {
|
|
36
35
|
tags: ["pages"],
|
|
@@ -65,7 +64,6 @@ const fetchRouteData = (0, react_1.cache)((path, host, mode, itemId, language) =
|
|
|
65
64
|
site: data.site,
|
|
66
65
|
pageEditing: true,
|
|
67
66
|
pageState: "",
|
|
68
|
-
database: data.page.database,
|
|
69
67
|
};
|
|
70
68
|
context.fields = data.page.fields;
|
|
71
69
|
context.dictionary = yield loadDictionary(context.pageContext.site.name, context.pageContext.language, mode);
|
|
@@ -9,8 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
13
|
-
import { hashImageUrl } from "../mediaProtection";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
// const addClassName = (otherAttrs: { [key: string]: unknown }): void => {
|
|
15
14
|
// if (otherAttrs.class) {
|
|
16
15
|
// // if any classes are defined properly already
|
|
@@ -25,82 +24,62 @@ import { hashImageUrl } from "../mediaProtection";
|
|
|
25
24
|
// }
|
|
26
25
|
// };
|
|
27
26
|
export const Picture = (_a) => {
|
|
28
|
-
var _b, _c, _d, _e
|
|
29
|
-
var { field, imageParams, sources, defaultVariant
|
|
27
|
+
var _b, _c, _d, _e;
|
|
28
|
+
var { field, imageParams, sources, defaultVariant } = _a, otherProps = __rest(_a, ["field", "imageParams", "sources", "defaultVariant"]);
|
|
30
29
|
if (!field)
|
|
31
|
-
return
|
|
32
|
-
const variants = (_b = field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
33
|
-
const img = (_d = (_c = field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
34
|
-
const attrs = Object.assign({
|
|
35
|
-
const video = img === null || img === void 0 ? void 0 : img.videoUrl;
|
|
36
|
-
const videoAttr = Object.assign({ src: video }, otherProps);
|
|
30
|
+
return;
|
|
31
|
+
const variants = (_b = field === null || field === void 0 ? void 0 : field.value) === null || _b === void 0 ? void 0 : _b.variants;
|
|
32
|
+
const img = (_d = (_c = field === null || field === void 0 ? void 0 : field.value) === null || _c === void 0 ? void 0 : _c.variants.find((x) => x.name.toUpperCase() == (defaultVariant === null || defaultVariant === void 0 ? void 0 : defaultVariant.toUpperCase()))) !== null && _d !== void 0 ? _d : (_e = field === null || field === void 0 ? void 0 : field.value) === null || _e === void 0 ? void 0 : _e.variants[0];
|
|
33
|
+
const attrs = Object.assign(Object.assign({}, img), otherProps);
|
|
37
34
|
if (!(sources === null || sources === void 0 ? void 0 : sources.length)) {
|
|
38
|
-
return _jsx("img", Object.assign({}, attrs, { alt:
|
|
35
|
+
return _jsx("img", Object.assign({}, attrs, { alt: "" }));
|
|
39
36
|
}
|
|
40
37
|
else {
|
|
41
|
-
return (_jsxs(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
return (_jsxs("picture", { children: [sources === null || sources === void 0 ? void 0 : sources.map((source) => {
|
|
39
|
+
const variant = variants === null || variants === void 0 ? void 0 : variants.find((v) => v.name.toLowerCase() == source.variant.toLowerCase());
|
|
40
|
+
if (!variant)
|
|
41
|
+
return;
|
|
42
|
+
let srcSet = variant.src;
|
|
43
|
+
if (source.widths && source.widths.length) {
|
|
44
|
+
const getScaledImage = (variant, width) => {
|
|
45
|
+
if (width > variant.width)
|
|
46
|
+
return { src: variant.src, width: 0 };
|
|
47
|
+
else
|
|
48
|
+
return { src: variant.src + "&mw=" + width, width: width };
|
|
49
|
+
};
|
|
50
|
+
let scaledImages = source.widths.map((x) => getScaledImage(variant, x));
|
|
51
|
+
srcSet = "";
|
|
52
|
+
for (let w = 0; w < scaledImages.length; w++) {
|
|
53
|
+
if (srcSet.length)
|
|
54
|
+
srcSet = srcSet + ", ";
|
|
55
|
+
srcSet += scaledImages[w].src + " " + source.widths[w] + "w";
|
|
56
|
+
if (scaledImages[w].width === 0)
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (source.width) {
|
|
46
62
|
const getScaledImage = (variant, width) => {
|
|
47
63
|
if (width > variant.width)
|
|
48
64
|
return { src: variant.src, width: 0 };
|
|
49
65
|
else
|
|
50
|
-
return { src: variant.src +
|
|
66
|
+
return { src: variant.src + "&mw=" + width, width: width };
|
|
51
67
|
};
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
srcSet = getScaledImage(variant, source.width).src;
|
|
69
|
+
if (source.scales) {
|
|
70
|
+
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
54
71
|
srcSet = "";
|
|
55
72
|
for (let w = 0; w < scaledImages.length; w++) {
|
|
56
73
|
if (srcSet.length)
|
|
57
74
|
srcSet = srcSet + ", ";
|
|
58
|
-
srcSet +=
|
|
59
|
-
hashImageUrl(scaledImages[w].src) +
|
|
60
|
-
" " +
|
|
61
|
-
source.widths[w] +
|
|
62
|
-
"w";
|
|
75
|
+
srcSet += scaledImages[w].src + " " + source.scales[w] + "x";
|
|
63
76
|
if (scaledImages[w].width === 0)
|
|
64
77
|
break;
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let scaledImages = source.scales.map((x) => { var _a; return getScaledImage(variant, ((_a = source.width) !== null && _a !== void 0 ? _a : 0) * x); });
|
|
72
|
-
srcSet = "";
|
|
73
|
-
for (let w = 0; w < scaledImages.length; w++) {
|
|
74
|
-
if (srcSet.length)
|
|
75
|
-
srcSet = srcSet + ", ";
|
|
76
|
-
srcSet +=
|
|
77
|
-
hashImageUrl(scaledImages[w].src) +
|
|
78
|
-
" " +
|
|
79
|
-
source.scales[w] +
|
|
80
|
-
"x";
|
|
81
|
-
if (scaledImages[w].width === 0)
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
88
|
-
}), _jsx("img", Object.assign({}, attrs, { alt: (_g = field.value) === null || _g === void 0 ? void 0 : _g.alt }))] }), renderJsonLinkedData && !video ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
89
|
-
__html: JSON.stringify({
|
|
90
|
-
"@context": "http://schema.org",
|
|
91
|
-
"@type": "ImageObject",
|
|
92
|
-
"image": img === null || img === void 0 ? void 0 : img.src,
|
|
93
|
-
"description": (_h = field.value) === null || _h === void 0 ? void 0 : _h.alt,
|
|
94
|
-
"name": (_j = field.value) === null || _j === void 0 ? void 0 : _j.name
|
|
95
|
-
})
|
|
96
|
-
} }) : null, video && _jsx("video", Object.assign({}, videoAttr)), renderJsonLinkedData && video ? _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
|
|
97
|
-
__html: JSON.stringify({
|
|
98
|
-
"@context": "http://schema.org",
|
|
99
|
-
"@type": "VideoObject",
|
|
100
|
-
"contentUrl": img === null || img === void 0 ? void 0 : img.src,
|
|
101
|
-
"description": (_k = field.value) === null || _k === void 0 ? void 0 : _k.alt,
|
|
102
|
-
"name": (_l = field.value) === null || _l === void 0 ? void 0 : _l.name
|
|
103
|
-
})
|
|
104
|
-
} }) : null] }));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (_jsx("source", { srcSet: srcSet, media: source.media }, source.variant + source.media));
|
|
83
|
+
}), _jsx("img", Object.assign({}, attrs, { alt: "" }))] }));
|
|
105
84
|
}
|
|
106
85
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -27,7 +27,6 @@ const fetchRouteData = cache((path, host, mode, itemId, language) => __awaiter(v
|
|
|
27
27
|
headers: {
|
|
28
28
|
"Content-Type": "application/json",
|
|
29
29
|
Cookie: cookies().toString(),
|
|
30
|
-
"x-api-key": process.env.API_KEY,
|
|
31
30
|
},
|
|
32
31
|
next: {
|
|
33
32
|
tags: ["pages"],
|
|
@@ -62,7 +61,6 @@ const fetchRouteData = cache((path, host, mode, itemId, language) => __awaiter(v
|
|
|
62
61
|
site: data.site,
|
|
63
62
|
pageEditing: true,
|
|
64
63
|
pageState: "",
|
|
65
|
-
database: data.page.database,
|
|
66
64
|
};
|
|
67
65
|
context.fields = data.page.fields;
|
|
68
66
|
context.dictionary = yield loadDictionary(context.pageContext.site.name, context.pageContext.language, mode);
|
package/package.json
CHANGED
package/types/alpacaContext.d.ts
CHANGED
package/types/fieldTypes.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface LinkField {
|
|
|
8
8
|
value: LinkValue;
|
|
9
9
|
}
|
|
10
10
|
export interface PictureValue {
|
|
11
|
-
|
|
11
|
+
altText: string;
|
|
12
12
|
alt: string;
|
|
13
13
|
variants: PictureVariant[];
|
|
14
14
|
loopVideos: boolean;
|
|
@@ -16,7 +16,7 @@ export interface PictureValue {
|
|
|
16
16
|
export interface PictureVariant {
|
|
17
17
|
name: string;
|
|
18
18
|
src: string;
|
|
19
|
-
|
|
19
|
+
videoId: string;
|
|
20
20
|
width: number;
|
|
21
21
|
}
|
|
22
22
|
export interface ImageField {
|
|
@@ -48,15 +48,3 @@ export interface EnhancedTreeListFieldItem {
|
|
|
48
48
|
export type EnhancedTreeListField = {
|
|
49
49
|
value: EnhancedTreeListFieldItem[];
|
|
50
50
|
};
|
|
51
|
-
export type CheckboxField = {
|
|
52
|
-
value: boolean;
|
|
53
|
-
};
|
|
54
|
-
export type DateField = {
|
|
55
|
-
value: DateFieldValue;
|
|
56
|
-
};
|
|
57
|
-
export type DateFieldValue = {
|
|
58
|
-
date: string;
|
|
59
|
-
};
|
|
60
|
-
export type NumberField = {
|
|
61
|
-
value: number;
|
|
62
|
-
};
|
package/types/index.d.ts
CHANGED
package/types/loadRouteData.d.ts
CHANGED
|
@@ -12,15 +12,6 @@ export type Page = Response & {
|
|
|
12
12
|
placeholders: PlaceholderData[];
|
|
13
13
|
meta: {
|
|
14
14
|
title: string;
|
|
15
|
-
description: string;
|
|
16
|
-
canonical: string;
|
|
17
|
-
keywords: string;
|
|
18
|
-
hrefLangTags: object;
|
|
19
|
-
"og:title": string;
|
|
20
|
-
"og:description": string;
|
|
21
|
-
"og:url": string;
|
|
22
|
-
"og:type": string;
|
|
23
|
-
"og:image": string;
|
|
24
15
|
};
|
|
25
16
|
};
|
|
26
17
|
export type Redirect = Response & {
|
package/dist/cjs/graphQLTypes.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hashImageUrl = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
require("url");
|
|
9
|
-
const protectedParams = [
|
|
10
|
-
"w",
|
|
11
|
-
"h",
|
|
12
|
-
"mw",
|
|
13
|
-
"mh",
|
|
14
|
-
"sc",
|
|
15
|
-
"as",
|
|
16
|
-
"bc",
|
|
17
|
-
"db",
|
|
18
|
-
"iar",
|
|
19
|
-
"la",
|
|
20
|
-
"thn",
|
|
21
|
-
"vs",
|
|
22
|
-
"sc_content",
|
|
23
|
-
"sc_lang",
|
|
24
|
-
"sc_site",
|
|
25
|
-
"gray",
|
|
26
|
-
"rev",
|
|
27
|
-
"devicepixelratio",
|
|
28
|
-
"encodequality",
|
|
29
|
-
"rx",
|
|
30
|
-
"ry",
|
|
31
|
-
"rw",
|
|
32
|
-
"rh",
|
|
33
|
-
"crop",
|
|
34
|
-
];
|
|
35
|
-
function hashImageUrl(url) {
|
|
36
|
-
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
37
|
-
return url;
|
|
38
|
-
const uri = new URL(url.toLowerCase());
|
|
39
|
-
uri.searchParams.delete("hash");
|
|
40
|
-
const searchParams = protectedParams
|
|
41
|
-
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
42
|
-
.filter((x) => x.val)
|
|
43
|
-
.map((x) => x.name + "=" + x.val)
|
|
44
|
-
.join("&");
|
|
45
|
-
const stringToProtect = uri.pathname.substring(1) + "?" + searchParams;
|
|
46
|
-
const hash = crypto_1.default
|
|
47
|
-
.createHash("md5")
|
|
48
|
-
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
49
|
-
.digest("hex");
|
|
50
|
-
uri.searchParams.set("hash", hash);
|
|
51
|
-
return uri.toString();
|
|
52
|
-
}
|
|
53
|
-
exports.hashImageUrl = hashImageUrl;
|
package/dist/esm/graphQLTypes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
import "url";
|
|
3
|
-
const protectedParams = [
|
|
4
|
-
"w",
|
|
5
|
-
"h",
|
|
6
|
-
"mw",
|
|
7
|
-
"mh",
|
|
8
|
-
"sc",
|
|
9
|
-
"as",
|
|
10
|
-
"bc",
|
|
11
|
-
"db",
|
|
12
|
-
"iar",
|
|
13
|
-
"la",
|
|
14
|
-
"thn",
|
|
15
|
-
"vs",
|
|
16
|
-
"sc_content",
|
|
17
|
-
"sc_lang",
|
|
18
|
-
"sc_site",
|
|
19
|
-
"gray",
|
|
20
|
-
"rev",
|
|
21
|
-
"devicepixelratio",
|
|
22
|
-
"encodequality",
|
|
23
|
-
"rx",
|
|
24
|
-
"ry",
|
|
25
|
-
"rw",
|
|
26
|
-
"rh",
|
|
27
|
-
"crop",
|
|
28
|
-
];
|
|
29
|
-
export function hashImageUrl(url) {
|
|
30
|
-
if (!process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET)
|
|
31
|
-
return url;
|
|
32
|
-
const uri = new URL(url.toLowerCase());
|
|
33
|
-
uri.searchParams.delete("hash");
|
|
34
|
-
const searchParams = protectedParams
|
|
35
|
-
.map((x) => ({ name: x, val: uri.searchParams.get(x) }))
|
|
36
|
-
.filter((x) => x.val)
|
|
37
|
-
.map((x) => x.name + "=" + x.val)
|
|
38
|
-
.join("&");
|
|
39
|
-
const stringToProtect = uri.pathname.substring(1) + "?" + searchParams;
|
|
40
|
-
const hash = crypto
|
|
41
|
-
.createHash("md5")
|
|
42
|
-
.update(stringToProtect + process.env.MEDIA_REQUESTPROTECTION_SHAREDSECRET, "utf16le")
|
|
43
|
-
.digest("hex");
|
|
44
|
-
uri.searchParams.set("hash", hash);
|
|
45
|
-
return uri.toString();
|
|
46
|
-
}
|
package/types/graphQLTypes.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type SitecoreItem = {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
key: string;
|
|
5
|
-
template: Template;
|
|
6
|
-
fields: Field[];
|
|
7
|
-
children: SitecoreItem[];
|
|
8
|
-
parentId: string;
|
|
9
|
-
url: string;
|
|
10
|
-
versionsCount: number;
|
|
11
|
-
};
|
|
12
|
-
export type Template = {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
};
|
|
16
|
-
export type Field = {
|
|
17
|
-
name: string;
|
|
18
|
-
value: string;
|
|
19
|
-
jsonValue: Value;
|
|
20
|
-
targetItems: SitecoreItem[];
|
|
21
|
-
};
|
|
22
|
-
export type Value = {
|
|
23
|
-
value: any;
|
|
24
|
-
};
|