@comet/site-react 9.0.0-beta.3 → 9.0.0-beta.4

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.
Files changed (71) hide show
  1. package/lib/blockLoader/blockLoader.js +1 -59
  2. package/lib/blocks/DamFileDownloadLinkBlock.js +1 -27
  3. package/lib/blocks/DamVideoBlock.js +5 -99
  4. package/lib/blocks/DamVideoBlock.module.scss.js +1 -14
  5. package/lib/blocks/EmailLinkBlock.js +1 -21
  6. package/lib/blocks/ExternalLinkBlock.js +1 -47
  7. package/lib/blocks/PhoneLinkBlock.js +1 -21
  8. package/lib/blocks/SvgImageBlock.js +1 -30
  9. package/lib/blocks/VimeoVideoBlock.js +4 -129
  10. package/lib/blocks/VimeoVideoBlock.module.scss.js +1 -14
  11. package/lib/blocks/YouTubeVideoBlock.js +4 -136
  12. package/lib/blocks/YouTubeVideoBlock.module.scss.js +1 -14
  13. package/lib/blocks/factories/BlocksBlock.js +1 -27
  14. package/lib/blocks/factories/ListBlock.js +1 -13
  15. package/lib/blocks/factories/OneOfBlock.js +1 -23
  16. package/lib/blocks/factories/OptionalBlock.js +1 -10
  17. package/lib/blocks/helpers/PlayPauseButton.js +1 -9
  18. package/lib/blocks/helpers/PlayPauseButton.module.scss.js +1 -14
  19. package/lib/blocks/helpers/RichTextBlockHelper.js +1 -7
  20. package/lib/blocks/helpers/TipTapRichTextRenderer.d.ts +35 -0
  21. package/lib/blocks/helpers/TipTapRichTextRenderer.d.ts.map +1 -0
  22. package/lib/blocks/helpers/TipTapRichTextRenderer.js +3 -0
  23. package/lib/blocks/helpers/VideoPreviewImage.js +2 -23
  24. package/lib/blocks/helpers/VideoPreviewImage.module.scss.js +1 -17
  25. package/lib/blocks/helpers/useIsElementInViewport.js +1 -21
  26. package/lib/cookies/CookieApiContext.js +2 -18
  27. package/lib/cookies/CookieSafe.js +2 -18
  28. package/lib/cookies/useCookieBotCookieApi.js +1 -33
  29. package/lib/cookies/useLocalStorageCookieApi.js +1 -40
  30. package/lib/cookies/useOneTrustCookieApi.js +1 -45
  31. package/lib/errorHandler/ErrorHandlerBoundary.js +2 -10
  32. package/lib/errorHandler/ErrorHandlerBoundaryInternal.js +1 -26
  33. package/lib/errorHandler/ErrorHandlerProvider.js +2 -20
  34. package/lib/graphQLFetch/fetchInMemoryCache.js +1 -37
  35. package/lib/graphQLFetch/graphQLFetch.js +1 -125
  36. package/lib/iframebridge/IFrameBridge.js +4 -253
  37. package/lib/iframebridge/IFrameBridge.module.scss.js +1 -8
  38. package/lib/iframebridge/IFrameMessage.js +1 -21
  39. package/lib/iframebridge/Preview.js +1 -56
  40. package/lib/iframebridge/Preview.module.scss.js +1 -8
  41. package/lib/iframebridge/PreviewOverlay.js +1 -28
  42. package/lib/iframebridge/PreviewOverlay.module.scss.js +1 -8
  43. package/lib/iframebridge/PreviewOverlayElement.js +2 -36
  44. package/lib/iframebridge/PreviewOverlayElement.module.scss.js +1 -20
  45. package/lib/iframebridge/useBlockPreviewFetch.js +1 -29
  46. package/lib/iframebridge/useIFrameBridge.js +1 -8
  47. package/lib/iframebridge/utils.js +1 -46
  48. package/lib/iframebridge/withPreview.js +1 -33
  49. package/lib/image/Image.js +2 -10
  50. package/lib/image/image.utils.js +1 -55
  51. package/lib/index.d.ts +2 -2
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +1 -96
  54. package/lib/jsonLd/JsonLd.d.ts +7 -0
  55. package/lib/jsonLd/JsonLd.d.ts.map +1 -0
  56. package/lib/jsonLd/JsonLd.js +1 -0
  57. package/lib/persistedQueries/createPersistedQueryGraphQLFetch.js +1 -70
  58. package/lib/persistedQueries/persistedQueryRoute.js +1 -100
  59. package/lib/persistedQueries/webpackPersistedQueriesLoader.js +1 -51
  60. package/lib/preview/BlockPreviewProvider.js +1 -32
  61. package/lib/preview/PreviewContext.js +1 -9
  62. package/lib/preview/usePreview.js +1 -41
  63. package/lib/previewskeleton/PreviewSkeleton.js +8 -64
  64. package/lib/previewskeleton/PreviewSkeleton.module.scss.js +1 -17
  65. package/lib/server.d.ts +2 -0
  66. package/lib/server.d.ts.map +1 -0
  67. package/lib/server.js +1 -0
  68. package/lib/sitePreview/iframebridge/SitePreviewIFrameMessage.js +1 -8
  69. package/lib/sitePreview/iframebridge/sendSitePreviewIFrameMessage.js +1 -6
  70. package/lib/style.css +1 -1
  71. package/package.json +15 -8
@@ -1,14 +1 @@
1
- const videoContainer = "_videoContainer_bhmhr_1";
2
- const fill = "_fill_bhmhr_7";
3
- const youtubeContainer = "_youtubeContainer_bhmhr_12";
4
- const styles = {
5
- videoContainer,
6
- fill,
7
- youtubeContainer
8
- };
9
- export {
10
- styles as default,
11
- fill,
12
- videoContainer,
13
- youtubeContainer
14
- };
1
+ const e="_videoContainer_bhmhr_1",o="_fill_bhmhr_7",n="_youtubeContainer_bhmhr_12",t={videoContainer:e,fill:o,youtubeContainer:n};export{t as default,o as fill,e as videoContainer,n as youtubeContainer};
@@ -1,27 +1 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { Fragment as Fragment$1 } from "react";
3
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
4
- import { PreviewSkeleton } from "../../previewskeleton/PreviewSkeleton.js";
5
- const BlocksBlock = ({ supportedBlocks, data: { blocks } }) => {
6
- if (blocks.length === 0) {
7
- return /* @__PURE__ */ jsx(PreviewSkeleton, { hasContent: false });
8
- }
9
- return /* @__PURE__ */ jsx(Fragment, { children: blocks.map((block) => {
10
- const blockFunction = supportedBlocks[block.type];
11
- if (!blockFunction) {
12
- if (process.env.NODE_ENV === "development") {
13
- return /* @__PURE__ */ jsxs("pre", { children: [
14
- "Unknown type (",
15
- block.type,
16
- "): ",
17
- JSON.stringify(block.props)
18
- ] }, block.key);
19
- }
20
- return null;
21
- }
22
- return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction(block.props) }) }, block.key);
23
- }) });
24
- };
25
- export {
26
- BlocksBlock
27
- };
1
+ import{jsx as r,Fragment as e,jsxs as o}from"react/jsx-runtime";import{Fragment as n}from"react";import{ErrorHandlerBoundary as t}from"../../errorHandler/ErrorHandlerBoundary.js";import{PreviewSkeleton as p}from"../../previewskeleton/PreviewSkeleton.js";const s=({supportedBlocks:s,data:{blocks:l}})=>0===l.length?/* @__PURE__ */r(p,{hasContent:!1}):/* @__PURE__ */r(e,{children:l.map(e=>{const p=s[e.type];return p?/* @__PURE__ */r(n,{children:/* @__PURE__ */r(t,{children:p(e.props)})},e.key):"development"===process.env.NODE_ENV?/* @__PURE__ */o("pre",{children:["Unknown type (",e.type,"): ",JSON.stringify(e.props)]},e.key):null})});export{s as BlocksBlock};
@@ -1,13 +1 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { Fragment as Fragment$1 } from "react";
3
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
4
- import { PreviewSkeleton } from "../../previewskeleton/PreviewSkeleton.js";
5
- const ListBlock = ({ block: blockFunction, data: { blocks } }) => {
6
- if (blocks.length === 0) {
7
- return /* @__PURE__ */ jsx(PreviewSkeleton, { hasContent: false });
8
- }
9
- return /* @__PURE__ */ jsx(Fragment, { children: blocks.map((block) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction(block.props) }) }, block.key)) });
10
- };
11
- export {
12
- ListBlock
13
- };
1
+ import{jsx as r,Fragment as e}from"react/jsx-runtime";import{Fragment as o}from"react";import{ErrorHandlerBoundary as t}from"../../errorHandler/ErrorHandlerBoundary.js";import{PreviewSkeleton as n}from"../../previewskeleton/PreviewSkeleton.js";const a=({block:a,data:{blocks:m}})=>0===m.length?/* @__PURE__ */r(n,{hasContent:!1}):/* @__PURE__ */r(e,{children:m.map(e=>/* @__PURE__ */r(o,{children:/* @__PURE__ */r(t,{children:a(e.props)})},e.key))});export{a as ListBlock};
@@ -1,23 +1 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { ErrorHandlerBoundary } from "../../errorHandler/ErrorHandlerBoundary.js";
3
- const OneOfBlock = ({ data: { block, ...additionalProps }, supportedBlocks, children, className }) => {
4
- if (!block) {
5
- return null;
6
- }
7
- const blockFunction = supportedBlocks[block.type];
8
- if (!blockFunction) {
9
- if (process.env.NODE_ENV === "development") {
10
- return /* @__PURE__ */ jsxs("pre", { children: [
11
- "Unknown type (",
12
- block.type,
13
- "): ",
14
- JSON.stringify(block.props)
15
- ] });
16
- }
17
- return null;
18
- }
19
- return /* @__PURE__ */ jsx(ErrorHandlerBoundary, { children: blockFunction({ ...block.props, ...additionalProps, children, className }) });
20
- };
21
- export {
22
- OneOfBlock
23
- };
1
+ import{jsxs as r,jsx as e}from"react/jsx-runtime";import{ErrorHandlerBoundary as n}from"../../errorHandler/ErrorHandlerBoundary.js";const o=({data:{block:o,...t},supportedBlocks:l,children:p,className:s})=>{if(!o)return null;const c=l[o.type];return c?/* @__PURE__ */e(n,{children:c({...o.props,...t,children:p,className:s})}):"development"===process.env.NODE_ENV?/* @__PURE__ */r("pre",{children:["Unknown type (",o.type,"): ",JSON.stringify(o.props)]}):null};export{o as OneOfBlock};
@@ -1,10 +1 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- const OptionalBlock = ({ block: blockFunction, data: { visible, block }, children }) => {
3
- if (!visible || !block) {
4
- return null;
5
- }
6
- return /* @__PURE__ */ jsx(Fragment, { children: blockFunction({ ...block, children }) });
7
- };
8
- export {
9
- OptionalBlock
10
- };
1
+ import{jsx as l,Fragment as r}from"react/jsx-runtime";const c=({block:c,data:{visible:e,block:i},children:n})=>e&&i?/* @__PURE__ */l(r,{children:c({...i,children:n})}):null;export{c as OptionalBlock};
@@ -1,9 +1 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import clsx from "clsx";
3
- import styles from "./PlayPauseButton.module.scss.js";
4
- const PlayPauseButton = ({ isPlaying, onClick, ariaLabelPlay, ariaLabelPause }) => {
5
- return /* @__PURE__ */ jsx("button", { className: clsx(styles.button), onClick, "aria-label": isPlaying ? ariaLabelPause ?? "Pause" : ariaLabelPlay ?? "Play", children: /* @__PURE__ */ jsx("div", { className: clsx(styles.animatedPlayPause, isPlaying && styles.animatedPlayPausePaused) }) });
6
- };
7
- export {
8
- PlayPauseButton
9
- };
1
+ import{jsx as a}from"react/jsx-runtime";import e from"clsx";import s from"./PlayPauseButton.module.scss.js";const l=({isPlaying:l,onClick:i,ariaLabelPlay:t,ariaLabelPause:o})=>/* @__PURE__ */a("button",{className:e(s.button),onClick:i,"aria-label":l?o??"Pause":t??"Play",children:/* @__PURE__ */a("div",{className:e(s.animatedPlayPause,l&&s.animatedPlayPausePaused)})});export{l as PlayPauseButton};
@@ -1,14 +1 @@
1
- const button = "_button_4r8gs_1";
2
- const animatedPlayPause = "_animatedPlayPause_4r8gs_23";
3
- const animatedPlayPausePaused = "_animatedPlayPausePaused_4r8gs_32";
4
- const styles = {
5
- button,
6
- animatedPlayPause,
7
- animatedPlayPausePaused
8
- };
9
- export {
10
- animatedPlayPause,
11
- animatedPlayPausePaused,
12
- button,
13
- styles as default
14
- };
1
+ const a="_button_4r8gs_1",e="_animatedPlayPause_4r8gs_23",s="_animatedPlayPausePaused_4r8gs_32",t={button:a,animatedPlayPause:e,animatedPlayPausePaused:s};export{e as animatedPlayPause,s as animatedPlayPausePaused,a as button,t as default};
@@ -1,7 +1 @@
1
- const hasRichTextBlockContent = (data) => {
2
- const draftContent = data.draftContent;
3
- return !(draftContent.blocks.length === 0 || draftContent.blocks.length === 1 && draftContent.blocks[0].text === "");
4
- };
5
- export {
6
- hasRichTextBlockContent
7
- };
1
+ const t=t=>{const n=t.draftContent;return!(0===n.blocks.length||1===n.blocks.length&&""===n.blocks[0].text)};export{t as hasRichTextBlockContent};
@@ -0,0 +1,35 @@
1
+ import { ReactNode } from 'react';
2
+ export interface TipTapMark {
3
+ type: string;
4
+ attrs?: Record<string, unknown>;
5
+ }
6
+ export interface TipTapNode {
7
+ type: string;
8
+ attrs?: Record<string, unknown>;
9
+ content?: TipTapNode[];
10
+ marks?: TipTapMark[];
11
+ text?: string;
12
+ }
13
+ export interface TipTapNodeHandlerProps {
14
+ node: TipTapNode;
15
+ parent?: TipTapNode;
16
+ children: ReactNode;
17
+ }
18
+ export interface TipTapMarkHandlerProps {
19
+ mark: TipTapMark;
20
+ node: TipTapNode;
21
+ children: ReactNode;
22
+ }
23
+ export type TipTapNodeHandler = (props: TipTapNodeHandlerProps) => ReactNode;
24
+ export type TipTapMarkHandler = (props: TipTapMarkHandlerProps) => ReactNode;
25
+ export interface RenderTipTapRichTextOptions {
26
+ content: TipTapNode;
27
+ nodeMapping?: Record<string, TipTapNodeHandler>;
28
+ markMapping?: Record<string, TipTapMarkHandler>;
29
+ }
30
+ /**
31
+ * @experimental
32
+ */
33
+ export declare function renderTipTapRichText({ content, nodeMapping, markMapping }: RenderTipTapRichTextOptions): ReactNode;
34
+ export declare function hasTipTapRichTextContent(content: TipTapNode | null | undefined): boolean;
35
+ //# sourceMappingURL=TipTapRichTextRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TipTapRichTextRenderer.d.ts","sourceRoot":"","sources":["../../../src/blocks/helpers/TipTapRichTextRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,SAAS,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,sBAAsB,KAAK,SAAS,CAAC;AAE7E,MAAM,WAAW,2BAA2B;IACxC,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CACnD;AA4BD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,2BAA2B,GAAG,SAAS,CAqClH;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAKxF"}
@@ -0,0 +1,3 @@
1
+ import{jsx as r,Fragment as n}from"react/jsx-runtime";import{isValidElement as e,cloneElement as t}from"react";const i=String.fromCodePoint(160),c=String.fromCodePoint(173),o={paragraph:({children:n})=>/* @__PURE__ */r("p",{children:n}),heading:({node:n,children:e})=>{const t=n.attrs?.level??1;/* @__PURE__ */
2
+ return r(`h${t}`,{children:e})},bulletList:({children:n})=>/* @__PURE__ */r("ul",{children:n}),orderedList:({children:n})=>/* @__PURE__ */r("ol",{children:n}),listItem:({children:n})=>/* @__PURE__ */r("li",{children:n}),hardBreak:()=>/* @__PURE__ */r("br",{}),nonBreakingSpace:()=>i,softHyphen:()=>c},d={bold:({children:n})=>/* @__PURE__ */r("strong",{children:n}),italic:({children:n})=>/* @__PURE__ */r("em",{children:n}),strike:({children:n})=>/* @__PURE__ */r("s",{children:n}),superscript:({children:n})=>/* @__PURE__ */r("sup",{children:n}),subscript:({children:n})=>/* @__PURE__ */r("sub",{children:n})};function l({content:i,nodeMapping:c,markMapping:l}){const h={...o,...c},s={...d,...l},a=(r,n)=>{if(!n.marks||0===n.marks.length)return r;let e=r;for(const t of n.marks){const r=s[t.type];r&&(e=r({mark:t,node:n,children:e}))}return e},p=(i,c)=>{if("text"===i.type)return a(i.text??"",i);const o=i.content?.map((r,n)=>{const c=p(r,i);return e(c)?t(c,{key:n}):c});if("doc"===i.type)/* @__PURE__ */
3
+ return r(n,{children:o});const d=h[i.type],l=d?d({node:i,parent:c,children:o}):/* @__PURE__ */r(n,{children:o});return a(l,i)};return p(i,void 0)}function h(r){return!(!r?.content||!Array.isArray(r.content))&&r.content.some(r=>"paragraph"!==r.type||Array.isArray(r.content)&&r.content.length>0)}export{h as hasTipTapRichTextContent,l as renderTipTapRichText};
@@ -1,23 +1,2 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import clsx from "clsx";
3
- import styles from "./VideoPreviewImage.module.scss.js";
4
- const VideoPreviewImage = ({
5
- onPlay,
6
- image,
7
- aspectRatio,
8
- sizes = "100vw",
9
- fill,
10
- playButtonAriaLabel = "Play video",
11
- icon = /* @__PURE__ */ jsx(PlayIcon, { playButtonAriaLabel }),
12
- className,
13
- renderImage
14
- }) => {
15
- return /* @__PURE__ */ jsxs("div", { className: clsx(styles.root, fill && styles.fill, className), children: [
16
- renderImage({ data: image, aspectRatio, sizes, fill }),
17
- /* @__PURE__ */ jsx("button", { className: styles.iconWrapper, onClick: onPlay, children: icon })
18
- ] });
19
- };
20
- const PlayIcon = ({ playButtonAriaLabel }) => /* @__PURE__ */ jsx("span", { className: styles.playIcon, "aria-label": playButtonAriaLabel });
21
- export {
22
- VideoPreviewImage
23
- };
1
+ import{jsxs as a,jsx as e}from"react/jsx-runtime";import l from"clsx";import i from"./VideoPreviewImage.module.scss.js";const o=({onPlay:o,image:r,aspectRatio:t,sizes:c="100vw",fill:m,playButtonAriaLabel:n="Play video",icon:p=/* @__PURE__ */e(s,{playButtonAriaLabel:n}),className:d,renderImage:f})=>/* @__PURE__ */a("div",{className:l(i.root,m&&i.fill,d),children:[f({data:r,aspectRatio:t,sizes:c,fill:m}),
2
+ /* @__PURE__ */e("button",{className:i.iconWrapper,onClick:o,children:p})]}),s=({playButtonAriaLabel:a})=>/* @__PURE__ */e("span",{className:i.playIcon,"aria-label":a});export{o as VideoPreviewImage};
@@ -1,17 +1 @@
1
- const root = "_root_1k5a5_1";
2
- const fill = "_fill_1k5a5_6";
3
- const iconWrapper = "_iconWrapper_1k5a5_10";
4
- const playIcon = "_playIcon_1k5a5_26";
5
- const styles = {
6
- root,
7
- fill,
8
- iconWrapper,
9
- playIcon
10
- };
11
- export {
12
- styles as default,
13
- fill,
14
- iconWrapper,
15
- playIcon,
16
- root
17
- };
1
+ const _="_root_1k5a5_1",a="_fill_1k5a5_6",o="_iconWrapper_1k5a5_10",l="_playIcon_1k5a5_26",p={root:_,fill:a,iconWrapper:o,playIcon:l};export{p as default,a as fill,o as iconWrapper,l as playIcon,_ as root};
@@ -1,22 +1,2 @@
1
1
  "use client";
2
- import { useEffect } from "react";
3
- const useIsElementInViewport = (ref, callback) => {
4
- useEffect(() => {
5
- if (!ref.current) {
6
- return;
7
- }
8
- const observer = new IntersectionObserver(
9
- ([entry]) => {
10
- callback(entry.isIntersecting);
11
- },
12
- { threshold: 0.5 }
13
- );
14
- observer.observe(ref.current);
15
- return () => {
16
- observer.disconnect();
17
- };
18
- }, [ref, callback]);
19
- };
20
- export {
21
- useIsElementInViewport
22
- };
2
+ import{useEffect as r}from"react";const e=(e,t)=>{r(()=>{if(!e.current)return;const r=new IntersectionObserver(([r])=>{t(r.isIntersecting)},{threshold:.5});return r.observe(e.current),()=>{r.disconnect()}},[e,t])};export{e as useIsElementInViewport};
@@ -1,19 +1,3 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { useContext, createContext } from "react";
4
- const CookieApiContext = createContext(void 0);
5
- const CookieApiProvider = ({ api: useCookieApi2, children }) => {
6
- const api = useCookieApi2();
7
- return /* @__PURE__ */ jsx(CookieApiContext.Provider, { value: api, children });
8
- };
9
- const useCookieApi = () => {
10
- const cookieApi = useContext(CookieApiContext);
11
- if (!cookieApi) {
12
- throw new Error("Can only be used inside CookieApiProvider.");
13
- }
14
- return cookieApi;
15
- };
16
- export {
17
- CookieApiProvider,
18
- useCookieApi
19
- };
2
+ import{jsx as r}from"react/jsx-runtime";import{useContext as e,createContext as o}from"react";const i=o(void 0),n=({api:e,children:o})=>{const n=e();/* @__PURE__ */
3
+ return r(i.Provider,{value:n,children:o})},t=()=>{const r=e(i);if(!r)throw new Error("Can only be used inside CookieApiProvider.");return r};export{n as CookieApiProvider,t as useCookieApi};
@@ -1,19 +1,3 @@
1
1
  "use client";
2
- import { jsx, Fragment } from "react/jsx-runtime";
3
- import { usePreview } from "../preview/usePreview.js";
4
- import { useCookieApi } from "./CookieApiContext.js";
5
- const CookieSafe = ({ consented, fallback, loading, children }) => {
6
- const { initialized } = useCookieApi();
7
- const { previewType } = usePreview();
8
- const isInPreview = previewType !== "NoPreview";
9
- if (initialized && consented || isInPreview) {
10
- return /* @__PURE__ */ jsx(Fragment, { children });
11
- }
12
- if (!initialized) {
13
- return /* @__PURE__ */ jsx(Fragment, { children: loading });
14
- }
15
- return /* @__PURE__ */ jsx(Fragment, { children: fallback });
16
- };
17
- export {
18
- CookieSafe
19
- };
2
+ import{jsx as e,Fragment as i}from"react/jsx-runtime";import{usePreview as r}from"../preview/usePreview.js";import{useCookieApi as o}from"./CookieApiContext.js";const n=({consented:n,fallback:t,loading:c,children:l})=>{const{initialized:p}=o(),{previewType:d}=r();/* @__PURE__ */
3
+ return e(i,p&&n||"NoPreview"!==d?{children:l}:p?{children:t}:{children:c})};export{n as CookieSafe};
@@ -1,34 +1,2 @@
1
1
  "use client";
2
- import { useState, useEffect } from "react";
3
- const isWindowWithCookiebot = (window2) => {
4
- return "Cookiebot" in window2;
5
- };
6
- const useCookieBotCookieApi = () => {
7
- const [consentedCookies, setConsentedCookies] = useState([]);
8
- const [initialized, setInitialized] = useState(false);
9
- useEffect(() => {
10
- const handleCookieUpdated = () => {
11
- if (isWindowWithCookiebot(window)) {
12
- setInitialized(true);
13
- const consentedList = window.Cookiebot.consent;
14
- setConsentedCookies(Object.keys(consentedList).filter((key) => consentedList[key]));
15
- }
16
- };
17
- window.addEventListener("CookiebotOnConsentReady", handleCookieUpdated);
18
- return () => {
19
- window.removeEventListener("CookiebotOnConsentReady", handleCookieUpdated);
20
- };
21
- }, []);
22
- return {
23
- initialized,
24
- consentedCookies,
25
- openCookieSettings: () => {
26
- if (isWindowWithCookiebot(window)) {
27
- window.Cookiebot.renew();
28
- }
29
- }
30
- };
31
- };
32
- export {
33
- useCookieBotCookieApi
34
- };
2
+ import{useState as o,useEffect as e}from"react";const n=o=>"Cookiebot"in o,t=()=>{const[t,i]=o([]),[r,s]=o(!1);return e(()=>{const o=()=>{if(n(window)){s(!0);const o=window.Cookiebot.consent;i(Object.keys(o).filter(e=>o[e]))}};return window.addEventListener("CookiebotOnConsentReady",o),()=>{window.removeEventListener("CookiebotOnConsentReady",o)}},[]),{initialized:r,consentedCookies:t,openCookieSettings:()=>{n(window)&&window.Cookiebot.renew()}}};export{t as useCookieBotCookieApi};
@@ -1,41 +1,2 @@
1
1
  "use client";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { useLocalStorage } from "usehooks-ts";
4
- const localStorageCookieApiKey = "comet-dev-cookie-api-consented-cookies";
5
- const useLocalStorageCookieApi = () => {
6
- const [consentedCookies, setConsentedCookies] = useLocalStorage(localStorageCookieApiKey, []);
7
- const [initialized, setInitialized] = useState(false);
8
- const openCookieSettings = useCallback(() => {
9
- const cookies = prompt('Define consented cookies (separated by ","):', consentedCookies.join(",")) ?? "";
10
- const cookiesList = cookies.split(",").map((cookie) => cookie.trim());
11
- setConsentedCookies(cookiesList);
12
- logCookieUpdate(cookiesList);
13
- }, [consentedCookies, setConsentedCookies]);
14
- useEffect(() => {
15
- const storedCookies = window.localStorage.getItem(localStorageCookieApiKey);
16
- const cookiesList = JSON.parse(storedCookies ?? "[]");
17
- logCookieUpdate(cookiesList);
18
- const simulateLoadingTimeout = setTimeout(() => {
19
- setInitialized(true);
20
- window.cometLocalStorageCookieApi = {
21
- initialized: true,
22
- consentedCookies,
23
- openCookieSettings
24
- };
25
- }, 1e3);
26
- return () => {
27
- clearTimeout(simulateLoadingTimeout);
28
- };
29
- }, [consentedCookies, openCookieSettings]);
30
- return {
31
- initialized,
32
- consentedCookies,
33
- openCookieSettings
34
- };
35
- };
36
- const logCookieUpdate = (cookies) => {
37
- console.info("Consented cookies updated:", cookies);
38
- };
39
- export {
40
- useLocalStorageCookieApi
41
- };
2
+ import{useState as o,useCallback as e,useEffect as t}from"react";import{useLocalStorage as i}from"usehooks-ts";const n="comet-dev-cookie-api-consented-cookies",s=()=>{const[s,r]=i(n,[]),[a,p]=o(!1),d=e(()=>{const o=(prompt('Define consented cookies (separated by ","):',s.join(","))??"").split(",").map(o=>o.trim());r(o),c(o)},[s,r]);return t(()=>{const o=window.localStorage.getItem(n),e=JSON.parse(o??"[]");c(e);const t=setTimeout(()=>{p(!0),window.cometLocalStorageCookieApi={initialized:!0,consentedCookies:s,openCookieSettings:d}},1e3);return()=>{clearTimeout(t)}},[s,d]),{initialized:a,consentedCookies:s,openCookieSettings:d}},c=o=>{console.info("Consented cookies updated:",o)};export{s as useLocalStorageCookieApi};
@@ -1,46 +1,2 @@
1
1
  "use client";
2
- import { useState, useEffect } from "react";
3
- const isWindowWithOneTrust = (window2) => {
4
- return "OneTrust" in window2;
5
- };
6
- const useOneTrustCookieApi = () => {
7
- const [consentedCookies, setConsentedCookies] = useState([]);
8
- const [initialized, setInitialized] = useState(false);
9
- useEffect(() => {
10
- const startListeningForConsentChanges = (window2) => {
11
- const oneTrust = window2.OneTrust;
12
- const initialCookieConsent = [];
13
- if (window2.OnetrustActiveGroups) {
14
- initialCookieConsent.push(
15
- ...window2.OnetrustActiveGroups.split(",").map((groupId) => groupId.trim()).filter(Boolean)
16
- );
17
- }
18
- setConsentedCookies(initialCookieConsent);
19
- oneTrust.OnConsentChanged((event) => {
20
- setConsentedCookies(event.detail);
21
- });
22
- };
23
- const tryToAccessOneTrustInterval = setInterval(() => {
24
- if (isWindowWithOneTrust(window)) {
25
- setInitialized(true);
26
- clearInterval(tryToAccessOneTrustInterval);
27
- startListeningForConsentChanges(window);
28
- }
29
- }, 200);
30
- return () => {
31
- clearInterval(tryToAccessOneTrustInterval);
32
- };
33
- }, []);
34
- return {
35
- initialized,
36
- consentedCookies,
37
- openCookieSettings: () => {
38
- if (isWindowWithOneTrust(window)) {
39
- window.OneTrust.ToggleInfoDisplay();
40
- }
41
- }
42
- };
43
- };
44
- export {
45
- useOneTrustCookieApi
46
- };
2
+ import{useState as t,useEffect as e}from"react";const n=t=>"OneTrust"in t,o=()=>{const[o,r]=t([]),[i,s]=t(!1);return e(()=>{const t=setInterval(()=>{n(window)&&(s(!0),clearInterval(t),(t=>{const e=t.OneTrust,n=[];t.OnetrustActiveGroups&&n.push(...t.OnetrustActiveGroups.split(",").map(t=>t.trim()).filter(Boolean)),r(n),e.OnConsentChanged(t=>{r(t.detail)})})(window))},200);return()=>{clearInterval(t)}},[]),{initialized:i,consentedCookies:o,openCookieSettings:()=>{n(window)&&window.OneTrust.ToggleInfoDisplay()}}};export{o as useOneTrustCookieApi};
@@ -1,10 +1,2 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ErrorHandlerBoundaryInternal } from "./ErrorHandlerBoundaryInternal.js";
3
- import { useErrorHandler } from "./ErrorHandlerProvider.js";
4
- function ErrorHandlerBoundary({ children }) {
5
- const { onError } = useErrorHandler();
6
- return /* @__PURE__ */ jsx(ErrorHandlerBoundaryInternal, { onError, children });
7
- }
8
- export {
9
- ErrorHandlerBoundary
10
- };
1
+ import{jsx as r}from"react/jsx-runtime";import{ErrorHandlerBoundaryInternal as o}from"./ErrorHandlerBoundaryInternal.js";import{useErrorHandler as n}from"./ErrorHandlerProvider.js";function e({children:e}){const{onError:t}=n();/* @__PURE__ */
2
+ return r(o,{onError:t,children:e})}export{e as ErrorHandlerBoundary};
@@ -1,27 +1,2 @@
1
1
  "use client";
2
- import { Component } from "react";
3
- class ErrorHandlerBoundaryInternal extends Component {
4
- constructor(props) {
5
- super(props);
6
- this.state = { hasError: false };
7
- }
8
- static getDerivedStateFromError() {
9
- return { hasError: true };
10
- }
11
- componentDidCatch(error, errorInfo) {
12
- console.error(error);
13
- if (this.props.onError) {
14
- this.props.onError(error, errorInfo);
15
- }
16
- }
17
- render() {
18
- var _a;
19
- if ((_a = this.state) == null ? void 0 : _a.hasError) {
20
- return null;
21
- }
22
- return this.props.children;
23
- }
24
- }
25
- export {
26
- ErrorHandlerBoundaryInternal
27
- };
2
+ import{Component as r}from"react";class t extends r{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(r,t){console.error(r),this.props.onError&&this.props.onError(r,t)}render(){return this.state?.hasError?null:this.props.children}}export{t as ErrorHandlerBoundaryInternal};
@@ -1,21 +1,3 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { useContext, createContext } from "react";
4
- const ErrorHandlerContext = createContext({
5
- onError: (error, errorInfo) => {
6
- if (process.env.NODE_ENV === "development") {
7
- console.error("Error caught by error handler", error, errorInfo.componentStack);
8
- throw error;
9
- }
10
- }
11
- });
12
- function ErrorHandlerProvider({ children, onError }) {
13
- return /* @__PURE__ */ jsx(ErrorHandlerContext.Provider, { value: { onError }, children });
14
- }
15
- const useErrorHandler = () => {
16
- return useContext(ErrorHandlerContext);
17
- };
18
- export {
19
- ErrorHandlerProvider,
20
- useErrorHandler
21
- };
2
+ import{jsx as r}from"react/jsx-runtime";import{useContext as o,createContext as e}from"react";const n=e({onError:(r,o)=>{if("development"===process.env.NODE_ENV)throw console.error("Error caught by error handler",r,o.componentStack),r}});function t({children:o,onError:e}){/* @__PURE__ */
3
+ return r(n.Provider,{value:{onError:e},children:o})}const c=()=>o(n);export{t as ErrorHandlerProvider,c as useErrorHandler};
@@ -1,37 +1 @@
1
- const cache = {};
2
- function createFetchInMemoryCache(fetch) {
3
- return async function(input, init) {
4
- var _a, _b;
5
- let cacheKey;
6
- if ((init == null ? void 0 : init.cache) === "no-store") ;
7
- else if (((_a = init == null ? void 0 : init.method) == null ? void 0 : _a.toUpperCase()) === "GET") {
8
- cacheKey = input.toString();
9
- } else if (init == null ? void 0 : init.body) {
10
- const bodyString = init.body.toString();
11
- if (bodyString.startsWith("{")) {
12
- try {
13
- const body = JSON.parse(init.body.toString());
14
- if ((body.query || ((_b = body.extensions) == null ? void 0 : _b.persistedQuery)) && body.variables) {
15
- cacheKey = `${input.toString()}#${init.body.toString()}`;
16
- }
17
- } catch {
18
- }
19
- }
20
- }
21
- if (!cacheKey) {
22
- return fetch(input, init);
23
- }
24
- const cachedResponse = cache[cacheKey];
25
- if (cachedResponse) {
26
- return cachedResponse.clone();
27
- } else {
28
- const fetchPromise = fetch(input, init);
29
- const response = await fetchPromise;
30
- cache[cacheKey] = response.clone();
31
- return fetchPromise;
32
- }
33
- };
34
- }
35
- export {
36
- createFetchInMemoryCache
37
- };
1
+ const t={};function e(e){return async function(n,o){let r;if("no-store"===o?.cache);else if("GET"===o?.method?.toUpperCase())r=n.toString();else if(o?.body){if(o.body.toString().startsWith("{"))try{const t=JSON.parse(o.body.toString());(t.query||t.extensions?.persistedQuery)&&t.variables&&(r=`${n.toString()}#${o.body.toString()}`)}catch{}}if(!r)return e(n,o);const i=t[r];if(i)return i.clone();{const i=e(n,o),s=await i;return t[r]=s.clone(),i}}}export{e as createFetchInMemoryCache};