@builder.io/sdk-react 0.4.5 → 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 +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/{sdk/components → components}/blocks/blocks.d.ts +2 -4
- package/dist/{sdk/components → components}/blocks/blocks.js +2 -2
- 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/components/content/content.js +79 -0
- 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/{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 +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 -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/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.js +0 -97
- 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
|
@@ -4,16 +4,24 @@ import { logger } from './logger.js';
|
|
|
4
4
|
import { TARGET } from '../constants/target.js';
|
|
5
5
|
const BUILDER_STORE_PREFIX = 'builder.tests';
|
|
6
6
|
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
7
|
-
const getContentVariationCookie = ({ contentId }) => getCookie({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const getContentVariationCookie = ({ contentId }) => getCookie({
|
|
8
|
+
name: getContentTestKey(contentId),
|
|
9
|
+
canTrack: true
|
|
10
|
+
});
|
|
11
|
+
const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
|
|
12
|
+
name: getContentTestKey(contentId),
|
|
13
|
+
canTrack: true
|
|
14
|
+
});
|
|
15
|
+
const setContentVariationCookie = ({ contentId, value }) => setCookie({
|
|
16
|
+
name: getContentTestKey(contentId),
|
|
17
|
+
value,
|
|
18
|
+
canTrack: true
|
|
19
|
+
});
|
|
20
|
+
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
13
21
|
/**
|
|
14
22
|
* Randomly assign a variation to a user
|
|
15
23
|
*/
|
|
16
|
-
const getRandomVariationId = ({ id, variations
|
|
24
|
+
const getRandomVariationId = ({ id, variations }) => {
|
|
17
25
|
let n = 0;
|
|
18
26
|
const random = Math.random();
|
|
19
27
|
// loop over variations test ratios, incrementing a counter,
|
|
@@ -35,31 +43,31 @@ const getAndSetVariantId = (args) => {
|
|
|
35
43
|
// store variation in cookies/storage
|
|
36
44
|
setContentVariationCookie({
|
|
37
45
|
contentId: args.id,
|
|
38
|
-
value: randomVariationId
|
|
39
|
-
}).catch(
|
|
46
|
+
value: randomVariationId
|
|
47
|
+
}).catch(err => {
|
|
40
48
|
logger.error('could not store A/B test variation: ', err);
|
|
41
49
|
});
|
|
42
50
|
return randomVariationId;
|
|
43
51
|
};
|
|
44
|
-
const getTestFields = ({ item, testGroupId
|
|
52
|
+
const getTestFields = ({ item, testGroupId }) => {
|
|
45
53
|
const variationValue = item.variations[testGroupId];
|
|
46
54
|
if (testGroupId === item.id ||
|
|
47
55
|
// handle edge-case where `testGroupId` points to non-existing variation
|
|
48
56
|
!variationValue) {
|
|
49
57
|
return {
|
|
50
58
|
testVariationId: item.id,
|
|
51
|
-
testVariationName: 'Default'
|
|
59
|
+
testVariationName: 'Default'
|
|
52
60
|
};
|
|
53
61
|
}
|
|
54
62
|
else {
|
|
55
63
|
return {
|
|
56
64
|
data: variationValue.data,
|
|
57
65
|
testVariationId: variationValue.id,
|
|
58
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : '')
|
|
66
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : '')
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
69
|
};
|
|
62
|
-
export const handleABTestingSync = ({ item, canTrack
|
|
70
|
+
export const handleABTestingSync = ({ item, canTrack }) => {
|
|
63
71
|
/**
|
|
64
72
|
* We cannot SSR in React-Native.
|
|
65
73
|
*/
|
|
@@ -75,19 +83,21 @@ export const handleABTestingSync = ({ item, canTrack, }) => {
|
|
|
75
83
|
return item;
|
|
76
84
|
}
|
|
77
85
|
const testGroupId = getContentVariationCookieSync({
|
|
78
|
-
contentId: item.id
|
|
79
|
-
}) ||
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
contentId: item.id
|
|
87
|
+
}) || getAndSetVariantId({
|
|
88
|
+
variations: item.variations,
|
|
89
|
+
id: item.id
|
|
90
|
+
});
|
|
91
|
+
const variationValue = getTestFields({
|
|
92
|
+
item,
|
|
93
|
+
testGroupId
|
|
94
|
+
});
|
|
85
95
|
return {
|
|
86
96
|
...item,
|
|
87
|
-
...variationValue
|
|
97
|
+
...variationValue
|
|
88
98
|
};
|
|
89
99
|
};
|
|
90
|
-
export const handleABTesting = async ({ item, canTrack
|
|
100
|
+
export const handleABTesting = async ({ item, canTrack }) => {
|
|
91
101
|
if (!canTrack) {
|
|
92
102
|
return item;
|
|
93
103
|
}
|
|
@@ -95,16 +105,18 @@ export const handleABTesting = async ({ item, canTrack, }) => {
|
|
|
95
105
|
return item;
|
|
96
106
|
}
|
|
97
107
|
const cookieValue = await getContentVariationCookie({
|
|
98
|
-
contentId: item.id
|
|
108
|
+
contentId: item.id
|
|
109
|
+
});
|
|
110
|
+
const testGroupId = cookieValue || getAndSetVariantId({
|
|
111
|
+
variations: item.variations,
|
|
112
|
+
id: item.id
|
|
113
|
+
});
|
|
114
|
+
const variationValue = getTestFields({
|
|
115
|
+
item,
|
|
116
|
+
testGroupId
|
|
99
117
|
});
|
|
100
|
-
const testGroupId = cookieValue ||
|
|
101
|
-
getAndSetVariantId({
|
|
102
|
-
variations: item.variations,
|
|
103
|
-
id: item.id,
|
|
104
|
-
});
|
|
105
|
-
const variationValue = getTestFields({ item, testGroupId });
|
|
106
118
|
return {
|
|
107
119
|
...item,
|
|
108
|
-
...variationValue
|
|
120
|
+
...variationValue
|
|
109
121
|
};
|
|
110
122
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { checkIsDefined } from './nullable';
|
|
1
|
+
import { checkIsDefined } from './nullable.js';
|
|
2
2
|
export const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
|
|
@@ -2,7 +2,7 @@ import type { CanTrack } from '../types/can-track.js';
|
|
|
2
2
|
type GetCookieArgs = {
|
|
3
3
|
name: string;
|
|
4
4
|
} & CanTrack;
|
|
5
|
-
export declare const getCookieSync: ({ name, canTrack
|
|
5
|
+
export declare const getCookieSync: ({ name, canTrack }: GetCookieArgs) => string | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
8
8
|
* The sync version is only safe to use in code blocks that `react-native` is guaranteed not to not run.
|
|
@@ -11,7 +11,7 @@ export declare const getCookie: (args: GetCookieArgs) => Promise<string>;
|
|
|
11
11
|
/**
|
|
12
12
|
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
13
13
|
*/
|
|
14
|
-
export declare const setCookie: ({ name, value, expires, canTrack
|
|
14
|
+
export declare const setCookie: ({ name, value, expires, canTrack }: {
|
|
15
15
|
name: string;
|
|
16
16
|
value: string;
|
|
17
17
|
expires?: Date;
|
|
@@ -2,7 +2,7 @@ import { isBrowser } from '../functions/is-browser.js';
|
|
|
2
2
|
import { logger } from './logger.js';
|
|
3
3
|
import { checkIsDefined } from './nullable.js';
|
|
4
4
|
import { getTopLevelDomain } from './url.js';
|
|
5
|
-
export const getCookieSync = ({ name, canTrack
|
|
5
|
+
export const getCookieSync = ({ name, canTrack }) => {
|
|
6
6
|
try {
|
|
7
7
|
if (!canTrack) {
|
|
8
8
|
return undefined;
|
|
@@ -11,10 +11,7 @@ export const getCookieSync = ({ name, canTrack, }) => {
|
|
|
11
11
|
* Extracted from MDN docs
|
|
12
12
|
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#example_2_get_a_sample_cookie_named_test2
|
|
13
13
|
*/
|
|
14
|
-
return document.cookie
|
|
15
|
-
.split('; ')
|
|
16
|
-
.find((row) => row.startsWith(`${name}=`))
|
|
17
|
-
?.split('=')[1];
|
|
14
|
+
return document.cookie.split('; ').find(row => row.startsWith(`${name}=`))?.split('=')[1];
|
|
18
15
|
}
|
|
19
16
|
catch (err) {
|
|
20
17
|
logger.warn('[COOKIE] GET error: ', err?.message || err);
|
|
@@ -26,40 +23,30 @@ export const getCookieSync = ({ name, canTrack, }) => {
|
|
|
26
23
|
* The sync version is only safe to use in code blocks that `react-native` is guaranteed not to not run.
|
|
27
24
|
*/
|
|
28
25
|
export const getCookie = async (args) => getCookieSync(args);
|
|
29
|
-
const stringifyCookie = (cookie) => cookie
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.join('; ');
|
|
33
|
-
const SECURE_CONFIG = [
|
|
34
|
-
['secure', ''],
|
|
35
|
-
['SameSite', 'None'],
|
|
36
|
-
];
|
|
37
|
-
const createCookieString = ({ name, value, expires, }) => {
|
|
26
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join('; ');
|
|
27
|
+
const SECURE_CONFIG = [['secure', ''], ['SameSite', 'None']];
|
|
28
|
+
const createCookieString = ({ name, value, expires }) => {
|
|
38
29
|
const secure = isBrowser() ? location.protocol === 'https:' : true;
|
|
39
30
|
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
40
31
|
// TODO: need to know if secure server side
|
|
41
|
-
const expiresObj = expires
|
|
42
|
-
|
|
43
|
-
: [[]];
|
|
44
|
-
const cookieValue = [
|
|
45
|
-
[name, value],
|
|
46
|
-
...expiresObj,
|
|
47
|
-
['path', '/'],
|
|
48
|
-
['domain', getTopLevelDomain(window.location.hostname)],
|
|
49
|
-
...secureObj,
|
|
50
|
-
];
|
|
32
|
+
const expiresObj = expires ? [['expires', expires.toUTCString()]] : [[]];
|
|
33
|
+
const cookieValue = [[name, value], ...expiresObj, ['path', '/'], ['domain', getTopLevelDomain(window.location.hostname)], ...secureObj];
|
|
51
34
|
const cookie = stringifyCookie(cookieValue);
|
|
52
35
|
return cookie;
|
|
53
36
|
};
|
|
54
37
|
/**
|
|
55
38
|
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
56
39
|
*/
|
|
57
|
-
export const setCookie = async ({ name, value, expires, canTrack
|
|
40
|
+
export const setCookie = async ({ name, value, expires, canTrack }) => {
|
|
58
41
|
try {
|
|
59
42
|
if (!canTrack) {
|
|
60
43
|
return;
|
|
61
44
|
}
|
|
62
|
-
const cookie = createCookieString({
|
|
45
|
+
const cookie = createCookieString({
|
|
46
|
+
name,
|
|
47
|
+
value,
|
|
48
|
+
expires
|
|
49
|
+
});
|
|
63
50
|
document.cookie = cookie;
|
|
64
51
|
}
|
|
65
52
|
catch (err) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const convertStyleMapToCSSArray: (style: Partial<CSSStyleDeclaration>) => string[];
|
|
2
2
|
export declare const convertStyleMapToCSS: (style: Partial<CSSStyleDeclaration>) => string;
|
|
3
|
-
export declare const createCssClass: ({ mediaQuery, className, styles
|
|
3
|
+
export declare const createCssClass: ({ mediaQuery, className, styles }: {
|
|
4
4
|
mediaQuery?: string;
|
|
5
5
|
className: string;
|
|
6
6
|
styles: Partial<CSSStyleDeclaration>;
|
|
@@ -12,7 +12,7 @@ export const convertStyleMapToCSSArray = (style) => {
|
|
|
12
12
|
return cssProps.filter(checkIsDefined);
|
|
13
13
|
};
|
|
14
14
|
export const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join('\n');
|
|
15
|
-
export const createCssClass = ({ mediaQuery, className, styles
|
|
15
|
+
export const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
16
16
|
const cssClass = `.${className} {
|
|
17
17
|
${convertStyleMapToCSS(styles)}
|
|
18
18
|
}`;
|
|
@@ -7,13 +7,13 @@ export function flatten(object, path = null, separator = '.') {
|
|
|
7
7
|
return Object.keys(object).reduce((acc, key) => {
|
|
8
8
|
const value = object[key];
|
|
9
9
|
const newPath = [path, key].filter(Boolean).join(separator);
|
|
10
|
-
const isObject = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const isObject = [typeof value === 'object', value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
|
|
11
|
+
return isObject ? {
|
|
12
|
+
...acc,
|
|
13
|
+
...flatten(value, newPath, separator)
|
|
14
|
+
} : {
|
|
15
|
+
...acc,
|
|
16
|
+
[newPath]: value
|
|
17
|
+
};
|
|
18
18
|
}, {});
|
|
19
19
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
2
|
import type { Nullable } from './nullable.js';
|
|
3
|
-
export declare const getLocalStorageItem: ({ key, canTrack
|
|
3
|
+
export declare const getLocalStorageItem: ({ key, canTrack }: {
|
|
4
4
|
key: string;
|
|
5
5
|
} & CanTrack) => Nullable<string>;
|
|
6
|
-
export declare const setLocalStorageItem: ({ key, canTrack, value
|
|
6
|
+
export declare const setLocalStorageItem: ({ key, canTrack, value }: {
|
|
7
7
|
key: string;
|
|
8
8
|
value: string;
|
|
9
9
|
} & CanTrack) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isBrowser } from '../functions/is-browser.js';
|
|
2
2
|
const getLocalStorage = () => isBrowser() && typeof localStorage !== 'undefined' ? localStorage : undefined;
|
|
3
|
-
export const getLocalStorageItem = ({ key, canTrack
|
|
3
|
+
export const getLocalStorageItem = ({ key, canTrack }) => {
|
|
4
4
|
try {
|
|
5
5
|
if (canTrack) {
|
|
6
6
|
return getLocalStorage()?.getItem(key);
|
|
@@ -12,7 +12,7 @@ export const getLocalStorageItem = ({ key, canTrack, }) => {
|
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
export const setLocalStorageItem = ({ key, canTrack, value
|
|
15
|
+
export const setLocalStorageItem = ({ key, canTrack, value }) => {
|
|
16
16
|
try {
|
|
17
17
|
if (canTrack) {
|
|
18
18
|
getLocalStorage()?.setItem(key, value);
|
|
@@ -3,5 +3,5 @@ export const logger = {
|
|
|
3
3
|
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
4
4
|
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
5
5
|
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
6
|
-
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
6
|
+
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
7
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPreviewContent(searchParams: URLSearchParams): import("../../types/builder-content").BuilderContent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getIdFromSearchParams } from './helpers';
|
|
2
|
+
import { init } from './init';
|
|
3
|
+
export function getPreviewContent(searchParams) {
|
|
4
|
+
init();
|
|
5
|
+
const id = getIdFromSearchParams(searchParams);
|
|
6
|
+
return typeof id === 'string' ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getIdFromSearchParams: (searchParams: URLSearchParams) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { logger } from '../logger';
|
|
2
|
+
export const getIdFromSearchParams = (searchParams) => {
|
|
3
|
+
const previewedModel = searchParams.get('preview');
|
|
4
|
+
const previewedId = searchParams.get('overrides.' + previewedModel);
|
|
5
|
+
if (!previewedId) {
|
|
6
|
+
logger.warn('No previewed ID found in search params.');
|
|
7
|
+
}
|
|
8
|
+
return previewedId;
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is an LRU cache to hold preview content on the server-side.
|
|
3
|
+
*
|
|
4
|
+
* Note: This logic is only used by the NextJS SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { LRUCache } from 'lru-cache';
|
|
7
|
+
export function init() {
|
|
8
|
+
if (!globalThis._BUILDER_PREVIEW_LRU_CACHE) {
|
|
9
|
+
globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
|
|
10
|
+
max: 500,
|
|
11
|
+
// how long to live in ms
|
|
12
|
+
ttl: 1000 * 60 * 5
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is an LRU cache to hold preview content on the server-side.
|
|
3
|
+
*
|
|
4
|
+
* Note: This logic is only used by the NextJS SDK.
|
|
5
|
+
*/
|
|
6
|
+
import type { LRUCache } from 'lru-cache';
|
|
7
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
8
|
+
type BuilderLRUCache = LRUCache<string, BuilderContent>;
|
|
9
|
+
export type GlobalWCache = typeof globalThis & {
|
|
10
|
+
_BUILDER_PREVIEW_LRU_CACHE: BuilderLRUCache;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
-
export declare const getSessionId: ({ canTrack
|
|
2
|
+
export declare const getSessionId: ({ canTrack }: CanTrack) => Promise<string | undefined>;
|
|
3
3
|
export declare const createSessionId: () => string;
|
|
4
|
-
export declare const setSessionId: ({ id, canTrack
|
|
4
|
+
export declare const setSessionId: ({ id, canTrack }: {
|
|
5
5
|
id: string;
|
|
6
6
|
} & CanTrack) => Promise<void>;
|
|
@@ -2,22 +2,29 @@ import { getCookie, setCookie } from './cookie.js';
|
|
|
2
2
|
import { checkIsDefined } from './nullable.js';
|
|
3
3
|
import { uuid } from './uuid.js';
|
|
4
4
|
const SESSION_LOCAL_STORAGE_KEY = 'builderSessionId';
|
|
5
|
-
export const getSessionId = async ({ canTrack
|
|
5
|
+
export const getSessionId = async ({ canTrack }) => {
|
|
6
6
|
if (!canTrack) {
|
|
7
7
|
return undefined;
|
|
8
8
|
}
|
|
9
9
|
const sessionId = await getCookie({
|
|
10
10
|
name: SESSION_LOCAL_STORAGE_KEY,
|
|
11
|
-
canTrack
|
|
11
|
+
canTrack
|
|
12
12
|
});
|
|
13
13
|
if (checkIsDefined(sessionId)) {
|
|
14
14
|
return sessionId;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
const newSessionId = createSessionId();
|
|
18
|
-
setSessionId({
|
|
18
|
+
setSessionId({
|
|
19
|
+
id: newSessionId,
|
|
20
|
+
canTrack
|
|
21
|
+
});
|
|
19
22
|
return newSessionId;
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
25
|
export const createSessionId = () => uuid();
|
|
23
|
-
export const setSessionId = ({ id, canTrack
|
|
26
|
+
export const setSessionId = ({ id, canTrack }) => setCookie({
|
|
27
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
28
|
+
value: id,
|
|
29
|
+
canTrack
|
|
30
|
+
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export function uuidv4() {
|
|
5
5
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
6
|
-
const r =
|
|
6
|
+
const r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
7
7
|
return v.toString(16);
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
2
|
export declare const getVisitorId: ({ canTrack }: CanTrack) => string | undefined;
|
|
3
3
|
export declare const createVisitorId: () => string;
|
|
4
|
-
export declare const setVisitorId: ({ id, canTrack
|
|
4
|
+
export declare const setVisitorId: ({ id, canTrack }: {
|
|
5
5
|
id: string;
|
|
6
6
|
} & CanTrack) => void;
|
|
@@ -8,20 +8,23 @@ export const getVisitorId = ({ canTrack }) => {
|
|
|
8
8
|
}
|
|
9
9
|
const visitorId = getLocalStorageItem({
|
|
10
10
|
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
11
|
-
canTrack
|
|
11
|
+
canTrack
|
|
12
12
|
});
|
|
13
13
|
if (checkIsDefined(visitorId)) {
|
|
14
14
|
return visitorId;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
const newVisitorId = createVisitorId();
|
|
18
|
-
setVisitorId({
|
|
18
|
+
setVisitorId({
|
|
19
|
+
id: newVisitorId,
|
|
20
|
+
canTrack
|
|
21
|
+
});
|
|
19
22
|
return newVisitorId;
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
25
|
export const createVisitorId = () => uuid();
|
|
23
|
-
export const setVisitorId = ({ id, canTrack
|
|
26
|
+
export const setVisitorId = ({ id, canTrack }) => setLocalStorageItem({
|
|
24
27
|
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
25
28
|
value: id,
|
|
26
|
-
canTrack
|
|
29
|
+
canTrack
|
|
27
30
|
});
|
|
@@ -2,9 +2,9 @@ export { default as Button } from '../blocks/button/button';
|
|
|
2
2
|
export { default as Columns } from '../blocks/columns/columns';
|
|
3
3
|
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
4
|
export { default as Image } from '../blocks/image/image';
|
|
5
|
-
export { default as RenderBlocks } from '../components/
|
|
5
|
+
export { default as RenderBlocks } from '../components/blocks/blocks';
|
|
6
6
|
export { default as Section } from '../blocks/section/section';
|
|
7
7
|
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
8
8
|
export { default as Text } from '../blocks/text/text';
|
|
9
9
|
export { default as Video } from '../blocks/video/video';
|
|
10
|
-
export { default as RenderContent } from '../components/
|
|
10
|
+
export { default as RenderContent } from '../components/content-variants/content-variants';
|
|
@@ -2,9 +2,9 @@ export { default as Button } from '../blocks/button/button';
|
|
|
2
2
|
export { default as Columns } from '../blocks/columns/columns';
|
|
3
3
|
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
4
|
export { default as Image } from '../blocks/image/image';
|
|
5
|
-
export { default as RenderBlocks } from '../components/
|
|
5
|
+
export { default as RenderBlocks } from '../components/blocks/blocks';
|
|
6
6
|
export { default as Section } from '../blocks/section/section';
|
|
7
7
|
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
8
8
|
export { default as Text } from '../blocks/text/text';
|
|
9
9
|
export { default as Video } from '../blocks/video/video';
|
|
10
|
-
export { default as RenderContent } from '../components/
|
|
10
|
+
export { default as RenderContent } from '../components/content-variants/content-variants';
|
|
@@ -7,9 +7,9 @@ export { register } from './functions/register.js';
|
|
|
7
7
|
export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
|
|
8
8
|
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
9
9
|
export type { Settings } from './functions/set-editor-settings.js';
|
|
10
|
-
export { getAllContent, getContent, processContentResult
|
|
10
|
+
export { getAllContent, getContent, processContentResult } from './functions/get-content/index.js';
|
|
11
11
|
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
12
12
|
export { track } from './functions/track/index.js';
|
|
13
13
|
export type { RegisteredComponent } from './context/types';
|
|
14
14
|
export type { ComponentInfo } from './types/components';
|
|
15
|
-
export type {
|
|
15
|
+
export type { ContentProps } from './components/content/content.types.js';
|
|
@@ -5,6 +5,6 @@ export { isPreviewing } from './functions/is-previewing.js';
|
|
|
5
5
|
export { createRegisterComponentMessage } from './functions/register-component.js';
|
|
6
6
|
export { register } from './functions/register.js';
|
|
7
7
|
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
8
|
-
export { getAllContent, getContent, processContentResult
|
|
8
|
+
export { getAllContent, getContent, processContentResult } from './functions/get-content/index.js';
|
|
9
9
|
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
10
10
|
export { track } from './functions/track/index.js';
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
}, {
|
|
12
|
+
name: 'Text'
|
|
13
|
+
}, {
|
|
14
|
+
name: 'Image'
|
|
15
|
+
}, {
|
|
16
|
+
name: 'Columns'
|
|
17
|
+
}, ...(TARGET === 'reactNative' ? [] : [{
|
|
18
|
+
name: 'Core:Section'
|
|
19
|
+
}, {
|
|
20
|
+
name: 'Core:Button'
|
|
21
|
+
}, {
|
|
22
|
+
name: 'Embed'
|
|
23
|
+
}, {
|
|
24
|
+
name: 'Custom Code'
|
|
25
|
+
}])]
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
let isSetupForEditing = false;
|
|
29
|
+
export const setupBrowserForEditing = (options = {}) => {
|
|
30
|
+
if (isSetupForEditing) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
isSetupForEditing = true;
|
|
34
|
+
if (isBrowser()) {
|
|
35
|
+
window.parent?.postMessage({
|
|
36
|
+
type: 'builder.sdkInfo',
|
|
37
|
+
data: {
|
|
38
|
+
target: TARGET,
|
|
39
|
+
version: 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
|
+
{
|
|
60
|
+
const text = data.data.text;
|
|
61
|
+
const args = data.data.arguments || [];
|
|
62
|
+
const id = data.data.id;
|
|
63
|
+
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
64
|
+
const fn = new Function(text);
|
|
65
|
+
let result;
|
|
66
|
+
let error = null;
|
|
67
|
+
try {
|
|
68
|
+
// eslint-disable-next-line prefer-spread
|
|
69
|
+
result = fn.apply(null, args);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
error = err;
|
|
73
|
+
}
|
|
74
|
+
if (error) {
|
|
75
|
+
window.parent?.postMessage({
|
|
76
|
+
type: 'builder.evaluateError',
|
|
77
|
+
data: {
|
|
78
|
+
id,
|
|
79
|
+
error: error.message
|
|
80
|
+
}
|
|
81
|
+
}, '*');
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (result && typeof result.then === 'function') {
|
|
85
|
+
result.then(finalResult => {
|
|
86
|
+
window.parent?.postMessage({
|
|
87
|
+
type: 'builder.evaluateResult',
|
|
88
|
+
data: {
|
|
89
|
+
id,
|
|
90
|
+
result: finalResult
|
|
91
|
+
}
|
|
92
|
+
}, '*');
|
|
93
|
+
}).catch(console.error);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
window.parent?.postMessage({
|
|
97
|
+
type: 'builder.evaluateResult',
|
|
98
|
+
data: {
|
|
99
|
+
result,
|
|
100
|
+
id
|
|
101
|
+
}
|
|
102
|
+
}, '*');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|