@builder.io/sdk-svelte 0.0.1-1 → 0.0.1-12
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 +15 -0
- package/package.json +16 -4
- package/src/blocks/columns/columns.svelte +1 -1
- package/src/blocks/form/form.svelte +1 -1
- package/src/blocks/image/image.svelte +2 -2
- package/src/blocks/img/img.svelte +1 -1
- package/src/blocks/input/input.svelte +1 -1
- package/src/blocks/select/select.svelte +1 -1
- package/src/blocks/symbol/component-info.js +1 -0
- package/src/blocks/symbol/symbol.svelte +1 -1
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.svelte +54 -55
- package/src/components/render-block/render-component-and-styles.svelte +61 -0
- package/src/components/render-blocks.svelte +1 -1
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.svelte +41 -17
- package/src/components/render-inlined-styles.svelte +3 -1
- package/src/constants/builder-registered-components.js +45 -0
- package/src/context/builder.context.js +1 -1
- package/src/functions/evaluate.js +2 -2
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-block-component-options.js +6 -1
- package/src/functions/get-block-styles.js +1 -1
- package/src/functions/get-content/index.js +1 -1
- package/src/functions/get-fetch.js +1 -1
- package/src/functions/get-processed-block.js +3 -3
- package/src/functions/get-processed-block.test.js +1 -1
- package/src/functions/if-target.js +1 -1
- package/src/functions/is-editing.js +1 -1
- package/src/functions/is-iframe.js +1 -1
- package/src/functions/is-previewing.js +2 -2
- package/src/functions/on-change.test.js +1 -1
- package/src/functions/previewing-model-name.js +1 -1
- package/src/functions/register-component.js +30 -13
- package/src/functions/register.js +1 -1
- package/src/functions/set-editor-settings.js +1 -1
- package/src/functions/set.test.js +1 -1
- package/src/functions/track.js +3 -3
- package/src/index-helpers/blocks-exports.js +8 -8
- package/src/index.js +10 -10
- package/src/scripts/init-editing.js +4 -4
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button/index.js +0 -7
- package/src/blocks/columns/index.js +0 -7
- package/src/blocks/custom-code/index.js +0 -7
- package/src/blocks/embed/index.js +0 -7
- package/src/blocks/form/index.js +0 -7
- package/src/blocks/fragment/index.js +0 -7
- package/src/blocks/image/index.js +0 -7
- package/src/blocks/img/index.js +0 -7
- package/src/blocks/input/index.js +0 -7
- package/src/blocks/raw-text/index.js +0 -7
- package/src/blocks/section/index.js +0 -7
- package/src/blocks/select/index.js +0 -7
- package/src/blocks/submit-button/index.js +0 -7
- package/src/blocks/symbol/index.js +0 -7
- package/src/blocks/text/index.js +0 -7
- package/src/blocks/textarea/index.js +0 -7
- package/src/blocks/video/index.js +0 -7
- package/src/functions/macro-eval.js +0 -5
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Builder.io Svelte SDK (BETA)
|
|
2
|
+
|
|
3
|
+
This is the Svelte SDK. It is currently in beta.
|
|
4
|
+
|
|
5
|
+
## Feature Support
|
|
6
|
+
|
|
7
|
+
To check the status of the SDK, look at [these tables](../../README.md#feature-implementation).
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm install @builder.io/sdk-svelte@dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Take a look at [our example repo](/examples/svelte/sveltekit) for how to use this SDK.
|
package/package.json
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.0.1-
|
|
5
|
-
"
|
|
6
|
-
|
|
4
|
+
"version": "0.0.1-12",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"main": "./src/index.js",
|
|
10
|
+
"module": "./src/index.js",
|
|
11
|
+
"svelte": "./src/index.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.js"
|
|
16
|
+
}
|
|
7
17
|
},
|
|
8
|
-
"main": "src/index.js",
|
|
9
18
|
"scripts": {
|
|
10
19
|
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"node-fetch": "^2.6.1"
|
|
11
23
|
}
|
|
12
24
|
}
|
|
@@ -38,10 +38,10 @@ export let builderBlock;
|
|
|
38
38
|
|
|
39
39
|
<picture >
|
|
40
40
|
|
|
41
|
-
<img loading="lazy" alt={altText}
|
|
41
|
+
<img loading="lazy" alt={altText} role={altText ? 'presentation' : undefined} style={{
|
|
42
42
|
objectPosition: backgroundSize || 'center',
|
|
43
43
|
objectFit: backgroundSize || 'cover'
|
|
44
|
-
}} class={'builder-image' + (className ? ' ' + className : '')} src={image}
|
|
44
|
+
}} class={'builder-image' + (className ? ' ' + className : '')} src={image} srcSet={srcset} sizes={sizes} />
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
<source srcSet={srcset} />
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import RenderContent, { } from '../../components/render-content/render-content.svelte';
|
|
7
7
|
import BuilderContext, { } from '../../context/builder.context';
|
|
8
|
-
import { getContent } from '../../functions/get-content';
|
|
8
|
+
import { getContent } from '../../functions/get-content/index.js';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const EMPTY_HTML_ELEMENTS = [
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"keygen",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
];
|
|
18
|
+
const isEmptyHtmlElement = (tagName) => {
|
|
19
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
isEmptyHtmlElement
|
|
23
|
+
};
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import BlockStyles, { } from './block-styles.svelte';
|
|
6
|
+
import BuilderContext, { } from '../../context/builder.context';
|
|
7
|
+
import { getBlockActions } from '../../functions/get-block-actions.js';
|
|
8
|
+
import { getBlockComponentOptions } from '../../functions/get-block-component-options.js';
|
|
9
|
+
import { getBlockProperties } from '../../functions/get-block-properties.js';
|
|
10
|
+
import { getBlockStyles } from '../../functions/get-block-styles.js';
|
|
11
|
+
import { getBlockTag } from '../../functions/get-block-tag.js';
|
|
12
|
+
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
13
|
+
import { isEmptyHtmlElement } from './render-block.helpers.js';
|
|
14
|
+
import RenderComponentAndStyles, { } from './render-component-and-styles.svelte';
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
|
|
@@ -29,20 +28,29 @@ if (!componentName) {
|
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
const ref =
|
|
31
|
+
const ref = builderContext.registeredComponents[componentName];
|
|
33
32
|
|
|
34
|
-
if (
|
|
33
|
+
if (!ref) {
|
|
35
34
|
// TODO: Public doc page with more info about this message
|
|
36
35
|
console.warn(`
|
|
37
36
|
Could not find a registered component named "${componentName}".
|
|
38
37
|
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
38
|
+
return undefined;
|
|
39
|
+
} else {
|
|
40
|
+
return ref;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
return ref;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
$: componentInfo = () => {
|
|
45
|
-
|
|
45
|
+
if (component()) {
|
|
46
|
+
const {
|
|
47
|
+
component: _,
|
|
48
|
+
...info
|
|
49
|
+
} = component();
|
|
50
|
+
return info;
|
|
51
|
+
} else {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
46
54
|
};
|
|
47
55
|
|
|
48
56
|
$: componentRef = () => {
|
|
@@ -61,22 +69,32 @@ return getProcessedBlock({
|
|
|
61
69
|
});
|
|
62
70
|
};
|
|
63
71
|
|
|
64
|
-
$:
|
|
72
|
+
$: attributes = () => {
|
|
65
73
|
return { ...getBlockProperties(useBlock()),
|
|
66
74
|
...getBlockActions({
|
|
67
75
|
block: useBlock(),
|
|
68
76
|
state: builderContext.state,
|
|
69
77
|
context: builderContext.context
|
|
70
|
-
})
|
|
78
|
+
}),
|
|
79
|
+
style: getBlockStyles(useBlock())
|
|
71
80
|
};
|
|
72
81
|
};
|
|
73
82
|
|
|
74
|
-
$:
|
|
75
|
-
return
|
|
83
|
+
$: shouldWrap = () => {
|
|
84
|
+
return !componentInfo?.()?.noWrap;
|
|
76
85
|
};
|
|
77
86
|
|
|
78
87
|
$: componentOptions = () => {
|
|
79
|
-
return getBlockComponentOptions(useBlock())
|
|
88
|
+
return { ...getBlockComponentOptions(useBlock()),
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
92
|
+
* they are provided to the component itself directly.
|
|
93
|
+
*/
|
|
94
|
+
...(shouldWrap() ? {} : {
|
|
95
|
+
attributes: attributes()
|
|
96
|
+
})
|
|
97
|
+
};
|
|
80
98
|
};
|
|
81
99
|
|
|
82
100
|
$: children = () => {
|
|
@@ -88,6 +106,10 @@ return useBlock().children ?? [];
|
|
|
88
106
|
};
|
|
89
107
|
|
|
90
108
|
$: noCompRefChildren = () => {
|
|
109
|
+
/**
|
|
110
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
111
|
+
* we render them outside of `componentRef`
|
|
112
|
+
*/
|
|
91
113
|
return componentRef() ? [] : children();
|
|
92
114
|
};
|
|
93
115
|
|
|
@@ -103,44 +125,21 @@ return componentRef() ? [] : children();
|
|
|
103
125
|
</script>
|
|
104
126
|
|
|
105
127
|
|
|
128
|
+
{#if shouldWrap() }
|
|
129
|
+
|
|
106
130
|
|
|
107
131
|
|
|
108
|
-
{#if !
|
|
132
|
+
{#if !isEmptyHtmlElement(tagName()) }
|
|
109
133
|
|
|
110
134
|
|
|
111
|
-
<svelte:element {...
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{#if TARGET === 'vue' || TARGET === 'svelte' }
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<BlockStyles block={useBlock()} ></BlockStyles>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
{/if}
|
|
123
|
-
|
|
135
|
+
<svelte:element {...attributes()} this={tagName()} >
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
{#if componentRef() }
|
|
127
|
-
<svelte:component {...componentOptions()} builderBlock={useBlock()} this={componentRef()} >
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
{#each children() as child, index }
|
|
131
|
-
<svelte:self block={child} ></svelte:self>
|
|
132
|
-
{/each}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
</svelte:component>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{/if}
|
|
137
|
+
<RenderComponentAndStyles block={useBlock()} blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponentAndStyles>
|
|
139
138
|
|
|
140
139
|
|
|
141
140
|
|
|
142
141
|
{#each noCompRefChildren() as child, index }
|
|
143
|
-
<svelte:self block={child} ></svelte:self>
|
|
142
|
+
<svelte:self key={child.id} block={child} ></svelte:self>
|
|
144
143
|
{/each}
|
|
145
144
|
|
|
146
145
|
|
|
@@ -150,14 +149,14 @@ return componentRef() ? [] : children();
|
|
|
150
149
|
|
|
151
150
|
|
|
152
151
|
{:else}
|
|
153
|
-
<svelte:
|
|
154
|
-
|
|
152
|
+
<svelte:element {...attributes()} this={tagName()} ></svelte:element>
|
|
155
153
|
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
{/if}
|
|
155
|
+
|
|
156
|
+
|
|
159
157
|
|
|
160
158
|
|
|
161
|
-
|
|
159
|
+
{:else}
|
|
160
|
+
<RenderComponentAndStyles block={useBlock()} blockChildren={children()} componentRef={componentRef()} componentOptions={componentOptions()} ></RenderComponentAndStyles>
|
|
162
161
|
|
|
163
162
|
{/if}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { TARGET } from '../../constants/target.js';
|
|
7
|
+
import BlockStyles, { } from './block-styles.svelte';
|
|
8
|
+
import RenderBlock, { } from './render-block.svelte';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export let block;
|
|
16
|
+
export let componentRef;
|
|
17
|
+
export let componentOptions;
|
|
18
|
+
export let blockChildren;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
{#if TARGET === 'vue' || TARGET === 'svelte' }
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<BlockStyles block={block} ></BlockStyles>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
{/if}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
{#if componentRef }
|
|
50
|
+
<svelte:component {...componentOptions} this={componentRef} >
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
{#each blockChildren as child, index }
|
|
54
|
+
<RenderBlock key={child.id} block={child} ></RenderBlock>
|
|
55
|
+
{/each}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
</svelte:component>
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
{/if}
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
import { afterUpdate } from 'svelte'
|
|
4
4
|
import { onDestroy } from 'svelte'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { getDefaultRegisteredComponents } from '../../constants/builder-registered-components.js';
|
|
7
|
+
import { TARGET } from '../../constants/target.js';
|
|
7
8
|
import BuilderContext, { } from '../../context/builder.context';
|
|
8
|
-
import { evaluate } from '../../functions/evaluate';
|
|
9
|
-
import { convertSearchParamsToQueryObject , getBuilderSearchParams } from '../../functions/get-builder-search-params';
|
|
10
|
-
import { getContent } from '../../functions/get-content';
|
|
11
|
-
import { getFetch } from '../../functions/get-fetch';
|
|
12
|
-
import { isBrowser } from '../../functions/is-browser';
|
|
13
|
-
import { isEditing } from '../../functions/is-editing';
|
|
14
|
-
import { isPreviewing } from '../../functions/is-previewing';
|
|
15
|
-
import { previewingModelName } from '../../functions/previewing-model-name';
|
|
16
|
-
import {
|
|
9
|
+
import { evaluate } from '../../functions/evaluate.js';
|
|
10
|
+
import { convertSearchParamsToQueryObject , getBuilderSearchParams } from '../../functions/get-builder-search-params/index.js';
|
|
11
|
+
import { getContent } from '../../functions/get-content/index.js';
|
|
12
|
+
import { getFetch } from '../../functions/get-fetch.js';
|
|
13
|
+
import { isBrowser } from '../../functions/is-browser.js';
|
|
14
|
+
import { isEditing } from '../../functions/is-editing.js';
|
|
15
|
+
import { isPreviewing } from '../../functions/is-previewing.js';
|
|
16
|
+
import { previewingModelName } from '../../functions/previewing-model-name.js';
|
|
17
|
+
import { components , createRegisterComponentMessage } from '../../functions/register-component.js';
|
|
18
|
+
import { track } from '../../functions/track.js';
|
|
17
19
|
import RenderBlocks, { } from '../render-blocks.svelte';
|
|
18
20
|
import RenderContentStyles, { } from './components/render-styles.svelte';
|
|
19
21
|
|
|
@@ -24,6 +26,7 @@ import RenderContentStyles, { } from './components/render-styles.svelte';
|
|
|
24
26
|
|
|
25
27
|
export let content;
|
|
26
28
|
export let data;
|
|
29
|
+
export let customComponents;
|
|
27
30
|
export let model;
|
|
28
31
|
export let apiKey;
|
|
29
32
|
|
|
@@ -108,14 +111,16 @@ Object.entries(requests).forEach(([key, url]) => {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
function emitStateUpdate() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
if (isEditing()) {
|
|
115
|
+
window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
|
|
116
|
+
detail: {
|
|
117
|
+
state: contentState(),
|
|
118
|
+
ref: {
|
|
119
|
+
name: model
|
|
120
|
+
}
|
|
116
121
|
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
119
124
|
}
|
|
120
125
|
$: useContent = () => {
|
|
121
126
|
const mergedContent = { ...content,
|
|
@@ -139,6 +144,19 @@ $: context = () => {
|
|
|
139
144
|
return {};
|
|
140
145
|
};
|
|
141
146
|
|
|
147
|
+
$: allRegisteredComponents = () => {
|
|
148
|
+
const allComponentsArray = [...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
149
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
150
|
+
// existing usage.
|
|
151
|
+
// This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
|
|
152
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
153
|
+
...components, ...(customComponents || [])];
|
|
154
|
+
const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
|
|
155
|
+
[curr.name]: curr
|
|
156
|
+
}), {});
|
|
157
|
+
return allComponents;
|
|
158
|
+
};
|
|
159
|
+
|
|
142
160
|
$: httpReqsData = () => {
|
|
143
161
|
return {};
|
|
144
162
|
};
|
|
@@ -152,6 +170,8 @@ return contentState();
|
|
|
152
170
|
return context();
|
|
153
171
|
}, get apiKey() {
|
|
154
172
|
return apiKey;
|
|
173
|
+
}, get registeredComponents() {
|
|
174
|
+
return allRegisteredComponents();
|
|
155
175
|
},});
|
|
156
176
|
let overrideContent = null;
|
|
157
177
|
let update = 0;
|
|
@@ -159,6 +179,10 @@ let overrideState = {};
|
|
|
159
179
|
|
|
160
180
|
onMount(() => { if (isBrowser()) {
|
|
161
181
|
if (isEditing()) {
|
|
182
|
+
Object.values(allRegisteredComponents()).forEach(registeredComponent => {
|
|
183
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
184
|
+
window.parent?.postMessage(message, '*');
|
|
185
|
+
});
|
|
162
186
|
window.addEventListener('message', processMessage);
|
|
163
187
|
window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
164
188
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { default as Button } from "../blocks/button/button.svelte";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.svelte";
|
|
20
|
+
import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
|
|
21
|
+
import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
|
|
22
|
+
import { default as Fragment } from "../blocks/fragment/fragment.svelte";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.svelte";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.svelte";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.svelte";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.svelte";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.svelte";
|
|
33
|
+
const getDefaultRegisteredComponents = () => [
|
|
34
|
+
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
35
|
+
__spreadValues({ component: Image }, imageComponentInfo),
|
|
36
|
+
__spreadValues({ component: Text }, textComponentInfo),
|
|
37
|
+
__spreadValues({ component: Video }, videoComponentInfo),
|
|
38
|
+
__spreadValues({ component: Symbol }, symbolComponentInfo),
|
|
39
|
+
__spreadValues({ component: Button }, buttonComponentInfo),
|
|
40
|
+
__spreadValues({ component: Section }, sectionComponentInfo),
|
|
41
|
+
__spreadValues({ component: Fragment }, fragmentComponentInfo)
|
|
42
|
+
];
|
|
43
|
+
export {
|
|
44
|
+
getDefaultRegisteredComponents
|
|
45
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { evaluate } from "./evaluate";
|
|
2
|
-
import { getEventHandlerName } from "./event-handler-name";
|
|
1
|
+
import { evaluate } from "./evaluate.js";
|
|
2
|
+
import { getEventHandlerName } from "./event-handler-name.js";
|
|
3
3
|
function getBlockActions(options) {
|
|
4
4
|
var _a;
|
|
5
5
|
const obj = {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,9 +16,12 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
function getBlockComponentOptions(block) {
|
|
18
21
|
var _a;
|
|
19
|
-
return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options)
|
|
22
|
+
return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
23
|
+
builderBlock: block
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
26
|
export {
|
|
22
27
|
getBlockComponentOptions
|
|
@@ -14,7 +14,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import { sizes } from "../constants/device-sizes";
|
|
17
|
+
import { sizes } from "../constants/device-sizes.js";
|
|
18
18
|
function getBlockStyles(block) {
|
|
19
19
|
var _a, _b, _c, _d, _e;
|
|
20
20
|
const styles = __spreadValues(__spreadValues({}, (_a = block.responsiveStyles) == null ? void 0 : _a.large), block.styles);
|
|
@@ -37,7 +37,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
import { getFetch } from "../get-fetch";
|
|
40
|
+
import { getFetch } from "../get-fetch.js";
|
|
41
41
|
const fetch$ = getFetch();
|
|
42
42
|
function flatten(object, path = null, separator = ".") {
|
|
43
43
|
return Object.keys(object).reduce((acc, key) => {
|
|
@@ -18,7 +18,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
18
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
-
import { getGlobalThis } from "./get-global-this";
|
|
21
|
+
import { getGlobalThis } from "./get-global-this.js";
|
|
22
22
|
function getFetch() {
|
|
23
23
|
return __async(this, null, function* () {
|
|
24
24
|
const globalFetch = getGlobalThis().fetch;
|
|
@@ -17,9 +17,9 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { evaluate } from "./evaluate";
|
|
21
|
-
import { set } from "./set";
|
|
22
|
-
import { transformBlock } from "./transform-block";
|
|
20
|
+
import { evaluate } from "./evaluate.js";
|
|
21
|
+
import { set } from "./set.js";
|
|
22
|
+
import { transformBlock } from "./transform-block.js";
|
|
23
23
|
function getProcessedBlock(options) {
|
|
24
24
|
const { state, context } = options;
|
|
25
25
|
const block = transformBlock(options.block);
|
|
@@ -17,27 +17,43 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { fastClone } from "./fast-clone.js";
|
|
33
|
+
const components = [];
|
|
22
34
|
function registerComponent(component, info) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (isBrowser()) {
|
|
26
|
-
const sendInfo = prepareComponentInfoToSend(info);
|
|
27
|
-
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
28
|
-
type: "builder.registerComponent",
|
|
29
|
-
data: sendInfo
|
|
30
|
-
}, "*");
|
|
31
|
-
}
|
|
35
|
+
components.push(__spreadValues({ component }, info));
|
|
36
|
+
console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
|
|
32
37
|
return component;
|
|
33
38
|
}
|
|
39
|
+
const createRegisterComponentMessage = (_a) => {
|
|
40
|
+
var _b = _a, {
|
|
41
|
+
component
|
|
42
|
+
} = _b, info = __objRest(_b, [
|
|
43
|
+
"component"
|
|
44
|
+
]);
|
|
45
|
+
return {
|
|
46
|
+
type: "builder.registerComponent",
|
|
47
|
+
data: prepareComponentInfoToSend(fastClone(info))
|
|
48
|
+
};
|
|
49
|
+
};
|
|
34
50
|
function prepareComponentInfoToSend(info) {
|
|
35
51
|
return __spreadValues(__spreadValues({}, info), info.inputs && {
|
|
36
52
|
inputs: info.inputs.map((input) => {
|
|
37
53
|
const keysToConvertFnToString = ["onChange", "showIf"];
|
|
38
54
|
for (const key of keysToConvertFnToString) {
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
const fn = input[key];
|
|
56
|
+
if (fn && typeof fn === "function") {
|
|
41
57
|
input = __spreadProps(__spreadValues({}, input), {
|
|
42
58
|
[key]: `return (${fn.toString()}).apply(this, arguments)`
|
|
43
59
|
});
|
|
@@ -49,5 +65,6 @@ function prepareComponentInfoToSend(info) {
|
|
|
49
65
|
}
|
|
50
66
|
export {
|
|
51
67
|
components,
|
|
68
|
+
createRegisterComponentMessage,
|
|
52
69
|
registerComponent
|
|
53
70
|
};
|
package/src/functions/track.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TARGET } from "../constants/target";
|
|
2
|
-
import { isBrowser } from "./is-browser";
|
|
3
|
-
import { isEditing } from "./is-editing";
|
|
1
|
+
import { TARGET } from "../constants/target.js";
|
|
2
|
+
import { isBrowser } from "./is-browser.js";
|
|
3
|
+
import { isEditing } from "./is-editing.js";
|
|
4
4
|
function track(event, properties) {
|
|
5
5
|
if (isEditing()) {
|
|
6
6
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { default as default2 } from "../blocks/columns";
|
|
2
|
-
import { default as default3 } from "../blocks/image";
|
|
3
|
-
import { default as default4 } from "../blocks/text";
|
|
4
|
-
import { default as default5 } from "../blocks/video";
|
|
5
|
-
import { default as default6 } from "../blocks/symbol";
|
|
6
|
-
import { default as default7 } from "../blocks/button";
|
|
7
|
-
import { default as default8 } from "../blocks/section";
|
|
8
|
-
import { default as default9 } from "../blocks/fragment";
|
|
1
|
+
import { default as default2 } from "../blocks/columns/columns.svelte";
|
|
2
|
+
import { default as default3 } from "../blocks/image/image.svelte";
|
|
3
|
+
import { default as default4 } from "../blocks/text/text.svelte";
|
|
4
|
+
import { default as default5 } from "../blocks/video/video.svelte";
|
|
5
|
+
import { default as default6 } from "../blocks/symbol/symbol.svelte";
|
|
6
|
+
import { default as default7 } from "../blocks/button/button.svelte";
|
|
7
|
+
import { default as default8 } from "../blocks/section/section.svelte";
|
|
8
|
+
import { default as default9 } from "../blocks/fragment/fragment.svelte";
|
|
9
9
|
import { default as default10 } from "../components/render-content/render-content.svelte";
|
|
10
10
|
export {
|
|
11
11
|
default7 as Button,
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./index-helpers/top-of-file";
|
|
2
|
-
import "./scripts/init-editing";
|
|
3
|
-
export * from "./index-helpers/blocks-exports";
|
|
4
|
-
export * from "./functions/is-editing";
|
|
5
|
-
export * from "./functions/is-previewing";
|
|
6
|
-
export * from "./functions/register-component";
|
|
7
|
-
export * from "./functions/register";
|
|
8
|
-
export * from "./functions/set-editor-settings";
|
|
9
|
-
export * from "./functions/get-content";
|
|
10
|
-
export * from "./functions/get-builder-search-params";
|
|
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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TARGET } from "../constants/target";
|
|
2
|
-
import { isBrowser } from "../functions/is-browser";
|
|
3
|
-
import { isEditing } from "../functions/is-editing";
|
|
4
|
-
import { register } from "../functions/register";
|
|
1
|
+
import { TARGET } from "../constants/target.js";
|
|
2
|
+
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import { register } from "../functions/register.js";
|
|
5
5
|
const registerInsertMenu = () => {
|
|
6
6
|
register("insertMenu", {
|
|
7
7
|
name: "_default",
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import component from "./button.svelte";
|
|
3
|
-
import { componentInfo } from "./component-info";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import component from "./columns.svelte";
|
|
3
|
-
import { componentInfo } from "./component-info";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./custom-code.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./embed.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
package/src/blocks/form/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./form.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./fragment.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./image.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
package/src/blocks/img/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./img.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./input.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./raw-text.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./section.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./select.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./submit-button.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./symbol.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
package/src/blocks/text/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./text.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./textarea.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { registerComponent } from "../../functions/register-component";
|
|
2
|
-
import { componentInfo } from "./component-info";
|
|
3
|
-
import component from "./video.svelte";
|
|
4
|
-
var stdin_default = registerComponent(component, componentInfo);
|
|
5
|
-
export {
|
|
6
|
-
stdin_default as default
|
|
7
|
-
};
|