@builder.io/sdk-svelte 0.0.1-9 → 0.0.2
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/README.md +4 -0
- package/package/CHANGELOG.md +19 -0
- package/package/README.md +19 -0
- package/{src/types/builder-block.js → package/blocks/button/button.lite.d.ts} +0 -0
- package/package/blocks/button/button.lite.tsx +36 -0
- package/package/blocks/button/button.svelte +28 -0
- package/package/blocks/button/button.svelte.d.ts +25 -0
- package/package/blocks/button/component-info.d.ts +2 -0
- package/package/blocks/button/component-info.js +39 -0
- package/{src/types/builder-content.js → package/blocks/columns/columns.lite.d.ts} +0 -0
- package/package/blocks/columns/columns.lite.tsx +139 -0
- package/package/blocks/columns/columns.svelte +109 -0
- package/package/blocks/columns/columns.svelte.d.ts +33 -0
- package/package/blocks/columns/component-info.d.ts +2 -0
- package/package/blocks/columns/component-info.js +241 -0
- package/package/blocks/custom-code/component-info.d.ts +2 -0
- package/package/blocks/custom-code/component-info.js +28 -0
- package/{src/types/components.js → package/blocks/custom-code/custom-code.lite.d.ts} +0 -0
- package/package/blocks/custom-code/custom-code.lite.tsx +70 -0
- package/package/blocks/custom-code/custom-code.svelte +55 -0
- package/package/blocks/custom-code/custom-code.svelte.d.ts +21 -0
- package/package/blocks/embed/component-info.d.ts +2 -0
- package/package/blocks/embed/component-info.js +47 -0
- package/{src/types/deep-partial.js → package/blocks/embed/embed.lite.d.ts} +0 -0
- package/package/blocks/embed/embed.lite.tsx +52 -0
- package/package/blocks/embed/embed.svelte +41 -0
- package/package/blocks/embed/embed.svelte.d.ts +19 -0
- package/package/blocks/embed/helpers.d.ts +1 -0
- package/package/blocks/embed/helpers.js +6 -0
- package/package/blocks/form/component-info.d.ts +2 -0
- package/package/blocks/form/component-info.js +268 -0
- package/{src/types/element.js → package/blocks/form/form.lite.d.ts} +0 -0
- package/package/blocks/form/form.lite.tsx +351 -0
- package/package/blocks/form/form.svelte +259 -0
- package/package/blocks/form/form.svelte.d.ts +70 -0
- package/package/blocks/fragment/component-info.d.ts +2 -0
- package/package/blocks/fragment/component-info.js +8 -0
- package/{src/types/targets.js → package/blocks/fragment/fragment.lite.d.ts} +0 -0
- package/package/blocks/fragment/fragment.lite.tsx +12 -0
- package/package/blocks/fragment/fragment.svelte +5 -0
- package/package/blocks/fragment/fragment.svelte.d.ts +21 -0
- package/package/blocks/image/component-info.d.ts +2 -0
- package/package/blocks/image/component-info.js +153 -0
- package/package/blocks/image/image.helpers.d.ts +1 -0
- package/package/blocks/image/image.helpers.js +56 -0
- package/{src/types/typescript.js → package/blocks/image/image.lite.d.ts} +0 -0
- package/package/blocks/image/image.lite.tsx +148 -0
- package/package/blocks/image/image.svelte +119 -0
- package/package/blocks/image/image.svelte.d.ts +48 -0
- package/package/blocks/img/component-info.d.ts +2 -0
- package/package/blocks/img/component-info.js +18 -0
- package/package/blocks/img/img.lite.d.ts +0 -0
- package/package/blocks/img/img.lite.tsx +48 -0
- package/package/blocks/img/img.svelte +26 -0
- package/package/blocks/img/img.svelte.d.ts +29 -0
- package/package/blocks/input/component-info.d.ts +2 -0
- package/package/blocks/input/component-info.js +72 -0
- package/package/blocks/input/input.lite.d.ts +0 -0
- package/package/blocks/input/input.lite.tsx +34 -0
- package/package/blocks/input/input.svelte +22 -0
- package/package/blocks/input/input.svelte.d.ts +31 -0
- package/package/blocks/raw-text/component-info.d.ts +2 -0
- package/package/blocks/raw-text/component-info.js +13 -0
- package/package/blocks/raw-text/raw-text.lite.d.ts +0 -0
- package/package/blocks/raw-text/raw-text.lite.tsx +15 -0
- package/package/blocks/raw-text/raw-text.svelte +9 -0
- package/package/blocks/raw-text/raw-text.svelte.d.ts +21 -0
- package/package/blocks/section/component-info.d.ts +2 -0
- package/package/blocks/section/component-info.js +46 -0
- package/package/blocks/section/section.lite.d.ts +0 -0
- package/package/blocks/section/section.lite.tsx +30 -0
- package/package/blocks/section/section.svelte +21 -0
- package/package/blocks/section/section.svelte.d.ts +25 -0
- package/package/blocks/select/component-info.d.ts +2 -0
- package/package/blocks/select/component-info.js +56 -0
- package/package/blocks/select/select.lite.d.ts +0 -0
- package/package/blocks/select/select.lite.tsx +34 -0
- package/package/blocks/select/select.svelte +21 -0
- package/package/blocks/select/select.svelte.d.ts +30 -0
- package/package/blocks/submit-button/component-info.d.ts +2 -0
- package/package/blocks/submit-button/component-info.js +29 -0
- package/package/blocks/submit-button/submit-button.lite.d.ts +0 -0
- package/package/blocks/submit-button/submit-button.lite.tsx +15 -0
- package/package/blocks/submit-button/submit-button.svelte +9 -0
- package/package/blocks/submit-button/submit-button.svelte.d.ts +21 -0
- package/package/blocks/symbol/component-info.d.ts +2 -0
- package/package/blocks/symbol/component-info.js +40 -0
- package/package/blocks/symbol/symbol.lite.d.ts +0 -0
- package/package/blocks/symbol/symbol.lite.tsx +92 -0
- package/package/blocks/symbol/symbol.svelte +66 -0
- package/package/blocks/symbol/symbol.svelte.d.ts +35 -0
- package/package/blocks/text/component-info.d.ts +2 -0
- package/package/blocks/text/component-info.js +21 -0
- package/package/blocks/text/text.lite.d.ts +0 -0
- package/package/blocks/text/text.lite.tsx +11 -0
- package/package/blocks/text/text.svelte +6 -0
- package/package/blocks/text/text.svelte.d.ts +19 -0
- package/package/blocks/textarea/component-info.d.ts +2 -0
- package/package/blocks/textarea/component-info.js +44 -0
- package/package/blocks/textarea/textarea.lite.d.ts +0 -0
- package/package/blocks/textarea/textarea.lite.tsx +19 -0
- package/package/blocks/textarea/textarea.svelte +10 -0
- package/package/blocks/textarea/textarea.svelte.d.ts +27 -0
- package/package/blocks/util.d.ts +1 -0
- package/package/blocks/util.js +4 -0
- package/package/blocks/video/component-info.d.ts +2 -0
- package/package/blocks/video/component-info.js +103 -0
- package/package/blocks/video/video.lite.d.ts +0 -0
- package/package/blocks/video/video.lite.tsx +92 -0
- package/package/blocks/video/video.svelte +63 -0
- package/package/blocks/video/video.svelte.d.ts +41 -0
- package/package/components/render-block/block-styles.lite.d.ts +0 -0
- package/package/components/render-block/block-styles.lite.tsx +60 -0
- package/package/components/render-block/block-styles.svelte +45 -0
- package/package/components/render-block/block-styles.svelte.d.ts +23 -0
- package/package/components/render-block/render-block.helpers.d.ts +1 -0
- package/package/components/render-block/render-block.helpers.js +24 -0
- package/package/components/render-block/render-block.lite.d.ts +0 -0
- package/package/components/render-block/render-block.lite.tsx +216 -0
- package/package/components/render-block/render-block.svelte +185 -0
- package/package/components/render-block/render-block.svelte.d.ts +23 -0
- package/package/components/render-block/render-component.lite.d.ts +0 -0
- package/package/components/render-block/render-component.lite.tsx +33 -0
- package/package/components/render-block/render-component.svelte +24 -0
- package/package/components/render-block/render-component.svelte.d.ts +27 -0
- package/package/components/render-block/render-repeated-block.lite.d.ts +0 -0
- package/package/components/render-block/render-repeated-block.lite.tsx +49 -0
- package/package/components/render-block/render-repeated-block.svelte +36 -0
- package/package/components/render-block/render-repeated-block.svelte.d.ts +23 -0
- package/package/components/render-block/types.d.ts +6 -0
- package/package/components/render-block/types.js +2 -0
- package/package/components/render-blocks.lite.d.ts +0 -0
- package/package/components/render-blocks.lite.tsx +91 -0
- package/package/components/render-blocks.svelte +73 -0
- package/package/components/render-blocks.svelte.d.ts +24 -0
- package/package/components/render-content/components/render-styles.lite.d.ts +0 -0
- package/package/components/render-content/components/render-styles.lite.tsx +86 -0
- package/package/components/render-content/components/render-styles.svelte +61 -0
- package/package/components/render-content/components/render-styles.svelte.d.ts +29 -0
- package/package/components/render-content/index.d.ts +1 -0
- package/package/components/render-content/index.js +1 -0
- package/package/components/render-content/render-content.lite.d.ts +0 -0
- package/package/components/render-content/render-content.lite.tsx +356 -0
- package/package/components/render-content/render-content.svelte +260 -0
- package/package/components/render-content/render-content.svelte.d.ts +36 -0
- package/package/components/render-inlined-styles.lite.d.ts +0 -0
- package/package/components/render-inlined-styles.lite.tsx +27 -0
- package/package/components/render-inlined-styles.svelte +19 -0
- package/package/components/render-inlined-styles.svelte.d.ts +19 -0
- package/package/constants/builder-registered-components.d.ts +6 -0
- package/package/constants/builder-registered-components.js +36 -0
- package/package/constants/device-sizes.d.ts +2 -0
- package/package/constants/device-sizes.js +18 -0
- package/package/constants/target.d.ts +2 -0
- package/package/constants/target.js +2 -0
- package/package/context/builder.context.d.ts +11 -0
- package/package/context/builder.context.js +11 -0
- package/package/context/types.d.ts +16 -0
- package/package/context/types.js +3 -0
- package/package/functions/camel-to-kebab-case.d.ts +1 -0
- package/package/functions/camel-to-kebab-case.js +1 -0
- package/package/functions/convert-style-object.d.ts +1 -0
- package/package/functions/convert-style-object.js +3 -0
- package/package/functions/evaluate.d.ts +5 -0
- package/package/functions/evaluate.js +25 -0
- package/package/functions/event-handler-name.d.ts +1 -0
- package/package/functions/event-handler-name.js +4 -0
- package/package/functions/get-block-actions.d.ts +9 -0
- package/package/functions/get-block-actions.js +21 -0
- package/package/functions/get-block-component-options.d.ts +2 -0
- package/package/functions/get-block-component-options.js +11 -0
- package/package/functions/get-block-properties.d.ts +5 -0
- package/package/functions/get-block-properties.js +10 -0
- package/package/functions/get-block-styles.d.ts +2 -0
- package/package/functions/get-block-styles.js +21 -0
- package/package/functions/get-block-tag.d.ts +3 -0
- package/package/functions/get-block-tag.js +4 -0
- package/package/functions/get-builder-search-params/fn.test.d.ts +1 -0
- package/package/functions/get-builder-search-params/fn.test.js +13 -0
- package/package/functions/get-builder-search-params/index.d.ts +6 -0
- package/package/functions/get-builder-search-params/index.js +29 -0
- package/package/functions/get-content/ab-testing.d.ts +3 -0
- package/package/functions/get-content/ab-testing.js +40 -0
- package/package/functions/get-content/fn.test.d.ts +1 -0
- package/package/functions/get-content/fn.test.js +31 -0
- package/package/functions/get-content/index.d.ts +9 -0
- package/package/functions/get-content/index.js +42 -0
- package/package/functions/get-content/types.d.ts +26 -0
- package/package/functions/get-content/types.js +1 -0
- package/package/functions/get-fetch.d.ts +1 -0
- package/package/functions/get-fetch.js +9 -0
- package/package/functions/get-global-this.d.ts +1 -0
- package/package/functions/get-global-this.js +15 -0
- package/package/functions/get-processed-block.d.ts +10 -0
- package/package/functions/get-processed-block.js +29 -0
- package/package/functions/get-processed-block.test.d.ts +1 -0
- package/package/functions/get-processed-block.test.js +32 -0
- package/package/functions/if-target.d.ts +7 -0
- package/package/functions/if-target.js +10 -0
- package/package/functions/is-browser.d.ts +1 -0
- package/package/functions/is-browser.js +3 -0
- package/package/functions/is-editing.d.ts +1 -0
- package/package/functions/is-editing.js +4 -0
- package/package/functions/is-iframe.d.ts +1 -0
- package/package/functions/is-iframe.js +4 -0
- package/package/functions/is-previewing.d.ts +1 -0
- package/package/functions/is-previewing.js +11 -0
- package/package/functions/mark-mutable.d.ts +2 -0
- package/package/functions/mark-mutable.js +6 -0
- package/package/functions/on-change.d.ts +7 -0
- package/package/functions/on-change.js +28 -0
- package/package/functions/on-change.test.d.ts +1 -0
- package/package/functions/on-change.test.js +20 -0
- package/package/functions/register-component.d.ts +14 -0
- package/package/functions/register-component.js +42 -0
- package/package/functions/register.d.ts +16 -0
- package/package/functions/register.js +29 -0
- package/package/functions/sanitize-styles.d.ts +4 -0
- package/package/functions/sanitize-styles.js +6 -0
- package/package/functions/set-editor-settings.d.ts +4 -0
- package/package/functions/set-editor-settings.js +12 -0
- package/package/functions/set.d.ts +7 -0
- package/package/functions/set.js +21 -0
- package/package/functions/set.test.d.ts +1 -0
- package/package/functions/set.test.js +16 -0
- package/package/functions/track.d.ts +21 -0
- package/package/functions/track.js +49 -0
- package/package/functions/transform-block.d.ts +2 -0
- package/package/functions/transform-block.js +5 -0
- package/package/helpers/cookie.d.ts +9 -0
- package/package/helpers/cookie.js +55 -0
- package/package/helpers/css.d.ts +1 -0
- package/package/helpers/css.js +9 -0
- package/package/helpers/flatten.d.ts +6 -0
- package/package/helpers/flatten.js +19 -0
- package/package/helpers/localStorage.d.ts +9 -0
- package/package/helpers/localStorage.js +23 -0
- package/package/helpers/nullable.d.ts +2 -0
- package/package/helpers/nullable.js +1 -0
- package/package/helpers/sessionId.d.ts +7 -0
- package/package/helpers/sessionId.js +20 -0
- package/package/helpers/time.d.ts +1 -0
- package/package/helpers/time.js +2 -0
- package/package/helpers/url.d.ts +6 -0
- package/package/helpers/url.js +12 -0
- package/package/helpers/url.test.d.ts +1 -0
- package/package/helpers/url.test.js +15 -0
- package/package/helpers/uuid.d.ts +8 -0
- package/package/helpers/uuid.js +15 -0
- package/package/helpers/visitorId.d.ts +8 -0
- package/package/helpers/visitorId.js +26 -0
- package/package/index-helpers/blocks-exports.d.ts +10 -0
- package/package/index-helpers/blocks-exports.js +10 -0
- package/package/index-helpers/top-of-file.d.ts +1 -0
- package/package/index-helpers/top-of-file.js +4 -0
- package/package/index.d.ts +10 -0
- package/package/index.js +10 -0
- package/package/scripts/init-editing.d.ts +2 -0
- package/package/scripts/init-editing.js +84 -0
- package/package/types/builder-block.d.ts +57 -0
- package/package/types/builder-block.js +1 -0
- package/package/types/builder-content.d.ts +38 -0
- package/package/types/builder-content.js +1 -0
- package/package/types/can-track.d.ts +3 -0
- package/package/types/can-track.js +1 -0
- package/package/types/components.d.ts +177 -0
- package/package/types/components.js +1 -0
- package/package/types/deep-partial.d.ts +3 -0
- package/package/types/deep-partial.js +1 -0
- package/package/types/element.d.ts +59 -0
- package/package/types/element.js +1 -0
- package/package/types/targets.d.ts +3 -0
- package/package/types/targets.js +1 -0
- package/package/types/typescript.d.ts +4 -0
- package/package/types/typescript.js +1 -0
- package/package.json +31 -8
- package/src/blocks/button/button.svelte +0 -49
- package/src/blocks/button/component-info.js +0 -41
- package/src/blocks/columns/columns.svelte +0 -103
- package/src/blocks/columns/component-info.js +0 -217
- package/src/blocks/custom-code/component-info.js +0 -31
- package/src/blocks/custom-code/custom-code.svelte +0 -64
- package/src/blocks/embed/component-info.js +0 -24
- package/src/blocks/embed/embed.svelte +0 -63
- package/src/blocks/form/component-info.js +0 -262
- package/src/blocks/form/form.svelte +0 -333
- package/src/blocks/fragment/component-info.js +0 -11
- package/src/blocks/fragment/fragment.svelte +0 -28
- package/src/blocks/image/component-info.js +0 -104
- package/src/blocks/image/image.svelte +0 -117
- package/src/blocks/img/component-info.js +0 -20
- package/src/blocks/img/img.svelte +0 -36
- package/src/blocks/input/component-info.js +0 -74
- package/src/blocks/input/input.svelte +0 -35
- package/src/blocks/raw-text/component-info.js +0 -16
- package/src/blocks/raw-text/raw-text.svelte +0 -29
- package/src/blocks/section/component-info.js +0 -49
- package/src/blocks/section/section.svelte +0 -36
- package/src/blocks/select/component-info.js +0 -59
- package/src/blocks/select/select.svelte +0 -41
- package/src/blocks/submit-button/component-info.js +0 -28
- package/src/blocks/submit-button/submit-button.svelte +0 -33
- package/src/blocks/symbol/component-info.js +0 -42
- package/src/blocks/symbol/symbol.svelte +0 -54
- package/src/blocks/text/component-info.js +0 -24
- package/src/blocks/text/text.svelte +0 -28
- package/src/blocks/textarea/component-info.js +0 -47
- package/src/blocks/textarea/textarea.svelte +0 -32
- package/src/blocks/video/component-info.js +0 -106
- package/src/blocks/video/video.svelte +0 -45
- package/src/components/error-boundary.svelte +0 -26
- package/src/components/render-block/block-styles.svelte +0 -51
- package/src/components/render-block/render-block.helpers.js +0 -23
- package/src/components/render-block/render-block.svelte +0 -174
- package/src/components/render-blocks.svelte +0 -82
- package/src/components/render-content/components/render-styles.svelte +0 -90
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/render-content.svelte +0 -252
- package/src/components/render-inlined-styles.svelte +0 -51
- package/src/constants/builder-registered-components.js +0 -45
- package/src/constants/device-sizes.js +0 -39
- package/src/constants/target.js +0 -4
- package/src/context/builder.context.js +0 -8
- package/src/functions/evaluate.js +0 -28
- package/src/functions/event-handler-name.js +0 -7
- package/src/functions/fast-clone.js +0 -4
- package/src/functions/get-block-actions.js +0 -23
- package/src/functions/get-block-component-options.js +0 -23
- package/src/functions/get-block-properties.js +0 -29
- package/src/functions/get-block-styles.js +0 -31
- package/src/functions/get-block-tag.js +0 -6
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-builder-search-params/index.js +0 -22
- package/src/functions/get-content/fn.test.js +0 -31
- package/src/functions/get-content/index.js +0 -138
- package/src/functions/get-fetch.js +0 -34
- package/src/functions/get-global-this.js +0 -18
- package/src/functions/get-processed-block.js +0 -46
- package/src/functions/get-processed-block.test.js +0 -31
- package/src/functions/if-target.js +0 -15
- package/src/functions/is-browser.js +0 -6
- package/src/functions/is-editing.js +0 -7
- package/src/functions/is-iframe.js +0 -7
- package/src/functions/is-previewing.js +0 -14
- package/src/functions/macro-eval.js +0 -5
- package/src/functions/on-change.js +0 -27
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/previewing-model-name.js +0 -11
- package/src/functions/register-component.js +0 -70
- package/src/functions/register.js +0 -29
- package/src/functions/set-editor-settings.js +0 -15
- package/src/functions/set.js +0 -11
- package/src/functions/set.test.js +0 -16
- package/src/functions/track.js +0 -22
- package/src/functions/transform-block.js +0 -6
- package/src/index-helpers/blocks-exports.js +0 -20
- package/src/index-helpers/top-of-file.js +0 -4
- package/src/index.js +0 -10
- package/src/scripts/init-editing.js +0 -80
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
const parts = host.split('.');
|
|
8
|
+
if (parts.length > 2) {
|
|
9
|
+
return parts.slice(1).join('.');
|
|
10
|
+
}
|
|
11
|
+
return host;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getTopLevelDomain } from './url.js';
|
|
2
|
+
describe('getTopLevelDomain', () => {
|
|
3
|
+
test('handles root domain', () => {
|
|
4
|
+
const output = getTopLevelDomain('example.com');
|
|
5
|
+
expect(output).toBe('example.com');
|
|
6
|
+
});
|
|
7
|
+
test('handles subdomain', () => {
|
|
8
|
+
const output = getTopLevelDomain('wwww.example.com');
|
|
9
|
+
expect(output).toBe('example.com');
|
|
10
|
+
});
|
|
11
|
+
test('handles subdomain with long suffix', () => {
|
|
12
|
+
const output = getTopLevelDomain('www.example.co.uk');
|
|
13
|
+
expect(output).toBe('example.co.uk');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @credit https://stackoverflow.com/a/2117523
|
|
3
|
+
*/
|
|
4
|
+
export function uuidv4() {
|
|
5
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
6
|
+
const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
7
|
+
return v.toString(16);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Slightly cleaner and smaller UUIDs
|
|
12
|
+
*/
|
|
13
|
+
export function uuid() {
|
|
14
|
+
return uuidv4().replace(/-/g, '');
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getLocalStorageItem, setLocalStorageItem } from './localStorage.js';
|
|
2
|
+
import { checkIsDefined } from './nullable.js';
|
|
3
|
+
import { uuid } from './uuid.js';
|
|
4
|
+
const VISITOR_LOCAL_STORAGE_KEY = 'builderVisitorId';
|
|
5
|
+
export const getVisitorId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const visitorId = getLocalStorageItem({
|
|
10
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
11
|
+
canTrack,
|
|
12
|
+
});
|
|
13
|
+
if (checkIsDefined(visitorId)) {
|
|
14
|
+
return visitorId;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const newVisitorId = createVisitorId();
|
|
18
|
+
setVisitorId({ id: newVisitorId, canTrack });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const createVisitorId = () => uuid();
|
|
22
|
+
export const setVisitorId = ({ id, canTrack, }) => setLocalStorageItem({
|
|
23
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
24
|
+
value: id,
|
|
25
|
+
canTrack,
|
|
26
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Columns } from '../blocks/columns/columns.svelte';
|
|
2
|
+
export { default as Image } from '../blocks/image/image.svelte';
|
|
3
|
+
export { default as Text } from '../blocks/text/text.svelte';
|
|
4
|
+
export { default as Video } from '../blocks/video/video.svelte';
|
|
5
|
+
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
6
|
+
export { default as Button } from '../blocks/button/button.svelte';
|
|
7
|
+
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
+
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
9
|
+
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
10
|
+
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Columns } from '../blocks/columns/columns.svelte';
|
|
2
|
+
export { default as Image } from '../blocks/image/image.svelte';
|
|
3
|
+
export { default as Text } from '../blocks/text/text.svelte';
|
|
4
|
+
export { default as Video } from '../blocks/video/video.svelte';
|
|
5
|
+
export { default as Symbol } from '../blocks/symbol/symbol.svelte';
|
|
6
|
+
export { default as Button } from '../blocks/button/button.svelte';
|
|
7
|
+
export { default as Section } from '../blocks/section/section.svelte';
|
|
8
|
+
export { default as Fragment } from '../blocks/fragment/fragment.svelte';
|
|
9
|
+
export { default as RenderContent } from '../components/render-content/render-content.svelte';
|
|
10
|
+
export { default as RenderBlocks } from '../components/render-blocks.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './index-helpers/top-of-file.js';
|
|
2
|
+
import './scripts/init-editing.js';
|
|
3
|
+
export * from './index-helpers/blocks-exports.js';
|
|
4
|
+
export * from './functions/is-editing.js';
|
|
5
|
+
export * from './functions/is-previewing.js';
|
|
6
|
+
export * from './functions/register-component.js';
|
|
7
|
+
export * from './functions/register.js';
|
|
8
|
+
export * from './functions/set-editor-settings.js';
|
|
9
|
+
export * from './functions/get-content/index.js';
|
|
10
|
+
export * from './functions/get-builder-search-params/index.js';
|
package/package/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './index-helpers/top-of-file.js';
|
|
2
|
+
import './scripts/init-editing.js';
|
|
3
|
+
export * from './index-helpers/blocks-exports.js';
|
|
4
|
+
export * from './functions/is-editing.js';
|
|
5
|
+
export * from './functions/is-previewing.js';
|
|
6
|
+
export * from './functions/register-component.js';
|
|
7
|
+
export * from './functions/register.js';
|
|
8
|
+
export * from './functions/set-editor-settings.js';
|
|
9
|
+
export * from './functions/get-content/index.js';
|
|
10
|
+
export * from './functions/get-builder-search-params/index.js';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TARGET } from '../constants/target.js';
|
|
2
|
+
import { isBrowser } from '../functions/is-browser.js';
|
|
3
|
+
import { register } from '../functions/register.js';
|
|
4
|
+
export const registerInsertMenu = () => {
|
|
5
|
+
register('insertMenu', {
|
|
6
|
+
name: '_default',
|
|
7
|
+
default: true,
|
|
8
|
+
items: [
|
|
9
|
+
{ name: 'Box' },
|
|
10
|
+
{ name: 'Text' },
|
|
11
|
+
{ name: 'Image' },
|
|
12
|
+
{ name: 'Columns' },
|
|
13
|
+
...(TARGET === 'reactNative'
|
|
14
|
+
? []
|
|
15
|
+
: [
|
|
16
|
+
{ name: 'Core:Section' },
|
|
17
|
+
{ name: 'Core:Button' },
|
|
18
|
+
{ name: 'Embed' },
|
|
19
|
+
{ name: 'Custom Code' },
|
|
20
|
+
]),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const setupBrowserForEditing = () => {
|
|
25
|
+
if (isBrowser()) {
|
|
26
|
+
window.parent?.postMessage({
|
|
27
|
+
type: 'builder.sdkInfo',
|
|
28
|
+
data: {
|
|
29
|
+
target: TARGET,
|
|
30
|
+
// TODO: compile these in
|
|
31
|
+
// type: process.env.SDK_TYPE,
|
|
32
|
+
// version: process.env.SDK_VERSION,
|
|
33
|
+
supportsPatchUpdates: false,
|
|
34
|
+
},
|
|
35
|
+
}, '*');
|
|
36
|
+
window.addEventListener('message', ({ data }) => {
|
|
37
|
+
if (data) {
|
|
38
|
+
switch (data.type) {
|
|
39
|
+
case 'builder.evaluate': {
|
|
40
|
+
const text = data.data.text;
|
|
41
|
+
const args = data.data.arguments || [];
|
|
42
|
+
const id = data.data.id;
|
|
43
|
+
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
44
|
+
const fn = new Function(text);
|
|
45
|
+
let result;
|
|
46
|
+
let error = null;
|
|
47
|
+
try {
|
|
48
|
+
// eslint-disable-next-line prefer-spread
|
|
49
|
+
result = fn.apply(null, args);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
error = err;
|
|
53
|
+
}
|
|
54
|
+
if (error) {
|
|
55
|
+
window.parent?.postMessage({
|
|
56
|
+
type: 'builder.evaluateError',
|
|
57
|
+
data: { id, error: error.message },
|
|
58
|
+
}, '*');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (result && typeof result.then === 'function') {
|
|
62
|
+
result
|
|
63
|
+
.then((finalResult) => {
|
|
64
|
+
window.parent?.postMessage({
|
|
65
|
+
type: 'builder.evaluateResult',
|
|
66
|
+
data: { id, result: finalResult },
|
|
67
|
+
}, '*');
|
|
68
|
+
})
|
|
69
|
+
.catch(console.error);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
window.parent?.postMessage({
|
|
73
|
+
type: 'builder.evaluateResult',
|
|
74
|
+
data: { result, id },
|
|
75
|
+
}, '*');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
declare 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
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BuilderBlock } from './builder-block.js';
|
|
2
|
+
declare type Input = any;
|
|
3
|
+
export interface BuilderContentVariation {
|
|
4
|
+
data?: {
|
|
5
|
+
title?: string;
|
|
6
|
+
blocks?: BuilderBlock[];
|
|
7
|
+
inputs?: Input[];
|
|
8
|
+
state?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
jsCode?: string;
|
|
12
|
+
tsCode?: string;
|
|
13
|
+
httpRequests?: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
name?: string;
|
|
19
|
+
testRatio?: number;
|
|
20
|
+
id?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface BuilderContent extends BuilderContentVariation {
|
|
23
|
+
'@version'?: number;
|
|
24
|
+
id?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
published?: 'published' | 'draft' | 'archived';
|
|
27
|
+
modelId?: string;
|
|
28
|
+
priority?: number;
|
|
29
|
+
lastUpdated?: number;
|
|
30
|
+
startDate?: number;
|
|
31
|
+
endDate?: number;
|
|
32
|
+
variations?: {
|
|
33
|
+
[id: string]: BuilderContentVariation | undefined;
|
|
34
|
+
};
|
|
35
|
+
testVariationId?: string;
|
|
36
|
+
testVariationName?: string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './builder-block.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { BuilderElement } from './element';
|
|
2
|
+
export interface Input {
|
|
3
|
+
name: string;
|
|
4
|
+
friendlyName?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
defaultValue?: any;
|
|
7
|
+
type: string;
|
|
8
|
+
valueType?: {
|
|
9
|
+
type?: string;
|
|
10
|
+
};
|
|
11
|
+
required?: boolean;
|
|
12
|
+
autoFocus?: boolean;
|
|
13
|
+
subFields?: Input[];
|
|
14
|
+
helperText?: string;
|
|
15
|
+
allowedFileTypes?: string[];
|
|
16
|
+
imageHeight?: number;
|
|
17
|
+
imageWidth?: number;
|
|
18
|
+
mediaHeight?: number;
|
|
19
|
+
mediaWidth?: number;
|
|
20
|
+
hideFromUI?: boolean;
|
|
21
|
+
modelId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Number field type validation maximum accepted input
|
|
24
|
+
*/
|
|
25
|
+
max?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Number field type validation minimum accepted input
|
|
28
|
+
*/
|
|
29
|
+
min?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Number field type step size when using arrows
|
|
32
|
+
*/
|
|
33
|
+
step?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Set this to `true` to show the editor for this input when
|
|
36
|
+
* children of this component are selected. This is useful for things
|
|
37
|
+
* like Tabs, such that users may not always select the Tabs component
|
|
38
|
+
* directly but will still be looking for how to add additional tabs
|
|
39
|
+
*/
|
|
40
|
+
broadcast?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Set this to `true` to show the editor for this input when
|
|
43
|
+
* group locked parents of this component are selected. This is useful
|
|
44
|
+
* to bubble up important inputs for locked groups, like text and images
|
|
45
|
+
*/
|
|
46
|
+
bubble?: boolean;
|
|
47
|
+
options?: {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
};
|
|
50
|
+
enum?: string[] | {
|
|
51
|
+
label: string;
|
|
52
|
+
value: any;
|
|
53
|
+
helperText?: string;
|
|
54
|
+
}[];
|
|
55
|
+
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
56
|
+
regex?: {
|
|
57
|
+
/** pattern to test, like "^\/[a-z]$" */
|
|
58
|
+
pattern: string;
|
|
59
|
+
/** flags for the RegExp constructor, e.g. "gi" */
|
|
60
|
+
options?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Friendly message to display to end-users if the regex fails, e.g.
|
|
63
|
+
* "You must use a relative url starting with '/...' "
|
|
64
|
+
*/
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
advanced?: boolean;
|
|
68
|
+
onChange?: ((options: Map<string, any>) => void | Promise<void>) | string;
|
|
69
|
+
code?: boolean;
|
|
70
|
+
richText?: boolean;
|
|
71
|
+
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
72
|
+
copyOnAdd?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface ComponentInfo {
|
|
75
|
+
/**
|
|
76
|
+
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
77
|
+
* by registering a component with the same name, e.g. 'Text', to replace the built-in text component
|
|
78
|
+
*/
|
|
79
|
+
name: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Link to a documentation page for this component
|
|
83
|
+
*/
|
|
84
|
+
docsLink?: string;
|
|
85
|
+
image?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Input schema for your component for users to fill in the options
|
|
88
|
+
*/
|
|
89
|
+
inputs?: Input[];
|
|
90
|
+
class?: any;
|
|
91
|
+
type?: 'angular' | 'webcomponent' | 'react' | 'vue';
|
|
92
|
+
defaultStyles?: {
|
|
93
|
+
[key: string]: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Turn on if your component can accept children. Be sure to use in combination with
|
|
97
|
+
* withChildren(YourComponent) like here
|
|
98
|
+
* github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
|
|
99
|
+
*/
|
|
100
|
+
canHaveChildren?: boolean;
|
|
101
|
+
fragment?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
|
|
104
|
+
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
105
|
+
*/
|
|
106
|
+
noWrap?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Default children
|
|
109
|
+
*/
|
|
110
|
+
defaultChildren?: BuilderElement[];
|
|
111
|
+
defaults?: Partial<BuilderElement>;
|
|
112
|
+
hooks?: {
|
|
113
|
+
[key: string]: string | Function;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Hide your component in editor, useful for gradually deprecating components
|
|
117
|
+
*/
|
|
118
|
+
hideFromInsertMenu?: boolean;
|
|
119
|
+
tag?: string;
|
|
120
|
+
static?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
|
|
123
|
+
*/
|
|
124
|
+
models?: string[];
|
|
125
|
+
builtIn: true;
|
|
126
|
+
/**
|
|
127
|
+
* Specify restrictions direct children must match
|
|
128
|
+
*/
|
|
129
|
+
childRequirements?: {
|
|
130
|
+
/** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
|
|
131
|
+
message: string;
|
|
132
|
+
/** Simple way to say children must be a specific component name */
|
|
133
|
+
component?: string;
|
|
134
|
+
/**
|
|
135
|
+
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
136
|
+
* of what the children objects should match, e.g.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* query: {
|
|
140
|
+
* // Child of this element must be a 'Button' or 'Text' component
|
|
141
|
+
* 'component.name': { $in: ['Button', 'Text'] }
|
|
142
|
+
* }
|
|
143
|
+
*/
|
|
144
|
+
query?: any;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Specify restrictions any parent must match
|
|
148
|
+
*/
|
|
149
|
+
requiresParent?: {
|
|
150
|
+
/** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
|
|
151
|
+
message: string;
|
|
152
|
+
/** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
|
|
153
|
+
component?: string;
|
|
154
|
+
/**
|
|
155
|
+
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
156
|
+
* of what at least one parent in the parents hierarchy should match, e.g.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* query: {
|
|
160
|
+
* // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
|
|
161
|
+
* 'component.name': { $in: ['Product Box', 'Collection'] }
|
|
162
|
+
* }
|
|
163
|
+
*/
|
|
164
|
+
query?: any;
|
|
165
|
+
};
|
|
166
|
+
/** not yet implemented */
|
|
167
|
+
friendlyName?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Use to restrict access to your component based on a the current user permissions
|
|
170
|
+
* By default components will show to all users
|
|
171
|
+
* for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
|
|
172
|
+
*/
|
|
173
|
+
requiredPermissions?: Array<Permission>;
|
|
174
|
+
hidden?: boolean;
|
|
175
|
+
}
|
|
176
|
+
declare type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
|
|
177
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
declare 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 BuilderElement {
|
|
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?: BuilderElement[];
|
|
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?: Animation[];
|
|
56
|
+
}
|
|
57
|
+
interface Animation {
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|