@cntrl-site/sdk-nextjs 0.15.1 → 0.15.3

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 (31) hide show
  1. package/cntrl-site-sdk-nextjs-0.15.2.tgz +0 -0
  2. package/cntrl-site-sdk-nextjs-0.15.3.tgz +0 -0
  3. package/lib/common/useCurrentLayout.js +2 -1
  4. package/lib/components/Article.js +4 -4
  5. package/lib/components/ArticleWrapper.js +2 -2
  6. package/lib/components/Head.js +4 -6
  7. package/lib/components/Item.js +4 -3
  8. package/lib/components/LayoutStyle.js +3 -3
  9. package/lib/components/LinkWrapper.js +1 -1
  10. package/lib/components/Page.js +1 -1
  11. package/lib/components/Section.js +4 -4
  12. package/lib/components/items/CustomItem.js +2 -2
  13. package/lib/components/items/ImageItem.js +4 -3
  14. package/lib/components/items/RectangleItem.js +4 -3
  15. package/lib/components/items/RichTextItem.js +5 -4
  16. package/lib/components/items/VideoItem.js +4 -3
  17. package/lib/components/items/VimeoEmbed.js +4 -3
  18. package/lib/components/items/YoutubeEmbed.js +6 -4
  19. package/lib/components/items/useRichTextItem.js +2 -1
  20. package/lib/components/useSectionHeightMap.js +1 -1
  21. package/lib/provider/CntrlProvider.js +1 -1
  22. package/lib/provider/CntrlSdkContext.js +22 -11
  23. package/lib/provider/CustomSectionRegistry.js +4 -2
  24. package/lib/utils/ArticleRectManager/ArticleRectObserver.js +5 -1
  25. package/lib/utils/EventEmitter.js +4 -2
  26. package/lib/utils/RichTextConverter/RichTextConverter.js +16 -18
  27. package/lib/utils/Youtube/YouTubeIframeApiLoader.js +17 -6
  28. package/package.json +4 -3
  29. package/src/common/useCurrentLayout.ts +1 -1
  30. package/src/components/items/RichTextItem.tsx +1 -0
  31. package/src/utils/ArticleRectManager/ArticleRectObserver.ts +1 -0
Binary file
Binary file
@@ -22,7 +22,8 @@ const useCurrentLayout = () => {
22
22
  }, []);
23
23
  }, [layouts]);
24
24
  const getCurrentLayout = (0, react_1.useCallback)((articleWidth) => {
25
- return layoutRanges.find(l => articleWidth >= l.start && articleWidth < l.end).layoutId;
25
+ var _a;
26
+ return (_a = layoutRanges.find(l => articleWidth >= l.start && articleWidth < l.end)) === null || _a === void 0 ? void 0 : _a.layoutId;
26
27
  }, [layoutRanges]);
27
28
  const [layoutId, setLayoutId] = (0, react_1.useState)(undefined);
28
29
  (0, react_1.useEffect)(() => {
@@ -16,14 +16,14 @@ const Article = ({ article, sectionData }) => {
16
16
  const articleRef = (0, react_1.useRef)(null);
17
17
  const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
18
18
  const id = (0, react_1.useId)();
19
- return ((0, jsx_runtime_1.jsxs)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: [(0, jsx_runtime_1.jsx)(ArticleWrapper_1.ArticleWrapper, { children: (0, jsx_runtime_1.jsx)("div", { className: "article", ref: articleRef, children: article.sections.map((section, i) => {
19
+ return ((0, jsx_runtime_1.jsxs)(ArticleRectContext_1.ArticleRectContext.Provider, Object.assign({ value: articleRectObserver }, { children: [(0, jsx_runtime_1.jsx)(ArticleWrapper_1.ArticleWrapper, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "article", ref: articleRef }, { children: article.sections.map((section, i) => {
20
20
  const data = section.name ? sectionData[section.name] : {};
21
- return ((0, jsx_runtime_1.jsx)(Section_1.Section, { section: section, data: data, children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: section.id }, item.id))) }, section.id));
22
- }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
21
+ return ((0, jsx_runtime_1.jsx)(Section_1.Section, Object.assign({ section: section, data: data }, { children: article.sections[i].items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: section.id }, item.id))) }), section.id));
22
+ }) })) }), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
23
23
  .article {
24
24
  position: relative;
25
25
  overflow: clip;
26
26
  }
27
- ` })] }));
27
+ ` }))] })));
28
28
  };
29
29
  exports.Article = Article;
@@ -25,11 +25,11 @@ const ArticleWrapper = ({ children }) => {
25
25
  return () => window.removeEventListener('load', onPageLoad);
26
26
  }
27
27
  }, []);
28
- return ((0, jsx_runtime_1.jsxs)(LayoutContext_1.LayoutContext.Provider, { value: layoutId, children: [(0, jsx_runtime_1.jsx)("div", { className: "article-wrapper", style: { opacity: layoutId && isPageLoaded ? 1 : 0 }, children: children }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
28
+ return ((0, jsx_runtime_1.jsxs)(LayoutContext_1.LayoutContext.Provider, Object.assign({ value: layoutId }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "article-wrapper", style: { opacity: layoutId && isPageLoaded ? 1 : 0 } }, { children: children })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
29
29
  .article-wrapper {
30
30
  opacity: 1;
31
31
  transition: opacity 0.2s ease;
32
32
  }
33
- ` })] }));
33
+ ` }))] })));
34
34
  };
35
35
  exports.ArticleWrapper = ArticleWrapper;
@@ -11,18 +11,16 @@ const sdk_1 = require("@cntrl-site/sdk");
11
11
  const CNTRLHead = ({ meta, project }) => {
12
12
  const googleFonts = (0, html_react_parser_1.default)(project.fonts.google);
13
13
  const adobeFonts = (0, html_react_parser_1.default)(project.fonts.adobe);
14
- const parsedFonts = {
15
- ...(typeof googleFonts === 'object' ? googleFonts : {}),
16
- ...(typeof adobeFonts === 'object' ? adobeFonts : {})
17
- };
14
+ const parsedFonts = Object.assign(Object.assign({}, (typeof googleFonts === 'object' ? googleFonts : {})), (typeof adobeFonts === 'object' ? adobeFonts : {}));
18
15
  const customFonts = project.fonts.custom;
19
16
  const htmlHead = (0, html_react_parser_1.default)(project.html.head);
20
17
  const ffGenerator = new sdk_1.FontFaceGenerator(customFonts);
21
18
  const links = Object.values(parsedFonts).map((value, i) => {
19
+ var _a, _b;
22
20
  if (!value)
23
21
  return;
24
- const rel = value?.rel || value.props?.rel;
25
- const href = value?.href || value.props?.href;
22
+ const rel = (value === null || value === void 0 ? void 0 : value.rel) || ((_a = value.props) === null || _a === void 0 ? void 0 : _a.rel);
23
+ const href = (value === null || value === void 0 ? void 0 : value.href) || ((_b = value.props) === null || _b === void 0 ? void 0 : _b.href);
26
24
  if (!rel || !href)
27
25
  return;
28
26
  return ((0, jsx_runtime_1.jsx)("link", { rel: rel, href: href }, `link-${rel}-${href}`));
@@ -79,7 +79,7 @@ const Item = ({ item, sectionId }) => {
79
79
  height: `${sizingAxis.y === sdk_1.ArticleItemSizingType.Manual ? `${height * 100}vw` : 'unset'}`,
80
80
  top: stickyTop
81
81
  };
82
- return ((0, jsx_runtime_1.jsxs)("div", { className: `item-wrapper-${item.id}`, style: isInitialRef.current ? {} : { top, left, ...(wrapperHeight ? { height: `${wrapperHeight * 100}vw` } : {}) }, children: [(0, jsx_runtime_1.jsx)("div", { suppressHydrationWarning: true, className: `item-${item.id}`, style: isInitialRef.current ? {} : styles, children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
82
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `item-wrapper-${item.id}`, style: isInitialRef.current ? {} : Object.assign({ top, left }, (wrapperHeight ? { height: `${wrapperHeight * 100}vw` } : {})) }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ suppressHydrationWarning: true, className: `item-${item.id}`, style: isInitialRef.current ? {} : styles }, { children: (0, jsx_runtime_1.jsx)(ItemComponent, { item: item, sectionId: sectionId, onResize: handleItemResize }) })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
83
83
  ${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, hidden, hoverParams, sticky, sectionHeight, layoutParams]) => {
84
84
  const sizingAxis = parseSizing(layoutParams.sizing);
85
85
  return (`
@@ -115,11 +115,12 @@ const Item = ({ item, sectionId }) => {
115
115
  }
116
116
  `);
117
117
  })}
118
- ` })] }));
118
+ ` }))] })));
119
119
  };
120
120
  exports.Item = Item;
121
121
  function getStickyItemWrapperHeight(sticky, itemHeight) {
122
- const end = sticky.to ?? 100;
122
+ var _a;
123
+ const end = (_a = sticky.to) !== null && _a !== void 0 ? _a : 100;
123
124
  return end - sticky.from + itemHeight;
124
125
  }
125
126
  function parseSizing(sizing = 'manual') {
@@ -9,10 +9,10 @@ const sdk_1 = require("@cntrl-site/sdk");
9
9
  const style_1 = __importDefault(require("styled-jsx/style"));
10
10
  const LayoutStyle = ({ id, layouts, layoutId, children }) => {
11
11
  const layout = layouts.find(l => l.id === layoutId);
12
- return ((0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
12
+ return ((0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
13
13
  ${(0, sdk_1.getLayoutMediaQuery)(layoutId, layouts)} {
14
- ${children?.(layout)}
14
+ ${children === null || children === void 0 ? void 0 : children(layout)}
15
15
  }
16
- ` }));
16
+ ` })));
17
17
  };
18
18
  exports.LayoutStyle = LayoutStyle;
@@ -4,7 +4,7 @@ exports.LinkWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const LinkWrapper = ({ url, children }) => {
6
6
  const validUrl = url && buildValidUrl(url);
7
- return url ? ((0, jsx_runtime_1.jsx)("a", { href: validUrl, target: url.startsWith('/') || url.startsWith('#') ? '_self' : '_blank', rel: "noreferrer", children: children })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
7
+ return url ? ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: validUrl, target: url.startsWith('/') || url.startsWith('#') ? '_self' : '_blank', rel: "noreferrer" }, { children: children }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
8
8
  };
9
9
  exports.LinkWrapper = LinkWrapper;
10
10
  function buildValidUrl(url) {
@@ -18,6 +18,6 @@ const Page = ({ article, project, meta, keyframes, sectionData }) => {
18
18
  const beforeBodyClose = (0, html_react_parser_1.default)(project.html.beforeBodyClose);
19
19
  const keyframesRepo = (0, react_1.useMemo)(() => new Keyframes_1.Keyframes(keyframes), [keyframes]);
20
20
  const { typePresets, layouts } = (0, useCntrlContext_1.useCntrlContext)();
21
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project, meta: meta }), afterBodyOpen, (0, jsx_runtime_1.jsx)(KeyframesContext_1.KeyframesContext.Provider, { value: keyframesRepo, children: (0, jsx_runtime_1.jsx)(Article_1.Article, { article: article, sectionData: sectionData }) }), beforeBodyClose, typePresets && typePresets.presets.length > 0 && ((0, jsx_runtime_1.jsx)("style", { children: (0, generateTypePresetStyles_1.generateTypePresetStyles)(typePresets, layouts) }))] }));
21
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Head_1.CNTRLHead, { project: project, meta: meta }), afterBodyOpen, (0, jsx_runtime_1.jsx)(KeyframesContext_1.KeyframesContext.Provider, Object.assign({ value: keyframesRepo }, { children: (0, jsx_runtime_1.jsx)(Article_1.Article, { article: article, sectionData: sectionData }) })), beforeBodyClose, typePresets && typePresets.presets.length > 0 && ((0, jsx_runtime_1.jsx)("style", { children: (0, generateTypePresetStyles_1.generateTypePresetStyles)(typePresets, layouts) }))] }));
22
22
  };
23
23
  exports.Page = Page;
@@ -33,10 +33,10 @@ const Section = ({ section, data, children }) => {
33
33
  }, '');
34
34
  };
35
35
  if (SectionComponent)
36
- return (0, jsx_runtime_1.jsx)("div", { ref: sectionRef, children: (0, jsx_runtime_1.jsx)(SectionComponent, { data: data, children: children }) });
37
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `section-${section.id}`, id: section.name, style: {
36
+ return (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: sectionRef }, { children: (0, jsx_runtime_1.jsx)(SectionComponent, Object.assign({ data: data }, { children: children })) }));
37
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `section-${section.id}`, id: section.name, style: {
38
38
  backgroundColor: backgroundColor.toCss()
39
- }, ref: sectionRef, children: children }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
39
+ }, ref: sectionRef }, { children: children })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
40
40
  ${(0, sdk_1.getLayoutStyles)(layouts, [section.height], ([height]) => (`
41
41
  .section-${section.id} {
42
42
  height: ${getSectionHeight(height)};
@@ -48,7 +48,7 @@ const Section = ({ section, data, children }) => {
48
48
  background-color: ${backgroundColor.fmt('rgba')};
49
49
  }
50
50
  }
51
- ` })] }));
51
+ ` }))] }));
52
52
  };
53
53
  exports.Section = Section;
54
54
  function getSectionHeight(heightData) {
@@ -15,7 +15,7 @@ const CustomItem = ({ item }) => {
15
15
  const component = sdk.customItems.get(item.commonParams.name);
16
16
  if (!component)
17
17
  return null;
18
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, children: component({}) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
18
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `custom-component-${item.id}` }, { children: component({}) })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: item.id }, { children: `${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
19
19
  return (`
20
20
  .custom-component-${item.id} {
21
21
  transition: ${(0, HoverStyles_1.getTransitions)(['angle'], hoverParams)};
@@ -24,6 +24,6 @@ const CustomItem = ({ item }) => {
24
24
  ${(0, HoverStyles_1.getHoverStyles)(['angle'], hoverParams)}
25
25
  }
26
26
  `);
27
- })}` })] }));
27
+ })}` }))] }));
28
28
  };
29
29
  exports.CustomItem = CustomItem;
@@ -14,19 +14,20 @@ const useItemAngle_1 = require("../useItemAngle");
14
14
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
15
15
  const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
16
16
  const ImageItem = ({ item, sectionId }) => {
17
+ var _a;
17
18
  const id = (0, react_1.useId)();
18
19
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
19
20
  const { radius, strokeWidth, opacity, strokeColor, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
20
21
  const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
21
22
  const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
22
- return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, style: {
23
+ return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `image-wrapper-${item.id}`, style: {
23
24
  borderRadius: `${radius * 100}vw`,
24
25
  borderWidth: `${strokeWidth * 100}vw`,
25
26
  opacity: `${opacity}`,
26
27
  borderColor: `${borderColor.toCss()}`,
27
28
  transform: `rotate(${angle}deg)`,
28
29
  filter: `blur(${blur * 100}vw)`
29
- }, children: (0, jsx_runtime_1.jsx)("img", { className: "image", src: item.commonParams.url }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
30
+ } }, { children: (0, jsx_runtime_1.jsx)("img", { className: "image", src: item.commonParams.url }) })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
30
31
  @supports not (color: oklch(42% 0.3 90 / 1)) {
31
32
  .image-wrapper-${item.id} {
32
33
  border-color: ${borderColor.fmt('rgba')};
@@ -58,6 +59,6 @@ const ImageItem = ({ item, sectionId }) => {
58
59
  }
59
60
  `);
60
61
  })}
61
- ` })] }) }));
62
+ ` }))] }) })));
62
63
  };
63
64
  exports.ImageItem = ImageItem;
@@ -14,13 +14,14 @@ const useItemAngle_1 = require("../useItemAngle");
14
14
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
15
15
  const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
16
16
  const RectangleItem = ({ item, sectionId }) => {
17
+ var _a;
17
18
  const id = (0, react_1.useId)();
18
19
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
19
20
  const { fillColor, radius, strokeWidth, strokeColor, blur, backdropBlur } = (0, useRectangleItem_1.useRectangleItem)(item, sectionId);
20
21
  const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
21
22
  const backgroundColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(fillColor), [fillColor]);
22
23
  const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
23
- return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, style: {
24
+ return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, style: {
24
25
  backgroundColor: `${backgroundColor.toCss()}`,
25
26
  borderRadius: `${radius * 100}vw`,
26
27
  borderWidth: `${strokeWidth * 100}vw`,
@@ -30,7 +31,7 @@ const RectangleItem = ({ item, sectionId }) => {
30
31
  backdropFilter: backdropBlur !== 0 ? `blur(${backdropBlur * 100}vw)` : 'unset',
31
32
  // @ts-ignore
32
33
  '-webkit-backdrop-filter': backdropBlur !== 0 ? `blur(${backdropBlur * 100}vw)` : 'unset',
33
- } }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
34
+ } }), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
34
35
  @supports not (color: oklch(42% 0.3 90 / 1)) {
35
36
  .rectangle-${item.id} {
36
37
  background-color: ${backgroundColor.fmt('rgba')};
@@ -54,6 +55,6 @@ const RectangleItem = ({ item, sectionId }) => {
54
55
  }
55
56
  `);
56
57
  })}
57
- ` })] }) }));
58
+ ` }))] }) })));
58
59
  };
59
60
  exports.RectangleItem = RectangleItem;
@@ -12,6 +12,7 @@ const useRichTextItem_1 = require("./useRichTextItem");
12
12
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
13
13
  const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
14
14
  const useRichTextItemValues_1 = require("./useRichTextItemValues");
15
+ const resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
15
16
  const RichTextItem = ({ item, sectionId, onResize }) => {
16
17
  const [content, styles, preset] = (0, useRichTextItem_1.useRichTextItem)(item);
17
18
  const id = (0, react_1.useId)();
@@ -22,7 +23,7 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
22
23
  (0, react_1.useEffect)(() => {
23
24
  if (!ref || !onResize)
24
25
  return;
25
- const observer = new ResizeObserver((entries) => {
26
+ const observer = new resize_observer_polyfill_1.default((entries) => {
26
27
  const [entry] = entries;
27
28
  onResize(entry.target.getBoundingClientRect().height / window.innerWidth);
28
29
  });
@@ -31,10 +32,10 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
31
32
  observer.unobserve(ref);
32
33
  };
33
34
  }, [ref, onResize]);
34
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ref: setRef, className: `${className} rich-text-wrapper-${item.id}`, style: {
35
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ ref: setRef, className: `${className} rich-text-wrapper-${item.id}`, style: {
35
36
  transform: `rotate(${angle}deg)`,
36
37
  filter: `blur(${blur * 100}vw)`
37
- }, children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
38
+ } }, { children: content })), (0, jsx_runtime_1.jsxs)(style_1.default, Object.assign({ id: id }, { children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, [item.state.hover], ([hoverParams]) => {
38
39
  return (`
39
40
  .rich-text-wrapper-${item.id} {
40
41
  transition: ${(0, HoverStyles_1.getTransitions)(['angle', 'blur'], hoverParams)};
@@ -43,6 +44,6 @@ const RichTextItem = ({ item, sectionId, onResize }) => {
43
44
  ${(0, HoverStyles_1.getHoverStyles)(['angle', 'blur'], hoverParams)}
44
45
  }
45
46
  `);
46
- })}`] })] }));
47
+ })}`] }))] }));
47
48
  };
48
49
  exports.RichTextItem = RichTextItem;
@@ -14,19 +14,20 @@ const useItemAngle_1 = require("../useItemAngle");
14
14
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
15
15
  const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
16
16
  const VideoItem = ({ item, sectionId }) => {
17
+ var _a;
17
18
  const id = (0, react_1.useId)();
18
19
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
19
20
  const { radius, strokeWidth, strokeColor, opacity, blur } = (0, useFileItem_1.useFileItem)(item, sectionId);
20
21
  const angle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
21
22
  const borderColor = (0, react_1.useMemo)(() => sdk_1.CntrlColor.parse(strokeColor), [strokeColor]);
22
- return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `video-wrapper-${item.id}`, style: {
23
+ return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `video-wrapper-${item.id}`, style: {
23
24
  borderRadius: `${radius * 100}vw`,
24
25
  borderWidth: `${strokeWidth * 100}vw`,
25
26
  opacity: `${opacity}`,
26
27
  borderColor: `${borderColor.toCss()}`,
27
28
  transform: `rotate(${angle}deg)`,
28
29
  filter: `blur(${blur * 100}vw)`
29
- }, children: (0, jsx_runtime_1.jsx)("video", { autoPlay: true, muted: true, loop: true, playsInline: true, className: "video", children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
30
+ } }, { children: (0, jsx_runtime_1.jsx)("video", Object.assign({ autoPlay: true, muted: true, loop: true, playsInline: true, className: "video" }, { children: (0, jsx_runtime_1.jsx)("source", { src: item.commonParams.url }) })) })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
30
31
  @supports not (color: oklch(42% 0.3 90 / 1)) {
31
32
  .video-wrapper-${item.id} {
32
33
  border-color: ${borderColor.fmt('rgba')};
@@ -59,6 +60,6 @@ const VideoItem = ({ item, sectionId }) => {
59
60
  }
60
61
  `);
61
62
  })}
62
- ` })] }));
63
+ ` }))] })));
63
64
  };
64
65
  exports.VideoItem = VideoItem;
@@ -15,6 +15,7 @@ const sdk_1 = require("@cntrl-site/sdk");
15
15
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
16
16
  const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
17
17
  const VimeoEmbedItem = ({ item, sectionId }) => {
18
+ var _a;
18
19
  const id = (0, react_1.useId)();
19
20
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
20
21
  const { radius, blur } = (0, useEmbedVideoItem_1.useEmbedVideoItem)(item, sectionId);
@@ -36,7 +37,7 @@ const VimeoEmbedItem = ({ item, sectionId }) => {
36
37
  return validURL.href;
37
38
  };
38
39
  const validUrl = getValidVimeoUrl(url);
39
- return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-video-wrapper-${item.id}`, style: {
40
+ return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `embed-video-wrapper-${item.id}`, style: {
40
41
  borderRadius: `${radius * 100}vw`,
41
42
  transform: `rotate(${angle}deg)`,
42
43
  filter: `blur(${blur * 100}vw)`
@@ -48,7 +49,7 @@ const VimeoEmbedItem = ({ item, sectionId }) => {
48
49
  if (!vimeoPlayer || play !== 'on-hover')
49
50
  return;
50
51
  vimeoPlayer.pause();
51
- }, children: (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embedVideo", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true }) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
52
+ } }, { children: (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embedVideo", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true }) })), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
52
53
  .embed-video-wrapper-${item.id} {
53
54
  position: absolute;
54
55
  overflow: hidden;
@@ -71,6 +72,6 @@ const VimeoEmbedItem = ({ item, sectionId }) => {
71
72
  }
72
73
  `);
73
74
  })}
74
- ` })] }));
75
+ ` }))] })));
75
76
  };
76
77
  exports.VimeoEmbedItem = VimeoEmbedItem;
@@ -16,6 +16,7 @@ const HoverStyles_1 = require("../../utils/HoverStyles/HoverStyles");
16
16
  const useCntrlContext_1 = require("../../provider/useCntrlContext");
17
17
  const useYouTubeIframeApi_1 = require("../../utils/Youtube/useYouTubeIframeApi");
18
18
  const YoutubeEmbedItem = ({ item, sectionId }) => {
19
+ var _a;
19
20
  const id = (0, react_1.useId)();
20
21
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
21
22
  const { play, controls, url } = item.commonParams;
@@ -48,12 +49,13 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
48
49
  }
49
50
  });
50
51
  return () => {
52
+ var _a;
51
53
  setPlayer(undefined);
52
54
  player.destroy();
53
- placeholder.parentElement?.removeChild(placeholder);
55
+ (_a = placeholder.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(placeholder);
54
56
  };
55
57
  }, [YT, div]);
56
- return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: item.link?.url, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
58
+ return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, Object.assign({ url: (_a = item.link) === null || _a === void 0 ? void 0 : _a.url }, { children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
57
59
  if (!player || play !== 'on-hover')
58
60
  return;
59
61
  player.playVideo();
@@ -65,7 +67,7 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
65
67
  borderRadius: `${radius * 100}vw`,
66
68
  transform: `rotate(${angle}deg)`,
67
69
  filter: `blur(${blur * 100}vw)`
68
- } }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
70
+ } }), (0, jsx_runtime_1.jsx)(style_1.default, Object.assign({ id: id }, { children: `
69
71
  .embed-youtube-video-wrapper-${item.id} {
70
72
  position: absolute;
71
73
  overflow: hidden;
@@ -88,6 +90,6 @@ const YoutubeEmbedItem = ({ item, sectionId }) => {
88
90
  }
89
91
  `);
90
92
  })}
91
- ` })] }));
93
+ ` }))] })));
92
94
  };
93
95
  exports.YoutubeEmbedItem = YoutubeEmbedItem;
@@ -6,11 +6,12 @@ const useCntrlContext_1 = require("../../provider/useCntrlContext");
6
6
  const useLayoutContext_1 = require("../useLayoutContext");
7
7
  const richTextConv = new RichTextConverter_1.RichTextConverter();
8
8
  const useRichTextItem = (item) => {
9
+ var _a;
9
10
  const layoutId = (0, useLayoutContext_1.useLayoutContext)();
10
11
  const { layouts, typePresets } = (0, useCntrlContext_1.useCntrlContext)();
11
12
  const presetId = layoutId ? item.layoutParams[layoutId].preset : null;
12
13
  const preset = presetId
13
- ? typePresets?.presets.find(p => p.id === presetId) ?? null
14
+ ? (_a = typePresets === null || typePresets === void 0 ? void 0 : typePresets.presets.find(p => p.id === presetId)) !== null && _a !== void 0 ? _a : null
14
15
  : null;
15
16
  const [content, styles] = richTextConv.toHtml(item, layouts, !!preset);
16
17
  return [content, styles, preset];
@@ -16,5 +16,5 @@ function getSectionHeightMap(sectionHeight) {
16
16
  }
17
17
  exports.getSectionHeightMap = getSectionHeightMap;
18
18
  function getDefaultHeightData(layouts) {
19
- return layouts.reduce((acc, layout) => ({ ...acc, [layout.id]: '0' }), {});
19
+ return layouts.reduce((acc, layout) => (Object.assign(Object.assign({}, acc), { [layout.id]: '0' })), {});
20
20
  }
@@ -5,6 +5,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const CntrlContext_1 = require("./CntrlContext");
6
6
  const defaultContext_1 = require("./defaultContext");
7
7
  const CntrlProvider = ({ children }) => {
8
- return ((0, jsx_runtime_1.jsx)(CntrlContext_1.CntrlContext.Provider, { value: defaultContext_1.cntrlSdkContext, children: children }));
8
+ return ((0, jsx_runtime_1.jsx)(CntrlContext_1.CntrlContext.Provider, Object.assign({ value: defaultContext_1.cntrlSdkContext }, { children: children })));
9
9
  };
10
10
  exports.CntrlProvider = CntrlProvider;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.CntrlSdkContext = void 0;
4
13
  class CntrlSdkContext {
@@ -8,17 +17,19 @@ class CntrlSdkContext {
8
17
  this._layouts = [];
9
18
  this.sectionHeightMap = new Map();
10
19
  }
11
- async resolveSectionData(sections) {
12
- const resolvers = sections.map(section => {
13
- const resolver = section.name ? this.customSections.getResolver(section.name) : undefined;
14
- if (!resolver)
15
- return;
16
- return {
17
- name: section.name,
18
- resolver
19
- };
20
- }).filter(isDefined);
21
- return Object.fromEntries(await Promise.all(resolvers.map(async ({ name, resolver }) => [name, await resolver()])));
20
+ resolveSectionData(sections) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const resolvers = sections.map(section => {
23
+ const resolver = section.name ? this.customSections.getResolver(section.name) : undefined;
24
+ if (!resolver)
25
+ return;
26
+ return {
27
+ name: section.name,
28
+ resolver
29
+ };
30
+ }).filter(isDefined);
31
+ return Object.fromEntries(yield Promise.all(resolvers.map(({ name, resolver }) => __awaiter(this, void 0, void 0, function* () { return [name, yield resolver()]; }))));
32
+ });
22
33
  }
23
34
  init({ project, typePresets, article }) {
24
35
  this.setTypePresets(typePresets);
@@ -10,10 +10,12 @@ class CustomSectionRegistry {
10
10
  return this;
11
11
  }
12
12
  getComponent(name) {
13
- return this.definitions.get(name)?.component;
13
+ var _a;
14
+ return (_a = this.definitions.get(name)) === null || _a === void 0 ? void 0 : _a.component;
14
15
  }
15
16
  getResolver(name) {
16
- return this.definitions.get(name)?.dataResolver;
17
+ var _a;
18
+ return (_a = this.definitions.get(name)) === null || _a === void 0 ? void 0 : _a.dataResolver;
17
19
  }
18
20
  }
19
21
  exports.CustomSectionRegistry = CustomSectionRegistry;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ArticleRectObserver = void 0;
4
7
  const EventEmitter_1 = require("../EventEmitter");
8
+ const resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
5
9
  class ArticleRectObserver extends EventEmitter_1.EventEmitter {
6
10
  constructor() {
7
11
  super();
@@ -14,7 +18,7 @@ class ArticleRectObserver extends EventEmitter_1.EventEmitter {
14
18
  this.handleScroll = (scroll) => {
15
19
  this.setScroll(scroll / this.articleWidth);
16
20
  };
17
- this.resizeObserver = new ResizeObserver(this.handleResize.bind(this));
21
+ this.resizeObserver = new resize_observer_polyfill_1.default(this.handleResize.bind(this));
18
22
  }
19
23
  get scroll() {
20
24
  return this.scrollPos;
@@ -6,16 +6,18 @@ class EventEmitter {
6
6
  this.listeners = {};
7
7
  }
8
8
  on(event, listener) {
9
+ var _a;
9
10
  if (!Array.isArray(this.listeners[event])) {
10
11
  this.listeners[event] = [];
11
12
  }
12
- this.listeners[event]?.push(listener);
13
+ (_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.push(listener);
13
14
  return () => {
14
15
  this.off(event, listener);
15
16
  };
16
17
  }
17
18
  off(event, listener) {
18
- const filtered = this.listeners[event]?.filter(l => l !== listener);
19
+ var _a;
20
+ const filtered = (_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.filter(l => l !== listener);
19
21
  this.listeners[event] = filtered && filtered.length > 0 ? filtered : undefined;
20
22
  }
21
23
  emit(event, payload) {
@@ -11,6 +11,7 @@ exports.FontStyles = {
11
11
  };
12
12
  class RichTextConverter {
13
13
  toHtml(richText, layouts, hasPreset) {
14
+ var _a, _b, _c;
14
15
  const { text, blocks = [] } = richText.commonParams;
15
16
  const root = [];
16
17
  const styleRules = layouts.reduce((rec, layout) => {
@@ -18,16 +19,17 @@ class RichTextConverter {
18
19
  return rec;
19
20
  }, {});
20
21
  let currentLineHeight = layouts.reduce((rec, layout) => {
22
+ var _a, _b;
21
23
  const styles = richText.layoutParams[layout.id].styles;
22
- rec[layout.id] = styles?.find(s => s.style === 'LINEHEIGHT')?.value ?? '0';
24
+ rec[layout.id] = (_b = (_a = styles === null || styles === void 0 ? void 0 : styles.find(s => s.style === 'LINEHEIGHT')) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '0';
23
25
  return rec;
24
26
  }, {});
25
27
  for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
26
28
  const block = blocks[blockIndex];
27
29
  const content = text.slice(block.start, block.end);
28
- const entities = block.entities.sort((a, b) => a.start - b.start) ?? [];
30
+ const entities = (_a = block.entities.sort((a, b) => a.start - b.start)) !== null && _a !== void 0 ? _a : [];
29
31
  if (content.length === 0) {
30
- root.push((0, jsx_runtime_1.jsx)("div", { className: `rt_${richText.id}_br_${blockIndex}`, children: (0, jsx_runtime_1.jsx)("br", {}) }));
32
+ root.push((0, jsx_runtime_1.jsx)("div", Object.assign({ className: `rt_${richText.id}_br_${blockIndex}` }, { children: (0, jsx_runtime_1.jsx)("br", {}) })));
31
33
  layouts.forEach(l => {
32
34
  const lh = RichTextConverter.fromDraftToInline({
33
35
  name: 'LINEHEIGHT',
@@ -41,13 +43,13 @@ class RichTextConverter {
41
43
  const params = richText.layoutParams[layoutId];
42
44
  const styles = params.styles
43
45
  .filter(s => s.start >= block.start && s.end <= block.end)
44
- .map(s => ({ ...s, start: s.start - block.start, end: s.end - block.start }));
46
+ .map(s => (Object.assign(Object.assign({}, s), { start: s.start - block.start, end: s.end - block.start })));
45
47
  return ({
46
48
  layout: layoutId,
47
49
  styles: this.normalizeStyles(styles, entities)
48
50
  });
49
51
  });
50
- const sameLayouts = groupBy(newStylesGroup, (item) => this.serializeRanges(item.styles ?? []));
52
+ const sameLayouts = groupBy(newStylesGroup, (item) => { var _a; return this.serializeRanges((_a = item.styles) !== null && _a !== void 0 ? _a : []); });
51
53
  for (const group of Object.values(sameLayouts)) {
52
54
  const blockClass = `rt_${richText.id}-b${blockIndex}_${layouts.map(l => group.some(g => g.layout === l.id) ? '1' : '0').join('')}`;
53
55
  const kids = [];
@@ -65,7 +67,7 @@ class RichTextConverter {
65
67
  `);
66
68
  });
67
69
  const item = group[0];
68
- const entitiesGroups = this.groupEntities(entities, item.styles) ?? [];
70
+ const entitiesGroups = (_b = this.groupEntities(entities, item.styles)) !== null && _b !== void 0 ? _b : [];
69
71
  let offset = 0;
70
72
  for (const entity of entitiesGroups) {
71
73
  const entityKids = [];
@@ -77,7 +79,7 @@ class RichTextConverter {
77
79
  if (offset < style.start) {
78
80
  entityKids.push(sliceSymbols(content, offset, style.start));
79
81
  }
80
- entityKids.push((0, jsx_runtime_1.jsx)("span", { className: `s-${style.start}-${style.end}`, children: sliceSymbols(content, style.start, style.end) }, style.start));
82
+ entityKids.push((0, jsx_runtime_1.jsx)("span", Object.assign({ className: `s-${style.start}-${style.end}` }, { children: sliceSymbols(content, style.start, style.end) }), style.start));
81
83
  offset = style.end;
82
84
  }
83
85
  if (offset < entity.end) {
@@ -85,7 +87,7 @@ class RichTextConverter {
85
87
  offset = entity.end;
86
88
  }
87
89
  if (entity.link) {
88
- kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: entity.link, children: entityKids }, entity.start));
90
+ kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, Object.assign({ url: entity.link }, { children: entityKids }), entity.start));
89
91
  continue;
90
92
  }
91
93
  kids.push(...entityKids);
@@ -94,14 +96,14 @@ class RichTextConverter {
94
96
  kids.push(sliceSymbols(content, offset));
95
97
  }
96
98
  for (const item of group) {
97
- const entitiesGroups = this.groupEntities(entities, item.styles) ?? [];
99
+ const entitiesGroups = (_c = this.groupEntities(entities, item.styles)) !== null && _c !== void 0 ? _c : [];
98
100
  for (const entitiesGroup of entitiesGroups) {
99
101
  if (!entitiesGroup.stylesGroup)
100
102
  continue;
101
103
  for (const styleGroup of entitiesGroup.stylesGroup) {
102
104
  const lineHeight = styleGroup.styles.find(s => s.name === 'LINEHEIGHT');
103
105
  const color = styleGroup.styles.find(s => s.name === 'COLOR');
104
- if (lineHeight?.value) {
106
+ if (lineHeight === null || lineHeight === void 0 ? void 0 : lineHeight.value) {
105
107
  currentLineHeight[item.layout] = lineHeight.value;
106
108
  }
107
109
  styleRules[item.layout].push(`
@@ -121,7 +123,7 @@ class RichTextConverter {
121
123
  }
122
124
  }
123
125
  }
124
- root.push((0, jsx_runtime_1.jsx)("div", { className: blockClass, children: kids }, blockClass));
126
+ root.push((0, jsx_runtime_1.jsx)("div", Object.assign({ className: blockClass }, { children: kids }), blockClass));
125
127
  }
126
128
  }
127
129
  const styles = layouts.map(l => `
@@ -185,12 +187,8 @@ class RichTextConverter {
185
187
  const start = entityDividers[i];
186
188
  const end = entityDividers[i + 1];
187
189
  const entity = entities.find(e => e.start === start);
188
- entitiesGroups.push({
189
- stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end),
190
- start,
191
- end,
192
- ...(entity && { link: entity.data.url })
193
- });
190
+ entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
191
+ end }, (entity && { link: entity.data.url })));
194
192
  }
195
193
  return entitiesGroups;
196
194
  }
@@ -199,7 +197,7 @@ class RichTextConverter {
199
197
  const map = {
200
198
  'COLOR': { 'color': getResolvedValue(value, name) },
201
199
  'TYPEFACE': { 'font-family': `${value}` },
202
- 'FONTSTYLE': value ? { ...exports.FontStyles[value] } : {},
200
+ 'FONTSTYLE': value ? Object.assign({}, exports.FontStyles[value]) : {},
203
201
  'FONTWEIGHT': { 'font-weight': value },
204
202
  'FONTSIZE': { 'font-size': `${parseFloat(value) * 100}vw` },
205
203
  'LINEHEIGHT': { 'line-height': `${parseFloat(value) * 100}vw` },
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.captureStackTrace = exports.YouTubeIframeApiLoader = void 0;
4
13
  const YT_IFRAME_API_URL = 'https://www.youtube.com/iframe_api';
@@ -12,12 +21,14 @@ class YouTubeIframeApiLoader {
12
21
  constructor() {
13
22
  this.loadingPromise = this.loadApi();
14
23
  }
15
- async getApi() {
16
- await this.loadingPromise;
17
- if (!window.YT) {
18
- throw new Error('YouTube IFrame API is not loaded');
19
- }
20
- return window.YT;
24
+ getApi() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ yield this.loadingPromise;
27
+ if (!window.YT) {
28
+ throw new Error('YouTube IFrame API is not loaded');
29
+ }
30
+ return window.YT;
31
+ });
21
32
  }
22
33
  loadApi() {
23
34
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -21,16 +21,17 @@
21
21
  },
22
22
  "homepage": "https://github.com/cntrl-site/sdk-nextjs#readme",
23
23
  "dependencies": {
24
- "@cntrl-site/sdk": "^1.1.9",
24
+ "@cntrl-site/sdk": "^1.1.10",
25
25
  "@types/vimeo__player": "^2.18.0",
26
26
  "@vimeo/player": "^2.20.1",
27
27
  "html-react-parser": "^3.0.1",
28
+ "resize-observer-polyfill": "^1.5.1",
28
29
  "styled-jsx": "^5.0.2"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "@types/lodash.isequal": "^4.5.6",
32
33
  "lodash.isequal": "^4.5.0",
33
- "next": "^13.4.2",
34
+ "next": "^13.0.0",
34
35
  "react": "^18.2.0",
35
36
  "react-dom": "^18.2.0"
36
37
  },
@@ -26,7 +26,7 @@ export const useCurrentLayout = (): string | undefined => {
26
26
  }, []);
27
27
  }, [layouts]);
28
28
  const getCurrentLayout = useCallback((articleWidth: number) => {
29
- return layoutRanges.find(l => articleWidth >= l.start && articleWidth < l.end)!.layoutId;
29
+ return layoutRanges.find(l => articleWidth >= l.start && articleWidth < l.end)?.layoutId;
30
30
  }, [layoutRanges]);
31
31
  const [layoutId, setLayoutId] = useState<string | undefined>(undefined);
32
32
  useEffect(() => {
@@ -6,6 +6,7 @@ import { useRichTextItem } from './useRichTextItem';
6
6
  import { useCntrlContext } from '../../provider/useCntrlContext';
7
7
  import { getHoverStyles, getTransitions } from '../../utils/HoverStyles/HoverStyles';
8
8
  import { useRichTextItemValues } from './useRichTextItemValues';
9
+ import ResizeObserver from 'resize-observer-polyfill';
9
10
 
10
11
  export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, onResize }) => {
11
12
  const [content, styles, preset] = useRichTextItem(item);
@@ -1,4 +1,5 @@
1
1
  import { EventEmitter } from '../EventEmitter';
2
+ import ResizeObserver from 'resize-observer-polyfill';
2
3
 
3
4
  interface EventMap {
4
5
  'scroll': undefined;