@builder.io/sdk-svelte 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/package/--package.json +43 -29
- package/package/CHANGELOG.md +13 -0
- package/package/blocks/BaseText.svelte +1 -1
- package/package/blocks/button/button.svelte +18 -33
- package/package/blocks/button/button.svelte.d.ts +3 -1
- package/package/blocks/button/component-info.d.ts +1 -1
- package/package/blocks/button/component-info.js +9 -13
- package/package/blocks/columns/columns.svelte +14 -20
- package/package/blocks/columns/columns.svelte.d.ts +11 -7
- package/package/blocks/columns/component-info.d.ts +1 -1
- package/package/blocks/columns/component-info.js +62 -83
- package/package/blocks/custom-code/component-info.d.ts +1 -1
- package/package/blocks/custom-code/component-info.js +7 -11
- package/package/blocks/embed/component-info.d.ts +1 -1
- package/package/blocks/embed/component-info.js +8 -15
- package/package/blocks/embed/helpers.js +1 -5
- package/package/blocks/form/component-info.d.ts +1 -1
- package/package/blocks/form/component-info.js +94 -129
- package/package/blocks/form/form.svelte +2 -289
- package/package/blocks/form/form.svelte.d.ts +1 -57
- package/package/blocks/fragment/component-info.d.ts +1 -1
- package/package/blocks/fragment/component-info.js +1 -1
- package/package/blocks/helpers.d.ts +13 -0
- package/package/blocks/helpers.js +40 -0
- package/package/blocks/image/component-info.d.ts +1 -1
- package/package/blocks/image/component-info.js +33 -63
- package/package/blocks/image/image.helpers.js +2 -11
- package/package/blocks/image/image.svelte.d.ts +0 -1
- package/package/blocks/img/component-info.d.ts +1 -1
- package/package/blocks/img/component-info.js +4 -6
- package/package/blocks/img/img.svelte +4 -29
- package/package/blocks/img/img.svelte.d.ts +3 -1
- package/package/blocks/input/component-info.d.ts +1 -1
- package/package/blocks/input/component-info.js +15 -40
- package/package/blocks/input/input.svelte +4 -29
- package/package/blocks/input/input.svelte.d.ts +3 -1
- package/package/blocks/raw-text/component-info.d.ts +1 -1
- package/package/blocks/raw-text/component-info.js +3 -5
- package/package/blocks/raw-text/raw-text.svelte +3 -5
- package/package/blocks/raw-text/raw-text.svelte.d.ts +1 -1
- package/package/blocks/section/component-info.d.ts +1 -1
- package/package/blocks/section/component-info.js +13 -18
- package/package/blocks/section/section.svelte +4 -29
- package/package/blocks/section/section.svelte.d.ts +3 -1
- package/package/blocks/select/component-info.d.ts +1 -1
- package/package/blocks/select/component-info.js +22 -34
- package/package/blocks/select/select.svelte +4 -29
- package/package/blocks/select/select.svelte.d.ts +3 -1
- package/package/blocks/submit-button/component-info.d.ts +1 -1
- package/package/blocks/submit-button/component-info.js +5 -7
- package/package/blocks/submit-button/submit-button.svelte +4 -29
- package/package/blocks/submit-button/submit-button.svelte.d.ts +3 -1
- package/package/blocks/symbol/component-info.d.ts +1 -1
- package/package/blocks/symbol/component-info.js +12 -17
- package/package/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/package/blocks/symbol/symbol.helpers.js +31 -0
- package/package/blocks/symbol/symbol.svelte +38 -85
- package/package/blocks/symbol/symbol.svelte.d.ts +13 -7
- package/package/blocks/text/component-info.d.ts +1 -1
- package/package/blocks/text/component-info.js +6 -7
- package/package/blocks/text/text.svelte +1 -1
- package/package/blocks/text/text.svelte.d.ts +1 -1
- package/package/blocks/textarea/component-info.d.ts +1 -1
- package/package/blocks/textarea/component-info.js +13 -19
- package/package/blocks/textarea/textarea.svelte +4 -29
- package/package/blocks/textarea/textarea.svelte.d.ts +3 -1
- package/package/blocks/video/component-info.d.ts +1 -1
- package/package/blocks/video/component-info.js +35 -55
- package/package/blocks/video/video.svelte +4 -30
- package/package/blocks/video/video.svelte.d.ts +2 -0
- package/package/components/block/block.helpers.d.ts +13 -0
- package/package/components/{render-block/render-block.helpers.js → block/block.helpers.js} +12 -29
- package/package/components/block/block.svelte +135 -0
- package/package/components/block/block.svelte.d.ts +26 -0
- package/package/components/{render-block → block/components}/block-styles.svelte +21 -23
- package/package/components/{render-block → block/components}/block-styles.svelte.d.ts +2 -2
- package/package/components/block/components/block-wrapper.svelte +53 -0
- package/package/components/block/components/block-wrapper.svelte.d.ts +33 -0
- package/package/components/block/components/component-ref/component-ref.helpers.d.ts +36 -0
- package/package/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/package/components/block/components/component-ref/component-ref.svelte +37 -0
- package/package/components/block/components/component-ref/component-ref.svelte.d.ts +24 -0
- package/package/components/block/components/interactive-element.svelte +29 -0
- package/package/components/block/components/interactive-element.svelte.d.ts +31 -0
- package/package/components/{render-block/render-repeated-block.svelte → block/components/repeated-block.svelte} +4 -3
- package/package/components/block/components/repeated-block.svelte.d.ts +25 -0
- package/package/components/{render-blocks.svelte → blocks/blocks-wrapper.svelte} +3 -20
- package/package/components/blocks/blocks-wrapper.svelte.d.ts +29 -0
- package/package/components/blocks/blocks.svelte +26 -0
- package/package/components/blocks/blocks.svelte.d.ts +28 -0
- package/package/components/{render-content/render-content.svelte → content/components/enable-editor.svelte} +51 -169
- package/package/components/content/components/enable-editor.svelte.d.ts +36 -0
- package/package/components/{render-content/components/render-styles.helpers.d.ts → content/components/styles.helpers.d.ts} +1 -1
- package/package/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +3 -4
- package/package/components/{render-content/components/render-styles.svelte → content/components/styles.svelte} +4 -4
- package/package/components/{render-content/components/render-styles.svelte.d.ts → content/components/styles.svelte.d.ts} +5 -5
- package/package/components/content/content.helpers.d.ts +7 -0
- package/package/components/content/content.helpers.js +30 -0
- package/package/components/content/content.svelte +113 -0
- package/package/components/content/content.svelte.d.ts +30 -0
- package/package/components/content/content.types.d.ts +24 -0
- package/package/components/content/index.d.ts +1 -0
- package/package/components/content/index.js +1 -0
- package/package/components/content-variants/content-variants.svelte +98 -0
- package/package/components/content-variants/content-variants.svelte.d.ts +34 -0
- package/package/components/content-variants/content-variants.types.d.ts +20 -0
- package/package/components/content-variants/helpers.d.ts +41 -0
- package/package/components/{render-content-variants → content-variants}/helpers.js +46 -41
- package/package/components/inlined-script.svelte +7 -0
- package/package/components/inlined-script.svelte.d.ts +21 -0
- package/package/components/inlined-styles.svelte.d.ts +21 -0
- package/package/constants/builder-registered-components.js +34 -13
- package/package/constants/device-sizes.js +9 -8
- package/package/constants/sdk-version.d.ts +1 -1
- package/package/constants/sdk-version.js +1 -1
- package/package/constants/target.d.ts +1 -1
- package/package/context/builder.context.d.ts +1 -1
- package/package/context/builder.context.js +1 -1
- package/package/context/types.d.ts +1 -1
- package/package/functions/apply-patch-with-mutation.d.ts +10 -0
- package/package/functions/apply-patch-with-mutation.js +54 -0
- package/package/functions/evaluate/acorn.d.ts +0 -0
- package/package/functions/evaluate/acorn.js +2433 -0
- package/package/functions/{evaluate.d.ts → evaluate/evaluate.d.ts} +5 -2
- package/package/functions/{evaluate.js → evaluate/evaluate.js} +34 -13
- package/package/functions/evaluate/index.d.ts +1 -0
- package/package/functions/evaluate/index.js +1 -0
- package/package/functions/evaluate/interpreter.d.ts +2 -0
- package/package/functions/evaluate/interpreter.js +3853 -0
- package/package/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/package/functions/evaluate/non-node-runtime.js +84 -0
- package/package/functions/evaluate/types.d.ts +10 -0
- package/package/functions/extract-text-styles.js +2 -14
- package/package/functions/get-block-actions-handler.js +3 -3
- package/package/functions/get-block-actions.d.ts +1 -0
- package/package/functions/get-block-actions.js +14 -1
- package/package/functions/get-block-component-options.js +1 -1
- package/package/functions/get-block-properties.d.ts +5 -1
- package/package/functions/get-block-properties.js +15 -9
- package/package/functions/get-builder-search-params/index.js +3 -7
- package/package/functions/get-content/generate-content-url.js +7 -5
- package/package/functions/get-content/index.d.ts +2 -6
- package/package/functions/get-content/index.js +26 -6
- package/package/functions/get-processed-block.d.ts +1 -1
- package/package/functions/get-processed-block.js +11 -7
- package/package/functions/get-react-native-block-styles.d.ts +1 -1
- package/package/functions/get-react-native-block-styles.js +2 -2
- package/package/functions/if-target.d.ts +1 -1
- package/package/functions/if-target.js +1 -1
- package/package/functions/is-editing.js +1 -3
- package/package/functions/is-non-node-server.d.ts +4 -0
- package/package/functions/is-non-node-server.js +8 -0
- package/package/functions/on-change.js +1 -1
- package/package/functions/register-component.d.ts +2 -1
- package/package/functions/register-component.js +20 -8
- package/package/functions/register.js +2 -2
- package/package/functions/sanitize-react-native-block-styles.js +13 -5
- package/package/functions/set-editor-settings.js +1 -1
- package/package/functions/set.js +2 -9
- package/package/functions/track/helpers.js +6 -11
- package/package/functions/track/index.js +26 -14
- package/package/functions/track/interaction.js +15 -16
- package/package/helpers/ab-tests.d.ts +2 -2
- package/package/helpers/ab-tests.js +48 -30
- package/package/helpers/canTrack.js +1 -1
- package/package/helpers/cookie.d.ts +2 -2
- package/package/helpers/cookie.js +13 -26
- package/package/helpers/css.d.ts +1 -1
- package/package/helpers/css.js +1 -1
- package/package/helpers/flatten.js +8 -8
- package/package/helpers/localStorage.d.ts +2 -2
- package/package/helpers/localStorage.js +2 -2
- package/package/helpers/logger.js +1 -1
- package/package/helpers/preview-lru-cache/get.d.ts +1 -0
- package/package/helpers/preview-lru-cache/get.js +7 -0
- package/package/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/package/helpers/preview-lru-cache/helpers.js +9 -0
- package/package/helpers/preview-lru-cache/init.d.ts +6 -0
- package/package/helpers/preview-lru-cache/init.js +15 -0
- package/package/helpers/preview-lru-cache/set.d.ts +7 -0
- package/package/helpers/preview-lru-cache/set.js +9 -0
- package/package/helpers/preview-lru-cache/types.d.ts +12 -0
- package/package/helpers/preview-lru-cache/types.js +6 -0
- package/package/helpers/sessionId.d.ts +2 -2
- package/package/helpers/sessionId.js +11 -4
- package/package/helpers/uuid.js +1 -1
- package/package/helpers/visitorId.d.ts +1 -1
- package/package/helpers/visitorId.js +7 -4
- package/package/index-helpers/blocks-exports.d.ts +2 -2
- package/package/index-helpers/blocks-exports.js +2 -2
- package/package/index.d.ts +2 -2
- package/package/index.js +1 -1
- package/package/scripts/init-editing.js +65 -57
- package/package/types/builder-props.d.ts +10 -0
- package/package/types/components.d.ts +8 -2
- package/package/types/enforced-partials.d.ts +21 -0
- package/package/types/targets.d.ts +1 -3
- package/package/types/typescript.d.ts +6 -0
- package/package.json +2 -2
- package/src/blocks/BaseText.svelte +1 -1
- package/src/blocks/button/button.svelte +21 -34
- package/src/blocks/button/component-info.ts +20 -27
- package/src/blocks/columns/columns.svelte +28 -32
- package/src/blocks/columns/component-info.ts +205 -240
- package/src/blocks/custom-code/component-info.ts +20 -27
- package/src/blocks/embed/component-info.ts +34 -51
- package/src/blocks/embed/helpers.ts +2 -8
- package/src/blocks/form/component-info.ts +204 -253
- package/src/blocks/form/form.svelte +1 -368
- package/src/blocks/fragment/component-info.ts +3 -5
- package/src/blocks/helpers.ts +43 -0
- package/src/blocks/image/component-info.ts +113 -161
- package/src/blocks/image/image.helpers.ts +5 -33
- package/src/blocks/img/component-info.ts +11 -16
- package/src/blocks/img/img.svelte +7 -31
- package/src/blocks/input/component-info.ts +35 -66
- package/src/blocks/input/input.svelte +7 -31
- package/src/blocks/raw-text/component-info.ts +8 -12
- package/src/blocks/raw-text/raw-text.svelte +2 -5
- package/src/blocks/section/component-info.ts +28 -37
- package/src/blocks/section/section.svelte +7 -30
- package/src/blocks/select/component-info.ts +38 -55
- package/src/blocks/select/select.svelte +7 -31
- package/src/blocks/submit-button/component-info.ts +10 -15
- package/src/blocks/submit-button/submit-button.svelte +7 -30
- package/src/blocks/symbol/component-info.ts +31 -39
- package/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/src/blocks/symbol/symbol.svelte +51 -95
- package/src/blocks/text/component-info.ts +14 -18
- package/src/blocks/text/text.svelte +2 -2
- package/src/blocks/textarea/component-info.ts +26 -36
- package/src/blocks/textarea/textarea.svelte +7 -30
- package/src/blocks/video/component-info.ts +77 -103
- package/src/blocks/video/video.svelte +4 -31
- package/src/components/{render-block/render-block.helpers.ts → block/block.helpers.ts} +22 -49
- package/src/components/block/block.svelte +158 -0
- package/src/components/{render-block → block/components}/block-styles.svelte +24 -25
- package/src/components/block/components/block-wrapper.svelte +70 -0
- package/src/components/block/components/component-ref/component-ref.helpers.ts +53 -0
- package/src/components/block/components/component-ref/component-ref.svelte +41 -0
- package/src/components/block/components/interactive-element.svelte +42 -0
- package/src/components/block/components/repeated-block.svelte +30 -0
- package/src/components/{render-block → block}/types.ts +1 -2
- package/src/components/{render-blocks.svelte → blocks/blocks-wrapper.svelte} +14 -32
- package/src/components/blocks/blocks.svelte +39 -0
- package/src/components/{render-content/render-content.svelte → content/components/enable-editor.svelte} +75 -202
- package/src/components/{render-content/components/render-styles.helpers.ts → content/components/styles.helpers.ts} +9 -11
- package/src/components/{render-content/components/render-styles.svelte → content/components/styles.svelte} +5 -5
- package/src/components/content/content.helpers.ts +42 -0
- package/src/components/content/content.svelte +138 -0
- package/src/components/content/content.types.ts +23 -0
- package/src/components/content/index.ts +1 -0
- package/src/components/{render-content → content}/wrap-component-ref.ts +1 -1
- package/src/components/content-variants/content-variants.svelte +120 -0
- package/src/components/content-variants/content-variants.types.ts +20 -0
- package/src/components/{render-content-variants → content-variants}/helpers.ts +53 -94
- package/src/components/inlined-script.svelte +13 -0
- package/src/constants/builder-registered-components.ts +34 -14
- package/src/constants/device-sizes.ts +16 -22
- package/src/constants/sdk-version.ts +1 -1
- package/src/constants/target.ts +3 -1
- package/src/context/builder.context.ts +1 -1
- package/src/context/types.ts +2 -7
- package/src/functions/apply-patch-with-mutation.ts +61 -0
- package/src/functions/camel-to-kebab-case.ts +1 -2
- package/src/functions/evaluate/acorn.ts +2501 -0
- package/src/functions/evaluate/evaluate.ts +90 -0
- package/src/functions/evaluate/index.ts +1 -0
- package/src/functions/evaluate/interpreter.ts +3887 -0
- package/src/functions/evaluate/non-node-runtime.ts +94 -0
- package/src/functions/evaluate/types.ts +10 -0
- package/src/functions/extract-text-styles.ts +3 -18
- package/src/functions/fast-clone.ts +1 -2
- package/src/functions/get-block-actions-handler.ts +11 -20
- package/src/functions/get-block-actions.ts +22 -14
- package/src/functions/get-block-component-options.ts +2 -3
- package/src/functions/get-block-properties.ts +24 -17
- package/src/functions/get-builder-search-params/index.ts +5 -21
- package/src/functions/get-content/generate-content-url.ts +10 -25
- package/src/functions/get-content/index.ts +34 -37
- package/src/functions/get-content/types.ts +4 -2
- package/src/functions/get-fetch.ts +3 -10
- package/src/functions/get-global-this.ts +1 -2
- package/src/functions/get-processed-block.ts +14 -21
- package/src/functions/get-react-native-block-styles.ts +6 -12
- package/src/functions/if-target.ts +2 -3
- package/src/functions/is-browser.ts +1 -1
- package/src/functions/is-editing.ts +2 -7
- package/src/functions/is-iframe.ts +1 -2
- package/src/functions/is-non-node-server.ts +9 -0
- package/src/functions/is-previewing.ts +1 -4
- package/src/functions/on-change.ts +2 -2
- package/src/functions/register-component.ts +24 -26
- package/src/functions/register.ts +6 -8
- package/src/functions/sanitize-react-native-block-styles.ts +17 -24
- package/src/functions/set-editor-settings.ts +5 -6
- package/src/functions/set.ts +3 -15
- package/src/functions/track/helpers.ts +8 -24
- package/src/functions/track/index.ts +37 -42
- package/src/functions/track/interaction.ts +21 -38
- package/src/functions/transform-block-properties.ts +1 -1
- package/src/functions/transform-block.ts +1 -1
- package/src/helpers/ab-tests.ts +69 -78
- package/src/helpers/canTrack.ts +2 -4
- package/src/helpers/cookie.ts +15 -46
- package/src/helpers/css.ts +4 -13
- package/src/helpers/flatten.ts +11 -16
- package/src/helpers/localStorage.ts +4 -8
- package/src/helpers/logger.ts +2 -2
- package/src/helpers/nullable.ts +1 -3
- package/src/helpers/preview-lru-cache/get.ts +8 -0
- package/src/helpers/preview-lru-cache/helpers.ts +9 -0
- package/src/helpers/preview-lru-cache/init.ts +17 -0
- package/src/helpers/preview-lru-cache/set.ts +18 -0
- package/src/helpers/preview-lru-cache/types.ts +12 -0
- package/src/helpers/sessionId.ts +12 -13
- package/src/helpers/time.ts +1 -3
- package/src/helpers/url.ts +1 -2
- package/src/helpers/uuid.ts +3 -3
- package/src/helpers/visitorId.ts +14 -17
- package/src/index-helpers/blocks-exports.ts +2 -2
- package/src/index-helpers/top-of-file.ts +1 -1
- package/src/index.ts +2 -13
- package/src/scripts/init-editing.ts +85 -98
- package/src/types/api-version.ts +1 -1
- package/src/types/builder-block.ts +1 -3
- package/src/types/builder-content.ts +7 -4
- package/src/types/builder-props.ts +10 -0
- package/src/types/can-track.ts +1 -1
- package/src/types/components.ts +17 -13
- package/src/types/deep-partial.ts +1 -7
- package/src/types/element.ts +1 -3
- package/src/types/enforced-partials.ts +13 -0
- package/src/types/input.ts +6 -9
- package/src/types/targets.ts +1 -6
- package/src/types/typescript.ts +10 -5
- package/package/blocks/util.d.ts +0 -4
- package/package/blocks/util.js +0 -13
- package/package/components/render-block/render-block.helpers.d.ts +0 -12
- package/package/components/render-block/render-block.svelte +0 -152
- package/package/components/render-block/render-block.svelte.d.ts +0 -24
- package/package/components/render-block/render-component.svelte +0 -21
- package/package/components/render-block/render-component.svelte.d.ts +0 -34
- package/package/components/render-block/render-repeated-block.svelte.d.ts +0 -23
- package/package/components/render-blocks.svelte.d.ts +0 -26
- package/package/components/render-content/builder-editing.svelte +0 -4
- package/package/components/render-content/builder-editing.svelte.d.ts +0 -14
- package/package/components/render-content/index.d.ts +0 -1
- package/package/components/render-content/index.js +0 -1
- package/package/components/render-content/render-content.helpers.d.ts +0 -7
- package/package/components/render-content/render-content.helpers.js +0 -30
- package/package/components/render-content/render-content.svelte.d.ts +0 -31
- package/package/components/render-content/render-content.types.d.ts +0 -38
- package/package/components/render-content-variants/helpers.d.ts +0 -17
- package/package/components/render-content-variants/render-content-variants.svelte +0 -70
- package/package/components/render-content-variants/render-content-variants.svelte.d.ts +0 -23
- package/package/components/render-inlined-styles.svelte.d.ts +0 -21
- package/package/functions/evaluate.test.js +0 -17
- package/package/functions/get-builder-search-params/fn.test.js +0 -13
- package/package/functions/get-content/generate-content-url.test.js +0 -97
- package/package/functions/get-processed-block.test.js +0 -33
- package/package/functions/on-change.test.d.ts +0 -1
- package/package/functions/on-change.test.js +0 -20
- package/package/functions/set.test.d.ts +0 -1
- package/package/functions/set.test.js +0 -16
- package/package/helpers/url.test.d.ts +0 -1
- package/package/helpers/url.test.js +0 -21
- package/src/blocks/util.ts +0 -18
- package/src/components/render-block/render-block.svelte +0 -173
- package/src/components/render-block/render-component.svelte +0 -40
- package/src/components/render-block/render-repeated-block.svelte +0 -25
- package/src/components/render-content/builder-editing.svelte +0 -4
- package/src/components/render-content/index.ts +0 -1
- package/src/components/render-content/render-content.helpers.ts +0 -48
- package/src/components/render-content/render-content.types.ts +0 -42
- package/src/components/render-content-variants/render-content-variants.svelte +0 -83
- package/src/functions/evaluate.test.ts +0 -21
- package/src/functions/evaluate.ts +0 -99
- package/src/functions/get-builder-search-params/fn.test.ts +0 -19
- package/src/functions/get-content/generate-content-url.test.ts +0 -112
- package/src/functions/get-processed-block.test.ts +0 -35
- package/src/functions/on-change.test.ts +0 -23
- package/src/functions/set.test.ts +0 -19
- package/src/helpers/url.test.ts +0 -23
- /package/package/components/{render-block → block}/types.d.ts +0 -0
- /package/package/components/{render-block → block}/types.js +0 -0
- /package/package/{functions/evaluate.test.d.ts → components/content/content.types.js} +0 -0
- /package/package/components/{render-content → content}/wrap-component-ref.d.ts +0 -0
- /package/package/components/{render-content → content}/wrap-component-ref.js +0 -0
- /package/package/components/{render-content/render-content.types.js → content-variants/content-variants.types.js} +0 -0
- /package/package/components/{render-inlined-styles.svelte → inlined-styles.svelte} +0 -0
- /package/package/functions/{get-builder-search-params/fn.test.d.ts → evaluate/types.js} +0 -0
- /package/package/{functions/get-content/generate-content-url.test.d.ts → types/builder-props.js} +0 -0
- /package/package/{functions/get-processed-block.test.d.ts → types/enforced-partials.js} +0 -0
- /package/src/components/{render-inlined-styles.svelte → inlined-styles.svelte} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import { onMount } from "svelte";
|
|
4
|
+
import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers.js";
|
|
5
|
+
import ContentComponent from "../content/content.svelte";
|
|
6
|
+
import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
7
|
+
import InlinedStyles from "../inlined-styles.svelte";
|
|
8
|
+
import { handleABTestingSync } from "../../helpers/ab-tests.js";
|
|
9
|
+
import InlinedScript from "../inlined-script.svelte";
|
|
10
|
+
import { TARGET } from "../../constants/target.js";
|
|
11
|
+
export let canTrack;
|
|
12
|
+
export let content;
|
|
13
|
+
export let __isNestedRender;
|
|
14
|
+
export let model;
|
|
15
|
+
export let data;
|
|
16
|
+
export let context;
|
|
17
|
+
export let apiKey;
|
|
18
|
+
export let apiVersion;
|
|
19
|
+
export let customComponents;
|
|
20
|
+
export let locale;
|
|
21
|
+
export let includeRefs;
|
|
22
|
+
export let enrich;
|
|
23
|
+
$: variantScriptStr = () => {
|
|
24
|
+
return getVariantsScriptString(getVariants(content).map((value) => ({
|
|
25
|
+
id: value.testVariationId,
|
|
26
|
+
testRatio: value.testRatio,
|
|
27
|
+
})), content?.id || "");
|
|
28
|
+
};
|
|
29
|
+
$: hideVariantsStyleString = () => {
|
|
30
|
+
return getVariants(content)
|
|
31
|
+
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
32
|
+
.join("");
|
|
33
|
+
};
|
|
34
|
+
let shouldRenderVariants = checkShouldRunVariants({
|
|
35
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
36
|
+
content: content,
|
|
37
|
+
});
|
|
38
|
+
onMount(() => {
|
|
39
|
+
/**
|
|
40
|
+
* We unmount the non-winning variants post-hydration in Vue.
|
|
41
|
+
*/
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
{#if !__isNestedRender && TARGET !== "reactNative"}
|
|
46
|
+
<InlinedScript scriptStr={getScriptString()} />
|
|
47
|
+
{/if}
|
|
48
|
+
|
|
49
|
+
{#if shouldRenderVariants}
|
|
50
|
+
<InlinedStyles
|
|
51
|
+
id={`variants-styles-${content?.id}`}
|
|
52
|
+
styles={hideVariantsStyleString()}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<InlinedScript scriptStr={variantScriptStr()} />
|
|
56
|
+
|
|
57
|
+
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
58
|
+
<ContentComponent
|
|
59
|
+
content={variant}
|
|
60
|
+
showContent={false}
|
|
61
|
+
classNameProp={undefined}
|
|
62
|
+
{model}
|
|
63
|
+
{data}
|
|
64
|
+
{context}
|
|
65
|
+
{apiKey}
|
|
66
|
+
{apiVersion}
|
|
67
|
+
{customComponents}
|
|
68
|
+
{canTrack}
|
|
69
|
+
{locale}
|
|
70
|
+
{includeRefs}
|
|
71
|
+
{enrich}
|
|
72
|
+
isSsrAbTest={shouldRenderVariants}
|
|
73
|
+
/>
|
|
74
|
+
{/each}
|
|
75
|
+
{/if}
|
|
76
|
+
|
|
77
|
+
<ContentComponent
|
|
78
|
+
{...{}}
|
|
79
|
+
content={shouldRenderVariants
|
|
80
|
+
? content
|
|
81
|
+
: handleABTestingSync({
|
|
82
|
+
item: content,
|
|
83
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
84
|
+
})}
|
|
85
|
+
classNameProp={`variant-${content?.id}`}
|
|
86
|
+
showContent={true}
|
|
87
|
+
{model}
|
|
88
|
+
{data}
|
|
89
|
+
{context}
|
|
90
|
+
{apiKey}
|
|
91
|
+
{apiVersion}
|
|
92
|
+
{customComponents}
|
|
93
|
+
{canTrack}
|
|
94
|
+
{locale}
|
|
95
|
+
{includeRefs}
|
|
96
|
+
{enrich}
|
|
97
|
+
isSsrAbTest={shouldRenderVariants}
|
|
98
|
+
/>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
type VariantsProviderProps = ContentVariantsProps & {
|
|
3
|
+
/**
|
|
4
|
+
* For internal use only. Do not provide this prop.
|
|
5
|
+
*/
|
|
6
|
+
__isNestedRender?: boolean;
|
|
7
|
+
};
|
|
8
|
+
import type { ContentVariantsProps } from "./content-variants.types.js";
|
|
9
|
+
declare const __propDef: {
|
|
10
|
+
props: {
|
|
11
|
+
canTrack: VariantsProviderProps["canTrack"];
|
|
12
|
+
content: VariantsProviderProps["content"];
|
|
13
|
+
__isNestedRender: VariantsProviderProps["__isNestedRender"];
|
|
14
|
+
model: VariantsProviderProps["model"];
|
|
15
|
+
data: VariantsProviderProps["data"];
|
|
16
|
+
context: VariantsProviderProps["context"];
|
|
17
|
+
apiKey: VariantsProviderProps["apiKey"];
|
|
18
|
+
apiVersion: VariantsProviderProps["apiVersion"];
|
|
19
|
+
customComponents: VariantsProviderProps["customComponents"];
|
|
20
|
+
locale: VariantsProviderProps["locale"];
|
|
21
|
+
includeRefs: VariantsProviderProps["includeRefs"];
|
|
22
|
+
enrich: VariantsProviderProps["enrich"];
|
|
23
|
+
};
|
|
24
|
+
events: {
|
|
25
|
+
[evt: string]: CustomEvent<any>;
|
|
26
|
+
};
|
|
27
|
+
slots: {};
|
|
28
|
+
};
|
|
29
|
+
export type ContentVariantsProps = typeof __propDef.props;
|
|
30
|
+
export type ContentVariantsEvents = typeof __propDef.events;
|
|
31
|
+
export type ContentVariantsSlots = typeof __propDef.slots;
|
|
32
|
+
export default class ContentVariants extends SvelteComponentTyped<ContentVariantsProps, ContentVariantsEvents, ContentVariantsSlots> {
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BuilderRenderContext, RegisteredComponent } from '../../context/types.js';
|
|
2
|
+
import type { ApiVersion } from '../../types/api-version.js';
|
|
3
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
4
|
+
import type { Nullable } from '../../types/typescript.js';
|
|
5
|
+
export interface ContentVariantsProps {
|
|
6
|
+
content?: Nullable<BuilderContent>;
|
|
7
|
+
model?: string;
|
|
8
|
+
data?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
context?: BuilderRenderContext;
|
|
12
|
+
apiKey: string;
|
|
13
|
+
apiVersion?: ApiVersion;
|
|
14
|
+
customComponents?: RegisteredComponent[];
|
|
15
|
+
canTrack?: boolean;
|
|
16
|
+
locale?: string;
|
|
17
|
+
/** @deprecated use `enrich` instead **/
|
|
18
|
+
includeRefs?: boolean;
|
|
19
|
+
enrich?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Nullable } from '../../helpers/nullable.js';
|
|
2
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
3
|
+
export declare const getVariants: (content: Nullable<BuilderContent>) => {
|
|
4
|
+
testVariationId: string | undefined;
|
|
5
|
+
id: string | undefined;
|
|
6
|
+
data?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
title?: string | undefined;
|
|
9
|
+
blocks?: import("../../types/builder-block.js").BuilderBlock[] | undefined;
|
|
10
|
+
inputs?: import("../../types/input.js").Input[] | undefined;
|
|
11
|
+
state?: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
} | undefined;
|
|
14
|
+
jsCode?: string | undefined;
|
|
15
|
+
tsCode?: string | undefined;
|
|
16
|
+
httpRequests?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
testRatio?: number | undefined;
|
|
22
|
+
meta?: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
breakpoints?: import("../../types/typescript.js").Nullable<import("../../types/builder-content.js").Breakpoints>;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}[];
|
|
27
|
+
export declare const checkShouldRunVariants: ({ canTrack, content }: {
|
|
28
|
+
canTrack: Nullable<boolean>;
|
|
29
|
+
content: Nullable<BuilderContent>;
|
|
30
|
+
}) => boolean;
|
|
31
|
+
type VariantData = {
|
|
32
|
+
id: string;
|
|
33
|
+
testRatio?: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const getScriptString: () => string;
|
|
36
|
+
export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
|
|
37
|
+
export declare const getRenderContentScriptString: ({ contentId, variationId }: {
|
|
38
|
+
variationId: string;
|
|
39
|
+
contentId: string;
|
|
40
|
+
}) => string;
|
|
41
|
+
export {};
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target';
|
|
2
|
-
import { isBrowser } from '../../functions/is-browser';
|
|
3
|
-
export const getVariants = (content) => Object.values(content?.variations || {})
|
|
4
|
-
|
|
1
|
+
import { TARGET } from '../../constants/target.js';
|
|
2
|
+
import { isBrowser } from '../../functions/is-browser.js';
|
|
3
|
+
export const getVariants = (content) => Object.values(content?.variations || {}).map(variant => ({
|
|
4
|
+
...variant,
|
|
5
|
+
testVariationId: variant.id,
|
|
6
|
+
id: content?.id
|
|
7
|
+
}));
|
|
8
|
+
export const checkShouldRunVariants = ({ canTrack, content }) => {
|
|
5
9
|
const hasVariants = getVariants(content).length > 0;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* We cannot SSR in React-Native.
|
|
12
|
+
*/
|
|
13
|
+
if (TARGET === 'reactNative')
|
|
7
14
|
return false;
|
|
8
|
-
|
|
9
|
-
if (!canTrack) {
|
|
15
|
+
if (!hasVariants)
|
|
10
16
|
return false;
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
if (!canTrack)
|
|
18
|
+
return false;
|
|
19
|
+
/**
|
|
20
|
+
* For Vue 2 and Vue 3, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
21
|
+
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
22
|
+
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
23
|
+
*
|
|
24
|
+
* NOTE: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
25
|
+
*/
|
|
26
|
+
if (TARGET === 'vue2' || TARGET === 'vue3')
|
|
27
|
+
return true;
|
|
28
|
+
if (isBrowser())
|
|
13
29
|
return false;
|
|
14
|
-
}
|
|
15
30
|
return true;
|
|
16
31
|
};
|
|
17
32
|
/**
|
|
@@ -27,13 +42,7 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
27
42
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
28
43
|
expires = '; expires=' + date.toUTCString();
|
|
29
44
|
}
|
|
30
|
-
document.cookie =
|
|
31
|
-
name +
|
|
32
|
-
'=' +
|
|
33
|
-
(value || '') +
|
|
34
|
-
expires +
|
|
35
|
-
'; path=/' +
|
|
36
|
-
'; Secure; SameSite=None';
|
|
45
|
+
document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';
|
|
37
46
|
}
|
|
38
47
|
function getCookie(name) {
|
|
39
48
|
const nameEQ = name + '=';
|
|
@@ -49,7 +58,7 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
49
58
|
}
|
|
50
59
|
const cookieName = `builder.tests.${contentId}`;
|
|
51
60
|
const variantInCookie = getCookie(cookieName);
|
|
52
|
-
const availableIDs = variants.map(
|
|
61
|
+
const availableIDs = variants.map(vr => vr.id).concat(contentId);
|
|
53
62
|
/**
|
|
54
63
|
* cookie already exists
|
|
55
64
|
*/
|
|
@@ -77,26 +86,23 @@ function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
|
77
86
|
return contentId;
|
|
78
87
|
}
|
|
79
88
|
const winningVariantId = getAndSetVariantId();
|
|
80
|
-
const styleEl = document.
|
|
89
|
+
const styleEl = document.currentScript?.previousElementSibling;
|
|
81
90
|
/**
|
|
82
91
|
* For React to work, we need hydration to match SSR, so we completely remove this node and the styles tag.
|
|
83
92
|
*/
|
|
84
93
|
if (isHydrationTarget) {
|
|
85
94
|
styleEl.remove();
|
|
86
|
-
const thisScriptEl = document.
|
|
95
|
+
const thisScriptEl = document.currentScript;
|
|
87
96
|
thisScriptEl?.remove();
|
|
88
97
|
}
|
|
89
98
|
else {
|
|
90
99
|
/* update styles to hide all variants except the winning variant */
|
|
91
|
-
const newStyleStr = variants
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.map((value) => {
|
|
100
|
+
const newStyleStr = variants.concat({
|
|
101
|
+
id: contentId
|
|
102
|
+
}).filter(variant => variant.id !== winningVariantId).map(value => {
|
|
95
103
|
return `.variant-${value.id} { display: none; }
|
|
96
104
|
`;
|
|
97
|
-
})
|
|
98
|
-
.join('');
|
|
99
|
-
/* TO-DO: check if this actually updates the style */
|
|
105
|
+
}).join('');
|
|
100
106
|
styleEl.innerHTML = newStyleStr;
|
|
101
107
|
}
|
|
102
108
|
}
|
|
@@ -122,8 +128,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget) {
|
|
|
122
128
|
}
|
|
123
129
|
const cookieName = `builder.tests.${defaultContentId}`;
|
|
124
130
|
const variantId = getCookie(cookieName);
|
|
125
|
-
|
|
126
|
-
const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
|
|
131
|
+
const parentDiv = document.currentScript?.parentElement;
|
|
127
132
|
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
128
133
|
if (variantId === variantContentId) {
|
|
129
134
|
if (variantIsDefaultContent) {
|
|
@@ -156,10 +161,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget) {
|
|
|
156
161
|
}
|
|
157
162
|
return;
|
|
158
163
|
}
|
|
159
|
-
const getIsHydrationTarget = (target) => target === 'react' ||
|
|
160
|
-
target === 'reactNative' ||
|
|
161
|
-
target === 'vue3' ||
|
|
162
|
-
target === 'vue2';
|
|
164
|
+
const getIsHydrationTarget = (target) => target === 'react' || target === 'reactNative';
|
|
163
165
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
164
166
|
/**
|
|
165
167
|
* We hardcode explicit function names here, because the `.toString()` of a function can change depending on the bundler.
|
|
@@ -167,18 +169,21 @@ const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
|
167
169
|
*
|
|
168
170
|
* So we hardcode the function names here, and then use those names in the script string to make sure the function names are consistent.
|
|
169
171
|
*/
|
|
170
|
-
const AB_TEST_FN_NAME = '
|
|
171
|
-
const CONTENT_FN_NAME = '
|
|
172
|
-
export const
|
|
172
|
+
const AB_TEST_FN_NAME = 'builderIoAbTest';
|
|
173
|
+
const CONTENT_FN_NAME = 'builderIoRenderContent';
|
|
174
|
+
export const getScriptString = () => {
|
|
173
175
|
const fnStr = bldrAbTest.toString().replace(/\s+/g, ' ');
|
|
174
176
|
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, ' ');
|
|
175
177
|
return `
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
|
|
178
|
+
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
179
|
+
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
179
180
|
`;
|
|
180
181
|
};
|
|
181
|
-
export const
|
|
182
|
+
export const getVariantsScriptString = (variants, contentId) => {
|
|
183
|
+
return `
|
|
184
|
+
window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
|
|
185
|
+
};
|
|
186
|
+
export const getRenderContentScriptString = ({ contentId, variationId }) => {
|
|
182
187
|
return `
|
|
183
|
-
|
|
188
|
+
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
184
189
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
interface Props {
|
|
3
|
+
scriptStr: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
scriptStr: Props["scriptStr"];
|
|
9
|
+
id: Props["id"];
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export type InlinedScriptProps = typeof __propDef.props;
|
|
17
|
+
export type InlinedScriptEvents = typeof __propDef.events;
|
|
18
|
+
export type InlinedScriptSlots = typeof __propDef.slots;
|
|
19
|
+
export default class InlinedScript extends SvelteComponentTyped<InlinedScriptProps, InlinedScriptEvents, InlinedScriptSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
interface Props {
|
|
3
|
+
styles: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
styles: Props["styles"];
|
|
9
|
+
id: Props["id"];
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
};
|
|
16
|
+
export type InlinedStylesProps = typeof __propDef.props;
|
|
17
|
+
export type InlinedStylesEvents = typeof __propDef.events;
|
|
18
|
+
export type InlinedStylesSlots = typeof __propDef.slots;
|
|
19
|
+
export default class InlinedStyles extends SvelteComponentTyped<InlinedStylesProps, InlinedStylesEvents, InlinedStylesSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -24,16 +24,37 @@ import { componentInfo as customCodeInfo } from '../blocks/custom-code/component
|
|
|
24
24
|
* Returns a list of all registered components.
|
|
25
25
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
26
26
|
*/
|
|
27
|
-
export const getDefaultRegisteredComponents = () => [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
export const getDefaultRegisteredComponents = () => [{
|
|
28
|
+
component: Button,
|
|
29
|
+
...buttonComponentInfo
|
|
30
|
+
}, {
|
|
31
|
+
component: Columns,
|
|
32
|
+
...columnsComponentInfo
|
|
33
|
+
}, {
|
|
34
|
+
component: customCode,
|
|
35
|
+
...customCodeInfo
|
|
36
|
+
}, {
|
|
37
|
+
component: embed,
|
|
38
|
+
...embedComponentInfo
|
|
39
|
+
}, {
|
|
40
|
+
component: Fragment,
|
|
41
|
+
...fragmentComponentInfo
|
|
42
|
+
}, {
|
|
43
|
+
component: Image,
|
|
44
|
+
...imageComponentInfo
|
|
45
|
+
}, {
|
|
46
|
+
component: Img,
|
|
47
|
+
...imgComponentInfo
|
|
48
|
+
}, {
|
|
49
|
+
component: Section,
|
|
50
|
+
...sectionComponentInfo
|
|
51
|
+
}, {
|
|
52
|
+
component: Symbol,
|
|
53
|
+
...symbolComponentInfo
|
|
54
|
+
}, {
|
|
55
|
+
component: Text,
|
|
56
|
+
...textComponentInfo
|
|
57
|
+
}, {
|
|
58
|
+
component: Video,
|
|
59
|
+
...videoComponentInfo
|
|
60
|
+
}];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { fastClone } from '../functions/fast-clone';
|
|
1
|
+
import { fastClone } from '../functions/fast-clone.js';
|
|
2
2
|
const SIZES = {
|
|
3
3
|
small: {
|
|
4
4
|
min: 320,
|
|
5
5
|
default: 321,
|
|
6
|
-
max: 640
|
|
6
|
+
max: 640
|
|
7
7
|
},
|
|
8
8
|
medium: {
|
|
9
9
|
min: 641,
|
|
10
10
|
default: 642,
|
|
11
|
-
max: 991
|
|
11
|
+
max: 991
|
|
12
12
|
},
|
|
13
13
|
large: {
|
|
14
14
|
min: 990,
|
|
15
15
|
default: 991,
|
|
16
|
-
max: 1200
|
|
17
|
-
}
|
|
16
|
+
max: 1200
|
|
17
|
+
}
|
|
18
18
|
};
|
|
19
19
|
export const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
20
|
export const getSizesForBreakpoints = ({ small, medium }) => {
|
|
@@ -26,19 +26,20 @@ export const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
26
26
|
newSizes.small = {
|
|
27
27
|
max: small,
|
|
28
28
|
min: smallMin,
|
|
29
|
-
default: smallMin + 1
|
|
29
|
+
default: smallMin + 1
|
|
30
30
|
};
|
|
31
31
|
const mediumMin = newSizes.small.max + 1;
|
|
32
32
|
newSizes.medium = {
|
|
33
33
|
max: medium,
|
|
34
34
|
min: mediumMin,
|
|
35
|
-
default: mediumMin + 1
|
|
35
|
+
default: mediumMin + 1
|
|
36
36
|
};
|
|
37
37
|
const largeMin = newSizes.medium.max + 1;
|
|
38
38
|
newSizes.large = {
|
|
39
39
|
max: 2000,
|
|
40
|
+
// TODO: decide upper limit
|
|
40
41
|
min: largeMin,
|
|
41
|
-
default: largeMin + 1
|
|
42
|
+
default: largeMin + 1
|
|
42
43
|
};
|
|
43
44
|
return newSizes;
|
|
44
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.5.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This file should be overriden for each framework. Ideally this would be implemented in Mitosis. */
|
|
2
|
-
export declare const TARGET
|
|
2
|
+
export declare const TARGET: import("../types/targets").Target;
|
|
@@ -30,6 +30,6 @@ export interface BuilderContextInterface {
|
|
|
30
30
|
localState: BuilderRenderState | undefined;
|
|
31
31
|
apiKey: string | null;
|
|
32
32
|
apiVersion: ApiVersion | undefined;
|
|
33
|
-
|
|
33
|
+
componentInfos: Dictionary<ComponentInfo>;
|
|
34
34
|
inheritedStyles: Record<string, unknown>;
|
|
35
35
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Patch = {
|
|
2
|
+
path: string;
|
|
3
|
+
op: 'add' | 'remove' | 'replace';
|
|
4
|
+
value: any;
|
|
5
|
+
};
|
|
6
|
+
export declare const applyPatchWithMinimalMutationChain: <T extends object>(obj: T, patch: {
|
|
7
|
+
path: string;
|
|
8
|
+
op: 'add' | 'remove' | 'replace';
|
|
9
|
+
value: any;
|
|
10
|
+
}, preserveRoot?: boolean) => T;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const applyPatchWithMinimalMutationChain = (obj, patch, preserveRoot = false) => {
|
|
2
|
+
if (Object(obj) !== obj) {
|
|
3
|
+
return obj;
|
|
4
|
+
}
|
|
5
|
+
const { path, op, value } = patch;
|
|
6
|
+
const pathArr = path.split(/\//);
|
|
7
|
+
if (pathArr[0] === '') {
|
|
8
|
+
pathArr.shift();
|
|
9
|
+
}
|
|
10
|
+
const newObj = preserveRoot ? obj : {
|
|
11
|
+
...obj
|
|
12
|
+
};
|
|
13
|
+
let objPart = newObj;
|
|
14
|
+
for (let i = 0; i < pathArr.length; i++) {
|
|
15
|
+
const isLast = i === pathArr.length - 1;
|
|
16
|
+
const property = pathArr[i];
|
|
17
|
+
if (isLast) {
|
|
18
|
+
if (op === 'replace') {
|
|
19
|
+
objPart[property] = value;
|
|
20
|
+
}
|
|
21
|
+
else if (op === 'add') {
|
|
22
|
+
const index = Number(property);
|
|
23
|
+
if (Array.isArray(objPart)) {
|
|
24
|
+
if (property === '-') {
|
|
25
|
+
objPart.push(value);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
objPart.splice(index, 0, value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
objPart[property] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (op === 'remove') {
|
|
36
|
+
const index = Number(property);
|
|
37
|
+
if (Array.isArray(objPart)) {
|
|
38
|
+
objPart.splice(index, 1);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
delete objPart[property];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const nextProperty = pathArr[i + 1];
|
|
47
|
+
const newPart = Object(objPart[property]) === objPart[property] ? objPart[property] : String(Number(nextProperty)) === nextProperty ? [] : {};
|
|
48
|
+
objPart = objPart[property] = Array.isArray(newPart) ? [...newPart] : {
|
|
49
|
+
...newPart
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return newObj;
|
|
54
|
+
};
|
|
File without changes
|