@gxpl/sdk 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist → lib}/index.d.ts +3 -4
- package/lib/sdk/FontFaceGenerator/FontFaceGenerator.js +28 -0
- package/lib/sdk/ScrollPlaybackVideoManager/ScrollPlaybackVideoManager.js +221 -0
- package/lib/sdk/VideoDecoder/VideoDecoder.js +184 -0
- package/{dist → lib}/sdk/schemas/article/Article.schema.d.ts +12 -12
- package/{dist → lib}/sdk/schemas/article/ItemBase.schema.d.ts +10 -10
- package/{dist → lib}/sdk/schemas/article/RichTextItem.schema.d.ts +30 -30
- package/{dist → lib}/sdk/schemas/article/Section.schema.d.ts +3 -3
- package/{dist → lib}/sdk/types/component/Component.d.ts +1 -1
- package/{dist → lib}/sdk/types/keyframe/Keyframe.d.ts +1 -1
- package/lib/sdk/types/project/Meta.js +2 -0
- package/lib/sdk/types/project/Page.js +2 -0
- package/lib/sdk/types/project/Project.js +2 -0
- package/lib/sdk-nextjs/common/useCurrentLayout.js +42 -0
- package/lib/sdk-nextjs/common/useExemplary.js +13 -0
- package/lib/sdk-nextjs/common/useItemFXData.js +36 -0
- package/lib/sdk-nextjs/common/useKeyframeValue.js +75 -0
- package/lib/sdk-nextjs/common/useRegisterResize.js +22 -0
- package/lib/sdk-nextjs/components/Article.js +41 -0
- package/lib/sdk-nextjs/components/ArticleWrapper.js +12 -0
- package/lib/sdk-nextjs/components/Head.js +32 -0
- package/lib/sdk-nextjs/components/Page.js +20 -0
- package/{dist → lib}/sdk-nextjs/components/ScrollPlaybackVideo.d.ts +1 -1
- package/lib/sdk-nextjs/components/ScrollPlaybackVideo.js +46 -0
- package/lib/sdk-nextjs/components/Section/Section.js +85 -0
- package/lib/sdk-nextjs/components/Section/SectionImage.js +24 -0
- package/lib/sdk-nextjs/components/Section/SectionVideo.js +91 -0
- package/lib/sdk-nextjs/components/Section/useSectionHeightMap.js +20 -0
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/CodeEmbedItem.js +120 -0
- package/lib/sdk-nextjs/components/items/CodeEmbedItem/useCodeEmbedItem.js +24 -0
- package/lib/sdk-nextjs/components/items/ComponentItem/ComponentItem.js +51 -0
- package/lib/sdk-nextjs/components/items/ComponentItem/useComponentItem.js +25 -0
- package/lib/sdk-nextjs/components/items/CompoundItem/CompoundChild.js +102 -0
- package/lib/sdk-nextjs/components/items/CompoundItem/CompoundItem.js +53 -0
- package/lib/sdk-nextjs/components/items/CompoundItem/useCompoundItem.js +16 -0
- package/lib/sdk-nextjs/components/items/CustomItem/CustomItem.js +40 -0
- package/{dist → lib}/sdk-nextjs/components/items/EmbedVideoItem/VimeoEmbed.d.ts +2 -2
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/VimeoEmbed.js +170 -0
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/YoutubeEmbed.js +166 -0
- package/lib/sdk-nextjs/components/items/EmbedVideoItem/useEmbedVideoItem.js +29 -0
- package/lib/sdk-nextjs/components/items/FileItem/ImageItem.js +140 -0
- package/lib/sdk-nextjs/components/items/FileItem/VideoItem.js +227 -0
- package/{dist → lib}/sdk-nextjs/components/items/FileItem/useFileItem.d.ts +1 -1
- package/lib/sdk-nextjs/components/items/FileItem/useFileItem.js +48 -0
- package/lib/sdk-nextjs/components/items/GroupItem/GroupItem.js +55 -0
- package/lib/sdk-nextjs/components/items/GroupItem/useGroupItem.js +22 -0
- package/lib/sdk-nextjs/components/items/Item.js +175 -0
- package/{dist → lib}/sdk-nextjs/components/items/LinkWrapper.d.ts +1 -1
- package/lib/sdk-nextjs/components/items/LinkWrapper.js +27 -0
- package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +130 -0
- package/lib/sdk-nextjs/components/items/RectangleItem/useRectangleItem.js +54 -0
- package/lib/sdk-nextjs/components/items/RichTextItem/RichTextItem.js +83 -0
- package/lib/sdk-nextjs/components/items/RichTextItem/useRichTextItem.js +12 -0
- package/lib/sdk-nextjs/components/items/RichTextWrapper.js +10 -0
- package/lib/sdk-nextjs/components/items/itemsMap.js +28 -0
- package/lib/sdk-nextjs/components/items/useDraggable.js +177 -0
- package/lib/sdk-nextjs/components/items/useItemAngle.js +10 -0
- package/lib/sdk-nextjs/components/items/useItemArea.js +21 -0
- package/lib/sdk-nextjs/components/items/useItemPointerEvents.js +23 -0
- package/lib/sdk-nextjs/components/items/useItemScale.js +12 -0
- package/lib/sdk-nextjs/components/items/useItemTriggers.js +16 -0
- package/lib/sdk-nextjs/components/items/useRichTextItemValues.js +38 -0
- package/lib/sdk-nextjs/components/items/useSizing.js +22 -0
- package/lib/sdk-nextjs/components/items/useStickyItemTop.js +17 -0
- package/lib/sdk-nextjs/components/useLayoutContext.js +9 -0
- package/{dist → lib}/sdk-nextjs/interactions/CSSPropertyNameMap.d.ts +2 -2
- package/lib/sdk-nextjs/interactions/CSSPropertyNameMap.js +38 -0
- package/lib/sdk-nextjs/interactions/InteractionsRegistry.js +355 -0
- package/lib/sdk-nextjs/interactions/ItemInteractionCtrl.js +72 -0
- package/lib/sdk-nextjs/interactions/getTransition.js +20 -0
- package/{dist → lib}/sdk-nextjs/interactions/types.d.ts +3 -3
- package/lib/sdk-nextjs/interactions/useItemInteractionCtrl.js +16 -0
- package/{dist → lib}/sdk-nextjs/provider/ArticleRectContext.d.ts +1 -1
- package/lib/sdk-nextjs/provider/ArticleRectContext.js +5 -0
- package/{dist → lib}/sdk-nextjs/provider/CntrlContext.d.ts +1 -1
- package/lib/sdk-nextjs/provider/CntrlContext.js +6 -0
- package/lib/sdk-nextjs/provider/CntrlProvider.js +10 -0
- package/lib/sdk-nextjs/provider/CntrlSdkContext.js +76 -0
- package/lib/sdk-nextjs/provider/CustomItemRegistry.js +16 -0
- package/{dist → lib}/sdk-nextjs/provider/CustomSectionRegistry.d.ts +1 -1
- package/lib/sdk-nextjs/provider/CustomSectionRegistry.js +21 -0
- package/{dist → lib}/sdk-nextjs/provider/InteractionsContext.d.ts +1 -1
- package/lib/sdk-nextjs/provider/InteractionsContext.js +52 -0
- package/{dist → lib}/sdk-nextjs/provider/Keyframes.d.ts +1 -1
- package/lib/sdk-nextjs/provider/Keyframes.js +12 -0
- package/lib/sdk-nextjs/provider/KeyframesContext.d.ts +2 -0
- package/lib/sdk-nextjs/provider/KeyframesContext.js +6 -0
- package/lib/sdk-nextjs/provider/LayoutContext.d.ts +1 -0
- package/lib/sdk-nextjs/provider/LayoutContext.js +5 -0
- package/{dist → lib}/sdk-nextjs/provider/WebGLContextManagerContext.d.ts +1 -1
- package/lib/sdk-nextjs/provider/WebGLContextManagerContext.js +6 -0
- package/lib/sdk-nextjs/provider/defaultContext.js +9 -0
- package/lib/sdk-nextjs/provider/useCntrlContext.js +9 -0
- package/lib/sdk-nextjs/utils/Animator/Animator.js +443 -0
- package/lib/sdk-nextjs/utils/ArticleRectManager/ArticleRectObserver.js +88 -0
- package/lib/sdk-nextjs/utils/ArticleRectManager/useArticleRectObserver.js +18 -0
- package/lib/sdk-nextjs/utils/ArticleRectManager/useSectionRegistry.js +14 -0
- package/lib/sdk-nextjs/utils/EventEmitter.js +37 -0
- package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +288 -0
- package/lib/sdk-nextjs/utils/ScaleAnchorMap.js +15 -0
- package/lib/sdk-nextjs/utils/Youtube/YouTubeIframeApiLoader.js +64 -0
- package/lib/sdk-nextjs/utils/Youtube/YoutubeIframeApi.js +12 -0
- package/lib/sdk-nextjs/utils/Youtube/useYouTubeIframeApi.js +13 -0
- package/lib/sdk-nextjs/utils/areFillsVisible/areFillsVisible.js +22 -0
- package/lib/sdk-nextjs/utils/binSearchInsertAt.js +35 -0
- package/lib/sdk-nextjs/utils/checkOverflowClipSupport.js +18 -0
- package/lib/sdk-nextjs/utils/effects/useImageFx.js +114 -0
- package/lib/sdk-nextjs/utils/effects/useVideoFx.js +117 -0
- package/lib/sdk-nextjs/utils/getAnchoredItemTop.js +14 -0
- package/lib/sdk-nextjs/utils/getCompoundBoundaryStyles.js +60 -0
- package/lib/sdk-nextjs/utils/getFill.js +42 -0
- package/lib/sdk-nextjs/utils/getFontFamilyValue.js +6 -0
- package/lib/sdk-nextjs/utils/getItemTopStyle.js +17 -0
- package/lib/sdk-nextjs/utils/getStyleFromItemStateAndParams.js +8 -0
- package/lib/sdk-nextjs/utils/getValidYoutubeUrl.js +33 -0
- package/lib/sdk-nextjs/utils/isItemType.js +6 -0
- package/lib/sdk-nextjs/utils/rangeMap.js +11 -0
- package/lib/sdk-nextjs/utils/useElementRect.js +24 -0
- package/lib/utils.js +30 -0
- package/package.json +3 -3
- package/dist/cli.js +0 -64
- package/dist/index.js +0 -7765
- package/dist/index.mjs +0 -7748
- package/dist/sdk/Client/Client.test.d.ts +0 -1
- package/dist/sdk/Client/__mock__/articleMock.d.ts +0 -2
- package/dist/sdk/Client/__mock__/keyframesMock.d.ts +0 -2
- package/dist/sdk/Client/__mock__/projectMock.d.ts +0 -2
- package/dist/sdk/Components/ControlSlider/ControlSlider.d.ts +0 -90
- package/dist/sdk/Components/ControlSlider/ControlSliderComponent.d.ts +0 -519
- package/dist/sdk/Components/ImageRevealSlider/ControlImageRevealSliderComponent.d.ts +0 -209
- package/dist/sdk/Components/ImageRevealSlider/ImageRevealSlider.d.ts +0 -38
- package/dist/sdk/Components/components.d.ts +0 -2
- package/dist/sdk/Components/helpers/RichTextRenderer/RichTextRenderer.d.ts +0 -6
- package/dist/sdk/Components/helpers/SvgImage/SvgImage.d.ts +0 -9
- package/dist/sdk/Components/utils/scalingValue.d.ts +0 -1
- package/dist/sdk/FontFaceGenerator/FontFaceGenerator.test.d.ts +0 -1
- package/dist/sdk/schemas/shared/FillLayer.schema.d.ts +0 -186
- package/dist/sdk-nextjs/components/LayoutStyle.d.ts +0 -9
- package/dist/sdk-nextjs/components/Section/useSectionColor.d.ts +0 -4
- package/dist/sdk-nextjs/provider/KeyframesContext.d.ts +0 -2
- package/dist/sdk-nextjs/provider/LayoutContext.d.ts +0 -1
- package/dist/sdk-nextjs/utils/StickyManager/StickyManager.d.ts +0 -10
- package/dist/sdk-nextjs/utils/areFillsVisible/areFillsVisible.test.d.ts +0 -1
- package/dist/sdk-nextjs/utils/castObject.d.ts +0 -5
- package/dist/sdk-nextjs/utils/getInvertedRanges.d.ts +0 -10
- package/dist/sdk.css +0 -1
- /package/{dist → lib}/cli.d.ts +0 -0
- /package/{dist → lib}/sdk/Client/Client.d.ts +0 -0
- /package/{dist → lib}/sdk/Client/Client.js +0 -0
- /package/{dist → lib}/sdk/FontFaceGenerator/FontFaceGenerator.d.ts +0 -0
- /package/{dist → lib}/sdk/ScrollPlaybackVideoManager/ScrollPlaybackVideoManager.d.ts +0 -0
- /package/{dist → lib}/sdk/VideoDecoder/VideoDecoder.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/Article.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/FillLayer.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/FillLayer.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/Interaction.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/Interaction.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/Item.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/Item.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/ItemArea.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/ItemArea.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/ItemBase.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/ItemState.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/article/ItemState.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/RichTextItem.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/article/Section.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/keyframe/Keyframes.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/keyframe/Keyframes.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/project/Layout.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/project/Layout.schema.js +0 -0
- /package/{dist → lib}/sdk/schemas/project/Project.schema.d.ts +0 -0
- /package/{dist → lib}/sdk/schemas/project/Project.schema.js +0 -0
- /package/{dist → lib}/sdk/types/article/Article.d.ts +0 -0
- /package/{dist/sdk/types/article/FX.js → lib/sdk/types/article/Article.js} +0 -0
- /package/{dist → lib}/sdk/types/article/ArticleItemType.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/ArticleItemType.js +0 -0
- /package/{dist → lib}/sdk/types/article/CompoundSettings.d.ts +0 -0
- /package/{dist/sdk/types/article/Interaction.js → lib/sdk/types/article/CompoundSettings.js} +0 -0
- /package/{dist → lib}/sdk/types/article/FX.d.ts +0 -0
- /package/{dist/sdk/types/project/Layout.js → lib/sdk/types/article/FX.js} +0 -0
- /package/{dist → lib}/sdk/types/article/Interaction.d.ts +0 -0
- /package/{dist/sdk/types/project/Meta.js → lib/sdk/types/article/Interaction.js} +0 -0
- /package/{dist → lib}/sdk/types/article/Item.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/Item.js +0 -0
- /package/{dist → lib}/sdk/types/article/ItemArea.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/ItemArea.js +0 -0
- /package/{dist → lib}/sdk/types/article/ItemState.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/ItemState.js +0 -0
- /package/{dist → lib}/sdk/types/article/RichText.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/RichText.js +0 -0
- /package/{dist → lib}/sdk/types/article/Section.d.ts +0 -0
- /package/{dist → lib}/sdk/types/article/Section.js +0 -0
- /package/{dist/sdk/types/project/Page.js → lib/sdk/types/component/Component.js} +0 -0
- /package/{dist → lib}/sdk/types/keyframe/Keyframe.js +0 -0
- /package/{dist → lib}/sdk/types/project/Fonts.d.ts +0 -0
- /package/{dist → lib}/sdk/types/project/Fonts.js +0 -0
- /package/{dist → lib}/sdk/types/project/Layout.d.ts +0 -0
- /package/{dist/sdk/types/project/Project.js → lib/sdk/types/project/Layout.js} +0 -0
- /package/{dist → lib}/sdk/types/project/Meta.d.ts +0 -0
- /package/{dist → lib}/sdk/types/project/Page.d.ts +0 -0
- /package/{dist → lib}/sdk/types/project/Project.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/common/useCurrentLayout.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/common/useExemplary.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/common/useItemFXData.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/common/useKeyframeValue.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/common/useRegisterResize.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Article.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/ArticleWrapper.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Head.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Page.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Section/Section.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Section/SectionImage.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Section/SectionVideo.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/Section/useSectionHeightMap.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CodeEmbedItem/CodeEmbedItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CodeEmbedItem/useCodeEmbedItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/ComponentItem/ComponentItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/ComponentItem/useComponentItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CompoundItem/CompoundChild.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CompoundItem/CompoundItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CompoundItem/useCompoundItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/CustomItem/CustomItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/EmbedVideoItem/YoutubeEmbed.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/EmbedVideoItem/useEmbedVideoItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/FileItem/ImageItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/FileItem/VideoItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/GroupItem/GroupItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/GroupItem/useGroupItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/Item.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/RectangleItem/RectangleItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/RectangleItem/useRectangleItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/RichTextItem/RichTextItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/RichTextItem/useRichTextItem.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/RichTextWrapper.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/itemsMap.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useDraggable.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useItemAngle.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useItemArea.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useItemPointerEvents.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useItemScale.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useItemTriggers.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useRichTextItemValues.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useSizing.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/items/useStickyItemTop.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/components/useLayoutContext.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/interactions/InteractionsRegistry.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/interactions/ItemInteractionCtrl.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/interactions/getTransition.d.ts +0 -0
- /package/{dist/sdk/types/article/Article.js → lib/sdk-nextjs/interactions/types.js} +0 -0
- /package/{dist → lib}/sdk-nextjs/interactions/useItemInteractionCtrl.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/CntrlProvider.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/CntrlSdkContext.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/CustomItemRegistry.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/CustomItemTypes.d.ts +0 -0
- /package/{dist/sdk/types/article/CompoundSettings.js → lib/sdk-nextjs/provider/CustomItemTypes.js} +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/defaultContext.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/provider/useCntrlContext.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/Animator/Animator.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/ArticleRectManager/ArticleRectObserver.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/ArticleRectManager/useArticleRectObserver.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/ArticleRectManager/useSectionRegistry.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/EventEmitter.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/RichTextConverter/RichTextConverter.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/ScaleAnchorMap.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/Youtube/YouTubeIframeApiLoader.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/Youtube/YoutubeIframeApi.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/Youtube/useYouTubeIframeApi.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/areFillsVisible/areFillsVisible.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/binSearchInsertAt.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/checkOverflowClipSupport.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/effects/useImageFx.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/effects/useVideoFx.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getAnchoredItemTop.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getCompoundBoundaryStyles.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getFill.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getFontFamilyValue.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getItemTopStyle.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getStyleFromItemStateAndParams.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/getValidYoutubeUrl.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/isItemType.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/rangeMap.d.ts +0 -0
- /package/{dist → lib}/sdk-nextjs/utils/useElementRect.d.ts +0 -0
- /package/{dist → lib}/utils.d.ts +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSizing = useSizing;
|
|
4
|
+
exports.parseSizing = parseSizing;
|
|
5
|
+
const ArticleItemType_1 = require("../../../sdk/types/article/ArticleItemType");
|
|
6
|
+
const isItemType_1 = require("../../utils/isItemType");
|
|
7
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
8
|
+
function useSizing(item) {
|
|
9
|
+
const layout = (0, useLayoutContext_1.useLayoutContext)();
|
|
10
|
+
const sizing = layout && (0, isItemType_1.isItemType)(item, ArticleItemType_1.ArticleItemType.RichText)
|
|
11
|
+
? item.layoutParams[layout].sizing
|
|
12
|
+
: undefined;
|
|
13
|
+
const sizingAxis = parseSizing(sizing);
|
|
14
|
+
return sizingAxis;
|
|
15
|
+
}
|
|
16
|
+
function parseSizing(sizing = 'manual') {
|
|
17
|
+
const axisSizing = sizing.split(' ');
|
|
18
|
+
return {
|
|
19
|
+
y: axisSizing[0],
|
|
20
|
+
x: axisSizing[1] ? axisSizing[1] : axisSizing[0]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStickyItemTop = useStickyItemTop;
|
|
4
|
+
const Keyframe_1 = require("../../../sdk/types/keyframe/Keyframe");
|
|
5
|
+
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
|
|
6
|
+
const useLayoutContext_1 = require("../useLayoutContext");
|
|
7
|
+
function useStickyItemTop(item, sectionId, stateTop) {
|
|
8
|
+
const layoutId = (0, useLayoutContext_1.useLayoutContext)();
|
|
9
|
+
const data = (0, useKeyframeValue_1.useKeyframeValue)(item, Keyframe_1.KeyframeType.Position, (item, layoutId) => {
|
|
10
|
+
if (!layoutId)
|
|
11
|
+
return;
|
|
12
|
+
return item.area[layoutId];
|
|
13
|
+
}, (animator, scroll, value) => value ? animator.getPositions(value, scroll) : undefined, sectionId, [layoutId]);
|
|
14
|
+
const top = data ? data.top : layoutId ? item.area[layoutId].top : 0;
|
|
15
|
+
const sticky = layoutId ? item.sticky[layoutId] : undefined;
|
|
16
|
+
return sticky ? (stateTop !== null && stateTop !== void 0 ? stateTop : top) - sticky.from : 0;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLayoutContext = useLayoutContext;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const LayoutContext_1 = require("../provider/LayoutContext");
|
|
6
|
+
function useLayoutContext() {
|
|
7
|
+
const layoutId = (0, react_1.useContext)(LayoutContext_1.LayoutContext);
|
|
8
|
+
return layoutId;
|
|
9
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArticleItemType } from
|
|
2
|
-
import { ItemState } from
|
|
1
|
+
import { ArticleItemType } from "../../sdk/types/article/ArticleItemType";
|
|
2
|
+
import { ItemState } from "../../sdk/types/article/ItemState";
|
|
3
3
|
export declare const CSSPropertyNameMap: Record<keyof ItemState<ArticleItemType>, string>;
|
|
4
4
|
export declare function getStyleKeysFromCSSProperty(cssProp: string): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CSSPropertyNameMap = void 0;
|
|
4
|
+
exports.getStyleKeysFromCSSProperty = getStyleKeysFromCSSProperty;
|
|
5
|
+
exports.CSSPropertyNameMap = {
|
|
6
|
+
width: 'width',
|
|
7
|
+
height: 'height',
|
|
8
|
+
top: 'top',
|
|
9
|
+
left: 'left',
|
|
10
|
+
scale: 'transform',
|
|
11
|
+
angle: 'transform',
|
|
12
|
+
opacity: 'opacity',
|
|
13
|
+
radius: 'border-radius',
|
|
14
|
+
strokeWidth: 'border-width',
|
|
15
|
+
strokeFill: 'border-color',
|
|
16
|
+
fill: 'background',
|
|
17
|
+
blur: 'filter',
|
|
18
|
+
backdropBlur: 'backdrop-filter',
|
|
19
|
+
letterSpacing: 'letter-spacing',
|
|
20
|
+
wordSpacing: 'word-spacing',
|
|
21
|
+
color: 'color'
|
|
22
|
+
};
|
|
23
|
+
const PropertyNameCSSMap = {
|
|
24
|
+
'transform': ['angle', 'scale'],
|
|
25
|
+
'border-radius': ['radius'],
|
|
26
|
+
'border-width': ['strokeWidth'],
|
|
27
|
+
'border-color': ['strokeFill'],
|
|
28
|
+
'background': ['fill'],
|
|
29
|
+
'filter': ['blur'],
|
|
30
|
+
'backdrop-filter': ['backdrop-blur'],
|
|
31
|
+
'letter-spacing': ['letterSpacing'],
|
|
32
|
+
'word-spacing': ['wordSpacing'],
|
|
33
|
+
};
|
|
34
|
+
function getStyleKeysFromCSSProperty(cssProp) {
|
|
35
|
+
var _a;
|
|
36
|
+
const key = (_a = PropertyNameCSSMap[cssProp]) !== null && _a !== void 0 ? _a : [cssProp];
|
|
37
|
+
return key;
|
|
38
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionsRegistry = void 0;
|
|
4
|
+
const isItemType_1 = require("../utils/isItemType");
|
|
5
|
+
const ArticleItemType_1 = require("../../sdk/types/article/ArticleItemType");
|
|
6
|
+
class InteractionsRegistry {
|
|
7
|
+
constructor(article, layoutId) {
|
|
8
|
+
var _a;
|
|
9
|
+
this.ctrls = new Map();
|
|
10
|
+
this.items = this.unpackItems(article);
|
|
11
|
+
const interactions = (_a = article.interactions[layoutId]) !== null && _a !== void 0 ? _a : [];
|
|
12
|
+
const activeStatesIds = interactions.reduce((map, inter) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const activeStateId = (_a = inter.states.find((state) => state.id !== inter.startStateId)) === null || _a === void 0 ? void 0 : _a.id;
|
|
15
|
+
if (!activeStateId) {
|
|
16
|
+
throw new Error(`Failed to find active state for interaction w/ id="${inter.id}"`);
|
|
17
|
+
}
|
|
18
|
+
map.push(activeStateId);
|
|
19
|
+
return map;
|
|
20
|
+
}, []);
|
|
21
|
+
const interactionStateMap = interactions.reduce((map, { id, startStateId }) => {
|
|
22
|
+
map[id] = startStateId;
|
|
23
|
+
return map;
|
|
24
|
+
}, {});
|
|
25
|
+
this.activeStateIdInteractionIdMap = interactions.reduce((map, interaction) => {
|
|
26
|
+
const activeState = interaction.states.find((state) => state.id !== interaction.startStateId);
|
|
27
|
+
if (activeState) {
|
|
28
|
+
map[activeState.id] = interaction.id;
|
|
29
|
+
}
|
|
30
|
+
return map;
|
|
31
|
+
}, {});
|
|
32
|
+
const stateItemsIdsMap = activeStatesIds.reduce((map, stateId) => {
|
|
33
|
+
map[stateId] = this.items
|
|
34
|
+
.filter((item) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const state = (_a = item.state[stateId]) !== null && _a !== void 0 ? _a : {};
|
|
37
|
+
const hasKeys = Object.keys(state).length !== 0;
|
|
38
|
+
return hasKeys;
|
|
39
|
+
})
|
|
40
|
+
.map((item) => item.id);
|
|
41
|
+
return map;
|
|
42
|
+
}, {});
|
|
43
|
+
this.interactions = interactions;
|
|
44
|
+
this.stateItemsIdsMap = stateItemsIdsMap;
|
|
45
|
+
this.interactionStateMap = interactionStateMap;
|
|
46
|
+
const itemStages = this.getDefaultItemStages();
|
|
47
|
+
this.itemsStages = itemStages;
|
|
48
|
+
}
|
|
49
|
+
register(itemId, ctrl) {
|
|
50
|
+
this.ctrls.set(itemId, ctrl);
|
|
51
|
+
}
|
|
52
|
+
getStatePropsForItem(itemId) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
const { items } = this;
|
|
55
|
+
const item = items.find((item) => item.id === itemId);
|
|
56
|
+
const itemStages = this.itemsStages.filter((stage) => stage.itemId === itemId);
|
|
57
|
+
itemStages.sort((a, b) => a.updated - b.updated);
|
|
58
|
+
const itemStyles = {};
|
|
59
|
+
for (const stage of itemStages) {
|
|
60
|
+
if (stage.type === 'active') {
|
|
61
|
+
if (stage.isStartState)
|
|
62
|
+
continue;
|
|
63
|
+
const params = (_a = item.state[stage.stateId]) !== null && _a !== void 0 ? _a : {};
|
|
64
|
+
for (const [key, stateDetails] of Object.entries(params)) {
|
|
65
|
+
itemStyles[key] = {
|
|
66
|
+
value: stateDetails.value
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (stage.type === 'transitioning') {
|
|
71
|
+
const activeStateId = stage.direction === 'in' ? stage.to : stage.from;
|
|
72
|
+
const params = (_b = item.state[activeStateId]) !== null && _b !== void 0 ? _b : {};
|
|
73
|
+
for (const [key, stateDetails] of Object.entries(params)) {
|
|
74
|
+
const transitionDetails = stateDetails[stage.direction];
|
|
75
|
+
if (!transitionDetails)
|
|
76
|
+
continue;
|
|
77
|
+
itemStyles[key] = {
|
|
78
|
+
value: stage.direction === 'in' ? stateDetails.value : (_c = itemStyles[key]) === null || _c === void 0 ? void 0 : _c.value,
|
|
79
|
+
transition: {
|
|
80
|
+
timing: transitionDetails.timing,
|
|
81
|
+
duration: transitionDetails.duration,
|
|
82
|
+
delay: transitionDetails.delay
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return itemStyles;
|
|
89
|
+
}
|
|
90
|
+
getItemAvailableTriggers(itemId) {
|
|
91
|
+
const available = new Set();
|
|
92
|
+
const activeStates = Object.values(this.interactionStateMap);
|
|
93
|
+
for (const interaction of this.interactions) {
|
|
94
|
+
const { triggers } = interaction;
|
|
95
|
+
for (const trigger of triggers) {
|
|
96
|
+
if (!('itemId' in trigger))
|
|
97
|
+
continue;
|
|
98
|
+
if (trigger.itemId !== itemId)
|
|
99
|
+
continue;
|
|
100
|
+
if (activeStates.includes(trigger.from)) {
|
|
101
|
+
available.add(trigger.type);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return available;
|
|
106
|
+
}
|
|
107
|
+
notifyLoad() {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
const timestamp = Date.now();
|
|
110
|
+
for (const interaction of this.interactions) {
|
|
111
|
+
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
112
|
+
const matchingTrigger = interaction.triggers.find(trigger => 'position' in trigger && trigger.position === 0 && trigger.from === currentStateId);
|
|
113
|
+
if (!matchingTrigger)
|
|
114
|
+
continue;
|
|
115
|
+
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
116
|
+
const isNewStateActive = matchingTrigger.to === activeStateId;
|
|
117
|
+
this.setCurrentStateForInteraction(interaction.id, matchingTrigger.to);
|
|
118
|
+
const transitioningItems = (_a = this.stateItemsIdsMap[activeStateId]) !== null && _a !== void 0 ? _a : [];
|
|
119
|
+
const state = interaction.states.find((state) => state.id === matchingTrigger.to);
|
|
120
|
+
const actions = (_b = state === null || state === void 0 ? void 0 : state.actions) !== null && _b !== void 0 ? _b : [];
|
|
121
|
+
for (const action of actions) {
|
|
122
|
+
const ctrl = this.ctrls.get(action.itemId);
|
|
123
|
+
if (!ctrl)
|
|
124
|
+
continue;
|
|
125
|
+
ctrl.receiveAction(action.type);
|
|
126
|
+
}
|
|
127
|
+
this.itemsStages = this.itemsStages.map((stage) => {
|
|
128
|
+
if (stage.interactionId !== interaction.id)
|
|
129
|
+
return stage;
|
|
130
|
+
return {
|
|
131
|
+
itemId: stage.itemId,
|
|
132
|
+
interactionId: stage.interactionId,
|
|
133
|
+
type: 'transitioning',
|
|
134
|
+
from: stage.type === 'transitioning' ? stage.to : stage.stateId,
|
|
135
|
+
to: matchingTrigger.to,
|
|
136
|
+
direction: isNewStateActive ? 'in' : 'out',
|
|
137
|
+
updated: timestamp
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
const itemsToNotify = new Set(transitioningItems);
|
|
141
|
+
for (const trigger of interaction.triggers) {
|
|
142
|
+
if (!('itemId' in trigger))
|
|
143
|
+
continue;
|
|
144
|
+
itemsToNotify.add(trigger.itemId);
|
|
145
|
+
}
|
|
146
|
+
this.notifyItemCtrlsChange(Array.from(itemsToNotify));
|
|
147
|
+
this.notifyTransitionStartForItems(transitioningItems, activeStateId);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
notifyScroll(position) {
|
|
151
|
+
var _a, _b, _c;
|
|
152
|
+
const timestamp = Date.now();
|
|
153
|
+
for (const interaction of this.interactions) {
|
|
154
|
+
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
155
|
+
const activeStateId = (_a = interaction.states.find((state) => state.id !== interaction.startStateId)) === null || _a === void 0 ? void 0 : _a.id;
|
|
156
|
+
const matchingTrigger = interaction.triggers.find((trigger) => {
|
|
157
|
+
if (!('position' in trigger) || trigger.position === 0)
|
|
158
|
+
return false;
|
|
159
|
+
const triggerPosition = trigger.position * window.innerWidth;
|
|
160
|
+
const isScrolledPastTrigger = triggerPosition < position;
|
|
161
|
+
if (!isScrolledPastTrigger && !trigger.isReverse)
|
|
162
|
+
return false;
|
|
163
|
+
const stateId = isScrolledPastTrigger ? trigger.from : trigger.to;
|
|
164
|
+
return stateId === currentStateId;
|
|
165
|
+
});
|
|
166
|
+
if (!matchingTrigger || !('position' in matchingTrigger) || !activeStateId)
|
|
167
|
+
continue;
|
|
168
|
+
const triggerPosition = matchingTrigger.position * window.innerWidth;
|
|
169
|
+
const isScrolledPastTrigger = triggerPosition < position;
|
|
170
|
+
const targetStateId = isScrolledPastTrigger ? matchingTrigger.to : matchingTrigger.from;
|
|
171
|
+
this.setCurrentStateForInteraction(interaction.id, targetStateId);
|
|
172
|
+
const transitioningItems = (_b = this.stateItemsIdsMap[activeStateId]) !== null && _b !== void 0 ? _b : [];
|
|
173
|
+
const state = interaction.states.find((state) => state.id === targetStateId);
|
|
174
|
+
const actions = (_c = state === null || state === void 0 ? void 0 : state.actions) !== null && _c !== void 0 ? _c : [];
|
|
175
|
+
for (const action of actions) {
|
|
176
|
+
const ctrl = this.ctrls.get(action.itemId);
|
|
177
|
+
if (!ctrl)
|
|
178
|
+
continue;
|
|
179
|
+
ctrl.receiveAction(action.type);
|
|
180
|
+
}
|
|
181
|
+
const itemsStages = this.itemsStages.map((stage) => {
|
|
182
|
+
if (stage.interactionId !== interaction.id)
|
|
183
|
+
return stage;
|
|
184
|
+
const newStage = {
|
|
185
|
+
itemId: stage.itemId,
|
|
186
|
+
interactionId: stage.interactionId,
|
|
187
|
+
type: 'transitioning',
|
|
188
|
+
from: stage.type === 'transitioning' ? stage.to : stage.stateId,
|
|
189
|
+
to: targetStateId,
|
|
190
|
+
direction: targetStateId === activeStateId ? 'in' : 'out',
|
|
191
|
+
updated: timestamp
|
|
192
|
+
};
|
|
193
|
+
return newStage;
|
|
194
|
+
});
|
|
195
|
+
this.itemsStages = itemsStages;
|
|
196
|
+
const itemsToNotify = new Set(transitioningItems);
|
|
197
|
+
for (const trigger of interaction.triggers) {
|
|
198
|
+
if (!('itemId' in trigger))
|
|
199
|
+
continue;
|
|
200
|
+
itemsToNotify.add(trigger.itemId);
|
|
201
|
+
}
|
|
202
|
+
this.notifyItemCtrlsChange(Array.from(itemsToNotify));
|
|
203
|
+
this.notifyTransitionStartForItems(transitioningItems, activeStateId);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
notifyItemTrigger(itemId, triggerType) {
|
|
207
|
+
var _a, _b;
|
|
208
|
+
const timestamp = Date.now();
|
|
209
|
+
for (const interaction of this.interactions) {
|
|
210
|
+
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
211
|
+
const matchingTrigger = interaction.triggers.find((trigger) => 'itemId' in trigger
|
|
212
|
+
&& trigger.itemId === itemId
|
|
213
|
+
&& trigger.from === currentStateId
|
|
214
|
+
&& trigger.type === triggerType);
|
|
215
|
+
if (!matchingTrigger)
|
|
216
|
+
continue;
|
|
217
|
+
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
218
|
+
const isNewStateActive = matchingTrigger.to === activeStateId;
|
|
219
|
+
this.setCurrentStateForInteraction(interaction.id, matchingTrigger.to);
|
|
220
|
+
const transitioningItems = (_a = this.stateItemsIdsMap[activeStateId]) !== null && _a !== void 0 ? _a : [];
|
|
221
|
+
const state = interaction.states.find((state) => state.id === matchingTrigger.to);
|
|
222
|
+
const actions = (_b = state === null || state === void 0 ? void 0 : state.actions) !== null && _b !== void 0 ? _b : [];
|
|
223
|
+
for (const action of actions) {
|
|
224
|
+
const ctrl = this.ctrls.get(action.itemId);
|
|
225
|
+
if (!ctrl)
|
|
226
|
+
continue;
|
|
227
|
+
ctrl.receiveAction(action.type);
|
|
228
|
+
}
|
|
229
|
+
this.itemsStages = this.itemsStages.map((stage) => {
|
|
230
|
+
if (stage.interactionId !== interaction.id)
|
|
231
|
+
return stage;
|
|
232
|
+
return {
|
|
233
|
+
itemId: stage.itemId,
|
|
234
|
+
interactionId: stage.interactionId,
|
|
235
|
+
type: 'transitioning',
|
|
236
|
+
from: stage.type === 'transitioning' ? stage.to : stage.stateId,
|
|
237
|
+
to: matchingTrigger.to,
|
|
238
|
+
direction: isNewStateActive ? 'in' : 'out',
|
|
239
|
+
updated: timestamp
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
const itemsToNotify = new Set(transitioningItems);
|
|
243
|
+
for (const trigger of interaction.triggers) {
|
|
244
|
+
if (!('itemId' in trigger))
|
|
245
|
+
continue;
|
|
246
|
+
itemsToNotify.add(trigger.itemId);
|
|
247
|
+
}
|
|
248
|
+
this.notifyItemCtrlsChange(Array.from(itemsToNotify));
|
|
249
|
+
this.notifyTransitionStartForItems(transitioningItems, activeStateId);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
notifyTransitionStartForItems(itemsIds, activeStateId) {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
for (const itemId of itemsIds) {
|
|
255
|
+
const ctrl = this.ctrls.get(itemId);
|
|
256
|
+
const item = this.items.find((item) => item.id === itemId);
|
|
257
|
+
const keys = Object.keys((_a = item.state[activeStateId]) !== null && _a !== void 0 ? _a : {});
|
|
258
|
+
(_b = ctrl === null || ctrl === void 0 ? void 0 : ctrl.handleTransitionStart) === null || _b === void 0 ? void 0 : _b.call(ctrl, keys);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
notifyTransitionEnd(itemId) {
|
|
262
|
+
var _a;
|
|
263
|
+
const timestamp = Date.now();
|
|
264
|
+
this.itemsStages = this.itemsStages.map((stage) => {
|
|
265
|
+
if (stage.itemId !== itemId || stage.type !== 'transitioning')
|
|
266
|
+
return stage;
|
|
267
|
+
return {
|
|
268
|
+
itemId,
|
|
269
|
+
interactionId: stage.interactionId,
|
|
270
|
+
type: 'active',
|
|
271
|
+
stateId: stage.to,
|
|
272
|
+
isStartState: stage.direction === 'out',
|
|
273
|
+
updated: timestamp
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
(_a = this.ctrls.get(itemId)) === null || _a === void 0 ? void 0 : _a.receiveChange();
|
|
277
|
+
}
|
|
278
|
+
getCurrentStateByInteractionId(id) {
|
|
279
|
+
let state;
|
|
280
|
+
for (const interactionId of Object.keys(this.interactionStateMap)) {
|
|
281
|
+
if (id !== interactionId)
|
|
282
|
+
continue;
|
|
283
|
+
state = this.interactionStateMap[interactionId];
|
|
284
|
+
}
|
|
285
|
+
if (!state)
|
|
286
|
+
throw new Error(`Failed to find current state for interaction w/ id="${id}"`);
|
|
287
|
+
return state;
|
|
288
|
+
}
|
|
289
|
+
setCurrentStateForInteraction(interactionId, stateId) {
|
|
290
|
+
this.interactionStateMap = Object.assign(Object.assign({}, this.interactionStateMap), { [interactionId]: stateId });
|
|
291
|
+
}
|
|
292
|
+
getActiveInteractionState(interactionId) {
|
|
293
|
+
var _a;
|
|
294
|
+
const { interactions } = this;
|
|
295
|
+
const interaction = interactions.find((interaction) => interaction.id === interactionId);
|
|
296
|
+
const activeStateId = (_a = interaction.states.find(state => state.id !== interaction.startStateId)) === null || _a === void 0 ? void 0 : _a.id;
|
|
297
|
+
if (!activeStateId) {
|
|
298
|
+
throw new Error(`Failed to find active state for interaction w/ id="${interactionId}"`);
|
|
299
|
+
}
|
|
300
|
+
return activeStateId;
|
|
301
|
+
}
|
|
302
|
+
notifyItemCtrlsChange(itemsIds) {
|
|
303
|
+
var _a;
|
|
304
|
+
for (const itemId of itemsIds) {
|
|
305
|
+
(_a = this.ctrls.get(itemId)) === null || _a === void 0 ? void 0 : _a.receiveChange();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
unpackItems(article) {
|
|
309
|
+
const itemsArr = [];
|
|
310
|
+
for (const section of article.sections) {
|
|
311
|
+
const items = this.getNestedItems(section.items);
|
|
312
|
+
itemsArr.push(...items);
|
|
313
|
+
}
|
|
314
|
+
return itemsArr;
|
|
315
|
+
}
|
|
316
|
+
getNestedItems(items) {
|
|
317
|
+
var _a;
|
|
318
|
+
const allItems = [];
|
|
319
|
+
for (const item of items) {
|
|
320
|
+
if ((0, isItemType_1.isItemType)(item, ArticleItemType_1.ArticleItemType.Group) || (0, isItemType_1.isItemType)(item, ArticleItemType_1.ArticleItemType.Compound)) {
|
|
321
|
+
const groupChildren = (_a = item === null || item === void 0 ? void 0 : item.items) !== null && _a !== void 0 ? _a : [];
|
|
322
|
+
const nestedItems = this.getNestedItems(groupChildren);
|
|
323
|
+
allItems.push(...nestedItems);
|
|
324
|
+
}
|
|
325
|
+
allItems.push(item);
|
|
326
|
+
}
|
|
327
|
+
return allItems;
|
|
328
|
+
}
|
|
329
|
+
getDefaultItemStages() {
|
|
330
|
+
var _a;
|
|
331
|
+
const timestamp = Date.now();
|
|
332
|
+
const { items } = this;
|
|
333
|
+
const stages = [];
|
|
334
|
+
for (const item of items) {
|
|
335
|
+
const itemStatesMap = item.state;
|
|
336
|
+
if (!itemStatesMap)
|
|
337
|
+
continue;
|
|
338
|
+
for (const stateId of Object.keys(itemStatesMap)) {
|
|
339
|
+
const interactionId = this.activeStateIdInteractionIdMap[stateId];
|
|
340
|
+
if (!interactionId)
|
|
341
|
+
continue;
|
|
342
|
+
stages.push({
|
|
343
|
+
itemId: item.id,
|
|
344
|
+
interactionId,
|
|
345
|
+
type: 'active',
|
|
346
|
+
isStartState: true,
|
|
347
|
+
updated: timestamp,
|
|
348
|
+
stateId: (_a = this.interactions.find((interaction) => interaction.id === interactionId)) === null || _a === void 0 ? void 0 : _a.startStateId
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return stages;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.InteractionsRegistry = InteractionsRegistry;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemInteractionController = void 0;
|
|
4
|
+
const getTransition_1 = require("./getTransition");
|
|
5
|
+
const CSSPropertyNameMap_1 = require("./CSSPropertyNameMap");
|
|
6
|
+
class ItemInteractionController {
|
|
7
|
+
constructor(itemId, registry, onChange) {
|
|
8
|
+
this.itemId = itemId;
|
|
9
|
+
this.registry = registry;
|
|
10
|
+
this.onChange = onChange;
|
|
11
|
+
this.transitionsInProgress = new Set();
|
|
12
|
+
this.handleTransitionStart = (types) => {
|
|
13
|
+
this.transitionsInProgress.clear();
|
|
14
|
+
for (const type of types) {
|
|
15
|
+
this.transitionsInProgress.add(type);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
this.handleTransitionEnd = (cssPropKey) => {
|
|
19
|
+
if (cssPropKey.startsWith('border-') && cssPropKey.endsWith('-radius')) {
|
|
20
|
+
cssPropKey = 'border-radius';
|
|
21
|
+
}
|
|
22
|
+
if (cssPropKey.startsWith('border-') && cssPropKey.endsWith('-width')) {
|
|
23
|
+
cssPropKey = 'border-width';
|
|
24
|
+
}
|
|
25
|
+
const styleKeys = (0, CSSPropertyNameMap_1.getStyleKeysFromCSSProperty)(cssPropKey);
|
|
26
|
+
for (const key of styleKeys) {
|
|
27
|
+
const found = this.transitionsInProgress.has(key);
|
|
28
|
+
if (!found)
|
|
29
|
+
continue;
|
|
30
|
+
this.transitionsInProgress.delete(key);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
if (this.transitionsInProgress.size !== 0)
|
|
34
|
+
return;
|
|
35
|
+
this.registry.notifyTransitionEnd(this.itemId);
|
|
36
|
+
};
|
|
37
|
+
this.registry.register(itemId, this);
|
|
38
|
+
}
|
|
39
|
+
getState(keys) {
|
|
40
|
+
const stateProps = this.registry.getStatePropsForItem(this.itemId);
|
|
41
|
+
const styles = keys.reduce((map, styleKey) => {
|
|
42
|
+
const prop = stateProps[styleKey];
|
|
43
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.value) === undefined)
|
|
44
|
+
return map;
|
|
45
|
+
map[styleKey] = prop.value;
|
|
46
|
+
return map;
|
|
47
|
+
}, {});
|
|
48
|
+
const transition = (0, getTransition_1.getTransition)(stateProps, keys);
|
|
49
|
+
return {
|
|
50
|
+
styles,
|
|
51
|
+
transition
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
getHasTrigger(itemId, triggerType) {
|
|
55
|
+
const triggers = this.registry.getItemAvailableTriggers(itemId);
|
|
56
|
+
return triggers.has(triggerType);
|
|
57
|
+
}
|
|
58
|
+
sendTrigger(type) {
|
|
59
|
+
this.registry.notifyItemTrigger(this.itemId, type);
|
|
60
|
+
}
|
|
61
|
+
receiveAction(type) {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = this.actionReceiver) === null || _a === void 0 ? void 0 : _a.call(this, type);
|
|
64
|
+
}
|
|
65
|
+
setActionReceiver(action) {
|
|
66
|
+
this.actionReceiver = action;
|
|
67
|
+
}
|
|
68
|
+
receiveChange() {
|
|
69
|
+
this.onChange();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ItemInteractionController = ItemInteractionController;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransition = getTransition;
|
|
4
|
+
const CSSPropertyNameMap_1 = require("./CSSPropertyNameMap");
|
|
5
|
+
function getTransition(state, keys) {
|
|
6
|
+
if (Object.keys(state).length === 0)
|
|
7
|
+
return 'none';
|
|
8
|
+
const transitions = [];
|
|
9
|
+
for (const [key, params] of Object.entries(state)) {
|
|
10
|
+
if (!keys.includes(key) || !params.transition)
|
|
11
|
+
continue;
|
|
12
|
+
const { transition: { duration, delay, timing } } = params;
|
|
13
|
+
const cssKey = CSSPropertyNameMap_1.CSSPropertyNameMap[key];
|
|
14
|
+
const nonZeroDuration = Math.max(duration, 0.01);
|
|
15
|
+
transitions.push(`${cssKey} ${nonZeroDuration}ms ${timing} ${delay}ms`);
|
|
16
|
+
}
|
|
17
|
+
return transitions.length > 0
|
|
18
|
+
? transitions.join(', ')
|
|
19
|
+
: 'none';
|
|
20
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArticleItemType } from
|
|
2
|
-
import { InteractionItemTrigger } from
|
|
3
|
-
import { ItemState } from
|
|
1
|
+
import { ArticleItemType } from "../../sdk/types/article/ArticleItemType";
|
|
2
|
+
import { InteractionItemTrigger } from "../../sdk/types/article/Interaction";
|
|
3
|
+
import { ItemState } from "../../sdk/types/article/ItemState";
|
|
4
4
|
export interface ItemInteractionCtrl {
|
|
5
5
|
getState<T>(keys: string[]): StateCSSInfo<T>;
|
|
6
6
|
getHasTrigger(itemId: string, triggerType: InteractionItemTrigger['type']): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useItemInteractionCtrl = useItemInteractionCtrl;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ItemInteractionCtrl_1 = require("./ItemInteractionCtrl");
|
|
6
|
+
const InteractionsContext_1 = require("../provider/InteractionsContext");
|
|
7
|
+
function useItemInteractionCtrl(itemId) {
|
|
8
|
+
const [_, triggerRender] = (0, react_1.useState)(0);
|
|
9
|
+
const registry = (0, InteractionsContext_1.useInteractionsRegistry)();
|
|
10
|
+
const ctrl = (0, react_1.useMemo)(() => {
|
|
11
|
+
if (!registry)
|
|
12
|
+
return;
|
|
13
|
+
return new ItemInteractionCtrl_1.ItemInteractionController(itemId, registry, () => triggerRender(prev => prev + 1));
|
|
14
|
+
}, [itemId, registry]);
|
|
15
|
+
return ctrl;
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ArticleRectObserver } from '../utils/ArticleRectManager/ArticleRectObserver';
|
|
2
|
-
export declare const ArticleRectContext: import(
|
|
2
|
+
export declare const ArticleRectContext: import("react").Context<ArticleRectObserver | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CntrlSdkContext } from './CntrlSdkContext';
|
|
2
|
-
export declare const CntrlContext: import(
|
|
2
|
+
export declare const CntrlContext: import("react").Context<CntrlSdkContext>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CntrlContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const defaultContext_1 = require("./defaultContext");
|
|
6
|
+
exports.CntrlContext = (0, react_1.createContext)(defaultContext_1.cntrlSdkContext);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CntrlProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const CntrlContext_1 = require("./CntrlContext");
|
|
6
|
+
const defaultContext_1 = require("./defaultContext");
|
|
7
|
+
const CntrlProvider = ({ children }) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(CntrlContext_1.CntrlContext.Provider, { value: defaultContext_1.cntrlSdkContext, children: children }));
|
|
9
|
+
};
|
|
10
|
+
exports.CntrlProvider = CntrlProvider;
|