@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
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { BuilderContextInterface, RegisteredComponent } from '../context/types';
|
|
2
|
-
import type { BuilderBlock } from './builder-block';
|
|
3
|
-
import type { Dictionary } from './typescript';
|
|
4
|
-
export type PropsWithBuilderData<T> = T & {
|
|
5
|
-
builderBlock: BuilderBlock;
|
|
6
|
-
builderContext: BuilderContextInterface;
|
|
7
|
-
};
|
|
8
|
-
export type BuilderComponentsProp = {
|
|
9
|
-
builderComponents: Dictionary<RegisteredComponent>;
|
|
10
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
type QueryObject = Record<string, string | string[]>;
|
|
2
|
-
export declare const convertSearchParamsToQueryObject: (searchParams: URLSearchParams) => QueryObject;
|
|
3
|
-
export declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
|
|
4
|
-
export declare const getBuilderSearchParamsFromWindow: () => QueryObject;
|
|
5
|
-
export declare const normalizeSearchParams: (searchParams: QueryObject | URLSearchParams) => QueryObject;
|
|
6
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from '../is-browser.js';
|
|
2
|
-
const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
|
|
3
|
-
const BUILDER_OPTIONS_PREFIX = 'options.';
|
|
4
|
-
export const convertSearchParamsToQueryObject = (searchParams) => {
|
|
5
|
-
const options = {};
|
|
6
|
-
searchParams.forEach((value, key) => {
|
|
7
|
-
options[key] = value;
|
|
8
|
-
});
|
|
9
|
-
return options;
|
|
10
|
-
};
|
|
11
|
-
export const getBuilderSearchParams = (_options) => {
|
|
12
|
-
if (!_options) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
const options = normalizeSearchParams(_options);
|
|
16
|
-
const newOptions = {};
|
|
17
|
-
Object.keys(options).forEach((key) => {
|
|
18
|
-
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
19
|
-
const trimmedKey = key
|
|
20
|
-
.replace(BUILDER_SEARCHPARAMS_PREFIX, '')
|
|
21
|
-
.replace(BUILDER_OPTIONS_PREFIX, '');
|
|
22
|
-
newOptions[trimmedKey] = options[key];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return newOptions;
|
|
26
|
-
};
|
|
27
|
-
export const getBuilderSearchParamsFromWindow = () => {
|
|
28
|
-
if (!isBrowser()) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
32
|
-
return getBuilderSearchParams(searchParams);
|
|
33
|
-
};
|
|
34
|
-
export const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams
|
|
35
|
-
? convertSearchParamsToQueryObject(searchParams)
|
|
36
|
-
: searchParams;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getContentVariationCookie, setContentVariationCookie, } from '../../helpers/ab-tests.js';
|
|
2
|
-
import { checkIsDefined } from '../../helpers/nullable.js';
|
|
3
|
-
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) &&
|
|
4
|
-
checkIsDefined(item.variations) &&
|
|
5
|
-
Object.keys(item.variations).length > 0;
|
|
6
|
-
/**
|
|
7
|
-
* Randomly assign a variation to this user and store it in cookies/storage
|
|
8
|
-
*/
|
|
9
|
-
const getRandomVariationId = ({ id, variations, }) => {
|
|
10
|
-
let n = 0;
|
|
11
|
-
const random = Math.random();
|
|
12
|
-
// loop over variations test ratios, incrementing a counter,
|
|
13
|
-
// until we find the variation that this user should be assigned to
|
|
14
|
-
for (const id in variations) {
|
|
15
|
-
const testRatio = variations[id]?.testRatio;
|
|
16
|
-
n += testRatio;
|
|
17
|
-
if (random < n) {
|
|
18
|
-
return id;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// `item.variations` does not include the default variation
|
|
22
|
-
// if we arrive here, then it means that the random number fits in the default variation bucket
|
|
23
|
-
return id;
|
|
24
|
-
};
|
|
25
|
-
const getTestFields = ({ item, testGroupId, }) => {
|
|
26
|
-
const variationValue = item.variations[testGroupId];
|
|
27
|
-
if (testGroupId === item.id ||
|
|
28
|
-
// handle edge-case where `testGroupId` points to non-existing variation
|
|
29
|
-
!variationValue) {
|
|
30
|
-
return {
|
|
31
|
-
testVariationId: item.id,
|
|
32
|
-
testVariationName: 'Default',
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return {
|
|
37
|
-
data: variationValue.data,
|
|
38
|
-
testVariationId: variationValue.id,
|
|
39
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : ''),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const getContentVariation = async ({ item, canTrack, }) => {
|
|
44
|
-
// try to find test variation in cookies/storage
|
|
45
|
-
const testGroupId = await getContentVariationCookie({
|
|
46
|
-
canTrack,
|
|
47
|
-
contentId: item.id,
|
|
48
|
-
});
|
|
49
|
-
const testFields = testGroupId
|
|
50
|
-
? getTestFields({ item, testGroupId })
|
|
51
|
-
: undefined;
|
|
52
|
-
if (testFields) {
|
|
53
|
-
return testFields;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// if variation not found in storage, assign a random variation to this user
|
|
57
|
-
const randomVariationId = getRandomVariationId({
|
|
58
|
-
variations: item.variations,
|
|
59
|
-
id: item.id,
|
|
60
|
-
});
|
|
61
|
-
// store variation in cookies/storage
|
|
62
|
-
setContentVariationCookie({
|
|
63
|
-
contentId: item.id,
|
|
64
|
-
value: randomVariationId,
|
|
65
|
-
canTrack,
|
|
66
|
-
}).catch((err) => {
|
|
67
|
-
console.error('could not store A/B test variation: ', err);
|
|
68
|
-
});
|
|
69
|
-
return getTestFields({ item, testGroupId: randomVariationId });
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
export const handleABTesting = async ({ item, canTrack, }) => {
|
|
73
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const variationValue = await getContentVariation({ item, canTrack });
|
|
77
|
-
Object.assign(item, variationValue);
|
|
78
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { flatten } from '../../helpers/flatten.js';
|
|
2
|
-
import { getBuilderSearchParamsFromWindow, normalizeSearchParams, } from '../get-builder-search-params/index.js';
|
|
3
|
-
import { DEFAULT_API_VERSION } from '../../types/api-version';
|
|
4
|
-
export const generateContentUrl = (options) => {
|
|
5
|
-
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = DEFAULT_API_VERSION, } = options;
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error('Missing API key');
|
|
8
|
-
}
|
|
9
|
-
if (!['v2', 'v3'].includes(apiVersion)) {
|
|
10
|
-
throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
|
|
11
|
-
}
|
|
12
|
-
const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
|
|
13
|
-
const queryOptions = {
|
|
14
|
-
...getBuilderSearchParamsFromWindow(),
|
|
15
|
-
...normalizeSearchParams(options.options || {}),
|
|
16
|
-
};
|
|
17
|
-
const flattened = flatten(queryOptions);
|
|
18
|
-
for (const key in flattened) {
|
|
19
|
-
url.searchParams.set(key, String(flattened[key]));
|
|
20
|
-
}
|
|
21
|
-
if (userAttributes) {
|
|
22
|
-
url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
|
|
23
|
-
}
|
|
24
|
-
if (query) {
|
|
25
|
-
const flattened = flatten({ query });
|
|
26
|
-
for (const key in flattened) {
|
|
27
|
-
url.searchParams.set(key, JSON.stringify(flattened[key]));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return url;
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { generateContentUrl } from './generate-content-url';
|
|
2
|
-
const testKey = 'YJIGb4i01jvw0SRdL5Bt';
|
|
3
|
-
const testModel = 'page';
|
|
4
|
-
const testId = 'c1b81bab59704599b997574eb0736def';
|
|
5
|
-
const options = {
|
|
6
|
-
cachebust: 'true',
|
|
7
|
-
noCache: 'true',
|
|
8
|
-
'overrides.037948e52eaf4743afed464f02c70da4': '037948e52eaf4743afed464f02c70da4',
|
|
9
|
-
'overrides.page': '037948e52eaf4743afed464f02c70da4',
|
|
10
|
-
'overrides.page:/': '037948e52eaf4743afed464f02c70da4',
|
|
11
|
-
preview: 'page',
|
|
12
|
-
};
|
|
13
|
-
describe('Generate Content URL', () => {
|
|
14
|
-
test('generates the proper value for a simple query', () => {
|
|
15
|
-
const output = generateContentUrl({
|
|
16
|
-
apiKey: testKey,
|
|
17
|
-
model: testModel,
|
|
18
|
-
query: { id: testId },
|
|
19
|
-
});
|
|
20
|
-
expect(output).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
test('Handles overrides correctly', () => {
|
|
23
|
-
const output = generateContentUrl({
|
|
24
|
-
apiKey: testKey,
|
|
25
|
-
model: testModel,
|
|
26
|
-
query: { id: testId },
|
|
27
|
-
options,
|
|
28
|
-
});
|
|
29
|
-
expect(output).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
test('generate content url with apiVersion as default', () => {
|
|
32
|
-
const output = generateContentUrl({
|
|
33
|
-
apiKey: testKey,
|
|
34
|
-
model: testModel,
|
|
35
|
-
query: { id: testId },
|
|
36
|
-
options,
|
|
37
|
-
});
|
|
38
|
-
expect(output).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
test('generate content url with apiVersion as v2', () => {
|
|
41
|
-
const output = generateContentUrl({
|
|
42
|
-
apiKey: testKey,
|
|
43
|
-
model: testModel,
|
|
44
|
-
query: { id: testId },
|
|
45
|
-
options,
|
|
46
|
-
apiVersion: 'v2',
|
|
47
|
-
});
|
|
48
|
-
expect(output).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
test('generate content url with apiVersion as v3', () => {
|
|
51
|
-
const output = generateContentUrl({
|
|
52
|
-
apiKey: testKey,
|
|
53
|
-
model: testModel,
|
|
54
|
-
query: { id: testId },
|
|
55
|
-
options,
|
|
56
|
-
apiVersion: 'v3',
|
|
57
|
-
});
|
|
58
|
-
expect(output).toMatchSnapshot();
|
|
59
|
-
});
|
|
60
|
-
test('throw error when trying to generate content url with apiVersion as v1', () => {
|
|
61
|
-
expect(() => {
|
|
62
|
-
generateContentUrl({
|
|
63
|
-
apiKey: testKey,
|
|
64
|
-
model: testModel,
|
|
65
|
-
query: { id: testId },
|
|
66
|
-
options,
|
|
67
|
-
apiVersion: 'v1',
|
|
68
|
-
});
|
|
69
|
-
}).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'v1'`);
|
|
70
|
-
});
|
|
71
|
-
test('throw error when trying to generate content url with an invalid apiVersion value', () => {
|
|
72
|
-
expect(() => {
|
|
73
|
-
generateContentUrl({
|
|
74
|
-
apiKey: testKey,
|
|
75
|
-
model: testModel,
|
|
76
|
-
query: { id: testId },
|
|
77
|
-
options,
|
|
78
|
-
apiVersion: 'INVALID_API_VERSION',
|
|
79
|
-
});
|
|
80
|
-
}).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'INVALID_API_VERSION'`);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { BuilderContent } from '../../types/builder-content.js';
|
|
2
|
-
import type { GetContentOptions } from './types.js';
|
|
3
|
-
export declare function getContent(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
4
|
-
type ContentResponse = {
|
|
5
|
-
results: BuilderContent[];
|
|
6
|
-
} | {
|
|
7
|
-
status: number;
|
|
8
|
-
message: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function getAllContent(options: GetContentOptions): Promise<ContentResponse | null>;
|
|
11
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { logger } from '../../helpers/logger.js';
|
|
2
|
-
import { fetch } from '../get-fetch.js';
|
|
3
|
-
import { handleABTesting } from './ab-testing.js';
|
|
4
|
-
import { generateContentUrl } from './generate-content-url.js';
|
|
5
|
-
export async function getContent(options) {
|
|
6
|
-
const allContent = await getAllContent({ ...options, limit: 1 });
|
|
7
|
-
if (allContent && 'results' in allContent) {
|
|
8
|
-
return allContent?.results[0] || null;
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
export async function getAllContent(options) {
|
|
13
|
-
try {
|
|
14
|
-
const url = generateContentUrl(options);
|
|
15
|
-
const res = await fetch(url.href);
|
|
16
|
-
const content = await res.json();
|
|
17
|
-
if ('status' in content && !('results' in content)) {
|
|
18
|
-
logger.error('Error fetching data. ', { url, content, options });
|
|
19
|
-
return content;
|
|
20
|
-
}
|
|
21
|
-
const canTrack = options.canTrack !== false;
|
|
22
|
-
try {
|
|
23
|
-
if (canTrack &&
|
|
24
|
-
// This makes sure we have a non-error response with the results array.
|
|
25
|
-
Array.isArray(content.results)) {
|
|
26
|
-
for (const item of content.results) {
|
|
27
|
-
await handleABTesting({ item, canTrack });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger.error('Could not setup A/B testing. ', e);
|
|
33
|
-
}
|
|
34
|
-
return content;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
logger.error('Error fetching data. ', error);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export interface GetContentOptions {
|
|
2
|
-
/** The model to get content for */
|
|
3
|
-
model: string;
|
|
4
|
-
/** Your public API key */
|
|
5
|
-
apiKey: string;
|
|
6
|
-
/** Number of items to fetch. Default is 1 */
|
|
7
|
-
limit?: number;
|
|
8
|
-
/** User attributes to target on, such as { urlPath: '/foo', device: 'mobile', ...etc } */
|
|
9
|
-
userAttributes?: (Record<string, string> & {
|
|
10
|
-
urlPath?: string;
|
|
11
|
-
}) | null;
|
|
12
|
-
/** Custom query */
|
|
13
|
-
query?: Record<string, any>;
|
|
14
|
-
/**
|
|
15
|
-
* Any other API options.
|
|
16
|
-
* Accepts both a key/value object or a `URLSearchParams` instance
|
|
17
|
-
* */
|
|
18
|
-
options?: Record<string, any> | URLSearchParams;
|
|
19
|
-
/**
|
|
20
|
-
* If set to `true`, it will lazy load symbols/references.
|
|
21
|
-
* If set to `false`, it will render the entire content tree eagerly.
|
|
22
|
-
*/
|
|
23
|
-
noTraverse?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
|
|
26
|
-
* only the default variation will be returned to every user.
|
|
27
|
-
*
|
|
28
|
-
* Defaults to `true`.
|
|
29
|
-
*/
|
|
30
|
-
canTrack?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Include references in the response. Defaults to `true`.
|
|
33
|
-
*/
|
|
34
|
-
includeRefs?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* If provided, the API will auto-resolve localized objects to the value of this `locale` key.
|
|
37
|
-
*/
|
|
38
|
-
locale?: string;
|
|
39
|
-
/**
|
|
40
|
-
* If provided, sets the Builder API version used to fetch content.
|
|
41
|
-
*
|
|
42
|
-
* Defaults to `v3`.
|
|
43
|
-
*/
|
|
44
|
-
apiVersion?: 'v2' | 'v3';
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetch: typeof globalThis.fetch;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getGlobalThis } from './get-global-this.js';
|
|
2
|
-
function getFetch() {
|
|
3
|
-
const globalFetch = getGlobalThis().fetch;
|
|
4
|
-
if (typeof globalFetch === 'undefined') {
|
|
5
|
-
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
6
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
7
|
-
throw new Error('Builder SDK could not find a global `fetch` function');
|
|
8
|
-
}
|
|
9
|
-
return globalFetch;
|
|
10
|
-
}
|
|
11
|
-
export const fetch = getFetch();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function getGlobalThis() {
|
|
2
|
-
if (typeof globalThis !== 'undefined') {
|
|
3
|
-
return globalThis;
|
|
4
|
-
}
|
|
5
|
-
if (typeof window !== 'undefined') {
|
|
6
|
-
return window;
|
|
7
|
-
}
|
|
8
|
-
if (typeof global !== 'undefined') {
|
|
9
|
-
return global;
|
|
10
|
-
}
|
|
11
|
-
if (typeof self !== 'undefined') {
|
|
12
|
-
return self;
|
|
13
|
-
}
|
|
14
|
-
return globalThis;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isBrowser(): boolean;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
-
export declare const getContentVariationCookie: ({ contentId, canTrack, }: {
|
|
3
|
-
contentId: string;
|
|
4
|
-
} & CanTrack) => Promise<string>;
|
|
5
|
-
export declare const setContentVariationCookie: ({ contentId, canTrack, value, }: {
|
|
6
|
-
contentId: string;
|
|
7
|
-
value: string;
|
|
8
|
-
} & CanTrack) => Promise<void>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { getCookie, setCookie } from './cookie.js';
|
|
2
|
-
const BUILDER_STORE_PREFIX = 'builderio.variations';
|
|
3
|
-
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
4
|
-
export const getContentVariationCookie = ({ contentId, canTrack, }) => getCookie({ name: getContentTestKey(contentId), canTrack });
|
|
5
|
-
export const setContentVariationCookie = ({ contentId, canTrack, value, }) => setCookie({ name: getContentTestKey(contentId), value, canTrack });
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
-
/**
|
|
3
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
4
|
-
*/
|
|
5
|
-
export declare const getCookie: ({ name, canTrack, }: {
|
|
6
|
-
name: string;
|
|
7
|
-
} & CanTrack) => Promise<string | undefined>;
|
|
8
|
-
/**
|
|
9
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
10
|
-
*/
|
|
11
|
-
export declare const setCookie: ({ name, value, expires, canTrack, }: {
|
|
12
|
-
name: string;
|
|
13
|
-
value: string;
|
|
14
|
-
expires?: Date;
|
|
15
|
-
} & CanTrack) => Promise<void>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from '../functions/is-browser.js';
|
|
2
|
-
import { checkIsDefined } from './nullable.js';
|
|
3
|
-
import { getTopLevelDomain } from './url.js';
|
|
4
|
-
/**
|
|
5
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
6
|
-
*/
|
|
7
|
-
export const getCookie = async ({ name, canTrack, }) => {
|
|
8
|
-
try {
|
|
9
|
-
if (!canTrack) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Extracted from MDN docs
|
|
14
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#example_2_get_a_sample_cookie_named_test2
|
|
15
|
-
*/
|
|
16
|
-
return document.cookie
|
|
17
|
-
.split('; ')
|
|
18
|
-
.find((row) => row.startsWith(`${name}=`))
|
|
19
|
-
?.split('=')[1];
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
console.debug('[COOKIE] GET error: ', err);
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const stringifyCookie = (cookie) => cookie
|
|
27
|
-
.map(([key, value]) => (value ? `${key}=${value}` : key))
|
|
28
|
-
.filter(checkIsDefined)
|
|
29
|
-
.join('; ');
|
|
30
|
-
const SECURE_CONFIG = [
|
|
31
|
-
['secure', ''],
|
|
32
|
-
['SameSite', 'None'],
|
|
33
|
-
];
|
|
34
|
-
const createCookieString = ({ name, value, expires, }) => {
|
|
35
|
-
const secure = isBrowser() ? location.protocol === 'https:' : true;
|
|
36
|
-
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
37
|
-
// TODO: need to know if secure server side
|
|
38
|
-
const expiresObj = expires
|
|
39
|
-
? [['expires', expires.toUTCString()]]
|
|
40
|
-
: [[]];
|
|
41
|
-
const cookieValue = [
|
|
42
|
-
[name, value],
|
|
43
|
-
...expiresObj,
|
|
44
|
-
['path', '/'],
|
|
45
|
-
['domain', getTopLevelDomain(window.location.hostname)],
|
|
46
|
-
...secureObj,
|
|
47
|
-
];
|
|
48
|
-
const cookie = stringifyCookie(cookieValue);
|
|
49
|
-
return cookie;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
53
|
-
*/
|
|
54
|
-
export const setCookie = async ({ name, value, expires, canTrack, }) => {
|
|
55
|
-
try {
|
|
56
|
-
if (!canTrack) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const cookie = createCookieString({ name, value, expires });
|
|
60
|
-
document.cookie = cookie;
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
console.warn('[COOKIE] SET error: ', err);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert deep object to a flat object with dots
|
|
3
|
-
*
|
|
4
|
-
* { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
|
|
5
|
-
*/
|
|
6
|
-
export function flatten(object, path = null, separator = '.') {
|
|
7
|
-
return Object.keys(object).reduce((acc, key) => {
|
|
8
|
-
const value = object[key];
|
|
9
|
-
const newPath = [path, key].filter(Boolean).join(separator);
|
|
10
|
-
const isObject = [
|
|
11
|
-
typeof value === 'object',
|
|
12
|
-
value !== null,
|
|
13
|
-
!(Array.isArray(value) && value.length === 0),
|
|
14
|
-
].every(Boolean);
|
|
15
|
-
return isObject
|
|
16
|
-
? { ...acc, ...flatten(value, newPath, separator) }
|
|
17
|
-
: { ...acc, [newPath]: value };
|
|
18
|
-
}, {});
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== undefined;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Only gets one level up from hostname
|
|
3
|
-
* wwww.example.com -> example.com
|
|
4
|
-
* www.example.co.uk -> example.co.uk
|
|
5
|
-
*/
|
|
6
|
-
export const getTopLevelDomain = (host) => {
|
|
7
|
-
if (host === 'localhost' || host === '127.0.0.1') {
|
|
8
|
-
return host;
|
|
9
|
-
}
|
|
10
|
-
const parts = host.split('.');
|
|
11
|
-
if (parts.length > 2) {
|
|
12
|
-
return parts.slice(1).join('.');
|
|
13
|
-
}
|
|
14
|
-
return host;
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_API_VERSION = 'v3';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
interface JSONObject {
|
|
3
|
-
[x: string]: JSONValue;
|
|
4
|
-
}
|
|
5
|
-
interface JSONArray extends Array<JSONValue> {
|
|
6
|
-
}
|
|
7
|
-
/** @todo typedoc this */
|
|
8
|
-
export interface BuilderBlock {
|
|
9
|
-
'@type': '@builder.io/sdk:Element';
|
|
10
|
-
'@version'?: number;
|
|
11
|
-
id?: string;
|
|
12
|
-
tagName?: string;
|
|
13
|
-
layerName?: string;
|
|
14
|
-
groupLocked?: boolean;
|
|
15
|
-
layerLocked?: boolean;
|
|
16
|
-
/** @todo make alias for properties.class */
|
|
17
|
-
class?: string;
|
|
18
|
-
children?: BuilderBlock[];
|
|
19
|
-
responsiveStyles?: {
|
|
20
|
-
large?: Partial<CSSStyleDeclaration>;
|
|
21
|
-
medium?: Partial<CSSStyleDeclaration>;
|
|
22
|
-
small?: Partial<CSSStyleDeclaration>;
|
|
23
|
-
/** @deprecated */
|
|
24
|
-
xsmall?: Partial<CSSStyleDeclaration>;
|
|
25
|
-
};
|
|
26
|
-
component?: {
|
|
27
|
-
name: string;
|
|
28
|
-
options?: any;
|
|
29
|
-
tag?: string;
|
|
30
|
-
};
|
|
31
|
-
bindings?: {
|
|
32
|
-
[key: string]: string;
|
|
33
|
-
};
|
|
34
|
-
meta?: {
|
|
35
|
-
[key: string]: JSONValue;
|
|
36
|
-
};
|
|
37
|
-
actions?: {
|
|
38
|
-
[key: string]: string;
|
|
39
|
-
};
|
|
40
|
-
properties?: {
|
|
41
|
-
[key: string]: string;
|
|
42
|
-
};
|
|
43
|
-
code?: {
|
|
44
|
-
bindings?: {
|
|
45
|
-
[key: string]: string;
|
|
46
|
-
};
|
|
47
|
-
actions?: {
|
|
48
|
-
[key: string]: string;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
repeat?: {
|
|
52
|
-
collection: string;
|
|
53
|
-
itemName?: string;
|
|
54
|
-
} | null;
|
|
55
|
-
animations?: any[];
|
|
56
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
57
|
-
/**
|
|
58
|
-
* generated by the "Hide If" binding
|
|
59
|
-
*/
|
|
60
|
-
hide?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* generated by the "Show If" binding
|
|
63
|
-
*/
|
|
64
|
-
show?: boolean;
|
|
65
|
-
}
|
|
66
|
-
export {};
|