@builder.io/sdk-solid 0.0.7 → 0.0.8-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -5
- package/src/blocks/button/button.jsx +13 -0
- package/src/blocks/button/button.lite.tsx +23 -0
- package/src/blocks/button/component-info.js +41 -0
- package/src/blocks/columns/columns.jsx +91 -0
- package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +34 -26
- package/src/blocks/columns/component-info.js +217 -0
- package/src/blocks/custom-code/component-info.js +31 -0
- package/src/blocks/{custom-code.jsx → custom-code/custom-code.jsx} +2 -2
- package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +2 -0
- package/src/blocks/embed/component-info.js +24 -0
- package/src/blocks/{embed.jsx → embed/embed.jsx} +3 -3
- package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
- package/src/blocks/form/component-info.js +262 -0
- package/src/blocks/{form.jsx → form/form.jsx} +9 -9
- package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +15 -11
- package/src/blocks/fragment/component-info.js +11 -0
- package/src/blocks/fragment/fragment.jsx +5 -0
- package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +0 -0
- package/src/blocks/image/component-info.js +104 -0
- package/src/blocks/image/image.jsx +54 -0
- package/src/blocks/image/image.lite.tsx +86 -0
- package/src/blocks/img/component-info.js +20 -0
- package/src/blocks/img/img.jsx +10 -0
- package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +1 -1
- package/src/blocks/input/component-info.js +74 -0
- package/src/blocks/input/input.jsx +7 -0
- package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +1 -1
- package/src/blocks/raw-text/component-info.js +16 -0
- package/src/blocks/raw-text/raw-text.jsx +5 -0
- package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +0 -0
- package/src/blocks/section/component-info.js +49 -0
- package/src/blocks/section/section.jsx +9 -0
- package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +0 -0
- package/src/blocks/select/component-info.js +59 -0
- package/src/blocks/select/select.jsx +16 -0
- package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +1 -1
- package/src/blocks/submit-button/component-info.js +28 -0
- package/src/blocks/submit-button/submit-button.jsx +7 -0
- package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +0 -0
- package/src/blocks/symbol/component-info.js +43 -0
- package/src/blocks/symbol/symbol.jsx +25 -0
- package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
- package/src/blocks/text/component-info.js +24 -0
- package/src/blocks/text/text.jsx +5 -0
- package/src/blocks/text/text.lite.tsx +5 -0
- package/src/blocks/textarea/component-info.js +47 -0
- package/src/blocks/textarea/textarea.jsx +5 -0
- package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +0 -0
- package/src/blocks/video/component-info.js +106 -0
- package/src/blocks/video/video.jsx +14 -0
- package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +0 -0
- package/src/components/render-block/block-styles.jsx +36 -0
- package/src/components/render-block/block-styles.lite.tsx +38 -0
- package/src/components/render-block/render-block.helpers.js +23 -0
- package/src/components/{render-block.jsx → render-block/render-block.jsx} +40 -22
- package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +57 -19
- package/src/components/render-blocks.jsx +2 -2
- package/src/components/render-blocks.lite.tsx +2 -2
- package/src/components/render-content/components/render-styles.jsx +6 -5
- package/src/components/render-content/components/render-styles.lite.tsx +9 -5
- package/src/components/render-content/index.js +4 -0
- package/src/components/render-content/render-content.jsx +50 -24
- package/src/components/render-content/render-content.lite.tsx +64 -33
- package/src/components/render-inlined-styles.jsx +24 -0
- package/src/components/render-inlined-styles.lite.tsx +29 -0
- package/src/constants/builder-registered-components.js +45 -0
- package/src/context/builder.context.js +2 -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-styles.js +2 -2
- package/src/functions/get-builder-search-params/fn.test.js +1 -1
- package/src/functions/get-content/index.js +3 -2
- package/src/functions/get-fetch.js +29 -7
- 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 +9 -9
- package/src/index.js +10 -13
- package/src/scripts/init-editing.js +72 -63
- package/src/solid-index.jsx +5 -0
- package/src/types/components.js +0 -0
- package/src/types/element.js +0 -0
- package/src/blocks/button.jsx +0 -8
- package/src/blocks/button.lite.tsx +0 -14
- package/src/blocks/columns.jsx +0 -96
- package/src/blocks/fragment.jsx +0 -6
- package/src/blocks/image.jsx +0 -120
- package/src/blocks/image.lite.tsx +0 -171
- package/src/blocks/img.jsx +0 -11
- package/src/blocks/input.jsx +0 -8
- package/src/blocks/raw-text.jsx +0 -6
- package/src/blocks/section.jsx +0 -10
- package/src/blocks/select.jsx +0 -17
- package/src/blocks/submit-button.jsx +0 -8
- package/src/blocks/symbol.jsx +0 -25
- package/src/blocks/text.jsx +0 -6
- package/src/blocks/text.lite.tsx +0 -5
- package/src/blocks/textarea.jsx +0 -6
- package/src/blocks/video.jsx +0 -15
- package/src/components/block-styles.jsx +0 -5
- package/src/components/block-styles.lite.tsx +0 -5
- package/src/functions/macro-eval.js +0 -5
|
@@ -2,22 +2,27 @@ import { useContext, Show, onMount } from "solid-js";
|
|
|
2
2
|
import { Dynamic } from "solid-js/web";
|
|
3
3
|
import { createMutable } from "solid-js/store";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
6
|
+
import { TARGET } from "../../constants/target.js";
|
|
6
7
|
import BuilderContext from "../../context/builder.context";
|
|
7
|
-
import {
|
|
8
|
-
import { isEditing } from "../../functions/is-editing";
|
|
9
|
-
import { isPreviewing } from "../../functions/is-previewing";
|
|
10
|
-
import { previewingModelName } from "../../functions/previewing-model-name";
|
|
11
|
-
import { getContent } from "../../functions/get-content";
|
|
8
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
12
9
|
import {
|
|
13
10
|
convertSearchParamsToQueryObject,
|
|
14
11
|
getBuilderSearchParams,
|
|
15
|
-
} from "../../functions/get-builder-search-params";
|
|
12
|
+
} from "../../functions/get-builder-search-params/index.js";
|
|
13
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
14
|
+
import { getFetch } from "../../functions/get-fetch.js";
|
|
15
|
+
import { isBrowser } from "../../functions/is-browser.js";
|
|
16
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
17
|
+
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
18
|
+
import { previewingModelName } from "../../functions/previewing-model-name.js";
|
|
19
|
+
import {
|
|
20
|
+
components,
|
|
21
|
+
createRegisterComponentMessage,
|
|
22
|
+
} from "../../functions/register-component.js";
|
|
23
|
+
import { track } from "../../functions/track.js";
|
|
16
24
|
import RenderBlocks from "../render-blocks.lite";
|
|
17
|
-
import
|
|
18
|
-
import { getFetch } from "../../functions/get-fetch";
|
|
19
|
-
import { TARGET } from "../../constants/target";
|
|
20
|
-
import RenderStyles from "./components/render-styles.lite";
|
|
25
|
+
import RenderContentStyles from "./components/render-styles.lite";
|
|
21
26
|
|
|
22
27
|
function RenderContent(props) {
|
|
23
28
|
const state = createMutable({
|
|
@@ -36,7 +41,7 @@ function RenderContent(props) {
|
|
|
36
41
|
overrideContent: null,
|
|
37
42
|
update: 0,
|
|
38
43
|
overrideState: {},
|
|
39
|
-
get
|
|
44
|
+
get contentState() {
|
|
40
45
|
return {
|
|
41
46
|
...props.content?.data?.state,
|
|
42
47
|
...props.data,
|
|
@@ -44,9 +49,23 @@ function RenderContent(props) {
|
|
|
44
49
|
};
|
|
45
50
|
},
|
|
46
51
|
get context() {
|
|
47
|
-
return {} as
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
return {} as Dictionary<any>;
|
|
53
|
+
},
|
|
54
|
+
get allRegisteredComponents() {
|
|
55
|
+
const allComponentsArray = [
|
|
56
|
+
...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
57
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
58
|
+
// existing usage.
|
|
59
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
60
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
61
|
+
...components,
|
|
62
|
+
...(props.customComponents || []),
|
|
63
|
+
];
|
|
64
|
+
const allComponents = allComponentsArray.reduce(
|
|
65
|
+
(acc, curr) => ({ ...acc, [curr.name]: curr }),
|
|
66
|
+
{} as RegisteredComponents
|
|
67
|
+
);
|
|
68
|
+
return allComponents;
|
|
50
69
|
},
|
|
51
70
|
processMessage(event: MessageEvent) {
|
|
52
71
|
const { data } = event;
|
|
@@ -84,7 +103,7 @@ function RenderContent(props) {
|
|
|
84
103
|
evaluate({
|
|
85
104
|
code: jsCode,
|
|
86
105
|
context: state.context,
|
|
87
|
-
state: state.
|
|
106
|
+
state: state.contentState,
|
|
88
107
|
});
|
|
89
108
|
}
|
|
90
109
|
},
|
|
@@ -96,13 +115,14 @@ function RenderContent(props) {
|
|
|
96
115
|
evaluate({
|
|
97
116
|
code: group,
|
|
98
117
|
context: state.context,
|
|
99
|
-
state: state.
|
|
118
|
+
state: state.contentState,
|
|
100
119
|
})
|
|
101
120
|
);
|
|
102
121
|
},
|
|
103
122
|
handleRequest({ url, key }: { key: string; url: string }) {
|
|
104
123
|
const fetchAndSetState = async () => {
|
|
105
|
-
const
|
|
124
|
+
const fetch = await getFetch();
|
|
125
|
+
const response = await fetch(url);
|
|
106
126
|
const json = await response.json();
|
|
107
127
|
const newOverrideState = { ...state.overrideState, [key]: json };
|
|
108
128
|
state.overrideState = newOverrideState;
|
|
@@ -123,25 +143,33 @@ function RenderContent(props) {
|
|
|
123
143
|
});
|
|
124
144
|
},
|
|
125
145
|
emitStateUpdate() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
if (isEditing()) {
|
|
147
|
+
window.dispatchEvent(
|
|
148
|
+
new CustomEvent<BuilderComponentStateChange>(
|
|
149
|
+
"builder:component:stateChange",
|
|
150
|
+
{
|
|
151
|
+
detail: {
|
|
152
|
+
state: state.contentState,
|
|
153
|
+
ref: {
|
|
154
|
+
name: props.model,
|
|
155
|
+
},
|
|
134
156
|
},
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
139
161
|
},
|
|
140
162
|
});
|
|
141
163
|
|
|
142
164
|
onMount(() => {
|
|
143
165
|
if (isBrowser()) {
|
|
144
166
|
if (isEditing()) {
|
|
167
|
+
Object.values(state.allRegisteredComponents).forEach(
|
|
168
|
+
(registeredComponent) => {
|
|
169
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
170
|
+
window.parent?.postMessage(message, "*");
|
|
171
|
+
}
|
|
172
|
+
);
|
|
145
173
|
window.addEventListener("message", state.processMessage);
|
|
146
174
|
window.addEventListener(
|
|
147
175
|
"builder:component:stateChangeListenerActivated",
|
|
@@ -189,7 +217,7 @@ function RenderContent(props) {
|
|
|
189
217
|
return state.useContent;
|
|
190
218
|
},
|
|
191
219
|
get state() {
|
|
192
|
-
return state.
|
|
220
|
+
return state.contentState;
|
|
193
221
|
},
|
|
194
222
|
get context() {
|
|
195
223
|
return state.context;
|
|
@@ -197,6 +225,9 @@ function RenderContent(props) {
|
|
|
197
225
|
get apiKey() {
|
|
198
226
|
return props.apiKey;
|
|
199
227
|
},
|
|
228
|
+
get registeredComponents() {
|
|
229
|
+
return state.allRegisteredComponents;
|
|
230
|
+
},
|
|
200
231
|
}}
|
|
201
232
|
component={BuilderContext.Provider}
|
|
202
233
|
>
|
|
@@ -216,10 +247,10 @@ function RenderContent(props) {
|
|
|
216
247
|
TARGET !== "reactNative"
|
|
217
248
|
}
|
|
218
249
|
>
|
|
219
|
-
<
|
|
250
|
+
<RenderContentStyles
|
|
220
251
|
cssCode={state.useContent.data.cssCode}
|
|
221
252
|
customFonts={state.useContent.data.customFonts}
|
|
222
|
-
></
|
|
253
|
+
></RenderContentStyles>
|
|
223
254
|
</Show>
|
|
224
255
|
<RenderBlocks blocks={state.useContent?.data?.blocks}></RenderBlocks>
|
|
225
256
|
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Show } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
import { createMutable } from "solid-js/store";
|
|
4
|
+
import { TARGET } from "../constants/target.js";
|
|
5
|
+
|
|
6
|
+
function RenderInlinedStyles(props) {
|
|
7
|
+
const state = createMutable({
|
|
8
|
+
get injectedStyleScript() {
|
|
9
|
+
return `<${state.tagName}>${props.styles}</${state.tagName}>`;
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
get tagName() {
|
|
13
|
+
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
14
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
15
|
+
return "sty" + "le";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
19
|
+
return <Show fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>} when={TARGET === "svelte"}>
|
|
20
|
+
<div innerHTML={state.injectedStyleScript}></div>
|
|
21
|
+
</Show>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default RenderInlinedStyles;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Show } from "solid-js";
|
|
2
|
+
import { Dynamic } from "solid-js/web";
|
|
3
|
+
import { createMutable } from "solid-js/store";
|
|
4
|
+
|
|
5
|
+
import { TARGET } from "../constants/target.js";
|
|
6
|
+
|
|
7
|
+
function RenderInlinedStyles(props) {
|
|
8
|
+
const state = createMutable({
|
|
9
|
+
get injectedStyleScript() {
|
|
10
|
+
return `<${state.tagName}>${props.styles}</${state.tagName}>`;
|
|
11
|
+
},
|
|
12
|
+
get tagName() {
|
|
13
|
+
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
14
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
15
|
+
return "sty" + "le";
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Show
|
|
21
|
+
fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>}
|
|
22
|
+
when={TARGET === "svelte"}
|
|
23
|
+
>
|
|
24
|
+
<div innerHTML={state.injectedStyleScript}></div>
|
|
25
|
+
</Show>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default RenderInlinedStyles;
|
|
@@ -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.jsx";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.jsx";
|
|
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.jsx";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.jsx";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.jsx";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.jsx";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.jsx";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.jsx";
|
|
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 = {};
|
|
@@ -30,10 +30,10 @@ function getBlockStyles(block) {
|
|
|
30
30
|
var _a, _b, _c, _d, _e;
|
|
31
31
|
const styles = __spreadValues({}, convertStyleObject((_a = block.responsiveStyles) == null ? void 0 : _a.large));
|
|
32
32
|
if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
|
|
33
|
-
styles[`@media (max-width: ${sizes.medium})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
33
|
+
styles[`@media (max-width: ${sizes.medium.max})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
|
|
34
34
|
}
|
|
35
35
|
if ((_d = block.responsiveStyles) == null ? void 0 : _d.small) {
|
|
36
|
-
styles[`@media (max-width: ${sizes.small})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
36
|
+
styles[`@media (max-width: ${sizes.small.max})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
|
|
37
37
|
}
|
|
38
38
|
return styles;
|
|
39
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
|
|
2
2
|
const querystring = "someotherValue=jklsjfdal&abc=klfdjklgfds&builder.cachebust=true&builder.preview=page&builder.noCache=true&__builder_editing__=true&builder.overrides.page=037948e52eaf4743afed464f02c70da4&builder.overrides.037948e52eaf4743afed464f02c70da4=037948e52eaf4743afed464f02c70da4&builder.overrides.page%3A%2F=037948e52eaf4743afed464f02c70da4&preview_theme_id=128854393017";
|
|
3
3
|
const url = new URL(`localhost:3000/about-us?${querystring}`);
|
|
4
4
|
describe("Get Builder SearchParams", () => {
|
|
@@ -37,8 +37,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
import { getFetch } from "../get-fetch";
|
|
41
|
-
const fetch = getFetch();
|
|
40
|
+
import { getFetch } from "../get-fetch.js";
|
|
41
|
+
const fetch$ = getFetch();
|
|
42
42
|
function flatten(object, path = null, separator = ".") {
|
|
43
43
|
return Object.keys(object).reduce((acc, key) => {
|
|
44
44
|
const value = object[key];
|
|
@@ -123,6 +123,7 @@ const handleABTesting = (content, testGroups) => {
|
|
|
123
123
|
function getAllContent(options) {
|
|
124
124
|
return __async(this, null, function* () {
|
|
125
125
|
const url = generateContentUrl(options);
|
|
126
|
+
const fetch = yield fetch$;
|
|
126
127
|
const content = yield fetch(url.href).then((res) => res.json());
|
|
127
128
|
if (options.testGroups) {
|
|
128
129
|
handleABTesting(content, options.testGroups);
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { getGlobalThis } from "./get-global-this.js";
|
|
2
22
|
function getFetch() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
const globalFetch = getGlobalThis().fetch;
|
|
25
|
+
if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
|
|
26
|
+
const nodeFetch = import("node-fetch").then((d) => d.default);
|
|
27
|
+
return nodeFetch;
|
|
28
|
+
}
|
|
29
|
+
return globalFetch;
|
|
30
|
+
});
|
|
9
31
|
}
|
|
10
32
|
export {
|
|
11
33
|
getFetch
|
|
@@ -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,12 +1,12 @@
|
|
|
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";
|
|
9
|
-
import { default as default10 } from "../components/render-content/render-content";
|
|
1
|
+
import { default as default2 } from "../blocks/columns/columns.jsx";
|
|
2
|
+
import { default as default3 } from "../blocks/image/image.jsx";
|
|
3
|
+
import { default as default4 } from "../blocks/text/text.jsx";
|
|
4
|
+
import { default as default5 } from "../blocks/video/video.jsx";
|
|
5
|
+
import { default as default6 } from "../blocks/symbol/symbol.jsx";
|
|
6
|
+
import { default as default7 } from "../blocks/button/button.jsx";
|
|
7
|
+
import { default as default8 } from "../blocks/section/section.jsx";
|
|
8
|
+
import { default as default9 } from "../blocks/fragment/fragment.jsx";
|
|
9
|
+
import { default as default10 } from "../components/render-content/render-content.jsx";
|
|
10
10
|
export {
|
|
11
11
|
default7 as Button,
|
|
12
12
|
default2 as Columns,
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./functions/
|
|
8
|
-
export * from "./functions/
|
|
9
|
-
export * from "./functions/
|
|
10
|
-
export * from "./functions/
|
|
11
|
-
export * from "./functions/set-editor-settings";
|
|
12
|
-
export * from "./functions/get-content";
|
|
13
|
-
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";
|