@builder.io/sdk-react 0.4.5 → 0.5.1-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 +13 -19
- 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 +0 -1
- 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/{sdk/components → components}/block/block.d.ts +2 -4
- package/dist/components/block/block.helpers.d.ts +13 -0
- package/dist/{sdk/components → components}/block/block.helpers.js +12 -29
- package/dist/components/block/block.js +94 -0
- package/dist/{sdk/components → components}/block/components/block-styles.d.ts +0 -1
- package/dist/{sdk/components → components}/block/components/block-styles.js +1 -1
- 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/{sdk/components → components}/block/components/repeated-block.js +3 -3
- package/dist/{sdk/components → components}/blocks/blocks-wrapper.d.ts +2 -5
- package/dist/{sdk/components → components}/blocks/blocks-wrapper.js +3 -3
- package/dist/components/blocks/blocks.d.ts +8 -0
- package/dist/{sdk/components → components}/blocks/blocks.js +9 -3
- package/dist/components/content/components/enable-editor.d.ts +9 -0
- package/dist/{sdk/components → components}/content/components/enable-editor.js +31 -39
- package/dist/{sdk/components/content/components/content-styles.d.ts → components/content/components/styles.d.ts} +1 -2
- package/dist/{sdk/components/content/components/content-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
- package/dist/{sdk/components/content/components/content-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
- package/dist/{sdk/components/content/components/content-styles.js → components/content/components/styles.js} +3 -3
- 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/{sdk/components → components}/content/content.js +26 -40
- package/dist/{sdk/components/render-content/render-content.types.d.ts → components/content/content.types.d.ts} +4 -4
- package/dist/components/content-variants/content-variants.d.ts +9 -0
- package/dist/{sdk/components/render-content-variants/render-content-variants.js → components/content-variants/content-variants.js} +23 -22
- package/dist/{sdk/components/render-content-variants/render-content-variants.types.d.ts → components/content-variants/content-variants.types.d.ts} +5 -5
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.d.ts +7 -7
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +13 -22
- package/dist/{sdk/components → components}/inlined-script.d.ts +0 -1
- package/dist/{sdk/components → components}/inlined-script.js +1 -1
- package/dist/{sdk/components → components}/inlined-styles.d.ts +0 -1
- package/dist/{sdk/components → components}/inlined-styles.js +1 -1
- 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/context/components.context.d.ts +3 -0
- package/dist/context/components.context.js +2 -0
- 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 +42 -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/{sdk/types → types}/enforced-partials.d.ts +1 -1
- package/dist/types/targets.d.ts +1 -0
- package/dist/{sdk/types → types}/typescript.d.ts +3 -0
- package/package.json +8 -16
- package/server/package.json +5 -0
- 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 -71
- 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/block/block.helpers.d.ts +0 -12
- package/dist/sdk/components/block/block.js +0 -124
- package/dist/sdk/components/block/components/component.d.ts +0 -20
- package/dist/sdk/components/block/components/component.js +0 -11
- package/dist/sdk/components/block/components/repeated-block.d.ts +0 -11
- package/dist/sdk/components/blocks/blocks.d.ts +0 -10
- package/dist/sdk/components/content/components/enable-editor.d.ts +0 -13
- package/dist/sdk/components/content/content.d.ts +0 -4
- package/dist/sdk/components/content/content.helpers.d.ts +0 -7
- package/dist/sdk/components/content/content.helpers.js +0 -30
- package/dist/sdk/components/content/content.types.d.ts +0 -38
- package/dist/sdk/components/content-variants/content-variants.d.ts +0 -5
- package/dist/sdk/components/content-variants/content-variants.js +0 -37
- package/dist/sdk/components/content-variants/helpers.d.ts +0 -17
- package/dist/sdk/components/content-variants/helpers.js +0 -184
- package/dist/sdk/components/render-block/block-styles.d.ts +0 -9
- package/dist/sdk/components/render-block/block-styles.js +0 -66
- 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.helpers.js +0 -86
- 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-block/types.d.ts +0 -6
- package/dist/sdk/components/render-blocks.d.ts +0 -10
- package/dist/sdk/components/render-blocks.js +0 -45
- 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/components/render-styles.helpers.d.ts +0 -15
- package/dist/sdk/components/render-content/components/render-styles.helpers.js +0 -59
- package/dist/sdk/components/render-content/components/render-styles.js +0 -32
- 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.js +0 -343
- package/dist/sdk/components/render-content/wrap-component-ref.d.ts +0 -6
- package/dist/sdk/components/render-content/wrap-component-ref.js +0 -6
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -10
- package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
- package/dist/sdk/components/render-inlined-styles.js +0 -6
- 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/builder-props.d.ts +0 -10
- package/dist/sdk/types/targets.d.ts +0 -3
- 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.d.ts +0 -1
- 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-block.js +0 -1
- package/dist/server/types/builder-content.d.ts +0 -46
- package/dist/server/types/builder-content.js +0 -1
- package/dist/server/types/can-track.d.ts +0 -3
- package/dist/server/types/can-track.js +0 -1
- package/dist/server/types/input.d.ts +0 -121
- package/dist/server/types/input.js +0 -1
- package/dist/server/types/typescript.d.ts +0 -5
- 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 → components}/block/types.d.ts +0 -0
- /package/dist/{sdk/components → components}/block/types.js +0 -0
- /package/dist/{sdk/components/render-block/types.js → components/content/content.types.js} +0 -0
- /package/dist/{sdk/components → components}/content/index.d.ts +0 -0
- /package/dist/{sdk/components → components}/content/index.js +0 -0
- /package/dist/{sdk/components → components}/content/wrap-component-ref.d.ts +0 -0
- /package/dist/{sdk/components → components}/content/wrap-component-ref.js +0 -0
- /package/dist/{sdk/components/content/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/context → context}/types.js +0 -0
- /package/dist/{sdk/components/render-content-variants/render-content-variants.types.js → 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/components/render-content/render-content.types.js → functions/evaluate/evaluate.test.d.ts} +0 -0
- /package/dist/{sdk/functions/get-content → functions/evaluate}/types.js +0 -0
- /package/dist/{sdk/functions → 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 → 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/{sdk/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/{server/functions → 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 → 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/functions → 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/functions → 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/helpers → 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/{sdk/types → types}/builder-block.js +0 -0
- /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
- /package/dist/{sdk/types → types}/builder-content.js +0 -0
- /package/dist/{sdk/types → types}/builder-props.js +0 -0
- /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
- /package/dist/{sdk/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 → types}/enforced-partials.js +0 -0
- /package/dist/{sdk/types → types}/input.d.ts +0 -0
- /package/dist/{sdk/types → types}/input.js +0 -0
- /package/dist/{sdk/types → types}/targets.js +0 -0
- /package/dist/{sdk/types → types}/typescript.js +0 -0
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useState, useRef, useEffect } from "react";
|
|
4
|
-
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
|
-
import { evaluate } from "../../functions/evaluate.js";
|
|
6
|
-
import { getContent } from "../../functions/get-content/index.js";
|
|
7
|
-
import { fetch } from "../../functions/get-fetch.js";
|
|
8
|
-
import { isBrowser } from "../../functions/is-browser.js";
|
|
9
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
10
|
-
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
11
|
-
import { components, createRegisterComponentMessage, } from "../../functions/register-component.js";
|
|
12
|
-
import { _track } from "../../functions/track/index.js";
|
|
13
|
-
import RenderBlocks from "../render-blocks";
|
|
14
|
-
import RenderContentStyles from "./components/render-styles";
|
|
15
|
-
import builderContext from "../../context/builder.context.js";
|
|
16
|
-
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
17
|
-
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
18
|
-
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
19
|
-
import { getContentInitialValue, getContextStateInitialValue, } from "./render-content.helpers.js";
|
|
20
|
-
import { TARGET } from "../../constants/target.js";
|
|
21
|
-
import { logger } from "../../helpers/logger.js";
|
|
22
|
-
import { getRenderContentScriptString } from "../render-content-variants/helpers.js";
|
|
23
|
-
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
24
|
-
import InlinedScript from "../inlined-script";
|
|
25
|
-
function RenderContent(props) {
|
|
26
|
-
const elementRef = useRef(null);
|
|
27
|
-
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
28
|
-
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
29
|
-
function mergeNewContent(newContent) {
|
|
30
|
-
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
31
|
-
...PREVIOUS_VALUE,
|
|
32
|
-
content: {
|
|
33
|
-
...builderContextSignal.content,
|
|
34
|
-
...newContent,
|
|
35
|
-
data: {
|
|
36
|
-
...builderContextSignal.content?.data,
|
|
37
|
-
...newContent?.data,
|
|
38
|
-
},
|
|
39
|
-
meta: {
|
|
40
|
-
...builderContextSignal.content?.meta,
|
|
41
|
-
...newContent?.meta,
|
|
42
|
-
breakpoints: newContent?.meta?.breakpoints ||
|
|
43
|
-
builderContextSignal.content?.meta?.breakpoints,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
function setBreakpoints(breakpoints) {
|
|
49
|
-
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
50
|
-
...PREVIOUS_VALUE,
|
|
51
|
-
content: {
|
|
52
|
-
...builderContextSignal.content,
|
|
53
|
-
meta: {
|
|
54
|
-
...builderContextSignal.content?.meta,
|
|
55
|
-
breakpoints,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
const [update, setUpdate] = useState(() => 0);
|
|
61
|
-
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
62
|
-
function contentSetState(newRootState) {
|
|
63
|
-
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
64
|
-
...PREVIOUS_VALUE,
|
|
65
|
-
rootState: newRootState,
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
function processMessage(event) {
|
|
69
|
-
const { data } = event;
|
|
70
|
-
if (data) {
|
|
71
|
-
switch (data.type) {
|
|
72
|
-
case "builder.configureSdk": {
|
|
73
|
-
const messageContent = data.data;
|
|
74
|
-
const { breakpoints, contentId } = messageContent;
|
|
75
|
-
if (!contentId || contentId !== builderContextSignal.content?.id) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (breakpoints) {
|
|
79
|
-
setBreakpoints(breakpoints);
|
|
80
|
-
}
|
|
81
|
-
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case "builder.contentUpdate": {
|
|
85
|
-
const messageContent = data.data;
|
|
86
|
-
const key = messageContent.key ||
|
|
87
|
-
messageContent.alias ||
|
|
88
|
-
messageContent.entry ||
|
|
89
|
-
messageContent.modelName;
|
|
90
|
-
const contentData = messageContent.data;
|
|
91
|
-
if (key === props.model) {
|
|
92
|
-
mergeNewContent(contentData);
|
|
93
|
-
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
case "builder.patchUpdates": {
|
|
98
|
-
// TODO
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function evaluateJsCode() {
|
|
105
|
-
// run any dynamic JS code attached to content
|
|
106
|
-
const jsCode = builderContextSignal.content?.data?.jsCode;
|
|
107
|
-
if (jsCode) {
|
|
108
|
-
evaluate({
|
|
109
|
-
code: jsCode,
|
|
110
|
-
context: props.context || {},
|
|
111
|
-
localState: undefined,
|
|
112
|
-
rootState: builderContextSignal.rootState,
|
|
113
|
-
rootSetState: contentSetState,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const [httpReqsData, setHttpReqsData] = useState(() => ({}));
|
|
118
|
-
const [clicked, setClicked] = useState(() => false);
|
|
119
|
-
function onClick(event) {
|
|
120
|
-
if (builderContextSignal.content) {
|
|
121
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
122
|
-
const contentId = builderContextSignal.content?.id;
|
|
123
|
-
_track({
|
|
124
|
-
type: "click",
|
|
125
|
-
canTrack: canTrackToUse,
|
|
126
|
-
contentId,
|
|
127
|
-
apiKey: props.apiKey,
|
|
128
|
-
variationId: variationId !== contentId ? variationId : undefined,
|
|
129
|
-
...getInteractionPropertiesForEvent(event),
|
|
130
|
-
unique: !clicked,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (!clicked) {
|
|
134
|
-
setClicked(true);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function evalExpression(expression) {
|
|
138
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
139
|
-
code: group,
|
|
140
|
-
context: props.context || {},
|
|
141
|
-
localState: undefined,
|
|
142
|
-
rootState: builderContextSignal.rootState,
|
|
143
|
-
rootSetState: contentSetState,
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
146
|
-
function handleRequest({ url, key }) {
|
|
147
|
-
fetch(url)
|
|
148
|
-
.then((response) => response.json())
|
|
149
|
-
.then((json) => {
|
|
150
|
-
const newState = {
|
|
151
|
-
...builderContextSignal.rootState,
|
|
152
|
-
[key]: json,
|
|
153
|
-
};
|
|
154
|
-
contentSetState(newState);
|
|
155
|
-
})
|
|
156
|
-
.catch((err) => {
|
|
157
|
-
console.error("error fetching dynamic data", url, err);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function runHttpRequests() {
|
|
161
|
-
const requests = builderContextSignal.content?.data?.httpRequests ?? {};
|
|
162
|
-
Object.entries(requests).forEach(([key, url]) => {
|
|
163
|
-
if (url && (!httpReqsData[key] || isEditing())) {
|
|
164
|
-
const evaluatedUrl = evalExpression(url);
|
|
165
|
-
handleRequest({
|
|
166
|
-
url: evaluatedUrl,
|
|
167
|
-
key,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
function emitStateUpdate() {
|
|
173
|
-
if (isEditing()) {
|
|
174
|
-
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
175
|
-
detail: {
|
|
176
|
-
state: builderContextSignal.rootState,
|
|
177
|
-
ref: {
|
|
178
|
-
name: props.model,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
}));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
|
|
185
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
186
|
-
variationId: props.content?.testVariationId,
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
188
|
-
contentId: props.content?.id,
|
|
189
|
-
}));
|
|
190
|
-
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
191
|
-
content: getContentInitialValue({
|
|
192
|
-
content: props.content,
|
|
193
|
-
data: props.data,
|
|
194
|
-
}),
|
|
195
|
-
localState: undefined,
|
|
196
|
-
rootState: getContextStateInitialValue({
|
|
197
|
-
content: props.content,
|
|
198
|
-
data: props.data,
|
|
199
|
-
locale: props.locale,
|
|
200
|
-
}),
|
|
201
|
-
rootSetState: contentSetState,
|
|
202
|
-
context: props.context || {},
|
|
203
|
-
apiKey: props.apiKey,
|
|
204
|
-
apiVersion: props.apiVersion,
|
|
205
|
-
registeredComponents: [
|
|
206
|
-
...getDefaultRegisteredComponents(),
|
|
207
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
208
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
209
|
-
// existing usage.
|
|
210
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
211
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
212
|
-
...components,
|
|
213
|
-
...(props.customComponents || []),
|
|
214
|
-
].reduce((acc, { component, ...curr }) => ({
|
|
215
|
-
...acc,
|
|
216
|
-
[curr.name]: {
|
|
217
|
-
component: TARGET === "vue3" ? wrapComponentRef(component) : component,
|
|
218
|
-
...curr,
|
|
219
|
-
},
|
|
220
|
-
}), {}),
|
|
221
|
-
inheritedStyles: {},
|
|
222
|
-
}));
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
if (!props.apiKey) {
|
|
225
|
-
logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
226
|
-
}
|
|
227
|
-
if (isBrowser()) {
|
|
228
|
-
if (isEditing()) {
|
|
229
|
-
setForceReRenderCount(forceReRenderCount + 1);
|
|
230
|
-
registerInsertMenu();
|
|
231
|
-
setupBrowserForEditing({
|
|
232
|
-
...(props.locale
|
|
233
|
-
? {
|
|
234
|
-
locale: props.locale,
|
|
235
|
-
}
|
|
236
|
-
: {}),
|
|
237
|
-
...(props.includeRefs
|
|
238
|
-
? {
|
|
239
|
-
includeRefs: props.includeRefs,
|
|
240
|
-
}
|
|
241
|
-
: {}),
|
|
242
|
-
...(props.enrich
|
|
243
|
-
? {
|
|
244
|
-
enrich: props.enrich,
|
|
245
|
-
}
|
|
246
|
-
: {}),
|
|
247
|
-
});
|
|
248
|
-
Object.values(builderContextSignal.registeredComponents).forEach((registeredComponent) => {
|
|
249
|
-
const message = createRegisterComponentMessage(registeredComponent);
|
|
250
|
-
window.parent?.postMessage(message, "*");
|
|
251
|
-
});
|
|
252
|
-
window.addEventListener("message", processMessage);
|
|
253
|
-
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
254
|
-
}
|
|
255
|
-
if (builderContextSignal.content) {
|
|
256
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
257
|
-
const contentId = builderContextSignal.content?.id;
|
|
258
|
-
_track({
|
|
259
|
-
type: "impression",
|
|
260
|
-
canTrack: canTrackToUse,
|
|
261
|
-
contentId,
|
|
262
|
-
apiKey: props.apiKey,
|
|
263
|
-
variationId: variationId !== contentId ? variationId : undefined,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
// override normal content in preview mode
|
|
267
|
-
if (isPreviewing()) {
|
|
268
|
-
const searchParams = new URL(location.href).searchParams;
|
|
269
|
-
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
270
|
-
const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
|
|
271
|
-
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
272
|
-
/**
|
|
273
|
-
* Make sure that:
|
|
274
|
-
* - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
|
|
275
|
-
* - if there is content, that the preview ID is the same as that of the one we receive.
|
|
276
|
-
*
|
|
277
|
-
* TO-DO: should we only update the state when there is a change?
|
|
278
|
-
**/
|
|
279
|
-
if (searchParamPreviewModel === props.model &&
|
|
280
|
-
previewApiKey === props.apiKey &&
|
|
281
|
-
(!props.content || searchParamPreviewId === props.content.id)) {
|
|
282
|
-
getContent({
|
|
283
|
-
model: props.model,
|
|
284
|
-
apiKey: props.apiKey,
|
|
285
|
-
apiVersion: props.apiVersion,
|
|
286
|
-
}).then((content) => {
|
|
287
|
-
if (content) {
|
|
288
|
-
mergeNewContent(content);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
evaluateJsCode();
|
|
294
|
-
runHttpRequests();
|
|
295
|
-
emitStateUpdate();
|
|
296
|
-
}
|
|
297
|
-
}, []);
|
|
298
|
-
useEffect(() => {
|
|
299
|
-
if (props.content) {
|
|
300
|
-
mergeNewContent(props.content);
|
|
301
|
-
}
|
|
302
|
-
}, [props.content]);
|
|
303
|
-
useEffect(() => {
|
|
304
|
-
evaluateJsCode();
|
|
305
|
-
}, [
|
|
306
|
-
builderContextSignal.content?.data?.jsCode,
|
|
307
|
-
builderContextSignal.rootState,
|
|
308
|
-
]);
|
|
309
|
-
useEffect(() => {
|
|
310
|
-
runHttpRequests();
|
|
311
|
-
}, [builderContextSignal.content?.data?.httpRequests]);
|
|
312
|
-
useEffect(() => {
|
|
313
|
-
emitStateUpdate();
|
|
314
|
-
}, [builderContextSignal.rootState]);
|
|
315
|
-
useEffect(() => {
|
|
316
|
-
return () => {
|
|
317
|
-
if (isBrowser()) {
|
|
318
|
-
window.removeEventListener("message", processMessage);
|
|
319
|
-
window.removeEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
}, []);
|
|
323
|
-
return (React.createElement(builderContext.Provider, { value: builderContextSignal }, builderContextSignal.content ? (React.createElement(React.Fragment, null,
|
|
324
|
-
React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": builderContextSignal.content?.id, "builder-model": props.model, ...(TARGET === "reactNative"
|
|
325
|
-
? {
|
|
326
|
-
dataSet: {
|
|
327
|
-
// currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
|
|
328
|
-
"builder-content-id": "",
|
|
329
|
-
},
|
|
330
|
-
}
|
|
331
|
-
: {}), ...(props.showContent
|
|
332
|
-
? {}
|
|
333
|
-
: {
|
|
334
|
-
hidden: true,
|
|
335
|
-
"aria-hidden": true,
|
|
336
|
-
}), className: props.classNameProp },
|
|
337
|
-
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
338
|
-
React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
|
|
339
|
-
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
340
|
-
React.createElement(RenderContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
|
|
341
|
-
React.createElement(RenderBlocks, { blocks: builderContextSignal.content?.data?.blocks, key: forceReRenderCount })))) : null));
|
|
342
|
-
}
|
|
343
|
-
export default RenderContent;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type VariantsProviderProps = RenderContentVariantsProps & {
|
|
3
|
-
/**
|
|
4
|
-
* For internal use only. Do not provide this prop.
|
|
5
|
-
*/
|
|
6
|
-
__isNestedRender?: boolean;
|
|
7
|
-
};
|
|
8
|
-
import type { RenderContentVariantsProps } from "./render-content-variants.types";
|
|
9
|
-
declare function RenderContentVariants(props: VariantsProviderProps): JSX.Element;
|
|
10
|
-
export default RenderContentVariants;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.4.5";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.4.5";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getEventHandlerName } from './event-handler-name.js';
|
|
2
|
-
import { createEventHandler } from './get-block-actions-handler.js';
|
|
3
|
-
export function getBlockActions(options) {
|
|
4
|
-
const obj = {};
|
|
5
|
-
const optionActions = options.block.actions ?? {};
|
|
6
|
-
for (const key in optionActions) {
|
|
7
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
8
|
-
if (!optionActions.hasOwnProperty(key)) {
|
|
9
|
-
continue;
|
|
10
|
-
}
|
|
11
|
-
const value = optionActions[key];
|
|
12
|
-
obj[getEventHandlerName(key)] = createEventHandler(value, options);
|
|
13
|
-
}
|
|
14
|
-
return obj;
|
|
15
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getContentVariationCookie, setContentVariationCookie, } from '../../helpers/ab-tests.js';
|
|
2
|
-
import { checkIsDefined } from '../../helpers/nullable.js';
|
|
3
|
-
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) &&
|
|
4
|
-
checkIsDefined(item.variations) &&
|
|
5
|
-
Object.keys(item.variations).length > 0;
|
|
6
|
-
/**
|
|
7
|
-
* Randomly assign a variation to this user and store it in cookies/storage
|
|
8
|
-
*/
|
|
9
|
-
const getRandomVariationId = ({ id, variations, }) => {
|
|
10
|
-
let n = 0;
|
|
11
|
-
const random = Math.random();
|
|
12
|
-
// loop over variations test ratios, incrementing a counter,
|
|
13
|
-
// until we find the variation that this user should be assigned to
|
|
14
|
-
for (const id in variations) {
|
|
15
|
-
const testRatio = variations[id]?.testRatio;
|
|
16
|
-
n += testRatio;
|
|
17
|
-
if (random < n) {
|
|
18
|
-
return id;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// `item.variations` does not include the default variation
|
|
22
|
-
// if we arrive here, then it means that the random number fits in the default variation bucket
|
|
23
|
-
return id;
|
|
24
|
-
};
|
|
25
|
-
const getTestFields = ({ item, testGroupId, }) => {
|
|
26
|
-
const variationValue = item.variations[testGroupId];
|
|
27
|
-
if (testGroupId === item.id ||
|
|
28
|
-
// handle edge-case where `testGroupId` points to non-existing variation
|
|
29
|
-
!variationValue) {
|
|
30
|
-
return {
|
|
31
|
-
testVariationId: item.id,
|
|
32
|
-
testVariationName: 'Default',
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return {
|
|
37
|
-
data: variationValue.data,
|
|
38
|
-
testVariationId: variationValue.id,
|
|
39
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : ''),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const getContentVariation = async ({ item, canTrack, }) => {
|
|
44
|
-
// try to find test variation in cookies/storage
|
|
45
|
-
const testGroupId = await getContentVariationCookie({
|
|
46
|
-
canTrack,
|
|
47
|
-
contentId: item.id,
|
|
48
|
-
});
|
|
49
|
-
const testFields = testGroupId
|
|
50
|
-
? getTestFields({ item, testGroupId })
|
|
51
|
-
: undefined;
|
|
52
|
-
if (testFields) {
|
|
53
|
-
return testFields;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// if variation not found in storage, assign a random variation to this user
|
|
57
|
-
const randomVariationId = getRandomVariationId({
|
|
58
|
-
variations: item.variations,
|
|
59
|
-
id: item.id,
|
|
60
|
-
});
|
|
61
|
-
// store variation in cookies/storage
|
|
62
|
-
setContentVariationCookie({
|
|
63
|
-
contentId: item.id,
|
|
64
|
-
value: randomVariationId,
|
|
65
|
-
canTrack,
|
|
66
|
-
}).catch((err) => {
|
|
67
|
-
console.error('could not store A/B test variation: ', err);
|
|
68
|
-
});
|
|
69
|
-
return getTestFields({ item, testGroupId: randomVariationId });
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
export const handleABTesting = async ({ item, canTrack, }) => {
|
|
73
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const variationValue = await getContentVariation({ item, canTrack });
|
|
77
|
-
Object.assign(item, variationValue);
|
|
78
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { serializeFn } from '../blocks/util.js';
|
|
2
|
-
import { fastClone } from './fast-clone.js';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
5
|
-
*/
|
|
6
|
-
export const components = [];
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
9
|
-
*/
|
|
10
|
-
export function registerComponent(component, info) {
|
|
11
|
-
components.push({ component, ...info });
|
|
12
|
-
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
13
|
-
return component;
|
|
14
|
-
}
|
|
15
|
-
export const createRegisterComponentMessage = ({ component: _, ...info }) => ({
|
|
16
|
-
type: 'builder.registerComponent',
|
|
17
|
-
data: prepareComponentInfoToSend(info),
|
|
18
|
-
});
|
|
19
|
-
const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
|
|
20
|
-
const prepareComponentInfoToSend = ({ inputs, ...info }) => ({
|
|
21
|
-
...fastClone(info),
|
|
22
|
-
inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
23
|
-
...acc,
|
|
24
|
-
[key]: serializeValue(value),
|
|
25
|
-
}), {})),
|
|
26
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal implementation of lodash's _.set
|
|
3
|
-
* https://lodash.com/docs/4.17.15#set
|
|
4
|
-
*
|
|
5
|
-
* See ./set.test.ts for usage examples
|
|
6
|
-
*/
|
|
7
|
-
export const set = (obj, _path, value) => {
|
|
8
|
-
if (Object(obj) !== obj) {
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
const path = Array.isArray(_path)
|
|
12
|
-
? _path
|
|
13
|
-
: _path.toString().match(/[^.[\]]+/g);
|
|
14
|
-
path
|
|
15
|
-
.slice(0, -1)
|
|
16
|
-
.reduce((a, c, i) => Object(a[c]) === a[c]
|
|
17
|
-
? a[c]
|
|
18
|
-
: (a[c] =
|
|
19
|
-
Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}), obj)[path[path.length - 1]] = value;
|
|
20
|
-
return obj;
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function transformBlockProperties<T>(properties: T): T;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SDK_VERSION } from '../constants/sdk-version.js';
|
|
2
|
-
import { TARGET } from '../constants/target.js';
|
|
3
|
-
import { isBrowser } from '../functions/is-browser.js';
|
|
4
|
-
import { register } from '../functions/register.js';
|
|
5
|
-
export const registerInsertMenu = () => {
|
|
6
|
-
register('insertMenu', {
|
|
7
|
-
name: '_default',
|
|
8
|
-
default: true,
|
|
9
|
-
items: [
|
|
10
|
-
{ name: 'Box' },
|
|
11
|
-
{ name: 'Text' },
|
|
12
|
-
{ name: 'Image' },
|
|
13
|
-
{ name: 'Columns' },
|
|
14
|
-
...(TARGET === 'reactNative'
|
|
15
|
-
? []
|
|
16
|
-
: [
|
|
17
|
-
{ name: 'Core:Section' },
|
|
18
|
-
{ name: 'Core:Button' },
|
|
19
|
-
{ name: 'Embed' },
|
|
20
|
-
{ name: 'Custom Code' },
|
|
21
|
-
]),
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
let isSetupForEditing = false;
|
|
26
|
-
export const setupBrowserForEditing = (options = {}) => {
|
|
27
|
-
if (isSetupForEditing) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
isSetupForEditing = true;
|
|
31
|
-
if (isBrowser()) {
|
|
32
|
-
window.parent?.postMessage({
|
|
33
|
-
type: 'builder.sdkInfo',
|
|
34
|
-
data: {
|
|
35
|
-
target: TARGET,
|
|
36
|
-
version: SDK_VERSION,
|
|
37
|
-
// TODO: compile these in
|
|
38
|
-
// type: process.env.SDK_TYPE,
|
|
39
|
-
// version: process.env.SDK_VERSION,
|
|
40
|
-
supportsPatchUpdates: false,
|
|
41
|
-
// Supports builder-model="..." attribute which is needed to
|
|
42
|
-
// scope our '+ add block' button styling
|
|
43
|
-
supportsAddBlockScoping: true,
|
|
44
|
-
supportsCustomBreakpoints: true,
|
|
45
|
-
},
|
|
46
|
-
}, '*');
|
|
47
|
-
window.parent?.postMessage({
|
|
48
|
-
type: 'builder.updateContent',
|
|
49
|
-
data: {
|
|
50
|
-
options,
|
|
51
|
-
},
|
|
52
|
-
}, '*');
|
|
53
|
-
window.addEventListener('message', ({ data }) => {
|
|
54
|
-
if (!data?.type) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
switch (data.type) {
|
|
58
|
-
case 'builder.evaluate': {
|
|
59
|
-
const text = data.data.text;
|
|
60
|
-
const args = data.data.arguments || [];
|
|
61
|
-
const id = data.data.id;
|
|
62
|
-
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
63
|
-
const fn = new Function(text);
|
|
64
|
-
let result;
|
|
65
|
-
let error = null;
|
|
66
|
-
try {
|
|
67
|
-
// eslint-disable-next-line prefer-spread
|
|
68
|
-
result = fn.apply(null, args);
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
error = err;
|
|
72
|
-
}
|
|
73
|
-
if (error) {
|
|
74
|
-
window.parent?.postMessage({
|
|
75
|
-
type: 'builder.evaluateError',
|
|
76
|
-
data: { id, error: error.message },
|
|
77
|
-
}, '*');
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if (result && typeof result.then === 'function') {
|
|
81
|
-
result
|
|
82
|
-
.then((finalResult) => {
|
|
83
|
-
window.parent?.postMessage({
|
|
84
|
-
type: 'builder.evaluateResult',
|
|
85
|
-
data: { id, result: finalResult },
|
|
86
|
-
}, '*');
|
|
87
|
-
})
|
|
88
|
-
.catch(console.error);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
window.parent?.postMessage({
|
|
92
|
-
type: 'builder.evaluateResult',
|
|
93
|
-
data: { result, id },
|
|
94
|
-
}, '*');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
};
|