@builder.io/sdk-react 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{sdk/blocks → blocks}/BaseText.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/BaseText.js +2 -2
- package/dist/{sdk/blocks → blocks}/button/button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/button/button.js +3 -5
- package/dist/blocks/button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/button/component-info.js +9 -13
- package/dist/blocks/columns/columns.d.ts +16 -0
- package/dist/{sdk/blocks → blocks}/columns/columns.js +15 -21
- package/dist/blocks/columns/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/columns/component-info.js +62 -83
- package/dist/blocks/custom-code/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/custom-code/component-info.js +7 -11
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/embed/component-info.js +8 -15
- package/dist/{sdk/blocks → blocks}/embed/embed.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -0
- package/dist/blocks/form/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/form/component-info.js +94 -129
- package/dist/blocks/form/form.d.ts +2 -0
- package/dist/blocks/form/form.js +6 -0
- package/dist/blocks/fragment/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/fragment/component-info.js +1 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.d.ts +13 -0
- package/dist/blocks/helpers.js +40 -0
- package/dist/blocks/image/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/image/component-info.js +33 -63
- package/dist/{sdk/blocks → blocks}/image/image.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/image/image.helpers.js +2 -11
- package/dist/{sdk/blocks → blocks}/image/image.js +7 -7
- package/dist/blocks/img/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/img/component-info.js +4 -6
- package/dist/{sdk/blocks → blocks}/img/img.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/img/img.js +1 -1
- package/dist/blocks/input/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/input/component-info.js +15 -40
- package/dist/{sdk/blocks → blocks}/input/input.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/input/input.js +1 -1
- package/dist/blocks/raw-text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/raw-text/component-info.js +3 -5
- package/dist/{sdk/blocks → blocks}/raw-text/raw-text.d.ts +0 -1
- package/dist/blocks/raw-text/raw-text.js +6 -0
- package/dist/blocks/section/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/section/component-info.js +13 -18
- package/dist/{sdk/blocks → blocks}/section/section.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/section/section.js +1 -1
- package/dist/blocks/select/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/select/component-info.js +22 -34
- package/dist/{sdk/blocks → blocks}/select/select.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/select/select.js +1 -1
- package/dist/blocks/submit-button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/submit-button/component-info.js +5 -7
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.js +1 -1
- package/dist/blocks/symbol/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/symbol/component-info.js +12 -17
- package/dist/blocks/symbol/symbol.d.ts +23 -0
- package/dist/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/dist/blocks/symbol/symbol.helpers.js +31 -0
- package/dist/blocks/symbol/symbol.js +45 -0
- package/dist/blocks/text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/text/component-info.js +6 -7
- package/dist/{sdk/blocks → blocks}/text/text.d.ts +1 -2
- package/dist/{sdk/blocks → blocks}/text/text.js +2 -2
- package/dist/blocks/textarea/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/textarea/component-info.js +13 -19
- package/dist/{sdk/blocks → blocks}/textarea/textarea.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/textarea/textarea.js +1 -1
- package/dist/blocks/video/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/video/component-info.js +35 -55
- package/dist/{sdk/blocks → blocks}/video/video.d.ts +1 -1
- package/dist/{sdk/blocks → blocks}/video/video.js +2 -2
- package/dist/components/block/block.d.ts +9 -0
- package/dist/components/block/block.helpers.d.ts +13 -0
- package/dist/{sdk/components/render-block/render-block.helpers.js → components/block/block.helpers.js} +12 -29
- package/dist/components/block/block.js +94 -0
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.d.ts +2 -3
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.js +23 -24
- package/dist/components/block/components/block-wrapper.d.ts +16 -0
- package/dist/components/block/components/block-wrapper.js +36 -0
- package/dist/components/block/components/component-ref/component-ref.d.ts +3 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/dist/components/block/components/component-ref/component-ref.js +23 -0
- package/dist/components/block/components/interactive-element.d.ts +11 -0
- package/dist/components/block/components/interactive-element.js +20 -0
- package/dist/components/block/components/repeated-block.d.ts +9 -0
- package/dist/components/block/components/repeated-block.js +11 -0
- package/dist/components/blocks/blocks-wrapper.d.ts +10 -0
- package/dist/{sdk/components/render-blocks.js → components/blocks/blocks-wrapper.js} +6 -13
- package/dist/components/blocks/blocks.d.ts +8 -0
- package/dist/components/blocks/blocks.js +11 -0
- package/dist/components/content/components/enable-editor.d.ts +9 -0
- package/dist/{sdk/components/render-content/render-content.js → components/content/components/enable-editor.js} +69 -140
- package/dist/components/content/components/styles.d.ts +8 -0
- package/dist/{sdk/components/render-content/components/render-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
- package/dist/{sdk/components/render-content/components/render-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
- package/dist/{sdk/components/render-content/components/render-styles.js → components/content/components/styles.js} +7 -7
- package/dist/components/content/content.d.ts +3 -0
- package/dist/components/content/content.helpers.d.ts +7 -0
- package/dist/components/content/content.helpers.js +30 -0
- package/dist/components/content/content.js +79 -0
- package/dist/components/content/content.types.d.ts +24 -0
- package/dist/components/content/index.d.ts +1 -0
- package/dist/components/content/index.js +1 -0
- package/dist/components/content-variants/content-variants.d.ts +9 -0
- package/dist/components/content-variants/content-variants.js +46 -0
- package/dist/components/content-variants/content-variants.types.d.ts +20 -0
- package/dist/components/content-variants/helpers.d.ts +41 -0
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +46 -41
- package/dist/components/inlined-script.d.ts +6 -0
- package/dist/components/inlined-script.js +6 -0
- package/dist/components/inlined-styles.d.ts +6 -0
- package/dist/{sdk/components/render-inlined-styles.js → components/inlined-styles.js} +3 -3
- package/dist/{sdk/constants → constants}/builder-registered-components.js +34 -13
- package/dist/{sdk/constants → constants}/device-sizes.js +9 -8
- package/dist/constants/sdk-version.d.ts +1 -0
- package/dist/constants/sdk-version.js +1 -0
- package/dist/{sdk/context → context}/builder.context.js +1 -1
- package/dist/{sdk/context → context}/types.d.ts +1 -1
- package/dist/functions/acorn_interpreter.d.ts +1 -0
- package/dist/functions/acorn_interpreter.js +3027 -0
- package/dist/functions/apply-patch-with-mutation.d.ts +10 -0
- package/dist/functions/apply-patch-with-mutation.js +54 -0
- package/dist/functions/apply-patch-with-mutation.test.js +53 -0
- package/dist/functions/evaluate/acorn.d.ts +0 -0
- package/dist/functions/evaluate/acorn.js +2432 -0
- package/dist/{sdk/functions → functions/evaluate}/evaluate.d.ts +5 -2
- package/dist/functions/evaluate/evaluate.js +70 -0
- package/dist/functions/evaluate/evaluate.test.js +23 -0
- package/dist/functions/evaluate/index.d.ts +1 -0
- package/dist/functions/evaluate/index.js +1 -0
- package/dist/functions/evaluate/interpreter.d.ts +2 -0
- package/dist/functions/evaluate/interpreter.js +3853 -0
- package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/dist/functions/evaluate/non-node-runtime.js +84 -0
- package/dist/functions/evaluate/types.d.ts +10 -0
- package/dist/functions/evaluate.d.ts +23 -0
- package/dist/{sdk/functions → functions}/evaluate.js +28 -9
- package/dist/{sdk/functions → functions}/evaluate.test.js +11 -5
- package/dist/{sdk/functions → functions}/extract-text-styles.js +2 -14
- package/dist/{sdk/functions → functions}/get-block-actions-handler.js +3 -3
- package/dist/{sdk/functions → functions}/get-block-actions.d.ts +1 -0
- package/dist/functions/get-block-actions.js +28 -0
- package/dist/{sdk/functions → functions}/get-block-component-options.js +1 -1
- package/dist/functions/get-block-properties.d.ts +6 -0
- package/dist/{sdk/functions → functions}/get-block-properties.js +15 -9
- package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.js +1 -1
- package/dist/{sdk/functions → functions}/get-builder-search-params/index.js +3 -7
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.js +7 -5
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.js +31 -17
- package/dist/{sdk/functions → functions}/get-content/index.d.ts +2 -6
- package/dist/{sdk/functions → functions}/get-content/index.js +26 -6
- package/dist/functions/get-content/processCookies.d.ts +2 -0
- package/dist/functions/get-content/processCookies.js +3 -0
- package/dist/{sdk/functions → functions}/get-processed-block.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-processed-block.js +11 -7
- package/dist/{sdk/functions → functions}/get-processed-block.test.js +8 -6
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.js +2 -2
- package/dist/{sdk/functions → functions}/if-target.d.ts +1 -1
- package/dist/{sdk/functions → functions}/if-target.js +1 -1
- package/dist/functions/is-editing.js +5 -0
- package/dist/functions/is-non-node-server.d.ts +4 -0
- package/dist/functions/is-non-node-server.js +8 -0
- package/dist/{sdk/functions → functions}/on-change.js +1 -1
- package/dist/{sdk/functions → functions}/on-change.test.js +13 -3
- package/dist/{sdk/functions → functions}/register-component.d.ts +2 -1
- package/dist/functions/register-component.js +38 -0
- package/dist/{sdk/functions → functions}/register.js +2 -2
- package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.js +13 -5
- package/dist/{sdk/functions → functions}/set-editor-settings.js +1 -1
- package/dist/functions/set.js +14 -0
- package/dist/{sdk/functions → functions}/set.test.js +9 -3
- package/dist/{sdk/functions → functions}/track/helpers.js +6 -11
- package/dist/{sdk/functions → functions}/track/index.js +26 -14
- package/dist/{sdk/functions → functions}/track/interaction.js +15 -16
- package/dist/functions/transform-block-properties.d.ts +1 -0
- package/dist/{sdk/functions → functions}/transform-block-properties.js +2 -0
- package/dist/{sdk/helpers → helpers}/ab-tests.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/ab-tests.js +48 -30
- package/dist/{sdk/helpers → helpers}/canTrack.js +1 -1
- package/dist/{sdk/helpers → helpers}/cookie.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/cookie.js +13 -26
- package/dist/{sdk/helpers → helpers}/css.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/css.js +1 -1
- package/dist/{sdk/helpers → helpers}/flatten.js +8 -8
- package/dist/{sdk/helpers → helpers}/localStorage.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/localStorage.js +2 -2
- package/dist/{sdk/helpers → helpers}/logger.js +1 -1
- package/dist/helpers/preview-lru-cache/get.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/get.js +7 -0
- package/dist/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/helpers.js +9 -0
- package/dist/helpers/preview-lru-cache/init.d.ts +6 -0
- package/dist/helpers/preview-lru-cache/init.js +15 -0
- package/dist/helpers/preview-lru-cache/set.d.ts +7 -0
- package/dist/helpers/preview-lru-cache/set.js +9 -0
- package/dist/helpers/preview-lru-cache/types.d.ts +12 -0
- package/dist/helpers/preview-lru-cache/types.js +6 -0
- package/dist/{sdk/helpers → helpers}/sessionId.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/sessionId.js +11 -4
- package/dist/{sdk/helpers → helpers}/uuid.js +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.js +7 -4
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.d.ts +2 -2
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.js +2 -2
- package/dist/{sdk/index.d.ts → index.d.ts} +2 -2
- package/dist/{sdk/index.js → index.js} +1 -1
- package/dist/scripts/init-editing.js +110 -0
- package/dist/types/builder-props.d.ts +9 -0
- package/dist/{sdk/types → types}/components.d.ts +8 -2
- package/dist/types/enforced-partials.d.ts +21 -0
- package/dist/types/targets.d.ts +1 -0
- package/dist/{server/types → types}/typescript.d.ts +6 -0
- package/package.json +6 -13
- package/dist/sdk/blocks/button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/columns/columns.d.ts +0 -16
- package/dist/sdk/blocks/columns/component-info.d.ts +0 -2
- package/dist/sdk/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/helpers.js +0 -6
- package/dist/sdk/blocks/form/component-info.d.ts +0 -2
- package/dist/sdk/blocks/form/form.d.ts +0 -40
- package/dist/sdk/blocks/form/form.js +0 -203
- package/dist/sdk/blocks/fragment/component-info.d.ts +0 -2
- package/dist/sdk/blocks/image/component-info.d.ts +0 -2
- package/dist/sdk/blocks/img/component-info.d.ts +0 -2
- package/dist/sdk/blocks/input/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/raw-text.js +0 -6
- package/dist/sdk/blocks/section/component-info.d.ts +0 -2
- package/dist/sdk/blocks/select/component-info.d.ts +0 -2
- package/dist/sdk/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/symbol.d.ts +0 -21
- package/dist/sdk/blocks/symbol/symbol.js +0 -69
- package/dist/sdk/blocks/text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/textarea/component-info.d.ts +0 -2
- package/dist/sdk/blocks/util.d.ts +0 -4
- package/dist/sdk/blocks/util.js +0 -13
- package/dist/sdk/blocks/video/component-info.d.ts +0 -2
- package/dist/sdk/components/render-block/render-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/sdk/components/render-block/render-block.js +0 -115
- package/dist/sdk/components/render-block/render-component.d.ts +0 -17
- package/dist/sdk/components/render-block/render-component.js +0 -11
- package/dist/sdk/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-repeated-block.js +0 -11
- package/dist/sdk/components/render-blocks.d.ts +0 -10
- package/dist/sdk/components/render-content/builder-editing.d.ts +0 -3
- package/dist/sdk/components/render-content/builder-editing.js +0 -6
- package/dist/sdk/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/sdk/components/render-content/index.d.ts +0 -1
- package/dist/sdk/components/render-content/index.js +0 -1
- package/dist/sdk/components/render-content/render-content.d.ts +0 -4
- package/dist/sdk/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/sdk/components/render-content/render-content.helpers.js +0 -30
- package/dist/sdk/components/render-content/render-content.types.d.ts +0 -38
- package/dist/sdk/components/render-content-variants/helpers.d.ts +0 -17
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -5
- package/dist/sdk/components/render-content-variants/render-content-variants.js +0 -37
- package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
- package/dist/sdk/constants/sdk-version.d.ts +0 -1
- package/dist/sdk/constants/sdk-version.js +0 -1
- package/dist/sdk/functions/get-block-actions.js +0 -15
- package/dist/sdk/functions/get-block-properties.d.ts +0 -7
- package/dist/sdk/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/sdk/functions/get-content/ab-testing.js +0 -78
- package/dist/sdk/functions/is-editing.js +0 -7
- package/dist/sdk/functions/register-component.js +0 -26
- package/dist/sdk/functions/set.js +0 -21
- package/dist/sdk/functions/transform-block-properties.d.ts +0 -1
- package/dist/sdk/scripts/init-editing.js +0 -102
- package/dist/sdk/types/targets.d.ts +0 -3
- package/dist/sdk/types/typescript.d.ts +0 -5
- package/dist/server/functions/get-builder-search-params/index.d.ts +0 -6
- package/dist/server/functions/get-builder-search-params/index.js +0 -36
- package/dist/server/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/server/functions/get-content/ab-testing.js +0 -78
- package/dist/server/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/server/functions/get-content/generate-content-url.js +0 -31
- package/dist/server/functions/get-content/generate-content-url.test.js +0 -82
- package/dist/server/functions/get-content/index.d.ts +0 -11
- package/dist/server/functions/get-content/index.js +0 -40
- package/dist/server/functions/get-content/types.d.ts +0 -45
- package/dist/server/functions/get-fetch.d.ts +0 -1
- package/dist/server/functions/get-fetch.js +0 -11
- package/dist/server/functions/get-global-this.d.ts +0 -4
- package/dist/server/functions/get-global-this.js +0 -15
- package/dist/server/functions/is-browser.d.ts +0 -1
- package/dist/server/functions/is-browser.js +0 -3
- package/dist/server/helpers/ab-tests.d.ts +0 -8
- package/dist/server/helpers/ab-tests.js +0 -5
- package/dist/server/helpers/cookie.d.ts +0 -15
- package/dist/server/helpers/cookie.js +0 -65
- package/dist/server/helpers/flatten.d.ts +0 -6
- package/dist/server/helpers/flatten.js +0 -19
- package/dist/server/helpers/logger.d.ts +0 -5
- package/dist/server/helpers/logger.js +0 -6
- package/dist/server/helpers/nullable.d.ts +0 -2
- package/dist/server/helpers/nullable.js +0 -1
- package/dist/server/helpers/url.d.ts +0 -6
- package/dist/server/helpers/url.js +0 -15
- package/dist/server/types/api-version.d.ts +0 -2
- package/dist/server/types/api-version.js +0 -1
- package/dist/server/types/builder-block.d.ts +0 -66
- package/dist/server/types/builder-content.d.ts +0 -46
- package/dist/server/types/can-track.d.ts +0 -3
- package/dist/server/types/input.d.ts +0 -121
- package/dist/server/types/typescript.js +0 -1
- /package/dist/{sdk/blocks → blocks}/embed/helpers.d.ts +0 -0
- /package/dist/{sdk/blocks → blocks}/image/image.helpers.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.js +0 -0
- /package/dist/{sdk/context/types.js → components/content/content.types.js} +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.d.ts +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.js +0 -0
- /package/dist/{sdk/components/render-content/render-content.types.js → components/content-variants/content-variants.types.js} +0 -0
- /package/dist/{sdk/constants → constants}/builder-registered-components.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/device-sizes.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.js +0 -0
- /package/dist/{sdk/context → context}/builder.context.d.ts +0 -0
- /package/dist/{sdk/functions/get-content → context}/types.js +0 -0
- /package/dist/{sdk/functions/evaluate.test.d.ts → functions/apply-patch-with-mutation.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.js +0 -0
- /package/dist/{sdk/functions/get-content/generate-content-url.test.d.ts → functions/evaluate/evaluate.test.d.ts} +0 -0
- /package/dist/{server/functions/get-content → functions/evaluate}/types.js +0 -0
- /package/dist/{sdk/functions/get-builder-search-params/fn.test.d.ts → functions/evaluate.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.js +0 -0
- /package/dist/{sdk/functions → functions}/extract-text-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.js +0 -0
- /package/dist/{sdk/functions → functions}/get-block-actions-handler.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-block-component-options.d.ts +0 -0
- /package/dist/{sdk/functions/get-processed-block.test.d.ts → functions/get-builder-search-params/fn.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/get-builder-search-params/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/generate-content-url.d.ts +0 -0
- /package/dist/{server/functions → functions}/get-content/generate-content-url.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/types.d.ts +0 -0
- /package/dist/{sdk/functions/on-change.test.d.ts → functions/get-content/types.js} +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.js +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.js +0 -0
- /package/dist/{sdk/functions/set.test.d.ts → functions/get-processed-block.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.js +0 -0
- /package/dist/{sdk/functions → functions}/is-editing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.js +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.js +0 -0
- /package/dist/{sdk/functions → functions}/on-change.d.ts +0 -0
- /package/dist/{sdk/helpers/url.test.d.ts → functions/on-change.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/register.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set-editor-settings.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set.d.ts +0 -0
- /package/dist/{sdk/types/builder-block.js → functions/set.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/track/helpers.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/interaction.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.js +0 -0
- /package/dist/{sdk/helpers → helpers}/canTrack.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/logger.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.js +0 -0
- /package/dist/{sdk/helpers → helpers}/time.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/time.js +0 -0
- /package/dist/{sdk/helpers → helpers}/url.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/url.js +0 -0
- /package/dist/{sdk/types/builder-content.js → helpers/url.test.d.ts} +0 -0
- /package/dist/{sdk/helpers → helpers}/url.test.js +0 -0
- /package/dist/{sdk/helpers → helpers}/uuid.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.js +0 -0
- /package/dist/{sdk/scripts → scripts}/init-editing.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.js +0 -0
- /package/dist/{sdk/types → types}/builder-block.d.ts +0 -0
- /package/dist/{server/types → types}/builder-block.js +0 -0
- /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
- /package/dist/{server/types → types}/builder-content.js +0 -0
- /package/dist/{sdk/types/can-track.js → types/builder-props.js} +0 -0
- /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
- /package/dist/{server/types → types}/can-track.js +0 -0
- /package/dist/{sdk/types → types}/components.js +0 -0
- /package/dist/{sdk/types → types}/deep-partial.d.ts +0 -0
- /package/dist/{sdk/types → types}/deep-partial.js +0 -0
- /package/dist/{sdk/types → types}/element.d.ts +0 -0
- /package/dist/{sdk/types → types}/element.js +0 -0
- /package/dist/{sdk/types/input.js → types/enforced-partials.js} +0 -0
- /package/dist/{sdk/types → types}/input.d.ts +0 -0
- /package/dist/{server/types → types}/input.js +0 -0
- /package/dist/{sdk/types → types}/targets.js +0 -0
- /package/dist/{sdk/types → types}/typescript.js +0 -0
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { evaluate } from './evaluate
|
|
1
|
+
import { evaluate } from './evaluate';
|
|
2
2
|
import { fastClone } from './fast-clone.js';
|
|
3
3
|
import { set } from './set.js';
|
|
4
4
|
import { transformBlock } from './transform-block.js';
|
|
5
|
-
const evaluateBindings = ({ block, context, localState, rootState, rootSetState
|
|
5
|
+
const evaluateBindings = ({ block, context, localState, rootState, rootSetState }) => {
|
|
6
6
|
if (!block.bindings) {
|
|
7
7
|
return block;
|
|
8
8
|
}
|
|
9
9
|
const copy = fastClone(block);
|
|
10
10
|
const copied = {
|
|
11
11
|
...copy,
|
|
12
|
-
properties: {
|
|
13
|
-
|
|
12
|
+
properties: {
|
|
13
|
+
...copy.properties
|
|
14
|
+
},
|
|
15
|
+
actions: {
|
|
16
|
+
...copy.actions
|
|
17
|
+
}
|
|
14
18
|
};
|
|
15
19
|
for (const binding in block.bindings) {
|
|
16
20
|
const expression = block.bindings[binding];
|
|
@@ -19,13 +23,13 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState,
|
|
|
19
23
|
localState,
|
|
20
24
|
rootState,
|
|
21
25
|
rootSetState,
|
|
22
|
-
context
|
|
26
|
+
context
|
|
23
27
|
});
|
|
24
28
|
set(copied, binding, value);
|
|
25
29
|
}
|
|
26
30
|
return copied;
|
|
27
31
|
};
|
|
28
|
-
export function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState
|
|
32
|
+
export function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
|
|
29
33
|
const transformedBlock = transformBlock(block);
|
|
30
34
|
if (shouldEvaluateBindings) {
|
|
31
35
|
return evaluateBindings({
|
|
@@ -33,7 +37,7 @@ export function getProcessedBlock({ block, context, shouldEvaluateBindings, loca
|
|
|
33
37
|
localState,
|
|
34
38
|
rootState,
|
|
35
39
|
rootSetState,
|
|
36
|
-
context
|
|
40
|
+
context
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
else {
|
|
@@ -3,26 +3,28 @@ test('Can process bindings', () => {
|
|
|
3
3
|
const block = {
|
|
4
4
|
'@type': '@builder.io/sdk:Element',
|
|
5
5
|
properties: {
|
|
6
|
-
foo: 'bar'
|
|
6
|
+
foo: 'bar'
|
|
7
7
|
},
|
|
8
8
|
bindings: {
|
|
9
9
|
'properties.foo': '"baz"',
|
|
10
10
|
'responsiveStyles.large.zIndex': '1 + 1',
|
|
11
11
|
'properties.test': 'state.test',
|
|
12
12
|
'properties.block': `
|
|
13
|
-
|
|
13
|
+
var foo = 'bar';
|
|
14
14
|
return foo;
|
|
15
15
|
`,
|
|
16
|
-
'properties.isEditing': 'builder.isEditing'
|
|
17
|
-
}
|
|
16
|
+
'properties.isEditing': 'builder.isEditing'
|
|
17
|
+
}
|
|
18
18
|
};
|
|
19
19
|
const processed = getProcessedBlock({
|
|
20
20
|
block,
|
|
21
21
|
context: {},
|
|
22
|
-
rootState: {
|
|
22
|
+
rootState: {
|
|
23
|
+
test: 'hello'
|
|
24
|
+
},
|
|
23
25
|
rootSetState: undefined,
|
|
24
26
|
localState: undefined,
|
|
25
|
-
shouldEvaluateBindings: true
|
|
27
|
+
shouldEvaluateBindings: true
|
|
26
28
|
});
|
|
27
29
|
expect(processed).not.toEqual(block);
|
|
28
30
|
expect(processed.properties?.foo).toEqual('baz');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
-
export declare function getReactNativeBlockStyles({ block, context, blockStyles
|
|
3
|
+
export declare function getReactNativeBlockStyles({ block, context, blockStyles }: {
|
|
4
4
|
block: BuilderBlock;
|
|
5
5
|
context: BuilderContextInterface;
|
|
6
6
|
blockStyles: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sanitizeReactNativeBlockStyles } from './sanitize-react-native-block-styles.js';
|
|
2
|
-
export function getReactNativeBlockStyles({ block, context, blockStyles
|
|
2
|
+
export function getReactNativeBlockStyles({ block, context, blockStyles }) {
|
|
3
3
|
const responsiveStyles = block.responsiveStyles;
|
|
4
4
|
if (!responsiveStyles) {
|
|
5
5
|
return {};
|
|
@@ -10,7 +10,7 @@ export function getReactNativeBlockStyles({ block, context, blockStyles, }) {
|
|
|
10
10
|
...(responsiveStyles.large || {}),
|
|
11
11
|
...(responsiveStyles.medium || {}),
|
|
12
12
|
...(responsiveStyles.small || {}),
|
|
13
|
-
...blockStyles
|
|
13
|
+
...blockStyles
|
|
14
14
|
};
|
|
15
15
|
const newStyles = sanitizeReactNativeBlockStyles(styles);
|
|
16
16
|
return newStyles;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TARGET } from '../constants/target.js';
|
|
2
2
|
// TODO: babel compile to include certain code only if the target matches
|
|
3
|
-
export function ifTarget({ targets, doThing, elseThing
|
|
3
|
+
export function ifTarget({ targets, doThing, elseThing }) {
|
|
4
4
|
if (TARGET && targets.includes(TARGET)) {
|
|
5
5
|
return doThing();
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isBrowser } from './is-browser';
|
|
2
|
+
/**
|
|
3
|
+
* Identifies non-node server runtimes (edge, workers, serverless, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export function isNonNodeServer() {
|
|
6
|
+
const hasNode = () => typeof process !== 'undefined' && process?.versions?.node;
|
|
7
|
+
return !isBrowser() && !hasNode();
|
|
8
|
+
}
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { onChange } from './on-change.js';
|
|
2
2
|
test('onChange can observe a shallow change', () => {
|
|
3
3
|
let changeHappend = false;
|
|
4
|
-
const obj = onChange({
|
|
4
|
+
const obj = onChange({
|
|
5
|
+
foo: 'hi'
|
|
6
|
+
}, () => changeHappend = true);
|
|
5
7
|
obj.foo = 'yo';
|
|
6
8
|
expect(changeHappend).toBe(true);
|
|
7
9
|
});
|
|
8
10
|
test('onChange can observe a deep change', () => {
|
|
9
11
|
let changeHappend = false;
|
|
10
|
-
const obj = onChange({
|
|
12
|
+
const obj = onChange({
|
|
13
|
+
foo: {
|
|
14
|
+
bar: 'hi'
|
|
15
|
+
}
|
|
16
|
+
}, () => changeHappend = true);
|
|
11
17
|
obj.foo.bar = 'yo';
|
|
12
18
|
expect(changeHappend).toBe(true);
|
|
13
19
|
});
|
|
14
20
|
test('Smoke test: callback is not fired if no properties updated', () => {
|
|
15
21
|
let changeHappend = false;
|
|
16
|
-
const obj = onChange({
|
|
22
|
+
const obj = onChange({
|
|
23
|
+
foo: {
|
|
24
|
+
bar: 'hi'
|
|
25
|
+
}
|
|
26
|
+
}, () => changeHappend = true);
|
|
17
27
|
// Access some properties
|
|
18
28
|
obj.foo.bar;
|
|
19
29
|
expect(changeHappend).toBe(false);
|
|
@@ -8,7 +8,8 @@ export declare const components: RegisteredComponent[];
|
|
|
8
8
|
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
9
9
|
*/
|
|
10
10
|
export declare function registerComponent(component: any, info: ComponentInfo): void;
|
|
11
|
-
export declare const createRegisterComponentMessage: (
|
|
11
|
+
export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
|
|
12
12
|
type: string;
|
|
13
13
|
data: ComponentInfo;
|
|
14
14
|
};
|
|
15
|
+
export declare const serializeComponentInfo: ({ inputs, ...info }: ComponentInfo) => ComponentInfo;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { fastClone } from './fast-clone.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
4
|
+
*/
|
|
5
|
+
export const components = [];
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
|
|
8
|
+
*/
|
|
9
|
+
export function registerComponent(component, info) {
|
|
10
|
+
components.push({
|
|
11
|
+
component,
|
|
12
|
+
...info
|
|
13
|
+
});
|
|
14
|
+
console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
|
|
15
|
+
return component;
|
|
16
|
+
}
|
|
17
|
+
export const createRegisterComponentMessage = (info) => ({
|
|
18
|
+
type: 'builder.registerComponent',
|
|
19
|
+
data: info
|
|
20
|
+
});
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
22
|
+
const serializeFn = (fnValue) => {
|
|
23
|
+
const fnStr = fnValue.toString().trim();
|
|
24
|
+
// we need to account for a few different fn syntaxes:
|
|
25
|
+
// 1. `function name(args) => {code}`
|
|
26
|
+
// 2. `name(args) => {code}`
|
|
27
|
+
// 3. `(args) => {}`
|
|
28
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
29
|
+
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
30
|
+
};
|
|
31
|
+
const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
|
|
32
|
+
export const serializeComponentInfo = ({ inputs, ...info }) => ({
|
|
33
|
+
...fastClone(info),
|
|
34
|
+
inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
|
|
35
|
+
...acc,
|
|
36
|
+
[key]: serializeValue(value)
|
|
37
|
+
}), {}))
|
|
38
|
+
});
|
|
@@ -22,8 +22,7 @@ export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
22
22
|
}
|
|
23
23
|
return acc;
|
|
24
24
|
}
|
|
25
|
-
if (propertiesThatMustBeNumber.has(key) &&
|
|
26
|
-
typeof propertyValue !== 'number') {
|
|
25
|
+
if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== 'number') {
|
|
27
26
|
if (SHOW_WARNINGS) {
|
|
28
27
|
console.warn(`Style key ${key} must be a number, but had value \`${styles[key]}\``);
|
|
29
28
|
}
|
|
@@ -37,7 +36,10 @@ export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
37
36
|
const newValue = parseFloat(propertyValue);
|
|
38
37
|
const normalizedValue = normalizeNumber(newValue);
|
|
39
38
|
if (normalizedValue) {
|
|
40
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...acc,
|
|
41
|
+
[key]: normalizedValue
|
|
42
|
+
};
|
|
41
43
|
}
|
|
42
44
|
else {
|
|
43
45
|
return acc;
|
|
@@ -45,9 +47,15 @@ export const sanitizeReactNativeBlockStyles = (styles) => {
|
|
|
45
47
|
}
|
|
46
48
|
else if (propertyValue === '0') {
|
|
47
49
|
// 0 edge case needs to be handled
|
|
48
|
-
return {
|
|
50
|
+
return {
|
|
51
|
+
...acc,
|
|
52
|
+
[key]: 0
|
|
53
|
+
};
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
|
-
return {
|
|
56
|
+
return {
|
|
57
|
+
...acc,
|
|
58
|
+
[key]: propertyValue
|
|
59
|
+
};
|
|
52
60
|
}, {});
|
|
53
61
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
12
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
13
|
+
return obj;
|
|
14
|
+
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { set } from './set.js';
|
|
2
2
|
test('can shallow set a property', () => {
|
|
3
|
-
const obj = {
|
|
3
|
+
const obj = {
|
|
4
|
+
foo: 'bar'
|
|
5
|
+
};
|
|
4
6
|
set(obj, 'foo', 'baz');
|
|
5
7
|
expect(obj.foo).toBe('baz');
|
|
6
8
|
});
|
|
7
9
|
test('can deeply set a property', () => {
|
|
8
|
-
const obj = {
|
|
10
|
+
const obj = {
|
|
11
|
+
foo: 'bar'
|
|
12
|
+
};
|
|
9
13
|
set(obj, 'foo.bar', 'baz');
|
|
10
14
|
expect(obj.foo.bar).toBe('baz');
|
|
11
15
|
});
|
|
12
16
|
test('can deeply create arrays', () => {
|
|
13
|
-
const obj = {
|
|
17
|
+
const obj = {
|
|
18
|
+
foo: 'bar'
|
|
19
|
+
};
|
|
14
20
|
set(obj, 'foo.bar.0', 'hi');
|
|
15
21
|
expect(obj.foo.bar).toEqual(['hi']);
|
|
16
22
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target';
|
|
2
|
-
import { isBrowser } from '../is-browser';
|
|
1
|
+
import { TARGET } from '../../constants/target.js';
|
|
2
|
+
import { isBrowser } from '../is-browser.js';
|
|
3
3
|
const getLocation = () => {
|
|
4
4
|
if (TARGET === 'reactNative') {
|
|
5
5
|
return null;
|
|
@@ -18,7 +18,7 @@ const getLocation = () => {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
const getUserAgent = () =>
|
|
21
|
+
const getUserAgent = () => typeof navigator === 'object' && navigator.userAgent || '';
|
|
22
22
|
export const getUserAttributes = () => {
|
|
23
23
|
const userAgent = getUserAgent();
|
|
24
24
|
const isMobile = {
|
|
@@ -38,19 +38,14 @@ export const getUserAttributes = () => {
|
|
|
38
38
|
return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
|
|
39
39
|
},
|
|
40
40
|
any() {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
isMobile.iOS() ||
|
|
44
|
-
isMobile.Opera() ||
|
|
45
|
-
isMobile.Windows() ||
|
|
46
|
-
TARGET === 'reactNative');
|
|
47
|
-
},
|
|
41
|
+
return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === 'reactNative';
|
|
42
|
+
}
|
|
48
43
|
};
|
|
49
44
|
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
50
45
|
const url = getLocation();
|
|
51
46
|
return {
|
|
52
47
|
urlPath: url?.pathname,
|
|
53
48
|
host: url?.host || url?.hostname,
|
|
54
|
-
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop'
|
|
49
|
+
device: isTablet ? 'tablet' : isMobile.any() ? 'mobile' : 'desktop'
|
|
55
50
|
};
|
|
56
51
|
};
|
|
@@ -5,15 +5,22 @@ import { getVisitorId } from '../../helpers/visitorId.js';
|
|
|
5
5
|
import { isBrowser } from '../is-browser.js';
|
|
6
6
|
import { isEditing } from '../is-editing.js';
|
|
7
7
|
import { getUserAttributes } from './helpers.js';
|
|
8
|
-
const getTrackingEventData = async ({ canTrack
|
|
8
|
+
const getTrackingEventData = async ({ canTrack }) => {
|
|
9
9
|
if (!canTrack) {
|
|
10
|
-
return {
|
|
10
|
+
return {
|
|
11
|
+
visitorId: undefined,
|
|
12
|
+
sessionId: undefined
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
|
-
const sessionId = await getSessionId({
|
|
13
|
-
|
|
15
|
+
const sessionId = await getSessionId({
|
|
16
|
+
canTrack
|
|
17
|
+
});
|
|
18
|
+
const visitorId = getVisitorId({
|
|
19
|
+
canTrack
|
|
20
|
+
});
|
|
14
21
|
return {
|
|
15
22
|
sessionId,
|
|
16
|
-
visitorId
|
|
23
|
+
visitorId
|
|
17
24
|
};
|
|
18
25
|
};
|
|
19
26
|
const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
|
|
@@ -22,12 +29,14 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
22
29
|
...properties,
|
|
23
30
|
metadata: {
|
|
24
31
|
url: location.href,
|
|
25
|
-
...metadata
|
|
32
|
+
...metadata
|
|
26
33
|
},
|
|
27
|
-
...(await getTrackingEventData({
|
|
34
|
+
...(await getTrackingEventData({
|
|
35
|
+
canTrack
|
|
36
|
+
})),
|
|
28
37
|
userAttributes: getUserAttributes(),
|
|
29
|
-
ownerId: apiKey
|
|
30
|
-
}
|
|
38
|
+
ownerId: apiKey
|
|
39
|
+
}
|
|
31
40
|
});
|
|
32
41
|
export async function _track(eventProps) {
|
|
33
42
|
if (!eventProps.apiKey) {
|
|
@@ -46,14 +55,17 @@ export async function _track(eventProps) {
|
|
|
46
55
|
return fetch(`https://cdn.builder.io/api/v1/track`, {
|
|
47
56
|
method: 'POST',
|
|
48
57
|
body: JSON.stringify({
|
|
49
|
-
events: [await createEvent(eventProps)]
|
|
58
|
+
events: [await createEvent(eventProps)]
|
|
50
59
|
}),
|
|
51
60
|
headers: {
|
|
52
|
-
'content-type': 'application/json'
|
|
61
|
+
'content-type': 'application/json'
|
|
53
62
|
},
|
|
54
|
-
mode: 'cors'
|
|
55
|
-
}).catch(
|
|
63
|
+
mode: 'cors'
|
|
64
|
+
}).catch(err => {
|
|
56
65
|
console.error('Failed to track: ', err);
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
|
-
export const track = (args) => _track({
|
|
68
|
+
export const track = (args) => _track({
|
|
69
|
+
...args,
|
|
70
|
+
canTrack: true
|
|
71
|
+
});
|
|
@@ -14,14 +14,14 @@ const findParentElement = (target, callback, checkElement = true) => {
|
|
|
14
14
|
if (matches) {
|
|
15
15
|
return parent;
|
|
16
16
|
}
|
|
17
|
-
} while (
|
|
17
|
+
} while (parent = parent.parentElement);
|
|
18
18
|
return null;
|
|
19
19
|
};
|
|
20
|
-
const findBuilderParent = (target) => findParentElement(target,
|
|
20
|
+
const findBuilderParent = (target) => findParentElement(target, el => {
|
|
21
21
|
const id = el.getAttribute('builder-id') || el.id;
|
|
22
22
|
return Boolean(id?.indexOf('builder-') === 0);
|
|
23
23
|
});
|
|
24
|
-
const computeOffset = ({ event, target
|
|
24
|
+
const computeOffset = ({ event, target }) => {
|
|
25
25
|
const targetRect = target.getBoundingClientRect();
|
|
26
26
|
const xOffset = event.clientX - targetRect.left;
|
|
27
27
|
const yOffset = event.clientY - targetRect.top;
|
|
@@ -29,26 +29,25 @@ const computeOffset = ({ event, target, }) => {
|
|
|
29
29
|
const yRatio = round(yOffset / targetRect.height);
|
|
30
30
|
return {
|
|
31
31
|
x: xRatio,
|
|
32
|
-
y: yRatio
|
|
32
|
+
y: yRatio
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
export const getInteractionPropertiesForEvent = (event) => {
|
|
36
36
|
const target = event.target;
|
|
37
37
|
const targetBuilderElement = target && findBuilderParent(target);
|
|
38
|
-
const builderId = targetBuilderElement?.getAttribute('builder-id') ||
|
|
39
|
-
targetBuilderElement?.id;
|
|
38
|
+
const builderId = targetBuilderElement?.getAttribute('builder-id') || targetBuilderElement?.id;
|
|
40
39
|
return {
|
|
41
40
|
targetBuilderElement: builderId || undefined,
|
|
42
41
|
metadata: {
|
|
43
|
-
targetOffset: target ? computeOffset({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
42
|
+
targetOffset: target ? computeOffset({
|
|
43
|
+
event,
|
|
44
|
+
target
|
|
45
|
+
}) : undefined,
|
|
46
|
+
builderTargetOffset: targetBuilderElement ? computeOffset({
|
|
47
|
+
event,
|
|
48
|
+
target: targetBuilderElement
|
|
49
|
+
}) : undefined,
|
|
50
|
+
builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : undefined
|
|
51
|
+
}
|
|
53
52
|
};
|
|
54
53
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transformBlockProperties(properties: any): any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
2
|
import type { BuilderContent } from '../types/builder-content.js';
|
|
3
3
|
import type { Nullable } from '../types/typescript.js';
|
|
4
|
-
export declare const handleABTestingSync: ({ item, canTrack
|
|
4
|
+
export declare const handleABTestingSync: ({ item, canTrack }: {
|
|
5
5
|
item: Nullable<BuilderContent>;
|
|
6
6
|
} & CanTrack) => Nullable<BuilderContent>;
|
|
7
|
-
export declare const handleABTesting: ({ item, canTrack
|
|
7
|
+
export declare const handleABTesting: ({ item, canTrack }: {
|
|
8
8
|
item: BuilderContent;
|
|
9
9
|
} & CanTrack) => Promise<BuilderContent>;
|