react-datocms 4.1.2 → 4.2.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/README.md +34 -6
- package/dist/cjs/Image/index.js +68 -74
- package/dist/cjs/Image/index.js.map +1 -1
- package/dist/cjs/Image/useInView.js +3 -14
- package/dist/cjs/Image/useInView.js.map +1 -1
- package/dist/cjs/Seo/index.js +6 -6
- package/dist/cjs/Seo/index.js.map +1 -1
- package/dist/cjs/Seo/nextUtils.js +34 -55
- package/dist/cjs/Seo/nextUtils.js.map +1 -1
- package/dist/cjs/Seo/remixUtils.js +6 -18
- package/dist/cjs/Seo/remixUtils.js.map +1 -1
- package/dist/cjs/Seo/renderMetaTags.js +6 -18
- package/dist/cjs/Seo/renderMetaTags.js.map +1 -1
- package/dist/cjs/Seo/renderMetaTagsToString.js +7 -7
- package/dist/cjs/Seo/renderMetaTagsToString.js.map +1 -1
- package/dist/cjs/Seo/types.js +31 -51
- package/dist/cjs/Seo/types.js.map +1 -1
- package/dist/cjs/StructuredText/index.js +40 -52
- package/dist/cjs/StructuredText/index.js.map +1 -1
- package/dist/cjs/VideoPlayer/index.js +67 -0
- package/dist/cjs/VideoPlayer/index.js.map +1 -0
- package/dist/cjs/index.js +8 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/useQuerySubscription/index.js +25 -70
- package/dist/cjs/useQuerySubscription/index.js.map +1 -1
- package/dist/cjs/useSiteSearch/index.js +71 -123
- package/dist/cjs/useSiteSearch/index.js.map +1 -1
- package/dist/cjs/useVideoPlayer/index.js +31 -0
- package/dist/cjs/useVideoPlayer/index.js.map +1 -0
- package/dist/esm/Image/index.js +62 -68
- package/dist/esm/Image/index.js.map +1 -1
- package/dist/esm/Image/useInView.js.map +1 -1
- package/dist/esm/Seo/index.js +5 -5
- package/dist/esm/Seo/index.js.map +1 -1
- package/dist/esm/Seo/nextUtils.js +27 -48
- package/dist/esm/Seo/nextUtils.js.map +1 -1
- package/dist/esm/Seo/remixUtils.js +5 -17
- package/dist/esm/Seo/remixUtils.js.map +1 -1
- package/dist/esm/Seo/renderMetaTags.js +4 -16
- package/dist/esm/Seo/renderMetaTags.js.map +1 -1
- package/dist/esm/Seo/renderMetaTagsToString.js +6 -6
- package/dist/esm/Seo/renderMetaTagsToString.js.map +1 -1
- package/dist/esm/Seo/types.js +30 -50
- package/dist/esm/Seo/types.js.map +1 -1
- package/dist/esm/StructuredText/index.js +33 -45
- package/dist/esm/StructuredText/index.js.map +1 -1
- package/dist/esm/VideoPlayer/index.js +38 -0
- package/dist/esm/VideoPlayer/index.js.map +1 -0
- package/dist/esm/index.js +7 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/useQuerySubscription/index.js +22 -67
- package/dist/esm/useQuerySubscription/index.js.map +1 -1
- package/dist/esm/useSiteSearch/index.js +65 -117
- package/dist/esm/useSiteSearch/index.js.map +1 -1
- package/dist/esm/useVideoPlayer/index.js +27 -0
- package/dist/esm/useVideoPlayer/index.js.map +1 -0
- package/dist/types/Seo/index.d.ts +5 -5
- package/dist/types/Seo/nextUtils.d.ts +1 -1
- package/dist/types/Seo/remixUtils.d.ts +1 -1
- package/dist/types/Seo/renderMetaTags.d.ts +1 -1
- package/dist/types/Seo/renderMetaTagsToString.d.ts +1 -1
- package/dist/types/StructuredText/index.d.ts +2 -2
- package/dist/types/VideoPlayer/index.d.ts +26 -0
- package/dist/types/index.d.ts +7 -5
- package/dist/types/useVideoPlayer/index.d.ts +17 -0
- package/package.json +41 -43
- package/src/Image/__tests__/__snapshots__/index.test.tsx.snap +91 -91
- package/src/Image/__tests__/index.test.tsx +2 -2
- package/src/Image/index.tsx +7 -5
- package/src/Seo/__tests__/__snapshots__/index.test.tsx.snap +53 -53
- package/src/Seo/__tests__/index.test.tsx +3 -3
- package/src/Seo/index.ts +5 -5
- package/src/Seo/nextUtils.ts +2 -2
- package/src/Seo/remixUtils.ts +1 -1
- package/src/Seo/renderMetaTags.tsx +1 -1
- package/src/Seo/renderMetaTagsToString.tsx +1 -1
- package/src/StructuredText/__tests__/__snapshots__/index.test.tsx.snap +58 -58
- package/src/StructuredText/__tests__/index.test.tsx +6 -6
- package/src/StructuredText/index.tsx +10 -10
- package/src/VideoPlayer/index.tsx +107 -0
- package/src/{setupTests.ts → __tests__/setup.ts} +4 -1
- package/src/index.ts +8 -5
- package/src/useQuerySubscription/index.ts +6 -6
- package/src/useVideoPlayer/__tests__/index.test.tsx +98 -0
- package/src/useVideoPlayer/index.ts +68 -0
- package/dist/cjs/Image/__tests__/index.test.js +0 -99
- package/dist/cjs/Image/__tests__/index.test.js.map +0 -1
- package/dist/cjs/Seo/__tests__/index.test.js +0 -330
- package/dist/cjs/Seo/__tests__/index.test.js.map +0 -1
- package/dist/cjs/StructuredText/__tests__/index.test.js +0 -243
- package/dist/cjs/StructuredText/__tests__/index.test.js.map +0 -1
- package/dist/cjs/setupTests.js +0 -11
- package/dist/cjs/setupTests.js.map +0 -1
- package/dist/esm/Image/__tests__/index.test.d.ts +0 -1
- package/dist/esm/Image/__tests__/index.test.js +0 -74
- package/dist/esm/Image/__tests__/index.test.js.map +0 -1
- package/dist/esm/Image/index.d.ts +0 -93
- package/dist/esm/Image/useInView.d.ts +0 -1
- package/dist/esm/Seo/__tests__/index.test.d.ts +0 -1
- package/dist/esm/Seo/__tests__/index.test.js +0 -305
- package/dist/esm/Seo/__tests__/index.test.js.map +0 -1
- package/dist/esm/Seo/index.d.ts +0 -5
- package/dist/esm/Seo/nextUtils.d.ts +0 -48
- package/dist/esm/Seo/remixUtils.d.ts +0 -6
- package/dist/esm/Seo/renderMetaTags.d.ts +0 -3
- package/dist/esm/Seo/renderMetaTagsToString.d.ts +0 -2
- package/dist/esm/Seo/types.d.ts +0 -55
- package/dist/esm/StructuredText/__tests__/index.test.d.ts +0 -1
- package/dist/esm/StructuredText/__tests__/index.test.js +0 -218
- package/dist/esm/StructuredText/__tests__/index.test.js.map +0 -1
- package/dist/esm/StructuredText/index.d.ts +0 -52
- package/dist/esm/index.d.ts +0 -5
- package/dist/esm/setupTests.d.ts +0 -1
- package/dist/esm/setupTests.js +0 -6
- package/dist/esm/setupTests.js.map +0 -1
- package/dist/esm/useQuerySubscription/index.d.ts +0 -20
- package/dist/esm/useSiteSearch/index.d.ts +0 -83
- package/dist/types/Image/__tests__/index.test.d.ts +0 -1
- package/dist/types/Seo/__tests__/index.test.d.ts +0 -1
- package/dist/types/StructuredText/__tests__/index.test.d.ts +0 -1
- package/dist/types/setupTests.d.ts +0 -1
- /package/src/Image/{useInView.tsx → useInView.ts} +0 -0
- /package/src/Seo/{types.tsx → types.ts} +0 -0
|
@@ -1,25 +1,13 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.renderMetaTags = void 0;
|
|
18
|
-
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
19
8
|
function renderMetaTags(data) {
|
|
20
|
-
return data.map(
|
|
21
|
-
|
|
22
|
-
var key = [tag];
|
|
9
|
+
return data.map(({ tag, attributes, content }) => {
|
|
10
|
+
let key = [tag];
|
|
23
11
|
if (attributes && 'property' in attributes) {
|
|
24
12
|
key.push(attributes.property);
|
|
25
13
|
}
|
|
@@ -32,8 +20,8 @@ function renderMetaTags(data) {
|
|
|
32
20
|
if (attributes && 'sizes' in attributes) {
|
|
33
21
|
key.push(attributes.sizes);
|
|
34
22
|
}
|
|
35
|
-
|
|
36
|
-
return (react_1
|
|
23
|
+
const Tag = tag;
|
|
24
|
+
return (react_1.default.createElement(Tag, Object.assign({ key: key.join('-') }, attributes), content));
|
|
37
25
|
});
|
|
38
26
|
}
|
|
39
27
|
exports.renderMetaTags = renderMetaTags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderMetaTags.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTags.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderMetaTags.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTags.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,SAAgB,cAAc,CAC5B,IAA4C;IAE5C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE;QAC/C,IAAI,GAAG,GAAa,CAAC,GAAG,CAAC,CAAC;QAE1B,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,UAAU,IAAI,MAAM,IAAI,UAAU,EAAE,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,UAAU,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC;YACtC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,UAAU,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;YACxC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAED,MAAM,GAAG,GAAG,GAAgC,CAAC;QAE7C,OAAO,CACL,8BAAC,GAAG,kBAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAM,UAAU,GACpC,OAAO,CACJ,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA9BD,wCA8BC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderMetaTagsToString = void 0;
|
|
4
4
|
function renderMetaTagsToString(data) {
|
|
5
5
|
return data
|
|
6
|
-
.map(
|
|
6
|
+
.map((tag) => {
|
|
7
7
|
if (tag.tag === 'title') {
|
|
8
|
-
return
|
|
8
|
+
return `<title>${tag.content}</title>`;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
for (
|
|
10
|
+
const serializedAttrs = [];
|
|
11
|
+
for (const key in tag.attributes) {
|
|
12
12
|
if (Object.prototype.hasOwnProperty.call(tag.attributes, key)) {
|
|
13
|
-
serializedAttrs.push(
|
|
13
|
+
serializedAttrs.push(`${key}="${tag.attributes[key]}"`);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return `<${tag.tag} ${serializedAttrs.join(' ')} />`;
|
|
17
17
|
})
|
|
18
18
|
.join('\n');
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderMetaTagsToString.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTagsToString.tsx"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CACpC,IAA4C;IAE5C,OAAO,IAAI;SACR,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"renderMetaTagsToString.js","sourceRoot":"","sources":["../../../src/Seo/renderMetaTagsToString.tsx"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CACpC,IAA4C;IAE5C,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACxB,OAAO,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC;QACzC,CAAC;QAED,MAAM,eAAe,GAAG,EAAE,CAAC;QAE3B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YACjC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC9D,eAAe,CAAC,IAAI,CAAC,GAAG,GAAG,KAAM,GAAG,CAAC,UAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QAED,OAAO,IAAI,GAAG,CAAC,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AApBD,wDAoBC"}
|
package/dist/cjs/Seo/types.js
CHANGED
|
@@ -1,64 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isSeoMetaTag = exports.isOgMetaAttributes = exports.isRegularMetaAttributes = exports.isSeoOrFaviconTag = exports.isFaviconTag = exports.isSeoLinkTag = exports.isAppleTouchIconAttributes = exports.isFaviconAttributes = exports.isSeoTag = exports.isSeoTitleTag = void 0;
|
|
4
|
-
|
|
5
|
-
return 'tag' in tag && tag.tag === 'title' && !tag.attributes;
|
|
6
|
-
};
|
|
4
|
+
const isSeoTitleTag = (tag) => 'tag' in tag && tag.tag === 'title' && !tag.attributes;
|
|
7
5
|
exports.isSeoTitleTag = isSeoTitleTag;
|
|
8
|
-
|
|
9
|
-
return (0, exports.isSeoTitleTag)(tag) || (0, exports.isSeoMetaTag)(tag);
|
|
10
|
-
};
|
|
6
|
+
const isSeoTag = (tag) => (0, exports.isSeoTitleTag)(tag) || (0, exports.isSeoMetaTag)(tag);
|
|
11
7
|
exports.isSeoTag = isSeoTag;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
typeof tag.href === 'string';
|
|
21
|
-
};
|
|
8
|
+
const isFaviconAttributes = (tag) => 'sizes' in tag &&
|
|
9
|
+
typeof tag.sizes === 'string' &&
|
|
10
|
+
'type' in tag &&
|
|
11
|
+
typeof tag.type === 'string' &&
|
|
12
|
+
'rel' in tag &&
|
|
13
|
+
typeof tag.rel === 'string' &&
|
|
14
|
+
'href' in tag &&
|
|
15
|
+
typeof tag.href === 'string';
|
|
22
16
|
exports.isFaviconAttributes = isFaviconAttributes;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
typeof tag.href === 'string';
|
|
30
|
-
};
|
|
17
|
+
const isAppleTouchIconAttributes = (tag) => 'sizes' in tag &&
|
|
18
|
+
typeof tag.sizes === 'string' &&
|
|
19
|
+
'rel' in tag &&
|
|
20
|
+
tag.rel === 'apple-touch-icon' &&
|
|
21
|
+
'href' in tag &&
|
|
22
|
+
typeof tag.href === 'string';
|
|
31
23
|
exports.isAppleTouchIconAttributes = isAppleTouchIconAttributes;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
(0, exports.isAppleTouchIconAttributes)(tag.attributes));
|
|
38
|
-
};
|
|
24
|
+
const isSeoLinkTag = (tag) => 'tag' in tag &&
|
|
25
|
+
tag.tag === 'link' &&
|
|
26
|
+
!tag.content &&
|
|
27
|
+
((0, exports.isFaviconAttributes)(tag.attributes) ||
|
|
28
|
+
(0, exports.isAppleTouchIconAttributes)(tag.attributes));
|
|
39
29
|
exports.isSeoLinkTag = isSeoLinkTag;
|
|
40
|
-
|
|
41
|
-
return (0, exports.isSeoMetaTag)(tag) || (0, exports.isSeoLinkTag)(tag);
|
|
42
|
-
};
|
|
30
|
+
const isFaviconTag = (tag) => (0, exports.isSeoMetaTag)(tag) || (0, exports.isSeoLinkTag)(tag);
|
|
43
31
|
exports.isFaviconTag = isFaviconTag;
|
|
44
|
-
|
|
45
|
-
return (0, exports.isSeoTag)(seoOrFaviconTag) || (0, exports.isFaviconTag)(seoOrFaviconTag);
|
|
46
|
-
};
|
|
32
|
+
const isSeoOrFaviconTag = (seoOrFaviconTag) => (0, exports.isSeoTag)(seoOrFaviconTag) || (0, exports.isFaviconTag)(seoOrFaviconTag);
|
|
47
33
|
exports.isSeoOrFaviconTag = isSeoOrFaviconTag;
|
|
48
|
-
|
|
49
|
-
return 'name' in attributes && 'content' in attributes;
|
|
50
|
-
};
|
|
34
|
+
const isRegularMetaAttributes = (attributes) => 'name' in attributes && 'content' in attributes;
|
|
51
35
|
exports.isRegularMetaAttributes = isRegularMetaAttributes;
|
|
52
|
-
|
|
53
|
-
return 'property' in attributes && 'content' in attributes;
|
|
54
|
-
};
|
|
36
|
+
const isOgMetaAttributes = (attributes) => 'property' in attributes && 'content' in attributes;
|
|
55
37
|
exports.isOgMetaAttributes = isOgMetaAttributes;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(
|
|
61
|
-
(0, exports.isOgMetaAttributes)(seoMetaTag.attributes));
|
|
62
|
-
};
|
|
38
|
+
const isSeoMetaTag = (seoMetaTag) => 'tag' in seoMetaTag &&
|
|
39
|
+
seoMetaTag.tag === 'meta' &&
|
|
40
|
+
!seoMetaTag.content &&
|
|
41
|
+
((0, exports.isRegularMetaAttributes)(seoMetaTag.attributes) ||
|
|
42
|
+
(0, exports.isOgMetaAttributes)(seoMetaTag.attributes));
|
|
63
43
|
exports.isSeoMetaTag = isSeoMetaTag;
|
|
64
44
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Se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C,GAAG,CAAC,UAAU,CAAC;QAClC,IAAA,kCAA0B,EAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AALnC,QAAA,YAAY,gBAKuB;AAEzC,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAqB,EAAE,CAC1D,IAAA,oBAAY,EAAC,GAAG,CAAC,IAAI,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;AAD5B,QAAA,YAAY,gBACgB;AAElC,MAAM,iBAAiB,GAAG,CAC/B,eAAmD,EACf,EAAE,CACtC,IAAA,gBAAQ,EAAC,eAAe,CAAC,IAAI,IAAA,oBAAY,EAAC,eAAe,CAAC,CAAC;AAHhD,QAAA,iBAAiB,qBAG+B;AAEtD,MAAM,uBAAuB,GAAG,CACrC,UAAoD,EACf,EAAE,CACvC,MAAM,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU,CAAC;AAHrC,QAAA,uBAAuB,2BAGc;AAE3C,MAAM,kBAAkB,GAAG,CAChC,UAAoD,EACpB,EAAE,CAClC,UAAU,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU,CAAC;AAHzC,QAAA,kBAAkB,sBAGuB;AAE/C,MAAM,YAAY,GAAG,CAC1B,UAA2B,EACD,EAAE,CAC5B,KAAK,IAAI,UAAU;IACnB,UAAU,CAAC,GAAG,KAAK,MAAM;IACzB,CAAC,UAAU,CAAC,OAAO;IACnB,CAAC,IAAA,+BAAuB,EAAC,UAAU,CAAC,UAAU,CAAC;QAC7C,IAAA,0BAAkB,EAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAPlC,QAAA,YAAY,gBAOsB"}
|
|
@@ -22,102 +22,90 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
-
if (ar || !(i in from)) {
|
|
28
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
-
ar[i] = from[i];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
|
-
exports.__esModule = true;
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
exports.StructuredText = exports.appendKeyToValidElement = exports.defaultAdapter = exports.renderRule = exports.RenderError = exports.renderMarkRule = exports.renderNodeRule = void 0;
|
|
36
|
-
|
|
37
|
-
exports
|
|
38
|
-
exports
|
|
39
|
-
exports
|
|
40
|
-
|
|
41
|
-
exports
|
|
42
|
-
|
|
27
|
+
const datocms_structured_text_generic_html_renderer_1 = require("datocms-structured-text-generic-html-renderer");
|
|
28
|
+
Object.defineProperty(exports, "renderMarkRule", { enumerable: true, get: function () { return datocms_structured_text_generic_html_renderer_1.renderMarkRule; } });
|
|
29
|
+
Object.defineProperty(exports, "renderNodeRule", { enumerable: true, get: function () { return datocms_structured_text_generic_html_renderer_1.renderNodeRule; } });
|
|
30
|
+
Object.defineProperty(exports, "renderRule", { enumerable: true, get: function () { return datocms_structured_text_generic_html_renderer_1.renderNodeRule; } });
|
|
31
|
+
const datocms_structured_text_utils_1 = require("datocms-structured-text-utils");
|
|
32
|
+
Object.defineProperty(exports, "RenderError", { enumerable: true, get: function () { return datocms_structured_text_utils_1.RenderError; } });
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
43
34
|
exports.defaultAdapter = {
|
|
44
|
-
renderNode: react_1
|
|
45
|
-
renderFragment:
|
|
46
|
-
renderText:
|
|
35
|
+
renderNode: react_1.default.createElement,
|
|
36
|
+
renderFragment: (children, key) => react_1.default.createElement(react_1.default.Fragment, { key: key }, children),
|
|
37
|
+
renderText: (text, key) => text,
|
|
47
38
|
};
|
|
48
39
|
function appendKeyToValidElement(element, key) {
|
|
49
40
|
if ((0, react_1.isValidElement)(element) && element.key === null) {
|
|
50
|
-
return (0, react_1.cloneElement)(element, { key
|
|
41
|
+
return (0, react_1.cloneElement)(element, { key });
|
|
51
42
|
}
|
|
52
43
|
return element;
|
|
53
44
|
}
|
|
54
45
|
exports.appendKeyToValidElement = appendKeyToValidElement;
|
|
55
|
-
function StructuredText(
|
|
56
|
-
|
|
57
|
-
var result = (0, datocms_structured_text_generic_html_renderer_1.render)(data, {
|
|
46
|
+
function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }) {
|
|
47
|
+
const result = (0, datocms_structured_text_generic_html_renderer_1.render)(data, {
|
|
58
48
|
adapter: {
|
|
59
49
|
renderText: renderText || exports.defaultAdapter.renderText,
|
|
60
50
|
renderNode: renderNode || exports.defaultAdapter.renderNode,
|
|
61
|
-
renderFragment: renderFragment || exports.defaultAdapter.renderFragment
|
|
51
|
+
renderFragment: renderFragment || exports.defaultAdapter.renderFragment,
|
|
62
52
|
},
|
|
63
|
-
metaTransformer
|
|
64
|
-
customMarkRules
|
|
65
|
-
customNodeRules:
|
|
66
|
-
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isInlineItem,
|
|
67
|
-
var node = _a.node, key = _a.key;
|
|
53
|
+
metaTransformer,
|
|
54
|
+
customMarkRules,
|
|
55
|
+
customNodeRules: [
|
|
56
|
+
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isInlineItem, ({ node, key }) => {
|
|
68
57
|
if (!renderInlineRecord) {
|
|
69
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
58
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'inlineItem' node, but no 'renderInlineRecord' prop is specified!`, node);
|
|
70
59
|
}
|
|
71
60
|
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.links)) {
|
|
72
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
61
|
+
throw new datocms_structured_text_utils_1.RenderError(`The document contains an 'itemLink' node, but the passed data prop is not a Structured Text GraphQL response, or data.links is not present!`, node);
|
|
73
62
|
}
|
|
74
|
-
|
|
63
|
+
const item = data.links.find((item) => item.id === node.item);
|
|
75
64
|
if (!item) {
|
|
76
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
65
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'inlineItem' node, but cannot find a record with ID ${node.item} inside data.links!`, node);
|
|
77
66
|
}
|
|
78
67
|
return appendKeyToValidElement(renderInlineRecord({ record: item }), key);
|
|
79
68
|
}),
|
|
80
|
-
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isItemLink,
|
|
81
|
-
var node = _a.node, key = _a.key, children = _a.children;
|
|
69
|
+
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isItemLink, ({ node, key, children }) => {
|
|
82
70
|
if (!renderLinkToRecord) {
|
|
83
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
71
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'itemLink' node, but no 'renderLinkToRecord' prop is specified!`, node);
|
|
84
72
|
}
|
|
85
73
|
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.links)) {
|
|
86
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
74
|
+
throw new datocms_structured_text_utils_1.RenderError(`The document contains an 'itemLink' node, but the passed data prop is not a Structured Text GraphQL response, or data.links is not present!`, node);
|
|
87
75
|
}
|
|
88
|
-
|
|
76
|
+
const item = data.links.find((item) => item.id === node.item);
|
|
89
77
|
if (!item) {
|
|
90
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
78
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'itemLink' node, but cannot find a record with ID ${node.item} inside data.links!`, node);
|
|
91
79
|
}
|
|
92
80
|
return appendKeyToValidElement(renderLinkToRecord({
|
|
93
81
|
record: item,
|
|
94
82
|
children: children,
|
|
95
83
|
transformedMeta: node.meta
|
|
96
84
|
? (metaTransformer || datocms_structured_text_generic_html_renderer_1.defaultMetaTransformer)({
|
|
97
|
-
node
|
|
98
|
-
meta: node.meta
|
|
85
|
+
node,
|
|
86
|
+
meta: node.meta,
|
|
99
87
|
})
|
|
100
|
-
: null
|
|
88
|
+
: null,
|
|
101
89
|
}), key);
|
|
102
90
|
}),
|
|
103
|
-
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isBlock,
|
|
104
|
-
var node = _a.node, key = _a.key;
|
|
91
|
+
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isBlock, ({ node, key }) => {
|
|
105
92
|
if (!renderBlock) {
|
|
106
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
93
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains a 'block' node, but no 'renderBlock' prop is specified!`, node);
|
|
107
94
|
}
|
|
108
95
|
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.blocks)) {
|
|
109
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
96
|
+
throw new datocms_structured_text_utils_1.RenderError(`The document contains an 'block' node, but the passed data prop is not a Structured Text GraphQL response, or data.blocks is not present!`, node);
|
|
110
97
|
}
|
|
111
|
-
|
|
98
|
+
const item = data.blocks.find((item) => item.id === node.item);
|
|
112
99
|
if (!item) {
|
|
113
|
-
throw new datocms_structured_text_utils_1.RenderError(
|
|
100
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains a 'block' node, but cannot find a record with ID ${node.item} inside data.blocks!`, node);
|
|
114
101
|
}
|
|
115
102
|
return appendKeyToValidElement(renderBlock({ record: item }), key);
|
|
116
|
-
})
|
|
117
|
-
|
|
103
|
+
}),
|
|
104
|
+
...(customNodeRules || customRules || []),
|
|
105
|
+
],
|
|
118
106
|
});
|
|
119
107
|
if (typeof result === 'string') {
|
|
120
|
-
return react_1
|
|
108
|
+
return react_1.default.createElement(react_1.default.Fragment, null, result);
|
|
121
109
|
}
|
|
122
110
|
return result || null;
|
|
123
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAQuD;AAgB9B,+FAlBvB,8DAAc,OAkBuB;AAA9B,+FAjBP,8DAAc,OAiBO;AAGI,2FApBzB,8DAAc,OAoBqB;AAlBrC,iFAYuC;AAGE,4FAXvC,2CAAW,OAWuC;AAFpD,+CAA0E;AAe7D,QAAA,cAAc,GAAG;IAC5B,UAAU,EAAE,eAAK,CAAC,aAAgD;IAClE,cAAc,EAAE,CACd,QAA+B,EAC/B,GAAW,EACI,EAAE,CAAC,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,IAAG,QAAQ,CAAkB;IACzE,UAAU,EAAE,CAAC,IAAY,EAAE,GAAW,EAAiB,EAAE,CAAC,IAAI;CAC/D,CAAC;AAEF,SAAgB,uBAAuB,CACrC,OAA4B,EAC5B,GAAW;IAEX,IAAI,IAAA,sBAAc,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,IAAA,oBAAY,EAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AARD,0DAQC;AA8DD,SAAgB,cAAc,CAG5B,EACA,IAAI,EACJ,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,eAAe,GACiB;IAChC,MAAM,MAAM,GAAG,IAAA,sDAAM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AI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE/D,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,2CAAW,CACnB,0FAA0F,IAAI,CAAC,IAAI,sBAAsB,EACzH,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,OAAO,uBAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;YACrE,CAAC,CAAC;YACF,GAAG,CAAC,eAAe,IAAI,WAAW,IAAI,EAAE,CAAC;SAC1C;KACF,CAAC,CAAC;IAEH,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,8DAAG,MAAM,CAAI,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC;AA/HD,wCA+HC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
27
|
+
var t = {};
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
29
|
+
t[p] = s[p];
|
|
30
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
31
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
32
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
33
|
+
t[p[i]] = s[p[i]];
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.VideoPlayer = void 0;
|
|
42
|
+
// This file defines a React component that easily displays a video player using
|
|
43
|
+
// data stored on DatoCMS and retrieved via DatoCMS GraphQL API. The component
|
|
44
|
+
// is a thin wrapper around the [React component made available by MUX][1].
|
|
45
|
+
//
|
|
46
|
+
// The React player written by MUX is an adapter for a web component.
|
|
47
|
+
//
|
|
48
|
+
// [1]: https://www.mux.com/player
|
|
49
|
+
const react_1 = __importStar(require("react"));
|
|
50
|
+
// React MUX player is made available in two flavours: eager and lazy loaded. We
|
|
51
|
+
// choose to use the lazy version to avoid loading the web component uselessly.
|
|
52
|
+
// MUX player lazy version loads internally the eager version using
|
|
53
|
+
// `React.lazy()`.
|
|
54
|
+
const lazy_1 = __importDefault(require("@mux/mux-player-react/lazy"));
|
|
55
|
+
// The core of this component is the `useVideoPlayer` hook: it takes
|
|
56
|
+
// data from DatoCMS GraphQL API and returns props as expected by the
|
|
57
|
+
// `<MuxPlayer />` component.
|
|
58
|
+
const index_js_1 = require("../useVideoPlayer/index.js");
|
|
59
|
+
exports.VideoPlayer = (0, react_1.forwardRef)((props, ref) => {
|
|
60
|
+
const { data = {}, disableCookies = true, preload = "metadata", style: styleFromProps } = props, rest = __rest(props, ["data", "disableCookies", "preload", "style"]);
|
|
61
|
+
const { title, playbackId, style: styleFromHook, placeholder, } = (0, index_js_1.useVideoPlayer)({
|
|
62
|
+
data,
|
|
63
|
+
});
|
|
64
|
+
const style = Object.assign(Object.assign({}, styleFromHook), styleFromProps);
|
|
65
|
+
return (react_1.default.createElement(lazy_1.default, Object.assign({ ref: ref, streamType: "on-demand", preload: preload, title: title, disableCookies: disableCookies, playbackId: playbackId, style: style, placeholder: placeholder }, rest)));
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VideoPlayer/index.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,gFAAgF;AAChF,8EAA8E;AAC9E,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,kCAAkC;AAElC,+CAA0C;AAO1C,gFAAgF;AAChF,+EAA+E;AAC/E,mEAAmE;AACnE,kBAAkB;AAElB,sEAAmD;AAEnD,oEAAoE;AACpE,qEAAqE;AACrE,6BAA6B;AAE7B,yDAA4D;AAqC/C,QAAA,WAAW,GAEY,IAAA,kBAAU,EAG5C,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACf,MAAM,EACJ,IAAI,GAAG,EAAE,EACT,cAAc,GAAG,IAAI,EACrB,OAAO,GAAG,UAAU,EACpB,KAAK,EAAE,cAAc,KAEnB,KAAK,EADJ,IAAI,UACL,KAAK,EANH,8CAML,CAAQ,CAAC;IAEV,MAAM,EACJ,KAAK,EACL,UAAU,EACV,KAAK,EAAE,aAAa,EACpB,WAAW,GACZ,GAAG,IAAA,yBAAc,EAAC;QACjB,IAAI;KACL,CAAC,CAAC;IAEH,MAAM,KAAK,mCACN,aAAa,GACb,cAAc,CAClB,CAAC;IAEF,OAAO,CACL,8BAAC,cAAS,kBACR,GAAG,EAAE,GAAG,EACR,UAAU,EAAC,WAAW,EACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,IACpB,IAAI,EACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -13,10 +13,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
17
|
-
__exportStar(require("./Image"), exports);
|
|
18
|
-
__exportStar(require("./Seo"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./StructuredText"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Image/index.js"), exports);
|
|
18
|
+
__exportStar(require("./Seo/index.js"), exports);
|
|
19
|
+
__exportStar(require("./VideoPlayer/index.js"), exports);
|
|
20
|
+
__exportStar(require("./StructuredText/index.js"), exports);
|
|
21
|
+
__exportStar(require("./useQuerySubscription/index.js"), exports);
|
|
22
|
+
__exportStar(require("./useSiteSearch/index.js"), exports);
|
|
23
|
+
__exportStar(require("./useVideoPlayer/index.js"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,iDAA+B;AAC/B,yDAAuC;AACvC,4DAA0C;AAE1C,kEAAgD;AAChD,2DAAyC;AACzC,4DAA0C"}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
3
|
-
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
2
|
+
'use client';
|
|
14
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -20,33 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
9
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
10
|
});
|
|
22
11
|
};
|
|
23
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
-
function step(op) {
|
|
28
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
-
switch (op[0]) {
|
|
33
|
-
case 0: case 1: t = op; break;
|
|
34
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
-
default:
|
|
38
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
-
if (t[2]) _.ops.pop();
|
|
43
|
-
_.trys.pop(); continue;
|
|
44
|
-
}
|
|
45
|
-
op = body.call(thisArg, _);
|
|
46
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
12
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
51
13
|
var t = {};
|
|
52
14
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -58,53 +20,46 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
58
20
|
}
|
|
59
21
|
return t;
|
|
60
22
|
};
|
|
61
|
-
exports
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
24
|
exports.useQuerySubscription = void 0;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
25
|
+
const datocms_listen_1 = require("datocms-listen");
|
|
26
|
+
const react_1 = require("react");
|
|
27
|
+
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
66
28
|
function useQuerySubscription(options) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(
|
|
29
|
+
const { enabled, initialData } = options, other = __rest(options, ["enabled", "initialData"]);
|
|
30
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
31
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
32
|
+
const [status, setStatus] = (0, react_1.useState)(enabled ? 'connecting' : 'closed');
|
|
33
|
+
const subscribeToQueryOptions = other;
|
|
34
|
+
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
73
35
|
if (enabled === false) {
|
|
74
36
|
setStatus('closed');
|
|
75
|
-
return
|
|
37
|
+
return () => {
|
|
76
38
|
// we don't have to perform any uninstall
|
|
77
39
|
};
|
|
78
40
|
}
|
|
79
|
-
|
|
41
|
+
let unsubscribe;
|
|
80
42
|
function subscribe() {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
setError(errorData);
|
|
92
|
-
} }))];
|
|
93
|
-
case 1:
|
|
94
|
-
unsubscribe = _a.sent();
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
unsubscribe = yield (0, datocms_listen_1.subscribeToQuery)(Object.assign(Object.assign({}, subscribeToQueryOptions), { onStatusChange: (status) => {
|
|
45
|
+
setStatus(status);
|
|
46
|
+
}, onUpdate: (updateData) => {
|
|
47
|
+
setError(null);
|
|
48
|
+
setData(updateData.response.data);
|
|
49
|
+
}, onChannelError: (errorData) => {
|
|
50
|
+
setData(null);
|
|
51
|
+
setError(errorData);
|
|
52
|
+
} }));
|
|
98
53
|
});
|
|
99
54
|
}
|
|
100
55
|
subscribe();
|
|
101
|
-
return
|
|
56
|
+
return () => {
|
|
102
57
|
if (unsubscribe) {
|
|
103
58
|
unsubscribe();
|
|
104
59
|
}
|
|
105
60
|
};
|
|
106
61
|
}, [subscribeToQueryOptions]);
|
|
107
|
-
return { error
|
|
62
|
+
return { error, status, data: data || initialData };
|
|
108
63
|
}
|
|
109
64
|
exports.useQuerySubscription = useQuerySubscription;
|
|
110
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/useQuerySubscription/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/useQuerySubscription/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAEb,mDAMwB;AACxB,iCAAiC;AACjC,qEAA8F;AAyB9F,SAAgB,oBAAoB,CAKlC,OAA0D;IAC1D,MAAM,EAAE,OAAO,EAAE,WAAW,KAAe,OAAO,EAAjB,KAAK,UAAK,OAAO,EAA5C,0BAAkC,CAAU,CAAC;IAEnD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAA0B,IAAI,CAAC,CAAC;IAClE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAqB,IAAI,CAAC,CAAC;IAC3D,MAAM,CAAC,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