@builder.io/sdk-react 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/{sdk/blocks → blocks}/BaseText.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/BaseText.js +2 -2
- package/dist/{sdk/blocks → blocks}/button/button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/button/button.js +3 -5
- package/dist/blocks/button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/button/component-info.js +9 -13
- package/dist/blocks/columns/columns.d.ts +16 -0
- package/dist/{sdk/blocks → blocks}/columns/columns.js +15 -21
- package/dist/blocks/columns/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/columns/component-info.js +62 -83
- package/dist/blocks/custom-code/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/custom-code/component-info.js +7 -11
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/embed/component-info.js +8 -15
- package/dist/{sdk/blocks → blocks}/embed/embed.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -0
- package/dist/blocks/form/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/form/component-info.js +94 -129
- package/dist/blocks/form/form.d.ts +2 -0
- package/dist/blocks/form/form.js +6 -0
- package/dist/blocks/fragment/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/fragment/component-info.js +1 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.d.ts +13 -0
- package/dist/blocks/helpers.js +40 -0
- package/dist/blocks/image/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/image/component-info.js +33 -63
- package/dist/{sdk/blocks → blocks}/image/image.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/image/image.helpers.js +2 -11
- package/dist/{sdk/blocks → blocks}/image/image.js +7 -7
- package/dist/blocks/img/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/img/component-info.js +4 -6
- package/dist/{sdk/blocks → blocks}/img/img.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/img/img.js +1 -1
- package/dist/blocks/input/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/input/component-info.js +15 -40
- package/dist/{sdk/blocks → blocks}/input/input.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/input/input.js +1 -1
- package/dist/blocks/raw-text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/raw-text/component-info.js +3 -5
- package/dist/{sdk/blocks → blocks}/raw-text/raw-text.d.ts +0 -1
- package/dist/blocks/raw-text/raw-text.js +6 -0
- package/dist/blocks/section/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/section/component-info.js +13 -18
- package/dist/{sdk/blocks → blocks}/section/section.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/section/section.js +1 -1
- package/dist/blocks/select/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/select/component-info.js +22 -34
- package/dist/{sdk/blocks → blocks}/select/select.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/select/select.js +1 -1
- package/dist/blocks/submit-button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/submit-button/component-info.js +5 -7
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.js +1 -1
- package/dist/blocks/symbol/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/symbol/component-info.js +12 -17
- package/dist/blocks/symbol/symbol.d.ts +23 -0
- package/dist/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/dist/blocks/symbol/symbol.helpers.js +31 -0
- package/dist/blocks/symbol/symbol.js +45 -0
- package/dist/blocks/text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/text/component-info.js +6 -7
- package/dist/{sdk/blocks → blocks}/text/text.d.ts +1 -2
- package/dist/{sdk/blocks → blocks}/text/text.js +2 -2
- package/dist/blocks/textarea/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/textarea/component-info.js +13 -19
- package/dist/{sdk/blocks → blocks}/textarea/textarea.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/textarea/textarea.js +1 -1
- package/dist/blocks/video/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/video/component-info.js +35 -55
- package/dist/{sdk/blocks → blocks}/video/video.d.ts +1 -1
- package/dist/{sdk/blocks → blocks}/video/video.js +2 -2
- package/dist/components/block/block.d.ts +9 -0
- package/dist/components/block/block.helpers.d.ts +13 -0
- package/dist/{sdk/components/render-block/render-block.helpers.js → components/block/block.helpers.js} +12 -29
- package/dist/components/block/block.js +94 -0
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.d.ts +2 -3
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.js +23 -24
- package/dist/components/block/components/block-wrapper.d.ts +16 -0
- package/dist/components/block/components/block-wrapper.js +36 -0
- package/dist/components/block/components/component-ref/component-ref.d.ts +3 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/dist/components/block/components/component-ref/component-ref.js +23 -0
- package/dist/components/block/components/interactive-element.d.ts +11 -0
- package/dist/components/block/components/interactive-element.js +20 -0
- package/dist/components/block/components/repeated-block.d.ts +9 -0
- package/dist/components/block/components/repeated-block.js +11 -0
- package/dist/components/blocks/blocks-wrapper.d.ts +10 -0
- package/dist/{sdk/components/render-blocks.js → components/blocks/blocks-wrapper.js} +6 -13
- package/dist/components/blocks/blocks.d.ts +8 -0
- package/dist/components/blocks/blocks.js +11 -0
- package/dist/components/content/components/enable-editor.d.ts +9 -0
- package/dist/{sdk/components/render-content/render-content.js → components/content/components/enable-editor.js} +69 -140
- package/dist/components/content/components/styles.d.ts +8 -0
- package/dist/{sdk/components/render-content/components/render-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
- package/dist/{sdk/components/render-content/components/render-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
- package/dist/{sdk/components/render-content/components/render-styles.js → components/content/components/styles.js} +7 -7
- package/dist/components/content/content.d.ts +3 -0
- package/dist/components/content/content.helpers.d.ts +7 -0
- package/dist/components/content/content.helpers.js +30 -0
- package/dist/components/content/content.js +79 -0
- package/dist/components/content/content.types.d.ts +24 -0
- package/dist/components/content/index.d.ts +1 -0
- package/dist/components/content/index.js +1 -0
- package/dist/components/content-variants/content-variants.d.ts +9 -0
- package/dist/components/content-variants/content-variants.js +46 -0
- package/dist/components/content-variants/content-variants.types.d.ts +20 -0
- package/dist/components/content-variants/helpers.d.ts +41 -0
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +46 -41
- package/dist/components/inlined-script.d.ts +6 -0
- package/dist/components/inlined-script.js +6 -0
- package/dist/components/inlined-styles.d.ts +6 -0
- package/dist/{sdk/components/render-inlined-styles.js → components/inlined-styles.js} +3 -3
- package/dist/{sdk/constants → constants}/builder-registered-components.js +34 -13
- package/dist/{sdk/constants → constants}/device-sizes.js +9 -8
- package/dist/constants/sdk-version.d.ts +1 -0
- package/dist/constants/sdk-version.js +1 -0
- package/dist/{sdk/context → context}/builder.context.js +1 -1
- package/dist/{sdk/context → context}/types.d.ts +1 -1
- package/dist/functions/acorn_interpreter.d.ts +1 -0
- package/dist/functions/acorn_interpreter.js +3027 -0
- package/dist/functions/apply-patch-with-mutation.d.ts +10 -0
- package/dist/functions/apply-patch-with-mutation.js +54 -0
- package/dist/functions/apply-patch-with-mutation.test.js +53 -0
- package/dist/functions/evaluate/acorn.d.ts +0 -0
- package/dist/functions/evaluate/acorn.js +2432 -0
- package/dist/{sdk/functions → functions/evaluate}/evaluate.d.ts +5 -2
- package/dist/functions/evaluate/evaluate.js +70 -0
- package/dist/functions/evaluate/evaluate.test.js +23 -0
- package/dist/functions/evaluate/index.d.ts +1 -0
- package/dist/functions/evaluate/index.js +1 -0
- package/dist/functions/evaluate/interpreter.d.ts +2 -0
- package/dist/functions/evaluate/interpreter.js +3853 -0
- package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/dist/functions/evaluate/non-node-runtime.js +84 -0
- package/dist/functions/evaluate/types.d.ts +10 -0
- package/dist/functions/evaluate.d.ts +23 -0
- package/dist/{sdk/functions → functions}/evaluate.js +28 -9
- package/dist/{sdk/functions → functions}/evaluate.test.js +11 -5
- package/dist/{sdk/functions → functions}/extract-text-styles.js +2 -14
- package/dist/{sdk/functions → functions}/get-block-actions-handler.js +3 -3
- package/dist/{sdk/functions → functions}/get-block-actions.d.ts +1 -0
- package/dist/functions/get-block-actions.js +28 -0
- package/dist/{sdk/functions → functions}/get-block-component-options.js +1 -1
- package/dist/functions/get-block-properties.d.ts +6 -0
- package/dist/{sdk/functions → functions}/get-block-properties.js +15 -9
- package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.js +1 -1
- package/dist/{sdk/functions → functions}/get-builder-search-params/index.js +3 -7
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.js +7 -5
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.js +31 -17
- package/dist/{sdk/functions → functions}/get-content/index.d.ts +2 -6
- package/dist/{sdk/functions → functions}/get-content/index.js +26 -6
- package/dist/functions/get-content/processCookies.d.ts +2 -0
- package/dist/functions/get-content/processCookies.js +3 -0
- package/dist/{sdk/functions → functions}/get-processed-block.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-processed-block.js +11 -7
- package/dist/{sdk/functions → functions}/get-processed-block.test.js +8 -6
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.js +2 -2
- package/dist/{sdk/functions → functions}/if-target.d.ts +1 -1
- package/dist/{sdk/functions → functions}/if-target.js +1 -1
- package/dist/functions/is-editing.js +5 -0
- package/dist/functions/is-non-node-server.d.ts +4 -0
- package/dist/functions/is-non-node-server.js +8 -0
- package/dist/{sdk/functions → functions}/on-change.js +1 -1
- package/dist/{sdk/functions → functions}/on-change.test.js +13 -3
- package/dist/{sdk/functions → functions}/register-component.d.ts +2 -1
- package/dist/functions/register-component.js +38 -0
- package/dist/{sdk/functions → functions}/register.js +2 -2
- package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.js +13 -5
- package/dist/{sdk/functions → functions}/set-editor-settings.js +1 -1
- package/dist/functions/set.js +14 -0
- package/dist/{sdk/functions → functions}/set.test.js +9 -3
- package/dist/{sdk/functions → functions}/track/helpers.js +6 -11
- package/dist/{sdk/functions → functions}/track/index.js +26 -14
- package/dist/{sdk/functions → functions}/track/interaction.js +15 -16
- package/dist/functions/transform-block-properties.d.ts +1 -0
- package/dist/{sdk/functions → functions}/transform-block-properties.js +2 -0
- package/dist/{sdk/helpers → helpers}/ab-tests.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/ab-tests.js +48 -30
- package/dist/{sdk/helpers → helpers}/canTrack.js +1 -1
- package/dist/{sdk/helpers → helpers}/cookie.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/cookie.js +13 -26
- package/dist/{sdk/helpers → helpers}/css.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/css.js +1 -1
- package/dist/{sdk/helpers → helpers}/flatten.js +8 -8
- package/dist/{sdk/helpers → helpers}/localStorage.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/localStorage.js +2 -2
- package/dist/{sdk/helpers → helpers}/logger.js +1 -1
- package/dist/helpers/preview-lru-cache/get.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/get.js +7 -0
- package/dist/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/helpers.js +9 -0
- package/dist/helpers/preview-lru-cache/init.d.ts +6 -0
- package/dist/helpers/preview-lru-cache/init.js +15 -0
- package/dist/helpers/preview-lru-cache/set.d.ts +7 -0
- package/dist/helpers/preview-lru-cache/set.js +9 -0
- package/dist/helpers/preview-lru-cache/types.d.ts +12 -0
- package/dist/helpers/preview-lru-cache/types.js +6 -0
- package/dist/{sdk/helpers → helpers}/sessionId.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/sessionId.js +11 -4
- package/dist/{sdk/helpers → helpers}/uuid.js +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.js +7 -4
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.d.ts +2 -2
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.js +2 -2
- package/dist/{sdk/index.d.ts → index.d.ts} +2 -2
- package/dist/{sdk/index.js → index.js} +1 -1
- package/dist/scripts/init-editing.js +110 -0
- package/dist/types/builder-props.d.ts +9 -0
- package/dist/{sdk/types → types}/components.d.ts +8 -2
- package/dist/types/enforced-partials.d.ts +21 -0
- package/dist/types/targets.d.ts +1 -0
- package/dist/{server/types → types}/typescript.d.ts +6 -0
- package/package.json +6 -13
- package/dist/sdk/blocks/button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/columns/columns.d.ts +0 -16
- package/dist/sdk/blocks/columns/component-info.d.ts +0 -2
- package/dist/sdk/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/helpers.js +0 -6
- package/dist/sdk/blocks/form/component-info.d.ts +0 -2
- package/dist/sdk/blocks/form/form.d.ts +0 -40
- package/dist/sdk/blocks/form/form.js +0 -203
- package/dist/sdk/blocks/fragment/component-info.d.ts +0 -2
- package/dist/sdk/blocks/image/component-info.d.ts +0 -2
- package/dist/sdk/blocks/img/component-info.d.ts +0 -2
- package/dist/sdk/blocks/input/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/raw-text.js +0 -6
- package/dist/sdk/blocks/section/component-info.d.ts +0 -2
- package/dist/sdk/blocks/select/component-info.d.ts +0 -2
- package/dist/sdk/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/symbol.d.ts +0 -21
- package/dist/sdk/blocks/symbol/symbol.js +0 -69
- package/dist/sdk/blocks/text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/textarea/component-info.d.ts +0 -2
- package/dist/sdk/blocks/util.d.ts +0 -4
- package/dist/sdk/blocks/util.js +0 -13
- package/dist/sdk/blocks/video/component-info.d.ts +0 -2
- package/dist/sdk/components/render-block/render-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/sdk/components/render-block/render-block.js +0 -115
- package/dist/sdk/components/render-block/render-component.d.ts +0 -17
- package/dist/sdk/components/render-block/render-component.js +0 -11
- package/dist/sdk/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-repeated-block.js +0 -11
- package/dist/sdk/components/render-blocks.d.ts +0 -10
- package/dist/sdk/components/render-content/builder-editing.d.ts +0 -3
- package/dist/sdk/components/render-content/builder-editing.js +0 -6
- package/dist/sdk/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/sdk/components/render-content/index.d.ts +0 -1
- package/dist/sdk/components/render-content/index.js +0 -1
- package/dist/sdk/components/render-content/render-content.d.ts +0 -4
- package/dist/sdk/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/sdk/components/render-content/render-content.helpers.js +0 -30
- package/dist/sdk/components/render-content/render-content.types.d.ts +0 -38
- package/dist/sdk/components/render-content-variants/helpers.d.ts +0 -17
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -5
- package/dist/sdk/components/render-content-variants/render-content-variants.js +0 -37
- package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
- package/dist/sdk/constants/sdk-version.d.ts +0 -1
- package/dist/sdk/constants/sdk-version.js +0 -1
- package/dist/sdk/functions/get-block-actions.js +0 -15
- package/dist/sdk/functions/get-block-properties.d.ts +0 -7
- package/dist/sdk/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/sdk/functions/get-content/ab-testing.js +0 -78
- package/dist/sdk/functions/is-editing.js +0 -7
- package/dist/sdk/functions/register-component.js +0 -26
- package/dist/sdk/functions/set.js +0 -21
- package/dist/sdk/functions/transform-block-properties.d.ts +0 -1
- package/dist/sdk/scripts/init-editing.js +0 -102
- package/dist/sdk/types/targets.d.ts +0 -3
- package/dist/sdk/types/typescript.d.ts +0 -5
- package/dist/server/functions/get-builder-search-params/index.d.ts +0 -6
- package/dist/server/functions/get-builder-search-params/index.js +0 -36
- package/dist/server/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/server/functions/get-content/ab-testing.js +0 -78
- package/dist/server/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/server/functions/get-content/generate-content-url.js +0 -31
- package/dist/server/functions/get-content/generate-content-url.test.js +0 -82
- package/dist/server/functions/get-content/index.d.ts +0 -11
- package/dist/server/functions/get-content/index.js +0 -40
- package/dist/server/functions/get-content/types.d.ts +0 -45
- package/dist/server/functions/get-fetch.d.ts +0 -1
- package/dist/server/functions/get-fetch.js +0 -11
- package/dist/server/functions/get-global-this.d.ts +0 -4
- package/dist/server/functions/get-global-this.js +0 -15
- package/dist/server/functions/is-browser.d.ts +0 -1
- package/dist/server/functions/is-browser.js +0 -3
- package/dist/server/helpers/ab-tests.d.ts +0 -8
- package/dist/server/helpers/ab-tests.js +0 -5
- package/dist/server/helpers/cookie.d.ts +0 -15
- package/dist/server/helpers/cookie.js +0 -65
- package/dist/server/helpers/flatten.d.ts +0 -6
- package/dist/server/helpers/flatten.js +0 -19
- package/dist/server/helpers/logger.d.ts +0 -5
- package/dist/server/helpers/logger.js +0 -6
- package/dist/server/helpers/nullable.d.ts +0 -2
- package/dist/server/helpers/nullable.js +0 -1
- package/dist/server/helpers/url.d.ts +0 -6
- package/dist/server/helpers/url.js +0 -15
- package/dist/server/types/api-version.d.ts +0 -2
- package/dist/server/types/api-version.js +0 -1
- package/dist/server/types/builder-block.d.ts +0 -66
- package/dist/server/types/builder-content.d.ts +0 -46
- package/dist/server/types/can-track.d.ts +0 -3
- package/dist/server/types/input.d.ts +0 -121
- package/dist/server/types/typescript.js +0 -1
- /package/dist/{sdk/blocks → blocks}/embed/helpers.d.ts +0 -0
- /package/dist/{sdk/blocks → blocks}/image/image.helpers.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.js +0 -0
- /package/dist/{sdk/context/types.js → components/content/content.types.js} +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.d.ts +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.js +0 -0
- /package/dist/{sdk/components/render-content/render-content.types.js → components/content-variants/content-variants.types.js} +0 -0
- /package/dist/{sdk/constants → constants}/builder-registered-components.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/device-sizes.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.js +0 -0
- /package/dist/{sdk/context → context}/builder.context.d.ts +0 -0
- /package/dist/{sdk/functions/get-content → context}/types.js +0 -0
- /package/dist/{sdk/functions/evaluate.test.d.ts → functions/apply-patch-with-mutation.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.js +0 -0
- /package/dist/{sdk/functions/get-content/generate-content-url.test.d.ts → functions/evaluate/evaluate.test.d.ts} +0 -0
- /package/dist/{server/functions/get-content → functions/evaluate}/types.js +0 -0
- /package/dist/{sdk/functions/get-builder-search-params/fn.test.d.ts → functions/evaluate.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.js +0 -0
- /package/dist/{sdk/functions → functions}/extract-text-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.js +0 -0
- /package/dist/{sdk/functions → functions}/get-block-actions-handler.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-block-component-options.d.ts +0 -0
- /package/dist/{sdk/functions/get-processed-block.test.d.ts → functions/get-builder-search-params/fn.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/get-builder-search-params/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/generate-content-url.d.ts +0 -0
- /package/dist/{server/functions → functions}/get-content/generate-content-url.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/types.d.ts +0 -0
- /package/dist/{sdk/functions/on-change.test.d.ts → functions/get-content/types.js} +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.js +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.js +0 -0
- /package/dist/{sdk/functions/set.test.d.ts → functions/get-processed-block.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.js +0 -0
- /package/dist/{sdk/functions → functions}/is-editing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.js +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.js +0 -0
- /package/dist/{sdk/functions → functions}/on-change.d.ts +0 -0
- /package/dist/{sdk/helpers/url.test.d.ts → functions/on-change.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/register.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set-editor-settings.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set.d.ts +0 -0
- /package/dist/{sdk/types/builder-block.js → functions/set.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/track/helpers.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/interaction.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.js +0 -0
- /package/dist/{sdk/helpers → helpers}/canTrack.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/logger.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.js +0 -0
- /package/dist/{sdk/helpers → helpers}/time.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/time.js +0 -0
- /package/dist/{sdk/helpers → helpers}/url.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/url.js +0 -0
- /package/dist/{sdk/types/builder-content.js → helpers/url.test.d.ts} +0 -0
- /package/dist/{sdk/helpers → helpers}/url.test.js +0 -0
- /package/dist/{sdk/helpers → helpers}/uuid.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.js +0 -0
- /package/dist/{sdk/scripts → scripts}/init-editing.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.js +0 -0
- /package/dist/{sdk/types → types}/builder-block.d.ts +0 -0
- /package/dist/{server/types → types}/builder-block.js +0 -0
- /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
- /package/dist/{server/types → types}/builder-content.js +0 -0
- /package/dist/{sdk/types/can-track.js → types/builder-props.js} +0 -0
- /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
- /package/dist/{server/types → types}/can-track.js +0 -0
- /package/dist/{sdk/types → types}/components.js +0 -0
- /package/dist/{sdk/types → types}/deep-partial.d.ts +0 -0
- /package/dist/{sdk/types → types}/deep-partial.js +0 -0
- /package/dist/{sdk/types → types}/element.d.ts +0 -0
- /package/dist/{sdk/types → types}/element.js +0 -0
- /package/dist/{sdk/types/input.js → types/enforced-partials.js} +0 -0
- /package/dist/{sdk/types → types}/input.d.ts +0 -0
- /package/dist/{server/types → types}/input.js +0 -0
- /package/dist/{sdk/types → types}/targets.js +0 -0
- /package/dist/{sdk/types → types}/typescript.js +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
|
+
import { components, serializeComponentInfo, } from "../../functions/register-component.js";
|
|
6
|
+
import Blocks from "../blocks/blocks";
|
|
7
|
+
import ContentStyles from "./components/styles";
|
|
8
|
+
import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
|
|
9
|
+
import { TARGET } from "../../constants/target.js";
|
|
10
|
+
import { getRenderContentScriptString } from "../content-variants/helpers.js";
|
|
11
|
+
import EnableEditor from "./components/enable-editor";
|
|
12
|
+
import InlinedScript from "../inlined-script";
|
|
13
|
+
function ContentComponent(props) {
|
|
14
|
+
const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
16
|
+
variationId: props.content?.testVariationId,
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
18
|
+
contentId: props.content?.id,
|
|
19
|
+
}));
|
|
20
|
+
function contentSetState(newRootState) {
|
|
21
|
+
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
22
|
+
...PREVIOUS_VALUE,
|
|
23
|
+
rootState: newRootState,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
const [registeredComponents, setRegisteredComponents] = useState(() => [
|
|
27
|
+
...getDefaultRegisteredComponents(),
|
|
28
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
29
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
30
|
+
// existing usage.
|
|
31
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
32
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
33
|
+
...components,
|
|
34
|
+
...(props.customComponents || []),
|
|
35
|
+
].reduce((acc, { component, ...info }) => ({
|
|
36
|
+
...acc,
|
|
37
|
+
[info.name]: {
|
|
38
|
+
component: component,
|
|
39
|
+
...serializeComponentInfo(info),
|
|
40
|
+
},
|
|
41
|
+
}), {}));
|
|
42
|
+
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
43
|
+
content: getContentInitialValue({
|
|
44
|
+
content: props.content,
|
|
45
|
+
data: props.data,
|
|
46
|
+
}),
|
|
47
|
+
localState: undefined,
|
|
48
|
+
rootState: getContextStateInitialValue({
|
|
49
|
+
content: props.content,
|
|
50
|
+
data: props.data,
|
|
51
|
+
locale: props.locale,
|
|
52
|
+
}),
|
|
53
|
+
rootSetState: contentSetState,
|
|
54
|
+
context: props.context || {},
|
|
55
|
+
apiKey: props.apiKey,
|
|
56
|
+
apiVersion: props.apiVersion,
|
|
57
|
+
componentInfos: [
|
|
58
|
+
...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
|
+
...components,
|
|
65
|
+
...(props.customComponents || []),
|
|
66
|
+
].reduce((acc, { component: _, ...info }) => ({
|
|
67
|
+
...acc,
|
|
68
|
+
[info.name]: serializeComponentInfo(info),
|
|
69
|
+
}), {}),
|
|
70
|
+
inheritedStyles: {},
|
|
71
|
+
}));
|
|
72
|
+
return (React.createElement(EnableEditor, { 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 },
|
|
73
|
+
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
74
|
+
React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
|
|
75
|
+
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
76
|
+
React.createElement(ContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
|
|
77
|
+
React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal, registeredComponents: registeredComponents })));
|
|
78
|
+
}
|
|
79
|
+
export default ContentComponent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BuilderRenderState } from '../../context/types.js';
|
|
2
|
+
import type { EnforcePartials } from '../../types/enforced-partials.js';
|
|
3
|
+
import type { ContentVariantsProps } from '../content-variants/content-variants.types.js';
|
|
4
|
+
interface InternalRenderProps {
|
|
5
|
+
/**
|
|
6
|
+
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
7
|
+
*/
|
|
8
|
+
classNameProp: string | undefined;
|
|
9
|
+
showContent: boolean;
|
|
10
|
+
isSsrAbTest: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsProps>;
|
|
13
|
+
export interface BuilderComponentStateChange {
|
|
14
|
+
state: BuilderRenderState;
|
|
15
|
+
ref: {
|
|
16
|
+
name?: string;
|
|
17
|
+
props?: {
|
|
18
|
+
builderBlock?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './content';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './content';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type VariantsProviderProps = ContentVariantsProps & {
|
|
2
|
+
/**
|
|
3
|
+
* For internal use only. Do not provide this prop.
|
|
4
|
+
*/
|
|
5
|
+
__isNestedRender?: boolean;
|
|
6
|
+
};
|
|
7
|
+
import type { ContentVariantsProps } from "./content-variants.types.js";
|
|
8
|
+
declare function ContentVariants(props: VariantsProviderProps): JSX.Element;
|
|
9
|
+
export default ContentVariants;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers.js";
|
|
5
|
+
import ContentComponent from "../content/content";
|
|
6
|
+
import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
7
|
+
import InlinedStyles from "../inlined-styles";
|
|
8
|
+
import { handleABTestingSync } from "../../helpers/ab-tests.js";
|
|
9
|
+
import InlinedScript from "../inlined-script";
|
|
10
|
+
import { TARGET } from "../../constants/target.js";
|
|
11
|
+
function ContentVariants(props) {
|
|
12
|
+
const [shouldRenderVariants, setShouldRenderVariants] = useState(() => checkShouldRunVariants({
|
|
13
|
+
canTrack: getDefaultCanTrack(props.canTrack),
|
|
14
|
+
content: props.content,
|
|
15
|
+
}));
|
|
16
|
+
function variantScriptStr() {
|
|
17
|
+
return getVariantsScriptString(getVariants(props.content).map((value) => ({
|
|
18
|
+
id: value.testVariationId,
|
|
19
|
+
testRatio: value.testRatio,
|
|
20
|
+
})), props.content?.id || "");
|
|
21
|
+
}
|
|
22
|
+
function hideVariantsStyleString() {
|
|
23
|
+
return getVariants(props.content)
|
|
24
|
+
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
25
|
+
.join("");
|
|
26
|
+
}
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
/**
|
|
29
|
+
* We unmount the non-winning variants post-hydration in Vue.
|
|
30
|
+
*/
|
|
31
|
+
}, []);
|
|
32
|
+
return (React.createElement(React.Fragment, null,
|
|
33
|
+
!props.__isNestedRender && TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
34
|
+
React.createElement(InlinedScript, { scriptStr: getScriptString() }))) : null,
|
|
35
|
+
shouldRenderVariants ? (React.createElement(React.Fragment, null,
|
|
36
|
+
React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString() }),
|
|
37
|
+
React.createElement(InlinedScript, { scriptStr: variantScriptStr() }),
|
|
38
|
+
getVariants(props.content)?.map((variant) => (React.createElement(ContentComponent, { 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,
|
|
39
|
+
React.createElement(ContentComponent, { content: shouldRenderVariants
|
|
40
|
+
? props.content
|
|
41
|
+
: handleABTestingSync({
|
|
42
|
+
item: props.content,
|
|
43
|
+
canTrack: getDefaultCanTrack(props.canTrack),
|
|
44
|
+
}), classNameProp: `variant-${props.content?.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 })));
|
|
45
|
+
}
|
|
46
|
+
export default ContentVariants;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BuilderRenderContext, RegisteredComponent } from '../../context/types.js';
|
|
2
|
+
import type { ApiVersion } from '../../types/api-version.js';
|
|
3
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
4
|
+
import type { Nullable } from '../../types/typescript.js';
|
|
5
|
+
export interface ContentVariantsProps {
|
|
6
|
+
content?: Nullable<BuilderContent>;
|
|
7
|
+
model?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
context?: BuilderRenderContext;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
apiVersion?: ApiVersion;
|
|
14
|
+
customComponents?: RegisteredComponent[];
|
|
15
|
+
canTrack?: boolean;
|
|
16
|
+
locale?: string;
|
|
17
|
+
/** @deprecated use `enrich` instead **/
|
|
18
|
+
includeRefs?: boolean;
|
|
19
|
+
enrich?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Nullable } from '../../helpers/nullable.js';
|
|
2
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
3
|
+
export declare const getVariants: (content: Nullable<BuilderContent>) => {
|
|
4
|
+
testVariationId: string;
|
|
5
|
+
id: string;
|
|
6
|
+
data?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
title?: string;
|
|
9
|
+
blocks?: import("../../types/builder-block.js").BuilderBlock[];
|
|
10
|
+
inputs?: import("../../types/input.js").Input[];
|
|
11
|
+
state?: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
jsCode?: string;
|
|
15
|
+
tsCode?: string;
|
|
16
|
+
httpRequests?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
name?: string;
|
|
21
|
+
testRatio?: number;
|
|
22
|
+
meta?: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
breakpoints?: import("../../types/builder-content.js").Breakpoints;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
export declare const checkShouldRunVariants: ({ canTrack, content }: {
|
|
28
|
+
canTrack: Nullable<boolean>;
|
|
29
|
+
content: Nullable<BuilderContent>;
|
|
30
|
+
}) => boolean;
|
|
31
|
+
type VariantData = {
|
|
32
|
+
id: string;
|
|
33
|
+
testRatio?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const getScriptString: () => string;
|
|
36
|
+
export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
|
|
37
|
+
export declare const getRenderContentScriptString: ({ contentId, variationId }: {
|
|
38
|
+
variationId: string;
|
|
39
|
+
contentId: string;
|
|
40
|
+
}) => string;
|
|
41
|
+
export {};
|
package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js
RENAMED
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target';
|
|
2
|
-
import { isBrowser } from '../../functions/is-browser';
|
|
3
|
-
export const getVariants = (content) => Object.values(content?.variations || {})
|
|
4
|
-
|
|
1
|
+
import { TARGET } from '../../constants/target.js';
|
|
2
|
+
import { isBrowser } from '../../functions/is-browser.js';
|
|
3
|
+
export const getVariants = (content) => Object.values(content?.variations || {}).map(variant => ({
|
|
4
|
+
...variant,
|
|
5
|
+
testVariationId: variant.id,
|
|
6
|
+
id: content?.id
|
|
7
|
+
}));
|
|
8
|
+
export const checkShouldRunVariants = ({ canTrack, content }) => {
|
|
5
9
|
const hasVariants = getVariants(content).length > 0;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* We cannot SSR in React-Native.
|
|
12
|
+
*/
|
|
13
|
+
if (TARGET === 'reactNative')
|
|
7
14
|
return false;
|
|
8
|
-
|
|
9
|
-
if (!canTrack) {
|
|
15
|
+
if (!hasVariants)
|
|
10
16
|
return false;
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
if (!canTrack)
|
|
18
|
+
return false;
|
|
19
|
+
/**
|
|
20
|
+
* For Vue 2 and Vue 3, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
21
|
+
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
22
|
+
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
23
|
+
*
|
|
24
|
+
* NOTE: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
25
|
+
*/
|
|
26
|
+
if (TARGET === 'vue2' || TARGET === 'vue3')
|
|
27
|
+
return true;
|
|
28
|
+
if (isBrowser())
|
|
13
29
|
return false;
|
|
14
|
-
}
|
|
15
30
|
return true;
|
|
16
31
|
};
|
|
17
32
|
/**
|
|
@@ -27,13 +42,7 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
27
42
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
28
43
|
expires = '; expires=' + date.toUTCString();
|
|
29
44
|
}
|
|
30
|
-
document.cookie =
|
|
31
|
-
name +
|
|
32
|
-
'=' +
|
|
33
|
-
(value || '') +
|
|
34
|
-
expires +
|
|
35
|
-
'; path=/' +
|
|
36
|
-
'; Secure; SameSite=None';
|
|
45
|
+
document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';
|
|
37
46
|
}
|
|
38
47
|
function getCookie(name) {
|
|
39
48
|
const nameEQ = name + '=';
|
|
@@ -49,7 +58,7 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
49
58
|
}
|
|
50
59
|
const cookieName = `builder.tests.${contentId}`;
|
|
51
60
|
const variantInCookie = getCookie(cookieName);
|
|
52
|
-
const availableIDs = variants.map(
|
|
61
|
+
const availableIDs = variants.map(vr => vr.id).concat(contentId);
|
|
53
62
|
/**
|
|
54
63
|
* cookie already exists
|
|
55
64
|
*/
|
|
@@ -77,26 +86,23 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
77
86
|
return contentId;
|
|
78
87
|
}
|
|
79
88
|
const winningVariantId = getAndSetVariantId();
|
|
80
|
-
const styleEl = document.
|
|
89
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
81
90
|
/**
|
|
82
91
|
* For React to work, we need hydration to match SSR, so we completely remove this node and the styles tag.
|
|
83
92
|
*/
|
|
84
93
|
if (isHydrationTarget) {
|
|
85
94
|
styleEl.remove();
|
|
86
|
-
const thisScriptEl = document.
|
|
95
|
+
const thisScriptEl = document.currentScript;
|
|
87
96
|
thisScriptEl?.remove();
|
|
88
97
|
}
|
|
89
98
|
else {
|
|
90
99
|
/* update styles to hide all variants except the winning variant */
|
|
91
|
-
const newStyleStr = variants
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.map((value) => {
|
|
100
|
+
const newStyleStr = variants.concat({
|
|
101
|
+
id: contentId
|
|
102
|
+
}).filter(variant => variant.id !== winningVariantId).map(value => {
|
|
95
103
|
return `.variant-${value.id} { display: none; }
|
|
96
104
|
`;
|
|
97
|
-
})
|
|
98
|
-
.join('');
|
|
99
|
-
/* TO-DO: check if this actually updates the style */
|
|
105
|
+
}).join('');
|
|
100
106
|
styleEl.innerHTML = newStyleStr;
|
|
101
107
|
}
|
|
102
108
|
}
|
|
@@ -122,8 +128,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget) {
|
|
|
122
128
|
}
|
|
123
129
|
const cookieName = `builder.tests.${defaultContentId}`;
|
|
124
130
|
const variantId = getCookie(cookieName);
|
|
125
|
-
|
|
126
|
-
const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
|
|
131
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
127
132
|
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
128
133
|
if (variantId === variantContentId) {
|
|
129
134
|
if (variantIsDefaultContent) {
|
|
@@ -156,10 +161,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget) {
|
|
|
156
161
|
}
|
|
157
162
|
return;
|
|
158
163
|
}
|
|
159
|
-
const getIsHydrationTarget = (target) => target === 'react' ||
|
|
160
|
-
target === 'reactNative' ||
|
|
161
|
-
target === 'vue3' ||
|
|
162
|
-
target === 'vue2';
|
|
164
|
+
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
163
165
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
164
166
|
/**
|
|
165
167
|
* We hardcode explicit function names here, because the `.toString()` of a function can change depending on the bundler.
|
|
@@ -167,18 +169,21 @@ const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
|
167
169
|
*
|
|
168
170
|
* So we hardcode the function names here, and then use those names in the script string to make sure the function names are consistent.
|
|
169
171
|
*/
|
|
170
|
-
const AB_TEST_FN_NAME = '
|
|
171
|
-
const CONTENT_FN_NAME = '
|
|
172
|
-
export const
|
|
172
|
+
const AB_TEST_FN_NAME = 'builderIoAbTest';
|
|
173
|
+
const CONTENT_FN_NAME = 'builderIoRenderContent';
|
|
174
|
+
export const getScriptString = () => {
|
|
173
175
|
const fnStr = bldrAbTest.toString().replace(/\s+/g, ' ');
|
|
174
176
|
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, ' ');
|
|
175
177
|
return `
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
|
|
178
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
179
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
179
180
|
`;
|
|
180
181
|
};
|
|
181
|
-
export const
|
|
182
|
+
export const getVariantsScriptString = (variants, contentId) => {
|
|
183
|
+
return `
|
|
184
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
185
|
+
};
|
|
186
|
+
export const getRenderContentScriptString = ({ contentId, variationId }) => {
|
|
182
187
|
return `
|
|
183
|
-
|
|
188
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
184
189
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
function
|
|
3
|
+
function InlinedStyles(props) {
|
|
4
4
|
return (React.createElement("style", { dangerouslySetInnerHTML: { __html: props.styles }, id: props.id }));
|
|
5
5
|
}
|
|
6
|
-
export default
|
|
6
|
+
export default InlinedStyles;
|
|
@@ -24,16 +24,37 @@ import { componentInfo as customCodeInfo } from '../blocks/custom-code/component
|
|
|
24
24
|
* Returns a list of all registered components.
|
|
25
25
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
26
26
|
*/
|
|
27
|
-
export const getDefaultRegisteredComponents = () => [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
export const getDefaultRegisteredComponents = () => [{
|
|
28
|
+
component: Button,
|
|
29
|
+
...buttonComponentInfo
|
|
30
|
+
}, {
|
|
31
|
+
component: Columns,
|
|
32
|
+
...columnsComponentInfo
|
|
33
|
+
}, {
|
|
34
|
+
component: customCode,
|
|
35
|
+
...customCodeInfo
|
|
36
|
+
}, {
|
|
37
|
+
component: embed,
|
|
38
|
+
...embedComponentInfo
|
|
39
|
+
}, {
|
|
40
|
+
component: Fragment,
|
|
41
|
+
...fragmentComponentInfo
|
|
42
|
+
}, {
|
|
43
|
+
component: Image,
|
|
44
|
+
...imageComponentInfo
|
|
45
|
+
}, {
|
|
46
|
+
component: Img,
|
|
47
|
+
...imgComponentInfo
|
|
48
|
+
}, {
|
|
49
|
+
component: Section,
|
|
50
|
+
...sectionComponentInfo
|
|
51
|
+
}, {
|
|
52
|
+
component: Symbol,
|
|
53
|
+
...symbolComponentInfo
|
|
54
|
+
}, {
|
|
55
|
+
component: Text,
|
|
56
|
+
...textComponentInfo
|
|
57
|
+
}, {
|
|
58
|
+
component: Video,
|
|
59
|
+
...videoComponentInfo
|
|
60
|
+
}];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { fastClone } from '../functions/fast-clone';
|
|
1
|
+
import { fastClone } from '../functions/fast-clone.js';
|
|
2
2
|
const SIZES = {
|
|
3
3
|
small: {
|
|
4
4
|
min: 320,
|
|
5
5
|
default: 321,
|
|
6
|
-
max: 640
|
|
6
|
+
max: 640
|
|
7
7
|
},
|
|
8
8
|
medium: {
|
|
9
9
|
min: 641,
|
|
10
10
|
default: 642,
|
|
11
|
-
max: 991
|
|
11
|
+
max: 991
|
|
12
12
|
},
|
|
13
13
|
large: {
|
|
14
14
|
min: 990,
|
|
15
15
|
default: 991,
|
|
16
|
-
max: 1200
|
|
17
|
-
}
|
|
16
|
+
max: 1200
|
|
17
|
+
}
|
|
18
18
|
};
|
|
19
19
|
export const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
20
|
export const getSizesForBreakpoints = ({ small, medium }) => {
|
|
@@ -26,19 +26,20 @@ export const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
26
26
|
newSizes.small = {
|
|
27
27
|
max: small,
|
|
28
28
|
min: smallMin,
|
|
29
|
-
default: smallMin + 1
|
|
29
|
+
default: smallMin + 1
|
|
30
30
|
};
|
|
31
31
|
const mediumMin = newSizes.small.max + 1;
|
|
32
32
|
newSizes.medium = {
|
|
33
33
|
max: medium,
|
|
34
34
|
min: mediumMin,
|
|
35
|
-
default: mediumMin + 1
|
|
35
|
+
default: mediumMin + 1
|
|
36
36
|
};
|
|
37
37
|
const largeMin = newSizes.medium.max + 1;
|
|
38
38
|
newSizes.large = {
|
|
39
39
|
max: 2000,
|
|
40
|
+
// TODO: decide upper limit
|
|
40
41
|
min: largeMin,
|
|
41
|
-
default: largeMin + 1
|
|
42
|
+
default: largeMin + 1
|
|
42
43
|
};
|
|
43
44
|
return newSizes;
|
|
44
45
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SDK_VERSION = "0.5.0";
|
|
@@ -30,6 +30,6 @@ export interface BuilderContextInterface {
|
|
|
30
30
|
localState: BuilderRenderState | undefined;
|
|
31
31
|
apiKey: string | null;
|
|
32
32
|
apiVersion: ApiVersion | undefined;
|
|
33
|
-
|
|
33
|
+
componentInfos: Dictionary<ComponentInfo>;
|
|
34
34
|
inheritedStyles: Record<string, unknown>;
|
|
35
35
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const j: {};
|