@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
package/src/helpers/sessionId.ts
CHANGED
|
@@ -2,37 +2,36 @@ import type { CanTrack } from '../types/can-track.js';
|
|
|
2
2
|
import { getCookie, setCookie } from './cookie.js';
|
|
3
3
|
import { checkIsDefined } from './nullable.js';
|
|
4
4
|
import { uuid } from './uuid.js';
|
|
5
|
-
|
|
6
5
|
const SESSION_LOCAL_STORAGE_KEY = 'builderSessionId';
|
|
7
|
-
|
|
8
6
|
export const getSessionId = async ({
|
|
9
|
-
canTrack
|
|
7
|
+
canTrack
|
|
10
8
|
}: CanTrack): Promise<string | undefined> => {
|
|
11
9
|
if (!canTrack) {
|
|
12
10
|
return undefined;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
const sessionId = await getCookie({
|
|
16
13
|
name: SESSION_LOCAL_STORAGE_KEY,
|
|
17
|
-
canTrack
|
|
14
|
+
canTrack
|
|
18
15
|
});
|
|
19
|
-
|
|
20
16
|
if (checkIsDefined(sessionId)) {
|
|
21
17
|
return sessionId;
|
|
22
18
|
} else {
|
|
23
19
|
const newSessionId = createSessionId();
|
|
24
|
-
setSessionId({
|
|
25
|
-
|
|
20
|
+
setSessionId({
|
|
21
|
+
id: newSessionId,
|
|
22
|
+
canTrack
|
|
23
|
+
});
|
|
26
24
|
return newSessionId;
|
|
27
25
|
}
|
|
28
26
|
};
|
|
29
|
-
|
|
30
27
|
export const createSessionId = () => uuid();
|
|
31
|
-
|
|
32
28
|
export const setSessionId = ({
|
|
33
29
|
id,
|
|
34
|
-
canTrack
|
|
30
|
+
canTrack
|
|
35
31
|
}: {
|
|
36
32
|
id: string;
|
|
37
|
-
} & CanTrack) =>
|
|
38
|
-
|
|
33
|
+
} & CanTrack) => setCookie({
|
|
34
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
35
|
+
value: id,
|
|
36
|
+
canTrack
|
|
37
|
+
})
|
package/src/helpers/time.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
const MINUTE_TO_MILLESECONDS_MULTIPLIER = 60000;
|
|
2
|
-
|
|
3
|
-
export const getCurrentDatePlusMinutes = (minutes = 30) =>
|
|
4
|
-
new Date(Date.now() + minutes * MINUTE_TO_MILLESECONDS_MULTIPLIER);
|
|
2
|
+
export const getCurrentDatePlusMinutes = (minutes = 30) => new Date(Date.now() + minutes * MINUTE_TO_MILLESECONDS_MULTIPLIER)
|
package/src/helpers/url.ts
CHANGED
|
@@ -7,10 +7,9 @@ export const getTopLevelDomain = (host: string) => {
|
|
|
7
7
|
if (host === 'localhost' || host === '127.0.0.1') {
|
|
8
8
|
return host;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
const parts = host.split('.');
|
|
12
11
|
if (parts.length > 2) {
|
|
13
12
|
return parts.slice(1).join('.');
|
|
14
13
|
}
|
|
15
14
|
return host;
|
|
16
|
-
}
|
|
15
|
+
}
|
package/src/helpers/uuid.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export function uuidv4() {
|
|
5
5
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
6
|
-
const r =
|
|
7
|
-
v = c == 'x' ? r :
|
|
6
|
+
const r = Math.random() * 16 | 0,
|
|
7
|
+
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
8
8
|
return v.toString(16);
|
|
9
9
|
});
|
|
10
10
|
}
|
|
@@ -14,4 +14,4 @@ export function uuidv4() {
|
|
|
14
14
|
*/
|
|
15
15
|
export function uuid() {
|
|
16
16
|
return uuidv4().replace(/-/g, '');
|
|
17
|
-
}
|
|
17
|
+
}
|
package/src/helpers/visitorId.ts
CHANGED
|
@@ -2,39 +2,36 @@ import type { CanTrack } from '../types/can-track.js';
|
|
|
2
2
|
import { getLocalStorageItem, setLocalStorageItem } from './localStorage.js';
|
|
3
3
|
import { checkIsDefined } from './nullable.js';
|
|
4
4
|
import { uuid } from './uuid.js';
|
|
5
|
-
|
|
6
5
|
const VISITOR_LOCAL_STORAGE_KEY = 'builderVisitorId';
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const getVisitorId = ({
|
|
7
|
+
canTrack
|
|
8
|
+
}: CanTrack): string | undefined => {
|
|
9
9
|
if (!canTrack) {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
const visitorId = getLocalStorageItem({
|
|
14
13
|
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
15
|
-
canTrack
|
|
14
|
+
canTrack
|
|
16
15
|
});
|
|
17
|
-
|
|
18
16
|
if (checkIsDefined(visitorId)) {
|
|
19
17
|
return visitorId;
|
|
20
18
|
} else {
|
|
21
19
|
const newVisitorId = createVisitorId();
|
|
22
|
-
setVisitorId({
|
|
23
|
-
|
|
20
|
+
setVisitorId({
|
|
21
|
+
id: newVisitorId,
|
|
22
|
+
canTrack
|
|
23
|
+
});
|
|
24
24
|
return newVisitorId;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
|
|
28
27
|
export const createVisitorId = () => uuid();
|
|
29
|
-
|
|
30
28
|
export const setVisitorId = ({
|
|
31
29
|
id,
|
|
32
|
-
canTrack
|
|
30
|
+
canTrack
|
|
33
31
|
}: {
|
|
34
32
|
id: string;
|
|
35
|
-
} & CanTrack) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
33
|
+
} & CanTrack) => setLocalStorageItem({
|
|
34
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
35
|
+
value: id,
|
|
36
|
+
canTrack
|
|
37
|
+
})
|
|
@@ -2,9 +2,9 @@ export { default as Button } from '../blocks/button/button.svelte';
|
|
|
2
2
|
export { default as Columns } from '../blocks/columns/columns.svelte';
|
|
3
3
|
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
4
4
|
export { default as Image } from '../blocks/image/image.svelte';
|
|
5
|
-
export { default as RenderBlocks } from '../components/
|
|
5
|
+
export { default as RenderBlocks } from '../components/blocks/blocks.svelte';
|
|
6
6
|
export { default as Section } from '../blocks/section/section.svelte';
|
|
7
7
|
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
8
8
|
export { default as Text } from '../blocks/text/text.svelte';
|
|
9
9
|
export { default as Video } from '../blocks/video/video.svelte';
|
|
10
|
-
export { default as RenderContent } from '../components/
|
|
10
|
+
export { default as RenderContent } from '../components/content-variants/content-variants.svelte'
|
package/src/index.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
export * from './index-helpers/blocks-exports.js';
|
|
3
|
-
|
|
4
3
|
export { isEditing } from './functions/is-editing.js';
|
|
5
4
|
export { isPreviewing } from './functions/is-previewing.js';
|
|
6
5
|
export { createRegisterComponentMessage } from './functions/register-component.js';
|
|
7
|
-
|
|
8
6
|
export { register } from './functions/register.js';
|
|
9
7
|
export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
|
|
10
|
-
|
|
11
8
|
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
12
9
|
export type { Settings } from './functions/set-editor-settings.js';
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
getAllContent,
|
|
16
|
-
getContent,
|
|
17
|
-
processContentResult,
|
|
18
|
-
} from './functions/get-content/index.js';
|
|
19
|
-
|
|
10
|
+
export { getAllContent, getContent, processContentResult } from './functions/get-content/index.js';
|
|
20
11
|
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
21
|
-
|
|
22
12
|
export { track } from './functions/track/index.js';
|
|
23
|
-
|
|
24
13
|
export type { RegisteredComponent } from './context/types';
|
|
25
14
|
export type { ComponentInfo } from './types/components';
|
|
26
|
-
export type {
|
|
15
|
+
export type { ContentProps } from './components/content/content.types.js'
|
|
@@ -2,125 +2,112 @@ import { SDK_VERSION } from '../constants/sdk-version.js';
|
|
|
2
2
|
import { TARGET } from '../constants/target.js';
|
|
3
3
|
import { isBrowser } from '../functions/is-browser.js';
|
|
4
4
|
import { register } from '../functions/register.js';
|
|
5
|
-
|
|
6
5
|
export const registerInsertMenu = () => {
|
|
7
6
|
register('insertMenu', {
|
|
8
7
|
name: '_default',
|
|
9
8
|
default: true,
|
|
10
|
-
items: [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
items: [{
|
|
10
|
+
name: 'Box'
|
|
11
|
+
}, {
|
|
12
|
+
name: 'Text'
|
|
13
|
+
}, {
|
|
14
|
+
name: 'Image'
|
|
15
|
+
}, {
|
|
16
|
+
name: 'Columns'
|
|
17
|
+
}, ...(TARGET === 'reactNative' ? [] : [{
|
|
18
|
+
name: 'Core:Section'
|
|
19
|
+
}, {
|
|
20
|
+
name: 'Core:Button'
|
|
21
|
+
}, {
|
|
22
|
+
name: 'Embed'
|
|
23
|
+
}, {
|
|
24
|
+
name: 'Custom Code'
|
|
25
|
+
}])]
|
|
24
26
|
});
|
|
25
27
|
};
|
|
26
|
-
|
|
27
28
|
let isSetupForEditing = false;
|
|
28
|
-
export const setupBrowserForEditing = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = {}
|
|
34
|
-
) => {
|
|
29
|
+
export const setupBrowserForEditing = (options: {
|
|
30
|
+
enrich?: boolean;
|
|
31
|
+
includeRefs?: boolean;
|
|
32
|
+
locale?: string;
|
|
33
|
+
} = {}) => {
|
|
35
34
|
if (isSetupForEditing) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
37
|
isSetupForEditing = true;
|
|
39
38
|
if (isBrowser()) {
|
|
40
|
-
window.parent?.postMessage(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type: 'builder.updateContent',
|
|
62
|
-
data: {
|
|
63
|
-
options,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
'*'
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
window.addEventListener('message', ({ data }) => {
|
|
39
|
+
window.parent?.postMessage({
|
|
40
|
+
type: 'builder.sdkInfo',
|
|
41
|
+
data: {
|
|
42
|
+
target: TARGET,
|
|
43
|
+
version: SDK_VERSION,
|
|
44
|
+
supportsPatchUpdates: false,
|
|
45
|
+
// Supports builder-model="..." attribute which is needed to
|
|
46
|
+
// scope our '+ add block' button styling
|
|
47
|
+
supportsAddBlockScoping: true,
|
|
48
|
+
supportsCustomBreakpoints: true
|
|
49
|
+
}
|
|
50
|
+
}, '*');
|
|
51
|
+
window.parent?.postMessage({
|
|
52
|
+
type: 'builder.updateContent',
|
|
53
|
+
data: {
|
|
54
|
+
options
|
|
55
|
+
}
|
|
56
|
+
}, '*');
|
|
57
|
+
window.addEventListener('message', ({
|
|
58
|
+
data
|
|
59
|
+
}) => {
|
|
70
60
|
if (!data?.type) {
|
|
71
61
|
return;
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
switch (data.type) {
|
|
75
|
-
case 'builder.evaluate':
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
64
|
+
case 'builder.evaluate':
|
|
65
|
+
{
|
|
66
|
+
const text = data.data.text;
|
|
67
|
+
const args = data.data.arguments || [];
|
|
68
|
+
const id = data.data.id;
|
|
69
|
+
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
70
|
+
const fn = new Function(text);
|
|
71
|
+
let result: any;
|
|
72
|
+
let error: Error | null = null;
|
|
73
|
+
try {
|
|
74
|
+
// eslint-disable-next-line prefer-spread
|
|
75
|
+
result = fn.apply(null, args);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
error = (err as Error);
|
|
78
|
+
}
|
|
79
|
+
if (error) {
|
|
80
|
+
window.parent?.postMessage({
|
|
93
81
|
type: 'builder.evaluateError',
|
|
94
|
-
data: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (result && typeof result.then === 'function') {
|
|
100
|
-
(result as Promise<any>)
|
|
101
|
-
.then((finalResult) => {
|
|
102
|
-
window.parent?.postMessage(
|
|
103
|
-
{
|
|
104
|
-
type: 'builder.evaluateResult',
|
|
105
|
-
data: { id, result: finalResult },
|
|
106
|
-
},
|
|
107
|
-
'*'
|
|
108
|
-
);
|
|
109
|
-
})
|
|
110
|
-
.catch(console.error);
|
|
82
|
+
data: {
|
|
83
|
+
id,
|
|
84
|
+
error: error.message
|
|
85
|
+
}
|
|
86
|
+
}, '*');
|
|
111
87
|
} else {
|
|
112
|
-
|
|
113
|
-
{
|
|
88
|
+
if (result && typeof result.then === 'function') {
|
|
89
|
+
(result as Promise<any>).then(finalResult => {
|
|
90
|
+
window.parent?.postMessage({
|
|
91
|
+
type: 'builder.evaluateResult',
|
|
92
|
+
data: {
|
|
93
|
+
id,
|
|
94
|
+
result: finalResult
|
|
95
|
+
}
|
|
96
|
+
}, '*');
|
|
97
|
+
}).catch(console.error);
|
|
98
|
+
} else {
|
|
99
|
+
window.parent?.postMessage({
|
|
114
100
|
type: 'builder.evaluateResult',
|
|
115
|
-
data: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
data: {
|
|
102
|
+
result,
|
|
103
|
+
id
|
|
104
|
+
}
|
|
105
|
+
}, '*');
|
|
106
|
+
}
|
|
119
107
|
}
|
|
108
|
+
break;
|
|
120
109
|
}
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
110
|
}
|
|
124
111
|
});
|
|
125
112
|
}
|
|
126
|
-
}
|
|
113
|
+
}
|
package/src/types/api-version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type ApiVersion = 'v2' | 'v3';
|
|
2
|
-
export const DEFAULT_API_VERSION: ApiVersion = 'v3'
|
|
2
|
+
export const DEFAULT_API_VERSION: ApiVersion = 'v3'
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
|
|
3
2
|
interface JSONObject {
|
|
4
3
|
[x: string]: JSONValue;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
interface JSONArray extends Array<JSONValue> {}
|
|
8
6
|
|
|
9
7
|
/** @todo typedoc this */
|
|
@@ -66,4 +64,4 @@ export interface BuilderBlock {
|
|
|
66
64
|
* generated by the "Show If" binding
|
|
67
65
|
*/
|
|
68
66
|
show?: boolean;
|
|
69
|
-
}
|
|
67
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BuilderBlock } from './builder-block.js';
|
|
2
2
|
import type { Input } from './input.js';
|
|
3
3
|
import type { Nullable } from './typescript.js';
|
|
4
|
-
|
|
5
4
|
export interface Breakpoints {
|
|
6
5
|
small: number;
|
|
7
6
|
medium: number;
|
|
@@ -11,10 +10,14 @@ export interface BuilderContentVariation {
|
|
|
11
10
|
title?: string;
|
|
12
11
|
blocks?: BuilderBlock[];
|
|
13
12
|
inputs?: Input[];
|
|
14
|
-
state?: {
|
|
13
|
+
state?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
15
16
|
jsCode?: string;
|
|
16
17
|
tsCode?: string;
|
|
17
|
-
httpRequests?: {
|
|
18
|
+
httpRequests?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
18
21
|
[key: string]: any;
|
|
19
22
|
};
|
|
20
23
|
name?: string;
|
|
@@ -41,4 +44,4 @@ export interface BuilderContent extends BuilderContentVariation {
|
|
|
41
44
|
};
|
|
42
45
|
testVariationId?: string;
|
|
43
46
|
testVariationName?: string;
|
|
44
|
-
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Writable } from "svelte/store";
|
|
2
|
+
import type { BuilderContextInterface, RegisteredComponents } from '../context/types.js';
|
|
3
|
+
import type { BuilderBlock } from './builder-block.js';
|
|
4
|
+
export type PropsWithBuilderData<T> = T & {
|
|
5
|
+
builderBlock: BuilderBlock;
|
|
6
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
7
|
+
};
|
|
8
|
+
export type BuilderComponentsProp = {
|
|
9
|
+
builderComponents: RegisteredComponents;
|
|
10
|
+
}
|
package/src/types/can-track.ts
CHANGED
package/src/types/components.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { BuilderElement } from './element';
|
|
2
|
-
import type { Input } from './input';
|
|
3
|
-
|
|
1
|
+
import type { BuilderElement } from './element.js';
|
|
2
|
+
import type { Input } from './input.js';
|
|
4
3
|
export interface ComponentInfo {
|
|
5
4
|
/**
|
|
6
5
|
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
@@ -19,7 +18,9 @@ export interface ComponentInfo {
|
|
|
19
18
|
inputs?: Input[];
|
|
20
19
|
class?: any;
|
|
21
20
|
type?: 'angular' | 'webcomponent' | 'react' | 'vue';
|
|
22
|
-
defaultStyles?: {
|
|
21
|
+
defaultStyles?: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
23
24
|
/**
|
|
24
25
|
* Turn on if your component can accept children. Be sure to use in combination with
|
|
25
26
|
* withChildren(YourComponent) like here
|
|
@@ -32,13 +33,23 @@ export interface ComponentInfo {
|
|
|
32
33
|
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
33
34
|
*/
|
|
34
35
|
noWrap?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* TO-DO: make this optional only for RSC SDK.
|
|
39
|
+
*
|
|
40
|
+
* Set this to `true` if your component is a React Server Component (RSC).
|
|
41
|
+
*/
|
|
42
|
+
isRSC?: boolean;
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* Default children
|
|
37
46
|
*/
|
|
38
47
|
defaultChildren?: BuilderElement[];
|
|
39
48
|
defaults?: Partial<BuilderElement>;
|
|
40
49
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
41
|
-
hooks?: {
|
|
50
|
+
hooks?: {
|
|
51
|
+
[key: string]: string | Function;
|
|
52
|
+
};
|
|
42
53
|
/**
|
|
43
54
|
* Hide your component in editor, useful for gradually deprecating components
|
|
44
55
|
*/
|
|
@@ -107,11 +118,4 @@ export interface ComponentInfo {
|
|
|
107
118
|
// TO-DO: is this used?
|
|
108
119
|
hidden?: boolean;
|
|
109
120
|
}
|
|
110
|
-
|
|
111
|
-
type Permission =
|
|
112
|
-
| 'read'
|
|
113
|
-
| 'publish'
|
|
114
|
-
| 'editCode'
|
|
115
|
-
| 'editDesigns'
|
|
116
|
-
| 'admin'
|
|
117
|
-
| 'create';
|
|
121
|
+
type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create'
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export type DeepPartial<T> = {
|
|
2
|
-
[P in keyof T]?: T[P] extends Array<infer U>
|
|
3
|
-
? Array<DeepPartial<U>>
|
|
4
|
-
: T[P] extends ReadonlyArray<infer U>
|
|
5
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
6
|
-
: DeepPartial<T[P]>;
|
|
7
|
-
};
|
|
1
|
+
export type DeepPartial<T> = { [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]> }
|
package/src/types/element.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
|
|
3
2
|
interface JSONObject {
|
|
4
3
|
[x: string]: JSONValue;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
interface JSONArray extends Array<JSONValue> {}
|
|
8
6
|
|
|
9
7
|
/** @todo typedoc this */
|
|
@@ -57,4 +55,4 @@ export interface BuilderElement {
|
|
|
57
55
|
animations?: Animation[]; // TODO: type the animation spec
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
interface Animation {}
|
|
58
|
+
interface Animation {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Prettify } from './typescript.js';
|
|
2
|
+
type OptionalFieldsOnly<T> = { [K in keyof T as T[K] extends Required<T>[K] ? never : K]: T[K] };
|
|
3
|
+
type RequiredFieldsOnly<T> = { [K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K] };
|
|
4
|
+
type Enforced<T> = { [K in keyof T]-?: T[K] };
|
|
5
|
+
type AndUndefined<T> = { [K in keyof T]: T[K] | undefined };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Enforce that all optional fields are undefined
|
|
9
|
+
* @example
|
|
10
|
+
* type Foo = { a: string, b?: number }
|
|
11
|
+
* type Bar = EnforcePartials<Foo> // { a: string, b: number | undefined }
|
|
12
|
+
*/
|
|
13
|
+
export type EnforcePartials<From> = Prettify<AndUndefined<Enforced<OptionalFieldsOnly<From>>> & RequiredFieldsOnly<From>>
|
package/src/types/input.ts
CHANGED
|
@@ -78,13 +78,11 @@ export interface Input {
|
|
|
78
78
|
/**
|
|
79
79
|
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
80
80
|
*/
|
|
81
|
-
enum?:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
helperText?: string;
|
|
87
|
-
}[];
|
|
81
|
+
enum?: string[] | {
|
|
82
|
+
label: string;
|
|
83
|
+
value: any;
|
|
84
|
+
helperText?: string;
|
|
85
|
+
}[];
|
|
88
86
|
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
89
87
|
regex?: {
|
|
90
88
|
/** pattern to test, like "^\/[a-z]$" */
|
|
@@ -117,9 +115,8 @@ export interface Input {
|
|
|
117
115
|
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
118
116
|
*/
|
|
119
117
|
model?: string;
|
|
120
|
-
|
|
121
118
|
valueType?: {
|
|
122
119
|
type?: string;
|
|
123
120
|
};
|
|
124
121
|
onChange?: ((options: Map<string, any>) => void | Promise<void>) | string;
|
|
125
|
-
}
|
|
122
|
+
}
|
package/src/types/targets.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
export type Target = Extract<
|
|
4
|
-
MitosisTargets,
|
|
5
|
-
'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid'
|
|
6
|
-
>;
|
|
1
|
+
export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc'
|
package/src/types/typescript.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export type Nullable<T> = T | null | undefined;
|
|
2
|
+
export type Dictionary<T> = {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
};
|
|
5
|
+
export type Overwrite<T, U> = keyof U extends keyof T ? Pick<T, Exclude<keyof T, keyof U>> & U : never;
|
|
6
|
+
export type Prettify<T> = {
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
9
|
+
[K in keyof T]: T[K] } & {};
|
|
10
|
+
export type PropsWithChildren<P> = P & {
|
|
11
|
+
children?: any;
|
|
12
|
+
}
|
package/package/blocks/util.d.ts
DELETED
package/package/blocks/util.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input attributes that are functions must be converted to strings before being serialized to JSON.
|
|
3
|
-
*/
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
-
export const serializeFn = (fnValue) => {
|
|
6
|
-
const fnStr = fnValue.toString().trim();
|
|
7
|
-
// we need to account for a few different fn syntaxes:
|
|
8
|
-
// 1. `function name(args) => {code}`
|
|
9
|
-
// 2. `name(args) => {code}`
|
|
10
|
-
// 3. `(args) => {}`
|
|
11
|
-
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
12
|
-
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
13
|
-
};
|