@builder.io/sdk-react-native 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/button/button.js +6 -2
- package/dist/blocks/button/component-info.js +4 -8
- package/dist/blocks/columns/columns.js +19 -23
- package/dist/blocks/columns/component-info.js +27 -48
- package/dist/blocks/custom-code/component-info.js +4 -8
- package/dist/blocks/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.js +7 -11
- package/dist/blocks/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -6
- package/dist/blocks/form/component-info.js +33 -69
- package/dist/blocks/form/form.js +2 -203
- package/dist/blocks/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.js +33 -0
- package/dist/blocks/image/component-info.js +21 -47
- package/dist/blocks/image/image.helpers.js +2 -2
- package/dist/blocks/img/component-info.js +2 -4
- package/dist/blocks/img/img.js +2 -1
- package/dist/blocks/input/component-info.js +8 -34
- package/dist/blocks/input/input.js +2 -1
- package/dist/blocks/raw-text/component-info.js +2 -4
- package/dist/blocks/raw-text/raw-text.js +3 -2
- package/dist/blocks/section/component-info.js +5 -10
- package/dist/blocks/section/section.js +2 -1
- package/dist/blocks/select/component-info.js +12 -24
- package/dist/blocks/select/select.js +2 -1
- package/dist/blocks/submit-button/component-info.js +2 -4
- package/dist/blocks/submit-button/submit-button.js +2 -1
- package/dist/blocks/symbol/component-info.js +7 -12
- package/dist/blocks/symbol/symbol.helpers.js +66 -0
- package/dist/blocks/symbol/symbol.js +23 -50
- package/dist/blocks/text/component-info.js +3 -4
- package/dist/blocks/textarea/component-info.js +6 -12
- package/dist/blocks/textarea/textarea.js +2 -1
- package/dist/blocks/video/component-info.js +21 -41
- package/dist/components/block/block.helpers.js +102 -0
- package/dist/components/block/block.js +141 -0
- package/dist/components/block/components/block-styles.js +95 -0
- package/dist/components/block/components/block-wrapper/block-wrapper.js +41 -0
- package/dist/components/block/components/block-wrapper.js +56 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +40 -0
- package/dist/components/block/components/component-ref/component-ref.js +63 -0
- package/dist/components/block/components/component-ref.js +81 -0
- package/dist/components/block/components/component.js +41 -0
- package/dist/components/block/components/interactive-element/interactive-element.helpers.js +35 -0
- package/dist/components/block/components/interactive-element/interactive-element.js +36 -0
- package/dist/components/block/components/interactive-element.js +46 -0
- package/dist/components/block/components/repeated-block.js +40 -0
- package/dist/components/block/types.js +1 -0
- package/dist/components/blocks/blocks-wrapper.js +69 -0
- package/dist/components/blocks/blocks.js +41 -0
- package/dist/components/content/builder-editing.js +32 -0
- package/dist/components/content/components/content-styles.helpers.js +55 -0
- package/dist/components/content/components/content-styles.js +61 -0
- package/dist/components/content/components/enable-editor.js +310 -0
- package/dist/components/content/components/styles.helpers.js +55 -0
- package/dist/components/content/components/styles.js +61 -0
- package/dist/components/content/content.helpers.js +49 -0
- package/dist/components/content/content.js +110 -0
- package/dist/components/content/content.types.js +1 -0
- package/dist/components/content/index.js +8 -0
- package/dist/components/content/wrap-component-ref.js +5 -0
- package/dist/components/content-variants/content-variants.js +77 -0
- package/dist/components/content-variants/content-variants.types.js +1 -0
- package/dist/components/content-variants/helpers.js +175 -0
- package/dist/components/inlined-script.js +32 -0
- package/dist/components/{render-inlined-styles.js → inlined-styles.js} +3 -3
- package/dist/components/render-block/block-styles.js +2 -2
- package/dist/components/render-content/components/render-styles.js +2 -2
- package/dist/components/render-content/render-content.js +10 -8
- package/dist/components/render-content-variants/helpers.js +49 -20
- package/dist/components/render-content-variants/render-content-variants.js +29 -24
- package/dist/components/render-content-variants/render-content-variants.types.js +1 -0
- package/dist/constants/device-sizes.js +2 -2
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/builder.context.js +1 -1
- package/dist/functions/apply-patch-with-mutation.js +75 -0
- package/dist/functions/apply-patch-with-mutation.test.js +55 -0
- package/dist/functions/camel-to-kebab-case.js +1 -1
- package/dist/functions/evaluate/acorn.js +1691 -0
- package/dist/functions/evaluate/evaluate.js +72 -0
- package/dist/functions/evaluate/index.js +5 -0
- package/dist/functions/evaluate/interpreter.js +2903 -0
- package/dist/functions/evaluate/non-node-runtime.js +97 -0
- package/dist/functions/evaluate/types.js +1 -0
- package/dist/functions/evaluate.test.js +12 -6
- package/dist/functions/event-handler-name.js +1 -1
- package/dist/functions/extract-text-styles.js +3 -9
- package/dist/functions/fast-clone.js +1 -1
- package/dist/functions/get-block-actions-handler.js +2 -2
- package/dist/functions/get-block-actions.js +14 -1
- package/dist/functions/get-block-component-options.js +6 -1
- package/dist/functions/get-block-properties.js +21 -8
- package/dist/functions/get-builder-search-params/fn.test.js +3 -3
- package/dist/functions/get-builder-search-params/index.js +4 -4
- package/dist/functions/get-content/generate-content-url.js +12 -5
- package/dist/functions/get-content/generate-content-url.test.js +31 -17
- package/dist/functions/get-content/index.js +36 -12
- package/dist/functions/get-content/processCookies.js +7 -0
- package/dist/functions/get-processed-block.js +8 -3
- package/dist/functions/get-processed-block.test.js +3 -1
- package/dist/functions/get-react-native-block-styles.js +6 -1
- package/dist/functions/is-non-node-server.js +12 -0
- package/dist/functions/on-change.test.js +13 -3
- package/dist/functions/register-component.js +24 -19
- package/dist/functions/sanitize-react-native-block-styles.js +17 -6
- package/dist/functions/set.test.js +9 -3
- package/dist/functions/track/helpers.js +5 -5
- package/dist/functions/track/index.js +29 -18
- package/dist/functions/track/interaction.js +10 -4
- package/dist/functions/transform-block-properties.js +2 -0
- package/dist/helpers/ab-tests.js +38 -14
- package/dist/helpers/canTrack.js +2 -2
- package/dist/helpers/css.js +2 -2
- package/dist/helpers/flatten.js +10 -7
- package/dist/helpers/nullable.js +1 -1
- package/dist/helpers/preview-lru-cache/get.js +11 -0
- package/dist/helpers/preview-lru-cache/helpers.js +13 -0
- package/dist/helpers/preview-lru-cache/init.js +13 -0
- package/dist/helpers/preview-lru-cache/set.js +37 -0
- package/dist/helpers/preview-lru-cache/types.js +1 -0
- package/dist/helpers/sessionId.js +13 -6
- package/dist/helpers/url.js +1 -1
- package/dist/helpers/visitorId.js +4 -1
- package/dist/index-helpers/blocks-exports.js +2 -2
- package/dist/scripts/init-editing.js +61 -46
- package/dist/types/builder-props.js +1 -0
- package/dist/types/enforced-partials.js +1 -0
- package/package.json +2 -2
- package/src/blocks/button/button.jsx +11 -2
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +29 -28
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/custom-code/custom-code.jsx +1 -1
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/embed.jsx +1 -1
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +3 -247
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/fragment/fragment.jsx +1 -1
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +3 -1
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +3 -1
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +4 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -1
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +3 -1
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -2
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +34 -59
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -1
- package/src/blocks/video/component-info.js +74 -96
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +68 -81
- package/src/components/{render-block → block/components}/block-styles.jsx +19 -18
- package/src/components/block/components/block-wrapper.jsx +58 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +72 -0
- package/src/components/block/components/interactive-element.jsx +37 -0
- package/src/components/{render-block/render-repeated-block.jsx → block/components/repeated-block.jsx} +10 -6
- package/src/components/blocks/blocks-wrapper.jsx +74 -0
- package/src/components/blocks/blocks.jsx +51 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +81 -165
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +7 -7
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +141 -0
- package/src/components/content/content.types.js +0 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/content-variants/content-variants.jsx +120 -0
- package/src/components/{render-content-variants → content-variants}/helpers.js +58 -41
- package/src/components/inlined-script.jsx +18 -0
- package/src/components/{render-inlined-styles.jsx → inlined-styles.jsx} +3 -3
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +2 -0
- package/src/helpers/ab-tests.js +46 -26
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +1 -1
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/types/enforced-partials.js +0 -0
- package/dist/blocks/BaseText.d.ts +0 -6
- package/dist/blocks/button/button.d.ts +0 -9
- package/dist/blocks/button/component-info.d.ts +0 -2
- package/dist/blocks/columns/columns.d.ts +0 -16
- package/dist/blocks/columns/component-info.d.ts +0 -2
- package/dist/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/blocks/custom-code/custom-code.d.ts +0 -5
- package/dist/blocks/embed/component-info.d.ts +0 -2
- package/dist/blocks/embed/embed.d.ts +0 -5
- package/dist/blocks/embed/helpers.d.ts +0 -1
- package/dist/blocks/form/component-info.d.ts +0 -2
- package/dist/blocks/form/form.d.ts +0 -28
- package/dist/blocks/fragment/component-info.d.ts +0 -2
- package/dist/blocks/fragment/fragment.d.ts +0 -8
- package/dist/blocks/image/component-info.d.ts +0 -2
- package/dist/blocks/image/image.d.ts +0 -17
- package/dist/blocks/image/image.helpers.d.ts +0 -1
- package/dist/blocks/img/component-info.d.ts +0 -2
- package/dist/blocks/img/img.d.ts +0 -11
- package/dist/blocks/input/component-info.d.ts +0 -2
- package/dist/blocks/input/input.d.ts +0 -12
- package/dist/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/blocks/raw-text/raw-text.d.ts +0 -5
- package/dist/blocks/section/component-info.d.ts +0 -2
- package/dist/blocks/section/section.d.ts +0 -9
- package/dist/blocks/select/component-info.d.ts +0 -2
- package/dist/blocks/select/select.d.ts +0 -13
- package/dist/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/blocks/submit-button/submit-button.d.ts +0 -7
- package/dist/blocks/symbol/component-info.d.ts +0 -2
- package/dist/blocks/symbol/symbol.d.ts +0 -21
- package/dist/blocks/text/component-info.d.ts +0 -2
- package/dist/blocks/text/text.d.ts +0 -7
- package/dist/blocks/textarea/component-info.d.ts +0 -2
- package/dist/blocks/textarea/textarea.d.ts +0 -10
- package/dist/blocks/util.d.ts +0 -4
- package/dist/blocks/video/component-info.d.ts +0 -2
- package/dist/blocks/video/video.d.ts +0 -31
- package/dist/components/render-block/block-styles.d.ts +0 -9
- package/dist/components/render-block/render-block.d.ts +0 -9
- package/dist/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/components/render-block/render-component.d.ts +0 -17
- package/dist/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/components/render-block/types.d.ts +0 -6
- package/dist/components/render-blocks.d.ts +0 -10
- package/dist/components/render-content/builder-editing.d.ts +0 -3
- package/dist/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/components/render-content/components/render-styles.helpers.d.ts +0 -15
- package/dist/components/render-content/index.d.ts +0 -1
- package/dist/components/render-content/render-content.d.ts +0 -4
- package/dist/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/components/render-content/render-content.types.d.ts +0 -38
- package/dist/components/render-content/wrap-component-ref.d.ts +0 -6
- package/dist/components/render-content-variants/helpers.d.ts +0 -17
- package/dist/components/render-content-variants/render-content-variants.d.ts +0 -5
- package/dist/components/render-inlined-styles.d.ts +0 -7
- package/dist/constants/builder-registered-components.d.ts +0 -6
- package/dist/constants/device-sizes.d.ts +0 -13
- package/dist/constants/sdk-version.d.ts +0 -1
- package/dist/constants/target.d.ts +0 -3
- package/dist/context/builder.context.d.ts +0 -3
- package/dist/context/types.d.ts +0 -35
- package/dist/functions/camel-to-kebab-case.d.ts +0 -1
- package/dist/functions/evaluate.d.ts +0 -7
- package/dist/functions/evaluate.test.d.ts +0 -1
- package/dist/functions/event-handler-name.d.ts +0 -1
- package/dist/functions/extract-text-styles.d.ts +0 -4
- package/dist/functions/fast-clone.d.ts +0 -4
- package/dist/functions/get-block-actions-handler.d.ts +0 -8
- package/dist/functions/get-block-actions.d.ts +0 -9
- package/dist/functions/get-block-component-options.d.ts +0 -2
- package/dist/functions/get-block-properties.d.ts +0 -2
- package/dist/functions/get-builder-search-params/fn.test.d.ts +0 -1
- package/dist/functions/get-builder-search-params/index.d.ts +0 -12
- package/dist/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/functions/get-content/generate-content-url.test.d.ts +0 -1
- package/dist/functions/get-content/index.d.ts +0 -16
- package/dist/functions/get-content/types.d.ts +0 -51
- package/dist/functions/get-fetch.d.ts +0 -1
- package/dist/functions/get-processed-block.d.ts +0 -10
- package/dist/functions/get-processed-block.test.d.ts +0 -1
- package/dist/functions/get-react-native-block-styles.d.ts +0 -7
- package/dist/functions/if-target.d.ts +0 -7
- package/dist/functions/is-browser.d.ts +0 -1
- package/dist/functions/is-editing.d.ts +0 -1
- package/dist/functions/is-iframe.d.ts +0 -1
- package/dist/functions/is-previewing.d.ts +0 -1
- package/dist/functions/on-change.d.ts +0 -7
- package/dist/functions/on-change.test.d.ts +0 -1
- package/dist/functions/register-component.d.ts +0 -14
- package/dist/functions/register.d.ts +0 -16
- package/dist/functions/sanitize-react-native-block-styles.d.ts +0 -3
- package/dist/functions/set-editor-settings.d.ts +0 -4
- package/dist/functions/set.d.ts +0 -7
- package/dist/functions/set.test.d.ts +0 -1
- package/dist/functions/track/helpers.d.ts +0 -5
- package/dist/functions/track/index.d.ts +0 -51
- package/dist/functions/track/interaction.d.ts +0 -13
- package/dist/functions/transform-block-properties.d.ts +0 -3
- package/dist/functions/transform-block.d.ts +0 -2
- package/dist/helpers/ab-tests.d.ts +0 -9
- package/dist/helpers/canTrack.d.ts +0 -1
- package/dist/helpers/cookie.d.ts +0 -9
- package/dist/helpers/css.d.ts +0 -7
- package/dist/helpers/flatten.d.ts +0 -6
- package/dist/helpers/localStorage.d.ts +0 -9
- package/dist/helpers/logger.d.ts +0 -6
- package/dist/helpers/nullable.d.ts +0 -2
- package/dist/helpers/sessionId.d.ts +0 -6
- package/dist/helpers/time.d.ts +0 -1
- package/dist/helpers/url.d.ts +0 -6
- package/dist/helpers/url.test.d.ts +0 -1
- package/dist/helpers/uuid.d.ts +0 -8
- package/dist/helpers/visitorId.d.ts +0 -6
- package/dist/index-helpers/blocks-exports.d.ts +0 -8
- package/dist/index-helpers/top-of-file.d.ts +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/scripts/init-editing.d.ts +0 -6
- package/dist/types/api-version.d.ts +0 -2
- package/dist/types/builder-block.d.ts +0 -66
- package/dist/types/builder-content.d.ts +0 -44
- package/dist/types/can-track.d.ts +0 -3
- package/dist/types/components.d.ts +0 -105
- package/dist/types/deep-partial.d.ts +0 -3
- package/dist/types/element.d.ts +0 -59
- package/dist/types/input.d.ts +0 -121
- package/dist/types/targets.d.ts +0 -3
- package/dist/types/typescript.d.ts +0 -5
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -55
- package/src/components/render-blocks.jsx +0 -101
- package/src/components/render-content/builder-editing.jsx +0 -16
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/components/render-content-variants/render-content-variants.jsx +0 -101
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content-variants/content-variants.types.js} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFontCss = exports.getCss = void 0;
|
|
4
|
+
const getCssFromFont = font => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
7
|
+
const name = family.split(",")[0];
|
|
8
|
+
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
9
|
+
let str = "";
|
|
10
|
+
if (url && family && name) {
|
|
11
|
+
str += `
|
|
12
|
+
@font-face {
|
|
13
|
+
font-family: "${family}";
|
|
14
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
15
|
+
font-display: fallback;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
}
|
|
18
|
+
`.trim();
|
|
19
|
+
}
|
|
20
|
+
if (font.files) {
|
|
21
|
+
for (const weight in font.files) {
|
|
22
|
+
const isNumber = String(Number(weight)) === weight;
|
|
23
|
+
if (!isNumber) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const weightUrl = font.files[weight];
|
|
27
|
+
if (weightUrl && weightUrl !== url) {
|
|
28
|
+
str += `
|
|
29
|
+
@font-face {
|
|
30
|
+
font-family: "${family}";
|
|
31
|
+
src: url('${weightUrl}') format('woff2');
|
|
32
|
+
font-display: fallback;
|
|
33
|
+
font-weight: ${weight};
|
|
34
|
+
}
|
|
35
|
+
`.trim();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return str;
|
|
40
|
+
};
|
|
41
|
+
const getFontCss = ({ customFonts }) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return ((_a = customFonts == null ? void 0 : customFonts.map(font => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
44
|
+
};
|
|
45
|
+
exports.getFontCss = getFontCss;
|
|
46
|
+
const getCss = ({ cssCode, contentId }) => {
|
|
47
|
+
if (!cssCode) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
if (!contentId) {
|
|
51
|
+
return cssCode;
|
|
52
|
+
}
|
|
53
|
+
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
54
|
+
};
|
|
55
|
+
exports.getCss = getCss;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const react_native_1 = require("react-native");
|
|
32
|
+
const react_1 = require("react");
|
|
33
|
+
const inlined_styles_1 = __importDefault(require("../../inlined-styles"));
|
|
34
|
+
const styles_helpers_js_1 = require("./styles.helpers.js");
|
|
35
|
+
const styles_helpers_js_2 = require("./styles.helpers.js");
|
|
36
|
+
function ContentStyles(props) {
|
|
37
|
+
const [injectedStyles, setInjectedStyles] = (0, react_1.useState)(() => `
|
|
38
|
+
${(0, styles_helpers_js_1.getCss)({
|
|
39
|
+
cssCode: props.cssCode,
|
|
40
|
+
contentId: props.contentId,
|
|
41
|
+
})}
|
|
42
|
+
${(0, styles_helpers_js_2.getFontCss)({
|
|
43
|
+
customFonts: props.customFonts,
|
|
44
|
+
})}
|
|
45
|
+
|
|
46
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
47
|
+
margin: 0;
|
|
48
|
+
}
|
|
49
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
50
|
+
color: inherit;
|
|
51
|
+
line-height: inherit;
|
|
52
|
+
letter-spacing: inherit;
|
|
53
|
+
font-weight: inherit;
|
|
54
|
+
font-size: inherit;
|
|
55
|
+
text-align: inherit;
|
|
56
|
+
font-family: inherit;
|
|
57
|
+
}
|
|
58
|
+
`.trim());
|
|
59
|
+
return React.createElement(inlined_styles_1.default, { styles: injectedStyles });
|
|
60
|
+
}
|
|
61
|
+
exports.default = ContentStyles;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContextStateInitialValue = exports.getContentInitialValue = void 0;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value
|
|
15
|
+
}) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
const defaultValues = {};
|
|
31
|
+
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach(input => {
|
|
32
|
+
var _a2;
|
|
33
|
+
if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
|
|
34
|
+
defaultValues[input.name] = input.defaultValue;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const stateToUse = __spreadValues(__spreadValues(__spreadValues({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
38
|
+
locale
|
|
39
|
+
} : {});
|
|
40
|
+
return __spreadValues(__spreadValues({}, defaultValues), stateToUse);
|
|
41
|
+
};
|
|
42
|
+
exports.getContextStateInitialValue = getContextStateInitialValue;
|
|
43
|
+
const getContentInitialValue = ({ content, data }) => {
|
|
44
|
+
return !content ? void 0 : __spreadProps(__spreadValues({}, content), {
|
|
45
|
+
data: __spreadValues(__spreadValues({}, content == null ? void 0 : content.data), data),
|
|
46
|
+
meta: content == null ? void 0 : content.meta
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.getContentInitialValue = getContentInitialValue;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const react_native_1 = require("react-native");
|
|
32
|
+
const react_1 = require("react");
|
|
33
|
+
const builder_registered_components_js_1 = require("../../constants/builder-registered-components.js");
|
|
34
|
+
const register_component_js_1 = require("../../functions/register-component.js");
|
|
35
|
+
const blocks_1 = __importDefault(require("../blocks/blocks"));
|
|
36
|
+
const styles_1 = __importDefault(require("./components/styles"));
|
|
37
|
+
const content_helpers_js_1 = require("./content.helpers.js");
|
|
38
|
+
const target_js_1 = require("../../constants/target.js");
|
|
39
|
+
const helpers_js_1 = require("../content-variants/helpers.js");
|
|
40
|
+
const enable_editor_1 = __importDefault(require("./components/enable-editor"));
|
|
41
|
+
const inlined_script_1 = __importDefault(require("../inlined-script"));
|
|
42
|
+
const wrap_component_ref_js_1 = require("./wrap-component-ref.js");
|
|
43
|
+
function ContentComponent(props) {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
45
|
+
const [scriptStr, setScriptStr] = (0, react_1.useState)(() => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return (0, helpers_js_1.getRenderContentScriptString)({
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
49
|
+
variationId: (_a = props.content) === null || _a === void 0 ? void 0 : _a.testVariationId,
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
51
|
+
contentId: (_b = props.content) === null || _b === void 0 ? void 0 : _b.id,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
function contentSetState(newRootState) {
|
|
55
|
+
builderContextSignal.rootState = newRootState;
|
|
56
|
+
}
|
|
57
|
+
const [registeredComponents, setRegisteredComponents] = (0, react_1.useState)(() => [
|
|
58
|
+
...(0, builder_registered_components_js_1.getDefaultRegisteredComponents)(),
|
|
59
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
60
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
61
|
+
// existing usage.
|
|
62
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
63
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
64
|
+
...register_component_js_1.components,
|
|
65
|
+
...(props.customComponents || []),
|
|
66
|
+
].reduce((acc, { component, ...info }) => ({
|
|
67
|
+
...acc,
|
|
68
|
+
[info.name]: {
|
|
69
|
+
component: component,
|
|
70
|
+
...(0, register_component_js_1.serializeComponentInfo)(info),
|
|
71
|
+
},
|
|
72
|
+
}), {}));
|
|
73
|
+
const [builderContextSignal, setBuilderContextSignal] = (0, react_1.useState)(() => ({
|
|
74
|
+
content: (0, content_helpers_js_1.getContentInitialValue)({
|
|
75
|
+
content: props.content,
|
|
76
|
+
data: props.data,
|
|
77
|
+
}),
|
|
78
|
+
localState: undefined,
|
|
79
|
+
rootState: (0, content_helpers_js_1.getContextStateInitialValue)({
|
|
80
|
+
content: props.content,
|
|
81
|
+
data: props.data,
|
|
82
|
+
locale: props.locale,
|
|
83
|
+
}),
|
|
84
|
+
rootSetState: contentSetState,
|
|
85
|
+
context: props.context || {},
|
|
86
|
+
apiKey: props.apiKey,
|
|
87
|
+
apiVersion: props.apiVersion,
|
|
88
|
+
componentInfos: [
|
|
89
|
+
...(0, builder_registered_components_js_1.getDefaultRegisteredComponents)(),
|
|
90
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
91
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
92
|
+
// existing usage.
|
|
93
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
94
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
95
|
+
...register_component_js_1.components,
|
|
96
|
+
...(props.customComponents || []),
|
|
97
|
+
].reduce((acc, { component: _, ...info }) => ({
|
|
98
|
+
...acc,
|
|
99
|
+
[info.name]: (0, register_component_js_1.serializeComponentInfo)(info),
|
|
100
|
+
}), {}),
|
|
101
|
+
inheritedStyles: {},
|
|
102
|
+
}));
|
|
103
|
+
return (React.createElement(enable_editor_1.default, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
|
|
104
|
+
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
105
|
+
React.createElement(inlined_script_1.default, { scriptStr: scriptStr }))) : null,
|
|
106
|
+
target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
107
|
+
React.createElement(styles_1.default, { contentId: (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.id, cssCode: (_c = (_b = builderContextSignal.content) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.cssCode, customFonts: (_e = (_d = builderContextSignal.content) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.customFonts }))) : null,
|
|
108
|
+
React.createElement(blocks_1.default, { blocks: (_g = (_f = builderContextSignal.content) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.blocks, context: builderContextSignal, registeredComponents: registeredComponents })));
|
|
109
|
+
}
|
|
110
|
+
exports.default = ContentComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const content_1 = __importDefault(require("./content"));
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return content_1.default; } });
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const react_native_1 = require("react-native");
|
|
32
|
+
const react_1 = require("react");
|
|
33
|
+
const helpers_js_1 = require("./helpers.js");
|
|
34
|
+
const content_1 = __importDefault(require("../content/content"));
|
|
35
|
+
const canTrack_js_1 = require("../../helpers/canTrack.js");
|
|
36
|
+
const inlined_styles_1 = __importDefault(require("../inlined-styles"));
|
|
37
|
+
const ab_tests_js_1 = require("../../helpers/ab-tests.js");
|
|
38
|
+
const inlined_script_1 = __importDefault(require("../inlined-script"));
|
|
39
|
+
const target_js_1 = require("../../constants/target.js");
|
|
40
|
+
function ContentVariants(props) {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const [shouldRenderVariants, setShouldRenderVariants] = (0, react_1.useState)(() => (0, helpers_js_1.checkShouldRunVariants)({
|
|
43
|
+
canTrack: (0, canTrack_js_1.getDefaultCanTrack)(props.canTrack),
|
|
44
|
+
content: props.content,
|
|
45
|
+
}));
|
|
46
|
+
function variantScriptStr() {
|
|
47
|
+
var _a;
|
|
48
|
+
return (0, helpers_js_1.getVariantsScriptString)((0, helpers_js_1.getVariants)(props.content).map((value) => ({
|
|
49
|
+
id: value.testVariationId,
|
|
50
|
+
testRatio: value.testRatio,
|
|
51
|
+
})), ((_a = props.content) === null || _a === void 0 ? void 0 : _a.id) || "");
|
|
52
|
+
}
|
|
53
|
+
function hideVariantsStyleString() {
|
|
54
|
+
return (0, helpers_js_1.getVariants)(props.content)
|
|
55
|
+
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
56
|
+
.join("");
|
|
57
|
+
}
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
/**
|
|
60
|
+
* We unmount the non-winning variants post-hydration in Vue.
|
|
61
|
+
*/
|
|
62
|
+
}, []);
|
|
63
|
+
return (React.createElement(React.Fragment, null,
|
|
64
|
+
!props.__isNestedRender && target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
65
|
+
React.createElement(inlined_script_1.default, { scriptStr: (0, helpers_js_1.getScriptString)() }))) : null,
|
|
66
|
+
shouldRenderVariants ? (React.createElement(React.Fragment, null,
|
|
67
|
+
React.createElement(inlined_styles_1.default, { id: `variants-styles-${(_a = props.content) === null || _a === void 0 ? void 0 : _a.id}`, styles: hideVariantsStyleString() }),
|
|
68
|
+
React.createElement(inlined_script_1.default, { scriptStr: variantScriptStr() }), (_b = (0, helpers_js_1.getVariants)(props.content)) === null || _b === void 0 ? void 0 :
|
|
69
|
+
_b.map((variant) => (React.createElement(content_1.default, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
|
|
70
|
+
React.createElement(content_1.default, { content: shouldRenderVariants
|
|
71
|
+
? props.content
|
|
72
|
+
: (0, ab_tests_js_1.handleABTestingSync)({
|
|
73
|
+
item: props.content,
|
|
74
|
+
canTrack: (0, canTrack_js_1.getDefaultCanTrack)(props.canTrack),
|
|
75
|
+
}), classNameProp: `variant-${(_c = props.content) === null || _c === void 0 ? void 0 : _c.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
|
|
76
|
+
}
|
|
77
|
+
exports.default = ContentVariants;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVariantsScriptString = exports.getVariants = exports.getScriptString = exports.getRenderContentScriptString = exports.checkShouldRunVariants = void 0;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value
|
|
15
|
+
}) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
28
|
+
const target_js_1 = require("../../constants/target.js");
|
|
29
|
+
const is_browser_js_1 = require("../../functions/is-browser.js");
|
|
30
|
+
const getVariants = content => Object.values((content == null ? void 0 : content.variations) || {}).map(variant => __spreadProps(__spreadValues({}, variant), {
|
|
31
|
+
testVariationId: variant.id,
|
|
32
|
+
id: content == null ? void 0 : content.id
|
|
33
|
+
}));
|
|
34
|
+
exports.getVariants = getVariants;
|
|
35
|
+
const checkShouldRunVariants = ({ canTrack, content }) => {
|
|
36
|
+
const hasVariants = getVariants(content).length > 0;
|
|
37
|
+
if (target_js_1.TARGET === "reactNative")
|
|
38
|
+
return false;
|
|
39
|
+
if (!hasVariants)
|
|
40
|
+
return false;
|
|
41
|
+
if (!canTrack)
|
|
42
|
+
return false;
|
|
43
|
+
if (target_js_1.TARGET === "vue2" || target_js_1.TARGET === "vue3")
|
|
44
|
+
return true;
|
|
45
|
+
if ((0, is_browser_js_1.isBrowser)())
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
exports.checkShouldRunVariants = checkShouldRunVariants;
|
|
50
|
+
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
51
|
+
var _a;
|
|
52
|
+
function getAndSetVariantId() {
|
|
53
|
+
function setCookie(name, value, days) {
|
|
54
|
+
let expires = "";
|
|
55
|
+
if (days) {
|
|
56
|
+
const date = new Date();
|
|
57
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
58
|
+
expires = "; expires=" + date.toUTCString();
|
|
59
|
+
}
|
|
60
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
61
|
+
}
|
|
62
|
+
function getCookie(name) {
|
|
63
|
+
const nameEQ = name + "=";
|
|
64
|
+
const ca = document.cookie.split(";");
|
|
65
|
+
for (let i = 0; i < ca.length; i++) {
|
|
66
|
+
let c = ca[i];
|
|
67
|
+
while (c.charAt(0) === " ")
|
|
68
|
+
c = c.substring(1, c.length);
|
|
69
|
+
if (c.indexOf(nameEQ) === 0)
|
|
70
|
+
return c.substring(nameEQ.length, c.length);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const cookieName = `builder.tests.${contentId}`;
|
|
75
|
+
const variantInCookie = getCookie(cookieName);
|
|
76
|
+
const availableIDs = variants.map(vr => vr.id).concat(contentId);
|
|
77
|
+
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
78
|
+
return variantInCookie;
|
|
79
|
+
}
|
|
80
|
+
let n = 0;
|
|
81
|
+
const random = Math.random();
|
|
82
|
+
for (let i = 0; i < variants.length; i++) {
|
|
83
|
+
const variant = variants[i];
|
|
84
|
+
const testRatio = variant.testRatio;
|
|
85
|
+
n += testRatio;
|
|
86
|
+
if (random < n) {
|
|
87
|
+
setCookie(cookieName, variant.id);
|
|
88
|
+
return variant.id;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setCookie(cookieName, contentId);
|
|
92
|
+
return contentId;
|
|
93
|
+
}
|
|
94
|
+
const winningVariantId = getAndSetVariantId();
|
|
95
|
+
const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
|
|
96
|
+
if (isHydrationTarget2) {
|
|
97
|
+
styleEl.remove();
|
|
98
|
+
const thisScriptEl = document.currentScript;
|
|
99
|
+
thisScriptEl == null ? void 0 : thisScriptEl.remove();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const newStyleStr = variants.concat({
|
|
103
|
+
id: contentId
|
|
104
|
+
}).filter(variant => variant.id !== winningVariantId).map(value => {
|
|
105
|
+
return `.variant-${value.id} { display: none; }
|
|
106
|
+
`;
|
|
107
|
+
}).join("");
|
|
108
|
+
styleEl.innerHTML = newStyleStr;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
112
|
+
var _a;
|
|
113
|
+
if (!navigator.cookieEnabled) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
function getCookie(name) {
|
|
117
|
+
const nameEQ = name + "=";
|
|
118
|
+
const ca = document.cookie.split(";");
|
|
119
|
+
for (let i = 0; i < ca.length; i++) {
|
|
120
|
+
let c = ca[i];
|
|
121
|
+
while (c.charAt(0) === " ")
|
|
122
|
+
c = c.substring(1, c.length);
|
|
123
|
+
if (c.indexOf(nameEQ) === 0)
|
|
124
|
+
return c.substring(nameEQ.length, c.length);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const cookieName = `builder.tests.${defaultContentId}`;
|
|
129
|
+
const variantId = getCookie(cookieName);
|
|
130
|
+
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
131
|
+
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
132
|
+
if (variantId === variantContentId) {
|
|
133
|
+
if (variantIsDefaultContent) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
137
|
+
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
if (variantIsDefaultContent) {
|
|
141
|
+
if (isHydrationTarget2) {
|
|
142
|
+
parentDiv == null ? void 0 : parentDiv.remove();
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
146
|
+
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const getIsHydrationTarget = target => target === "react" || target === "reactNative";
|
|
154
|
+
const isHydrationTarget = getIsHydrationTarget(target_js_1.TARGET);
|
|
155
|
+
const AB_TEST_FN_NAME = "builderIoAbTest";
|
|
156
|
+
const CONTENT_FN_NAME = "builderIoRenderContent";
|
|
157
|
+
const getScriptString = () => {
|
|
158
|
+
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
159
|
+
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
160
|
+
return `
|
|
161
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
162
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
163
|
+
`;
|
|
164
|
+
};
|
|
165
|
+
exports.getScriptString = getScriptString;
|
|
166
|
+
const getVariantsScriptString = (variants, contentId) => {
|
|
167
|
+
return `
|
|
168
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
169
|
+
};
|
|
170
|
+
exports.getVariantsScriptString = getVariantsScriptString;
|
|
171
|
+
const getRenderContentScriptString = ({ contentId, variationId }) => {
|
|
172
|
+
return `
|
|
173
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
174
|
+
};
|
|
175
|
+
exports.getRenderContentScriptString = getRenderContentScriptString;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const react_native_1 = require("react-native");
|
|
29
|
+
function InlinedScript(props) {
|
|
30
|
+
return (React.createElement(react_native_1.View, { dangerouslySetInnerHTML: { __html: props.scriptStr }, id: props.id }));
|
|
31
|
+
}
|
|
32
|
+
exports.default = InlinedScript;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
"use client";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
const React = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
|
-
function
|
|
29
|
+
function InlinedStyles(props) {
|
|
30
30
|
return (React.createElement(react_native_1.View, { dangerouslySetInnerHTML: { __html: props.styles }, id: props.id }));
|
|
31
31
|
}
|
|
32
|
-
exports.default =
|
|
32
|
+
exports.default = InlinedStyles;
|
|
@@ -34,7 +34,7 @@ const target_js_1 = require("../../constants/target.js");
|
|
|
34
34
|
const get_processed_block_js_1 = require("../../functions/get-processed-block.js");
|
|
35
35
|
const css_js_1 = require("../../helpers/css.js");
|
|
36
36
|
const nullable_js_1 = require("../../helpers/nullable.js");
|
|
37
|
-
const
|
|
37
|
+
const inlined_styles_1 = __importDefault(require("../inlined-styles"));
|
|
38
38
|
function BlockStyles(props) {
|
|
39
39
|
function useBlock() {
|
|
40
40
|
return (0, get_processed_block_js_1.getProcessedBlock)({
|
|
@@ -91,6 +91,6 @@ function BlockStyles(props) {
|
|
|
91
91
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
92
92
|
}
|
|
93
93
|
return (React.createElement(React.Fragment, null, target_js_1.TARGET !== "reactNative" && css() && canShowBlock() ? (React.createElement(React.Fragment, null,
|
|
94
|
-
React.createElement(
|
|
94
|
+
React.createElement(inlined_styles_1.default, { styles: css() }))) : null));
|
|
95
95
|
}
|
|
96
96
|
exports.default = BlockStyles;
|
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
const React = __importStar(require("react"));
|
|
31
31
|
const react_native_1 = require("react-native");
|
|
32
32
|
const react_1 = require("react");
|
|
33
|
-
const
|
|
33
|
+
const inlined_styles_1 = __importDefault(require("../../inlined-styles"));
|
|
34
34
|
const render_styles_helpers_1 = require("./render-styles.helpers");
|
|
35
35
|
const render_styles_helpers_2 = require("./render-styles.helpers");
|
|
36
36
|
function RenderContentStyles(props) {
|
|
@@ -56,6 +56,6 @@ ${(0, render_styles_helpers_2.getFontCss)({
|
|
|
56
56
|
font-family: inherit;
|
|
57
57
|
}
|
|
58
58
|
`.trim());
|
|
59
|
-
return React.createElement(
|
|
59
|
+
return React.createElement(inlined_styles_1.default, { styles: injectedStyles });
|
|
60
60
|
}
|
|
61
61
|
exports.default = RenderContentStyles;
|