@builder.io/sdk-svelte 0.0.1-0 → 0.0.1-11
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/{button.svelte → button/button.svelte} +29 -18
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/{columns.svelte → columns/columns.svelte} +22 -14
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/custom-code/custom-code.svelte +64 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/embed/embed.svelte +63 -0
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/{form.svelte → form/form.svelte} +49 -16
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/{fragment.svelte → fragment/fragment.svelte} +5 -2
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/{image.svelte → image/image.svelte} +27 -9
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/{img.svelte → img/img.svelte} +5 -2
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/{input.svelte → input/input.svelte} +5 -2
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/{raw-text.svelte → raw-text/raw-text.svelte} +4 -1
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/{section.svelte → section/section.svelte} +4 -1
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/{select.svelte → select/select.svelte} +10 -3
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/{submit-button.svelte → submit-button/submit-button.svelte} +4 -1
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.svelte +54 -0
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/{text.svelte → text/text.svelte} +4 -1
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/{textarea.svelte → textarea/textarea.svelte} +4 -1
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/{video.svelte → video/video.svelte} +4 -1
- package/src/components/error-boundary.svelte +4 -1
- package/src/components/render-block/block-styles.svelte +51 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/render-block/render-block.svelte +182 -0
- package/src/components/render-blocks.svelte +18 -6
- package/src/components/render-content/components/render-styles.svelte +8 -13
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.svelte +210 -174
- package/src/components/render-inlined-styles.svelte +51 -0
- package/src/constants/builder-registered-components.js +45 -0
- package/src/constants/device-sizes.js +4 -11
- package/src/constants/target.js +3 -10
- package/src/context/builder.context.js +6 -31
- package/src/functions/evaluate.js +8 -31
- package/src/functions/event-handler-name.js +3 -10
- package/src/functions/fast-clone.js +4 -0
- package/src/functions/get-block-actions.js +6 -29
- package/src/functions/get-block-component-options.js +3 -9
- package/src/functions/get-block-properties.js +3 -9
- package/src/functions/get-block-styles.js +6 -27
- package/src/functions/get-block-tag.js +3 -10
- package/src/functions/get-builder-search-params/fn.test.js +3 -21
- package/src/functions/get-builder-search-params/index.js +4 -11
- package/src/functions/get-content/fn.test.js +3 -21
- package/src/functions/get-content/index.js +8 -28
- package/src/functions/get-fetch.js +31 -32
- package/src/functions/get-global-this.js +3 -10
- package/src/functions/get-processed-block.js +9 -30
- package/src/functions/get-processed-block.test.js +2 -20
- package/src/functions/if-target.js +5 -28
- package/src/functions/is-browser.js +3 -10
- package/src/functions/is-editing.js +5 -28
- package/src/functions/is-iframe.js +5 -28
- package/src/functions/is-previewing.js +7 -30
- package/src/functions/on-change.js +4 -11
- package/src/functions/on-change.test.js +4 -22
- package/src/functions/previewing-model-name.js +5 -28
- package/src/functions/register-component.js +32 -36
- package/src/functions/register.js +5 -28
- package/src/functions/set-editor-settings.js +5 -28
- package/src/functions/set.js +3 -10
- package/src/functions/set.test.js +4 -22
- package/src/functions/track.js +8 -31
- package/src/functions/transform-block.js +3 -10
- package/src/index-helpers/blocks-exports.js +19 -42
- package/src/index-helpers/top-of-file.js +3 -10
- package/src/index.js +10 -32
- package/src/scripts/init-editing.js +72 -81
- package/src/types/builder-block.js +0 -3
- package/src/types/builder-content.js +0 -3
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -3
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -3
- package/src/types/typescript.js +0 -3
- package/src/blocks/custom-code.svelte +0 -63
- package/src/blocks/embed.svelte +0 -62
- package/src/blocks/symbol.svelte +0 -55
- package/src/components/block-styles.svelte +0 -23
- package/src/components/render-block.svelte +0 -121
- package/src/functions/macro-eval.js +0 -12
|
@@ -1,216 +1,252 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import { afterUpdate } from 'svelte'
|
|
4
|
+
import { onDestroy } from 'svelte'
|
|
5
|
+
|
|
6
|
+
import { getDefaultRegisteredComponents } from '../../constants/builder-registered-components.js';
|
|
7
|
+
import { TARGET } from '../../constants/target.js';
|
|
8
|
+
import BuilderContext, { } from '../../context/builder.context';
|
|
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';
|
|
19
|
+
import RenderBlocks, { } from '../render-blocks.svelte';
|
|
20
|
+
import RenderContentStyles, { } from './components/render-styles.svelte';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
import { getContext, setContext } from "svelte";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export let content;
|
|
25
28
|
export let data;
|
|
29
|
+
export let customComponents;
|
|
26
30
|
export let model;
|
|
27
31
|
export let apiKey;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
|
|
33
|
+
function processMessage(event) {
|
|
34
|
+
const {
|
|
35
|
+
data
|
|
36
|
+
} = event;
|
|
37
|
+
|
|
38
|
+
if (data) {
|
|
39
|
+
switch (data.type) {
|
|
40
|
+
case 'builder.contentUpdate':
|
|
41
|
+
{
|
|
42
|
+
const messageContent = data.data;
|
|
43
|
+
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
44
|
+
const contentData = messageContent.data;
|
|
45
|
+
|
|
46
|
+
if (key === model) {
|
|
47
|
+
overrideContent = contentData;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case 'builder.patchUpdates':
|
|
54
|
+
{
|
|
55
|
+
// TODO
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
function evaluateJsCode() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
// run any dynamic JS code attached to content
|
|
64
|
+
const jsCode = useContent?.()?.data?.jsCode;
|
|
65
|
+
|
|
66
|
+
if (jsCode) {
|
|
67
|
+
evaluate({
|
|
68
|
+
code: jsCode,
|
|
69
|
+
context: context(),
|
|
70
|
+
state: contentState()
|
|
71
|
+
});
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
function evalExpression(expression) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
77
|
+
code: group,
|
|
78
|
+
context: context(),
|
|
79
|
+
state: contentState()
|
|
80
|
+
}));
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
function handleRequest({
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
url,
|
|
85
|
+
key
|
|
82
86
|
}) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
const fetchAndSetState = async () => {
|
|
88
|
+
const fetch = await getFetch();
|
|
89
|
+
const response = await fetch(url);
|
|
90
|
+
const json = await response.json();
|
|
91
|
+
const newOverrideState = { ...overrideState,
|
|
92
|
+
[key]: json
|
|
93
|
+
};
|
|
94
|
+
overrideState = newOverrideState;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
fetchAndSetState();
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
function runHttpRequests() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
const requests = useContent?.()?.data?.httpRequests ?? {};
|
|
102
|
+
Object.entries(requests).forEach(([key, url]) => {
|
|
103
|
+
if (url && (!httpReqsData()[key] || isEditing())) {
|
|
104
|
+
const evaluatedUrl = evalExpression(url);
|
|
105
|
+
handleRequest({
|
|
106
|
+
url: evaluatedUrl,
|
|
107
|
+
key
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
function emitStateUpdate() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
if (isEditing()) {
|
|
115
|
+
window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
|
|
116
|
+
detail: {
|
|
117
|
+
state: contentState(),
|
|
118
|
+
ref: {
|
|
119
|
+
name: model
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
117
123
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
}
|
|
125
|
+
$: useContent = () => {
|
|
126
|
+
const mergedContent = { ...content,
|
|
127
|
+
...overrideContent,
|
|
128
|
+
data: { ...content?.data,
|
|
129
|
+
...data,
|
|
130
|
+
...overrideContent?.data
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return mergedContent;
|
|
127
134
|
};
|
|
128
135
|
|
|
129
|
-
$:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
$: contentState = () => {
|
|
137
|
+
return { ...content?.data?.state,
|
|
138
|
+
...data,
|
|
139
|
+
...overrideState
|
|
140
|
+
};
|
|
134
141
|
};
|
|
135
142
|
|
|
136
143
|
$: context = () => {
|
|
137
|
-
|
|
144
|
+
return {};
|
|
145
|
+
};
|
|
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;
|
|
138
158
|
};
|
|
139
159
|
|
|
140
160
|
$: httpReqsData = () => {
|
|
141
|
-
|
|
161
|
+
return {};
|
|
142
162
|
};
|
|
143
163
|
|
|
144
|
-
|
|
164
|
+
|
|
165
|
+
setContext(BuilderContext.key, { get content() {
|
|
166
|
+
return useContent();
|
|
167
|
+
}, get state() {
|
|
168
|
+
return contentState();
|
|
169
|
+
}, get context() {
|
|
170
|
+
return context();
|
|
171
|
+
}, get apiKey() {
|
|
172
|
+
return apiKey;
|
|
173
|
+
}, get registeredComponents() {
|
|
174
|
+
return allRegisteredComponents();
|
|
175
|
+
},});
|
|
176
|
+
let overrideContent = null;
|
|
145
177
|
let update = 0;
|
|
146
178
|
let overrideState = {};
|
|
147
179
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
contentId: useContent().id
|
|
158
|
-
});
|
|
159
|
-
} // override normal content in preview mode
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (isPreviewing()) {
|
|
163
|
-
if (model && previewingModelName() === model) {
|
|
164
|
-
const currentUrl = new URL(location.href);
|
|
165
|
-
const previewApiKey = currentUrl.searchParams.get('apiKey');
|
|
166
|
-
|
|
167
|
-
if (previewApiKey) {
|
|
168
|
-
getContent({
|
|
169
|
-
model: model,
|
|
170
|
-
apiKey: previewApiKey,
|
|
171
|
-
options: getBuilderSearchParams(convertSearchParamsToQueryObject(currentUrl.searchParams))
|
|
172
|
-
}).then(content => {
|
|
173
|
-
if (content) {
|
|
174
|
-
overrideContent = content;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
evaluateJsCode();
|
|
182
|
-
runHttpRequests();
|
|
183
|
-
emitStateUpdate();
|
|
184
|
-
}
|
|
185
|
-
});
|
|
180
|
+
onMount(() => { if (isBrowser()) {
|
|
181
|
+
if (isEditing()) {
|
|
182
|
+
Object.values(allRegisteredComponents()).forEach(registeredComponent => {
|
|
183
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
184
|
+
window.parent?.postMessage(message, '*');
|
|
185
|
+
});
|
|
186
|
+
window.addEventListener('message', processMessage);
|
|
187
|
+
window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
188
|
+
}
|
|
186
189
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
190
|
+
if (useContent()) {
|
|
191
|
+
track('impression', {
|
|
192
|
+
contentId: useContent().id
|
|
193
|
+
});
|
|
194
|
+
} // override normal content in preview mode
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
if (isPreviewing()) {
|
|
198
|
+
if (model && previewingModelName() === model) {
|
|
199
|
+
const currentUrl = new URL(location.href);
|
|
200
|
+
const previewApiKey = currentUrl.searchParams.get('apiKey');
|
|
201
|
+
|
|
202
|
+
if (previewApiKey) {
|
|
203
|
+
getContent({
|
|
204
|
+
model: model,
|
|
205
|
+
apiKey: previewApiKey,
|
|
206
|
+
options: getBuilderSearchParams(convertSearchParamsToQueryObject(currentUrl.searchParams))
|
|
207
|
+
}).then(content => {
|
|
208
|
+
if (content) {
|
|
209
|
+
overrideContent = content;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
evaluateJsCode();
|
|
217
|
+
runHttpRequests();
|
|
218
|
+
emitStateUpdate();
|
|
219
|
+
} });
|
|
220
|
+
|
|
221
|
+
afterUpdate(() => { evaluateJsCode(); });afterUpdate(() => { runHttpRequests(); });afterUpdate(() => { emitStateUpdate(); })
|
|
222
|
+
|
|
223
|
+
onDestroy(() => { if (isBrowser()) {
|
|
224
|
+
window.removeEventListener('message', processMessage);
|
|
225
|
+
window.removeEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
|
|
226
|
+
} });
|
|
227
|
+
</script>
|
|
202
228
|
|
|
203
|
-
|
|
204
|
-
|
|
229
|
+
|
|
230
|
+
{#if useContent() }
|
|
231
|
+
|
|
232
|
+
|
|
205
233
|
<div on:click="{event => track('click', {
|
|
206
|
-
|
|
234
|
+
contentId: useContent().id
|
|
207
235
|
})}" data-builder-content-id={useContent?.()?.id} >
|
|
208
|
-
|
|
209
|
-
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
{#if (useContent?.()?.data?.cssCode || useContent?.()?.data?.customFonts?.length) && TARGET !== 'reactNative' }
|
|
239
|
+
<RenderContentStyles cssCode={useContent().data.cssCode} customFonts={useContent().data.customFonts} ></RenderContentStyles>
|
|
240
|
+
|
|
210
241
|
|
|
211
|
-
|
|
242
|
+
{/if}
|
|
243
|
+
|
|
244
|
+
|
|
212
245
|
<RenderBlocks blocks={useContent?.()?.data?.blocks} ></RenderBlocks>
|
|
213
246
|
|
|
214
|
-
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
215
251
|
|
|
216
|
-
|
|
252
|
+
{/if}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { TARGET } from '../constants/target.js';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export let styles;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
$: injectedStyleScript = () => {
|
|
17
|
+
return `<${tagName()}>${styles}</${tagName()}>`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
$: tagName = () => {
|
|
21
|
+
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
22
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
23
|
+
return 'sty' + 'le';
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
{#if TARGET === 'svelte' }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
{@html injectedStyleScript()}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{:else}
|
|
49
|
+
<svelte:component this={tagName()} >{styles}</svelte:component>
|
|
50
|
+
|
|
51
|
+
{/if}
|
|
@@ -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,14 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
__markAsModule(target);
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
-
};
|
|
8
|
-
__export(exports, {
|
|
9
|
-
sizeNames: () => sizeNames,
|
|
10
|
-
sizes: () => sizes
|
|
11
|
-
});
|
|
12
1
|
const sizeNames = ["xsmall", "small", "medium", "large"];
|
|
13
2
|
const sizes = {
|
|
14
3
|
xsmall: {
|
|
@@ -44,3 +33,7 @@ const sizes = {
|
|
|
44
33
|
return "large";
|
|
45
34
|
}
|
|
46
35
|
};
|
|
36
|
+
export {
|
|
37
|
+
sizeNames,
|
|
38
|
+
sizes
|
|
39
|
+
};
|
package/src/constants/target.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__markAsModule(target);
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1
|
+
const TARGET = "svelte";
|
|
2
|
+
export {
|
|
3
|
+
TARGET
|
|
7
4
|
};
|
|
8
|
-
__export(exports, {
|
|
9
|
-
TARGET: () => TARGET
|
|
10
|
-
});
|
|
11
|
-
const TARGET = "reactNative";
|
|
@@ -1,33 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1
|
+
const key = Symbol();
|
|
2
|
+
var stdin_default = {
|
|
3
|
+
Builder: { content: null, context: {}, state: {}, apiKey: null, registeredComponents: {} },
|
|
4
|
+
key
|
|
12
5
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (let key of __getOwnPropNames(module2))
|
|
16
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
6
|
+
export {
|
|
7
|
+
stdin_default as default
|
|
20
8
|
};
|
|
21
|
-
var __toModule = (module2) => {
|
|
22
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
-
};
|
|
24
|
-
__export(exports, {
|
|
25
|
-
default: () => stdin_default
|
|
26
|
-
});
|
|
27
|
-
var import_react = __toModule(require("react"));
|
|
28
|
-
var stdin_default = (0, import_react.createContext)({
|
|
29
|
-
content: null,
|
|
30
|
-
context: {},
|
|
31
|
-
state: {},
|
|
32
|
-
apiKey: null
|
|
33
|
-
});
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, module2, desc) => {
|
|
14
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(module2))
|
|
16
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __toModule = (module2) => {
|
|
22
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
-
};
|
|
24
|
-
__export(exports, {
|
|
25
|
-
evaluate: () => evaluate
|
|
26
|
-
});
|
|
27
|
-
var import_is_browser = __toModule(require("./is-browser"));
|
|
28
|
-
var import_is_editing = __toModule(require("./is-editing"));
|
|
1
|
+
import { isBrowser } from "./is-browser.js";
|
|
2
|
+
import { isEditing } from "./is-editing.js";
|
|
29
3
|
function evaluate({
|
|
30
4
|
code,
|
|
31
5
|
context,
|
|
@@ -37,9 +11,9 @@ function evaluate({
|
|
|
37
11
|
return;
|
|
38
12
|
}
|
|
39
13
|
const builder = {
|
|
40
|
-
isEditing:
|
|
41
|
-
isBrowser:
|
|
42
|
-
isServer: !
|
|
14
|
+
isEditing: isEditing(),
|
|
15
|
+
isBrowser: isBrowser(),
|
|
16
|
+
isServer: !isBrowser()
|
|
43
17
|
};
|
|
44
18
|
const useReturn = !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
45
19
|
const useCode = useReturn ? `return (${code});` : code;
|
|
@@ -49,3 +23,6 @@ function evaluate({
|
|
|
49
23
|
console.warn("Builder custom code error: ", e);
|
|
50
24
|
}
|
|
51
25
|
}
|
|
26
|
+
export {
|
|
27
|
+
evaluate
|
|
28
|
+
};
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
__markAsModule(target);
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
-
};
|
|
8
|
-
__export(exports, {
|
|
9
|
-
getEventHandlerName: () => getEventHandlerName
|
|
10
|
-
});
|
|
11
1
|
function capitalizeFirstLetter(string) {
|
|
12
2
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
13
3
|
}
|
|
14
4
|
const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
|
|
5
|
+
export {
|
|
6
|
+
getEventHandlerName
|
|
7
|
+
};
|