@builder.io/sdk-svelte 1.0.16 → 1.0.19
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/lib/browser/components/content/components/enable-editor.svelte +31 -31
- package/lib/browser/components/content-variants/content-variants.svelte +1 -1
- package/lib/browser/components/content-variants/helpers.js +2 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/context/index.d.ts +1 -0
- package/lib/browser/context/index.js +1 -0
- package/lib/browser/index-helpers/blocks-exports.d.ts +4 -0
- package/lib/browser/index-helpers/blocks-exports.js +4 -0
- package/lib/edge/components/content/components/enable-editor.svelte +31 -31
- package/lib/edge/components/content-variants/content-variants.svelte +1 -1
- package/lib/edge/components/content-variants/helpers.js +2 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/context/index.d.ts +1 -0
- package/lib/edge/context/index.js +1 -0
- package/lib/edge/index-helpers/blocks-exports.d.ts +4 -0
- package/lib/edge/index-helpers/blocks-exports.js +4 -0
- package/lib/node/components/content/components/enable-editor.svelte +31 -31
- package/lib/node/components/content-variants/content-variants.svelte +1 -1
- package/lib/node/components/content-variants/helpers.js +2 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/context/index.d.ts +1 -0
- package/lib/node/context/index.js +1 -0
- package/lib/node/index-helpers/blocks-exports.d.ts +4 -0
- package/lib/node/index-helpers/blocks-exports.js +4 -0
- package/package.json +1 -1
- package/src/components/content/components/enable-editor.svelte +34 -35
- package/src/components/content-variants/content-variants.svelte +1 -1
- package/src/components/content-variants/helpers.ts +2 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/context/index.ts +1 -0
- package/src/index-helpers/blocks-exports.ts +6 -1
|
@@ -122,41 +122,40 @@ function onClick(event) {
|
|
|
122
122
|
clicked = true;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function evalExpression(expression) {
|
|
126
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
127
|
-
code: group,
|
|
128
|
-
context: context || {},
|
|
129
|
-
localState: undefined,
|
|
130
|
-
rootState: $builderContextSignal.rootState,
|
|
131
|
-
rootSetState: $builderContextSignal.rootSetState,
|
|
132
|
-
enableCache: true,
|
|
133
|
-
})));
|
|
134
|
-
}
|
|
135
|
-
function handleRequest({ url, key }) {
|
|
136
|
-
fetch(url)
|
|
137
|
-
.then((response) => response.json())
|
|
138
|
-
.then((json) => {
|
|
139
|
-
const newState = {
|
|
140
|
-
...$builderContextSignal.rootState,
|
|
141
|
-
[key]: json,
|
|
142
|
-
};
|
|
143
|
-
$builderContextSignal.rootSetState?.(newState);
|
|
144
|
-
httpReqsData[key] = true;
|
|
145
|
-
})
|
|
146
|
-
.catch((err) => {
|
|
147
|
-
console.error("error fetching dynamic data", url, err);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
125
|
function runHttpRequests() {
|
|
151
126
|
const requests = $builderContextSignal.content?.data?.httpRequests ?? {};
|
|
152
127
|
Object.entries(requests).forEach(([key, url]) => {
|
|
153
|
-
if (url
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
128
|
+
if (!url)
|
|
129
|
+
return;
|
|
130
|
+
// request already in progress
|
|
131
|
+
if (httpReqsPending[key])
|
|
132
|
+
return;
|
|
133
|
+
// request already completed, and not in edit mode
|
|
134
|
+
if (httpReqsData[key] && !isEditing())
|
|
135
|
+
return;
|
|
136
|
+
httpReqsPending[key] = true;
|
|
137
|
+
const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
138
|
+
code: group,
|
|
139
|
+
context: context || {},
|
|
140
|
+
localState: undefined,
|
|
141
|
+
rootState: $builderContextSignal.rootState,
|
|
142
|
+
rootSetState: $builderContextSignal.rootSetState,
|
|
143
|
+
enableCache: true,
|
|
144
|
+
})));
|
|
145
|
+
fetch(evaluatedUrl)
|
|
146
|
+
.then((response) => response.json())
|
|
147
|
+
.then((json) => {
|
|
148
|
+
mergeNewRootState({
|
|
149
|
+
[key]: json,
|
|
158
150
|
});
|
|
159
|
-
|
|
151
|
+
httpReqsData[key] = true;
|
|
152
|
+
})
|
|
153
|
+
.catch((err) => {
|
|
154
|
+
console.error("error fetching dynamic data", url, err);
|
|
155
|
+
})
|
|
156
|
+
.finally(() => {
|
|
157
|
+
httpReqsPending[key] = false;
|
|
158
|
+
});
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
function emitStateUpdate() {
|
|
@@ -228,6 +227,7 @@ function elementRef_onInitpreviewingbldr(event) {
|
|
|
228
227
|
let elementRef;
|
|
229
228
|
let ContentWrapper = contentWrapper || "div";
|
|
230
229
|
let httpReqsData = {};
|
|
230
|
+
let httpReqsPending = {};
|
|
231
231
|
let clicked = false;
|
|
232
232
|
onMount(() => {
|
|
233
233
|
if (isBrowser()) {
|
|
@@ -53,7 +53,7 @@ let shouldRenderVariants = checkShouldRenderVariants({
|
|
|
53
53
|
});
|
|
54
54
|
onMount(() => {
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* For Solid/Svelte: we unmount the non-winning variants post-hydration.
|
|
57
57
|
*/
|
|
58
58
|
shouldRenderVariants = false;
|
|
59
59
|
});
|
|
@@ -27,10 +27,11 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
27
27
|
return false;
|
|
28
28
|
/**
|
|
29
29
|
* For Vue and Svelte, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
30
|
+
*
|
|
30
31
|
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
31
32
|
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
32
33
|
*
|
|
33
|
-
* NOTE: For
|
|
34
|
+
* NOTE: For Solid/Svelte: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
34
35
|
* This isn't necessary, just a nice to have.
|
|
35
36
|
*/
|
|
36
37
|
if (TARGET === 'vue' || TARGET === 'svelte')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.19";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.19";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
|
@@ -122,41 +122,40 @@ function onClick(event) {
|
|
|
122
122
|
clicked = true;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function evalExpression(expression) {
|
|
126
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
127
|
-
code: group,
|
|
128
|
-
context: context || {},
|
|
129
|
-
localState: undefined,
|
|
130
|
-
rootState: $builderContextSignal.rootState,
|
|
131
|
-
rootSetState: $builderContextSignal.rootSetState,
|
|
132
|
-
enableCache: true,
|
|
133
|
-
})));
|
|
134
|
-
}
|
|
135
|
-
function handleRequest({ url, key }) {
|
|
136
|
-
fetch(url)
|
|
137
|
-
.then((response) => response.json())
|
|
138
|
-
.then((json) => {
|
|
139
|
-
const newState = {
|
|
140
|
-
...$builderContextSignal.rootState,
|
|
141
|
-
[key]: json,
|
|
142
|
-
};
|
|
143
|
-
$builderContextSignal.rootSetState?.(newState);
|
|
144
|
-
httpReqsData[key] = true;
|
|
145
|
-
})
|
|
146
|
-
.catch((err) => {
|
|
147
|
-
console.error("error fetching dynamic data", url, err);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
125
|
function runHttpRequests() {
|
|
151
126
|
const requests = $builderContextSignal.content?.data?.httpRequests ?? {};
|
|
152
127
|
Object.entries(requests).forEach(([key, url]) => {
|
|
153
|
-
if (url
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
128
|
+
if (!url)
|
|
129
|
+
return;
|
|
130
|
+
// request already in progress
|
|
131
|
+
if (httpReqsPending[key])
|
|
132
|
+
return;
|
|
133
|
+
// request already completed, and not in edit mode
|
|
134
|
+
if (httpReqsData[key] && !isEditing())
|
|
135
|
+
return;
|
|
136
|
+
httpReqsPending[key] = true;
|
|
137
|
+
const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
138
|
+
code: group,
|
|
139
|
+
context: context || {},
|
|
140
|
+
localState: undefined,
|
|
141
|
+
rootState: $builderContextSignal.rootState,
|
|
142
|
+
rootSetState: $builderContextSignal.rootSetState,
|
|
143
|
+
enableCache: true,
|
|
144
|
+
})));
|
|
145
|
+
fetch(evaluatedUrl)
|
|
146
|
+
.then((response) => response.json())
|
|
147
|
+
.then((json) => {
|
|
148
|
+
mergeNewRootState({
|
|
149
|
+
[key]: json,
|
|
158
150
|
});
|
|
159
|
-
|
|
151
|
+
httpReqsData[key] = true;
|
|
152
|
+
})
|
|
153
|
+
.catch((err) => {
|
|
154
|
+
console.error("error fetching dynamic data", url, err);
|
|
155
|
+
})
|
|
156
|
+
.finally(() => {
|
|
157
|
+
httpReqsPending[key] = false;
|
|
158
|
+
});
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
function emitStateUpdate() {
|
|
@@ -228,6 +227,7 @@ function elementRef_onInitpreviewingbldr(event) {
|
|
|
228
227
|
let elementRef;
|
|
229
228
|
let ContentWrapper = contentWrapper || "div";
|
|
230
229
|
let httpReqsData = {};
|
|
230
|
+
let httpReqsPending = {};
|
|
231
231
|
let clicked = false;
|
|
232
232
|
onMount(() => {
|
|
233
233
|
if (isBrowser()) {
|
|
@@ -53,7 +53,7 @@ let shouldRenderVariants = checkShouldRenderVariants({
|
|
|
53
53
|
});
|
|
54
54
|
onMount(() => {
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* For Solid/Svelte: we unmount the non-winning variants post-hydration.
|
|
57
57
|
*/
|
|
58
58
|
shouldRenderVariants = false;
|
|
59
59
|
});
|
|
@@ -27,10 +27,11 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
27
27
|
return false;
|
|
28
28
|
/**
|
|
29
29
|
* For Vue and Svelte, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
30
|
+
*
|
|
30
31
|
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
31
32
|
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
32
33
|
*
|
|
33
|
-
* NOTE: For
|
|
34
|
+
* NOTE: For Solid/Svelte: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
34
35
|
* This isn't necessary, just a nice to have.
|
|
35
36
|
*/
|
|
36
37
|
if (TARGET === 'vue' || TARGET === 'svelte')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.19";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.19";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
|
@@ -122,41 +122,40 @@ function onClick(event) {
|
|
|
122
122
|
clicked = true;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function evalExpression(expression) {
|
|
126
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
127
|
-
code: group,
|
|
128
|
-
context: context || {},
|
|
129
|
-
localState: undefined,
|
|
130
|
-
rootState: $builderContextSignal.rootState,
|
|
131
|
-
rootSetState: $builderContextSignal.rootSetState,
|
|
132
|
-
enableCache: true,
|
|
133
|
-
})));
|
|
134
|
-
}
|
|
135
|
-
function handleRequest({ url, key }) {
|
|
136
|
-
fetch(url)
|
|
137
|
-
.then((response) => response.json())
|
|
138
|
-
.then((json) => {
|
|
139
|
-
const newState = {
|
|
140
|
-
...$builderContextSignal.rootState,
|
|
141
|
-
[key]: json,
|
|
142
|
-
};
|
|
143
|
-
$builderContextSignal.rootSetState?.(newState);
|
|
144
|
-
httpReqsData[key] = true;
|
|
145
|
-
})
|
|
146
|
-
.catch((err) => {
|
|
147
|
-
console.error("error fetching dynamic data", url, err);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
125
|
function runHttpRequests() {
|
|
151
126
|
const requests = $builderContextSignal.content?.data?.httpRequests ?? {};
|
|
152
127
|
Object.entries(requests).forEach(([key, url]) => {
|
|
153
|
-
if (url
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
128
|
+
if (!url)
|
|
129
|
+
return;
|
|
130
|
+
// request already in progress
|
|
131
|
+
if (httpReqsPending[key])
|
|
132
|
+
return;
|
|
133
|
+
// request already completed, and not in edit mode
|
|
134
|
+
if (httpReqsData[key] && !isEditing())
|
|
135
|
+
return;
|
|
136
|
+
httpReqsPending[key] = true;
|
|
137
|
+
const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
138
|
+
code: group,
|
|
139
|
+
context: context || {},
|
|
140
|
+
localState: undefined,
|
|
141
|
+
rootState: $builderContextSignal.rootState,
|
|
142
|
+
rootSetState: $builderContextSignal.rootSetState,
|
|
143
|
+
enableCache: true,
|
|
144
|
+
})));
|
|
145
|
+
fetch(evaluatedUrl)
|
|
146
|
+
.then((response) => response.json())
|
|
147
|
+
.then((json) => {
|
|
148
|
+
mergeNewRootState({
|
|
149
|
+
[key]: json,
|
|
158
150
|
});
|
|
159
|
-
|
|
151
|
+
httpReqsData[key] = true;
|
|
152
|
+
})
|
|
153
|
+
.catch((err) => {
|
|
154
|
+
console.error("error fetching dynamic data", url, err);
|
|
155
|
+
})
|
|
156
|
+
.finally(() => {
|
|
157
|
+
httpReqsPending[key] = false;
|
|
158
|
+
});
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
function emitStateUpdate() {
|
|
@@ -228,6 +227,7 @@ function elementRef_onInitpreviewingbldr(event) {
|
|
|
228
227
|
let elementRef;
|
|
229
228
|
let ContentWrapper = contentWrapper || "div";
|
|
230
229
|
let httpReqsData = {};
|
|
230
|
+
let httpReqsPending = {};
|
|
231
231
|
let clicked = false;
|
|
232
232
|
onMount(() => {
|
|
233
233
|
if (isBrowser()) {
|
|
@@ -53,7 +53,7 @@ let shouldRenderVariants = checkShouldRenderVariants({
|
|
|
53
53
|
});
|
|
54
54
|
onMount(() => {
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* For Solid/Svelte: we unmount the non-winning variants post-hydration.
|
|
57
57
|
*/
|
|
58
58
|
shouldRenderVariants = false;
|
|
59
59
|
});
|
|
@@ -27,10 +27,11 @@ export const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
|
27
27
|
return false;
|
|
28
28
|
/**
|
|
29
29
|
* For Vue and Svelte, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
30
|
+
*
|
|
30
31
|
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
31
32
|
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
32
33
|
*
|
|
33
|
-
* NOTE: For
|
|
34
|
+
* NOTE: For Solid/Svelte: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
34
35
|
* This isn't necessary, just a nice to have.
|
|
35
36
|
*/
|
|
36
37
|
if (TARGET === 'vue' || TARGET === 'svelte')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.19";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.19";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
|
@@ -8,3 +8,7 @@ export { default as Text } from '../blocks/text/index.js';
|
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
10
|
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Builder Context
|
|
13
|
+
*/
|
|
14
|
+
export { BuilderContext } from '../context/index.js';
|
package/package.json
CHANGED
|
@@ -154,47 +154,45 @@
|
|
|
154
154
|
clicked = true;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
function evalExpression(expression: string) {
|
|
158
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
|
|
159
|
-
String(
|
|
160
|
-
evaluate({
|
|
161
|
-
code: group,
|
|
162
|
-
context: context || {},
|
|
163
|
-
localState: undefined,
|
|
164
|
-
rootState: $builderContextSignal.rootState,
|
|
165
|
-
rootSetState: $builderContextSignal.rootSetState,
|
|
166
|
-
enableCache: true,
|
|
167
|
-
})
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
function handleRequest({ url, key }: { key: string; url: string }) {
|
|
172
|
-
fetch(url)
|
|
173
|
-
.then((response) => response.json())
|
|
174
|
-
.then((json) => {
|
|
175
|
-
const newState = {
|
|
176
|
-
...$builderContextSignal.rootState,
|
|
177
|
-
[key]: json,
|
|
178
|
-
};
|
|
179
|
-
$builderContextSignal.rootSetState?.(newState);
|
|
180
|
-
httpReqsData[key] = true;
|
|
181
|
-
})
|
|
182
|
-
.catch((err) => {
|
|
183
|
-
console.error("error fetching dynamic data", url, err);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
157
|
function runHttpRequests() {
|
|
187
158
|
const requests: {
|
|
188
159
|
[key: string]: string;
|
|
189
160
|
} = $builderContextSignal.content?.data?.httpRequests ?? {};
|
|
190
161
|
Object.entries(requests).forEach(([key, url]) => {
|
|
191
|
-
if (url
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
162
|
+
if (!url) return;
|
|
163
|
+
|
|
164
|
+
// request already in progress
|
|
165
|
+
if (httpReqsPending[key]) return;
|
|
166
|
+
|
|
167
|
+
// request already completed, and not in edit mode
|
|
168
|
+
if (httpReqsData[key] && !isEditing()) return;
|
|
169
|
+
httpReqsPending[key] = true;
|
|
170
|
+
const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) =>
|
|
171
|
+
String(
|
|
172
|
+
evaluate({
|
|
173
|
+
code: group,
|
|
174
|
+
context: context || {},
|
|
175
|
+
localState: undefined,
|
|
176
|
+
rootState: $builderContextSignal.rootState,
|
|
177
|
+
rootSetState: $builderContextSignal.rootSetState,
|
|
178
|
+
enableCache: true,
|
|
179
|
+
})
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
fetch(evaluatedUrl)
|
|
183
|
+
.then((response) => response.json())
|
|
184
|
+
.then((json) => {
|
|
185
|
+
mergeNewRootState({
|
|
186
|
+
[key]: json,
|
|
187
|
+
});
|
|
188
|
+
httpReqsData[key] = true;
|
|
189
|
+
})
|
|
190
|
+
.catch((err) => {
|
|
191
|
+
console.error("error fetching dynamic data", url, err);
|
|
192
|
+
})
|
|
193
|
+
.finally(() => {
|
|
194
|
+
httpReqsPending[key] = false;
|
|
196
195
|
});
|
|
197
|
-
}
|
|
198
196
|
});
|
|
199
197
|
}
|
|
200
198
|
function emitStateUpdate() {
|
|
@@ -284,6 +282,7 @@
|
|
|
284
282
|
|
|
285
283
|
let ContentWrapper = contentWrapper || "div";
|
|
286
284
|
let httpReqsData = {};
|
|
285
|
+
let httpReqsPending = {};
|
|
287
286
|
let clicked = false;
|
|
288
287
|
|
|
289
288
|
onMount(() => {
|
|
@@ -36,10 +36,11 @@ export const checkShouldRenderVariants = ({
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* For Vue and Svelte, we need to (initially) render the variants. This is to avoid hydration mismatch errors.
|
|
39
|
+
*
|
|
39
40
|
* Unlike React, Vue's hydration checks are shallow and do not check the attributes/contents of each element, so we
|
|
40
41
|
* are able to modify the `hidden` HTML attributes and `display` CSS properties without causing a hydration mismatch error.
|
|
41
42
|
*
|
|
42
|
-
* NOTE: For
|
|
43
|
+
* NOTE: For Solid/Svelte: after the app is hydrated, we strip the variants from the DOM (on mount) to reduce the amount of HTML in the DOM.
|
|
43
44
|
* This isn't necessary, just a nice to have.
|
|
44
45
|
*/
|
|
45
46
|
if (TARGET === 'vue' || TARGET === 'svelte') return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.19"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BuilderContext } from './builder.context.js'
|
|
@@ -7,4 +7,9 @@ export { default as Symbol } from '../blocks/symbol/index.js';
|
|
|
7
7
|
export { default as Text } from '../blocks/text/index.js';
|
|
8
8
|
export { default as Video } from '../blocks/video/index.js';
|
|
9
9
|
export { default as Blocks } from '../components/blocks/index.js';
|
|
10
|
-
export { default as Content } from '../components/content-variants/index.js'
|
|
10
|
+
export { default as Content } from '../components/content-variants/index.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Builder Context
|
|
14
|
+
*/
|
|
15
|
+
export { BuilderContext } from '../context/index.js'
|