@builder.io/sdk-solid 0.0.5 → 0.0.8-0

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.
Files changed (128) hide show
  1. package/package.json +9 -2
  2. package/src/blocks/button/button.jsx +13 -0
  3. package/src/blocks/button/button.lite.tsx +20 -0
  4. package/src/blocks/button/component-info.js +41 -0
  5. package/src/blocks/button/index.js +7 -0
  6. package/src/blocks/columns/columns.jsx +91 -0
  7. package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +32 -26
  8. package/src/blocks/columns/component-info.js +217 -0
  9. package/src/blocks/columns/index.js +7 -0
  10. package/src/blocks/custom-code/component-info.js +31 -0
  11. package/src/blocks/{custom-code.js → custom-code/custom-code.jsx} +5 -26
  12. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +3 -1
  13. package/src/blocks/custom-code/index.js +7 -0
  14. package/src/blocks/embed/component-info.js +24 -0
  15. package/src/blocks/embed/embed.jsx +51 -0
  16. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
  17. package/src/blocks/embed/index.js +7 -0
  18. package/src/blocks/form/component-info.js +262 -0
  19. package/src/blocks/form/form.jsx +253 -0
  20. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +14 -8
  21. package/src/blocks/form/index.js +7 -0
  22. package/src/blocks/fragment/component-info.js +11 -0
  23. package/src/blocks/fragment/fragment.jsx +5 -0
  24. package/src/blocks/fragment/fragment.lite.tsx +5 -0
  25. package/src/blocks/fragment/index.js +7 -0
  26. package/src/blocks/image/component-info.js +104 -0
  27. package/src/blocks/image/image.jsx +54 -0
  28. package/src/blocks/image/image.lite.tsx +83 -0
  29. package/src/blocks/image/index.js +7 -0
  30. package/src/blocks/img/component-info.js +20 -0
  31. package/src/blocks/img/img.jsx +10 -0
  32. package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +4 -2
  33. package/src/blocks/img/index.js +7 -0
  34. package/src/blocks/input/component-info.js +74 -0
  35. package/src/blocks/input/index.js +7 -0
  36. package/src/blocks/input/input.jsx +7 -0
  37. package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +4 -2
  38. package/src/blocks/raw-text/component-info.js +16 -0
  39. package/src/blocks/raw-text/index.js +7 -0
  40. package/src/blocks/raw-text/raw-text.jsx +5 -0
  41. package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +3 -1
  42. package/src/blocks/section/component-info.js +49 -0
  43. package/src/blocks/section/index.js +7 -0
  44. package/src/blocks/section/section.jsx +9 -0
  45. package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +3 -1
  46. package/src/blocks/select/component-info.js +59 -0
  47. package/src/blocks/select/index.js +7 -0
  48. package/src/blocks/select/select.jsx +16 -0
  49. package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +10 -5
  50. package/src/blocks/submit-button/component-info.js +28 -0
  51. package/src/blocks/submit-button/index.js +7 -0
  52. package/src/blocks/submit-button/submit-button.jsx +7 -0
  53. package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +3 -1
  54. package/src/blocks/symbol/component-info.js +42 -0
  55. package/src/blocks/symbol/index.js +7 -0
  56. package/src/blocks/symbol/symbol.jsx +24 -0
  57. package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
  58. package/src/blocks/text/component-info.js +24 -0
  59. package/src/blocks/text/index.js +7 -0
  60. package/src/blocks/{text.lite.tsx → text/text.jsx} +3 -1
  61. package/src/blocks/text/text.lite.tsx +5 -0
  62. package/src/blocks/textarea/component-info.js +47 -0
  63. package/src/blocks/textarea/index.js +7 -0
  64. package/src/blocks/textarea/textarea.jsx +5 -0
  65. package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +3 -1
  66. package/src/blocks/video/component-info.js +106 -0
  67. package/src/blocks/video/index.js +7 -0
  68. package/src/blocks/video/video.jsx +14 -0
  69. package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +3 -1
  70. package/src/components/error-boundary.jsx +5 -0
  71. package/src/components/error-boundary.lite.tsx +3 -1
  72. package/src/components/render-block/block-styles.jsx +36 -0
  73. package/src/components/render-block/block-styles.lite.tsx +38 -0
  74. package/src/components/render-block/render-block.jsx +117 -0
  75. package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +24 -13
  76. package/src/components/render-blocks.jsx +57 -0
  77. package/src/components/render-blocks.lite.tsx +9 -6
  78. package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +8 -15
  79. package/src/components/render-content/components/render-styles.lite.tsx +10 -4
  80. package/src/components/render-content/{render-content.js → render-content.jsx} +42 -94
  81. package/src/components/render-content/render-content.lite.tsx +23 -20
  82. package/src/components/render-inlined-styles.jsx +23 -0
  83. package/src/components/render-inlined-styles.lite.tsx +26 -0
  84. package/src/functions/evaluate.js +2 -2
  85. package/src/functions/get-block-actions.js +2 -2
  86. package/src/functions/get-builder-search-params/fn.test.js +1 -1
  87. package/src/functions/get-content/index.js +3 -2
  88. package/src/functions/get-fetch.js +29 -7
  89. package/src/functions/get-processed-block.js +3 -3
  90. package/src/functions/get-processed-block.test.js +1 -1
  91. package/src/functions/if-target.js +1 -1
  92. package/src/functions/is-editing.js +1 -1
  93. package/src/functions/is-iframe.js +1 -1
  94. package/src/functions/is-previewing.js +2 -2
  95. package/src/functions/on-change.test.js +1 -1
  96. package/src/functions/previewing-model-name.js +1 -1
  97. package/src/functions/register-component.js +1 -1
  98. package/src/functions/register.js +1 -1
  99. package/src/functions/set-editor-settings.js +1 -1
  100. package/src/functions/set.test.js +1 -1
  101. package/src/functions/track.js +3 -3
  102. package/src/index-helpers/blocks-exports.js +8 -8
  103. package/src/index.js +10 -13
  104. package/src/scripts/init-editing.js +72 -63
  105. package/src/blocks/button.js +0 -32
  106. package/src/blocks/button.lite.tsx +0 -12
  107. package/src/blocks/columns.js +0 -133
  108. package/src/blocks/embed.js +0 -62
  109. package/src/blocks/form.js +0 -355
  110. package/src/blocks/fragment.js +0 -15
  111. package/src/blocks/fragment.lite.tsx +0 -3
  112. package/src/blocks/image.js +0 -211
  113. package/src/blocks/image.lite.tsx +0 -169
  114. package/src/blocks/img.js +0 -39
  115. package/src/blocks/input.js +0 -45
  116. package/src/blocks/raw-text.js +0 -25
  117. package/src/blocks/section.js +0 -24
  118. package/src/blocks/select.js +0 -57
  119. package/src/blocks/submit-button.js +0 -18
  120. package/src/blocks/symbol.js +0 -69
  121. package/src/blocks/text.js +0 -15
  122. package/src/blocks/textarea.js +0 -34
  123. package/src/blocks/video.js +0 -54
  124. package/src/components/block-styles.js +0 -3
  125. package/src/components/block-styles.lite.tsx +0 -3
  126. package/src/components/error-boundary.js +0 -3
  127. package/src/components/render-block.js +0 -154
  128. package/src/components/render-blocks.js +0 -104
@@ -2,17 +2,18 @@ import { useContext, Show, For } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
3
  import { createMutable } from "solid-js/store";
4
4
 
5
- import { getBlockComponentOptions } from "../functions/get-block-component-options";
6
- import { getBlockProperties } from "../functions/get-block-properties";
7
- import { getBlockStyles } from "../functions/get-block-styles";
8
- import { getBlockTag } from "../functions/get-block-tag";
9
- import { components } from "../functions/register-component";
10
- import BuilderContext from "../context/builder.context";
11
- import { getBlockActions } from "../functions/get-block-actions";
12
- import { getProcessedBlock } from "../functions/get-processed-block";
5
+ import { TARGET } from "../../constants/target.js";
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 { components } from "../../functions/register-component.js";
13
14
  import BlockStyles from "./block-styles.lite";
14
15
 
15
- export default function RenderBlock(props) {
16
+ function RenderBlock(props) {
16
17
  const state = createMutable({
17
18
  get component() {
18
19
  const componentName = state.useBlock.component?.name;
@@ -21,7 +22,7 @@ export default function RenderBlock(props) {
21
22
  return null;
22
23
  }
23
24
 
24
- const ref = components[state.useBlock.component?.name!];
25
+ const ref = components[componentName];
25
26
 
26
27
  if (componentName && !ref) {
27
28
  // TODO: Public doc page with more info about this message
@@ -86,7 +87,9 @@ export default function RenderBlock(props) {
86
87
  style={state.css}
87
88
  component={state.tagName}
88
89
  >
89
- <BlockStyles block={state.useBlock}></BlockStyles>
90
+ <Show when={TARGET === "vue" || TARGET === "svelte"}>
91
+ <BlockStyles block={state.useBlock}></BlockStyles>
92
+ </Show>
90
93
  <Show when={state.componentRef}>
91
94
  <Dynamic
92
95
  {...state.componentOptions}
@@ -94,15 +97,23 @@ export default function RenderBlock(props) {
94
97
  component={state.componentRef}
95
98
  >
96
99
  <For each={state.children}>
97
- {(child, index) => <RenderBlock block={child}></RenderBlock>}
100
+ {(child, _index) => {
101
+ const index = _index();
102
+ return <RenderBlock block={child}></RenderBlock>;
103
+ }}
98
104
  </For>
99
105
  </Dynamic>
100
106
  </Show>
101
107
  <For each={state.noCompRefChildren}>
102
- {(child, index) => <RenderBlock block={child}></RenderBlock>}
108
+ {(child, _index) => {
109
+ const index = _index();
110
+ return <RenderBlock block={child}></RenderBlock>;
111
+ }}
103
112
  </For>
104
113
  </Dynamic>
105
114
  </Show>
106
115
  </>
107
116
  );
108
117
  }
118
+
119
+ export default RenderBlock;
@@ -0,0 +1,57 @@
1
+ import { Show, For } from "solid-js";
2
+ import { createMutable } from "solid-js/store";
3
+ import { css } from "solid-styled-components";
4
+ import { isEditing } from "../functions/is-editing.js";
5
+ import RenderBlock from "./render-block/render-block";
6
+
7
+ function RenderBlocks(props) {
8
+ const state = createMutable({
9
+ get className() {
10
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
11
+ },
12
+
13
+ onClick() {
14
+ if (isEditing() && !props.blocks?.length) {
15
+ window.parent?.postMessage({
16
+ type: "builder.clickEmptyBlocks",
17
+ data: {
18
+ parentElementId: props.parent,
19
+ dataPath: props.path
20
+ }
21
+ }, "*");
22
+ }
23
+ },
24
+
25
+ onMouseEnter() {
26
+ if (isEditing() && !props.blocks?.length) {
27
+ window.parent?.postMessage({
28
+ type: "builder.hoverEmptyBlocks",
29
+ data: {
30
+ parentElementId: props.parent,
31
+ dataPath: props.path
32
+ }
33
+ }, "*");
34
+ }
35
+ }
36
+
37
+ });
38
+ return <div class={state.className + " " + css({
39
+ display: "flex",
40
+ flexDirection: "column",
41
+ alignItems: "stretch"
42
+ })} builder-path={props.path} builder-parent-id={props.parent} dataSet={{
43
+ class: state.className
44
+ }} onClick={event => state.onClick()} onMouseEnter={event => state.onMouseEnter()}>
45
+ <Show when={props.blocks}>
46
+ <For each={props.blocks}>
47
+ {(block, _index) => {
48
+ const index = _index();
49
+
50
+ return <RenderBlock key={block.id} block={block}></RenderBlock>;
51
+ }}
52
+ </For>
53
+ </Show>
54
+ </div>;
55
+ }
56
+
57
+ export default RenderBlocks;
@@ -3,10 +3,10 @@ import { Show, For } from "solid-js";
3
3
  import { createMutable } from "solid-js/store";
4
4
  import { css } from "solid-styled-components";
5
5
 
6
- import { isEditing } from "../functions/is-editing";
7
- import RenderBlock from "./render-block.lite";
6
+ import { isEditing } from "../functions/is-editing.js";
7
+ import RenderBlock from "./render-block/render-block.lite";
8
8
 
9
- export default function RenderBlocks(props) {
9
+ function RenderBlocks(props) {
10
10
  const state = createMutable({
11
11
  get className() {
12
12
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -62,11 +62,14 @@ export default function RenderBlocks(props) {
62
62
  >
63
63
  <Show when={props.blocks}>
64
64
  <For each={props.blocks}>
65
- {(block, index) => (
66
- <RenderBlock key={block.id} block={block}></RenderBlock>
67
- )}
65
+ {(block, _index) => {
66
+ const index = _index();
67
+ return <RenderBlock key={block.id} block={block}></RenderBlock>;
68
+ }}
68
69
  </For>
69
70
  </Show>
70
71
  </div>
71
72
  );
72
73
  }
74
+
75
+ export default RenderBlocks;
@@ -1,10 +1,7 @@
1
- import { template as _$template } from "solid-js/web";
2
- import { insert as _$insert } from "solid-js/web";
3
-
4
- const _tmpl$ = /*#__PURE__*/_$template(`<style></style>`, 2);
5
-
6
1
  import { createMutable } from "solid-js/store";
7
- export default function RenderStyles(props) {
2
+ import RenderInlinedStyles from "../../render-inlined-styles";
3
+
4
+ function RenderContentStyles(props) {
8
5
  const state = createMutable({
9
6
  getCssFromFont(font) {
10
7
  // TODO: compute what font sizes are used and only load those.......
@@ -62,20 +59,16 @@ export default function RenderStyles(props) {
62
59
  return customFonts?.map(font => this.getCssFromFont(font))?.join(" ") || "";
63
60
  },
64
61
 
65
- getInjectedStyles() {
62
+ get injectedStyles() {
66
63
  return `
67
- ${props.cssCode}
64
+ ${props.cssCode || ""}
68
65
  ${state.getFontCss({
69
66
  customFonts: props.customFonts
70
67
  })}`;
71
68
  }
72
69
 
73
70
  });
74
- return (() => {
75
- const _el$ = _tmpl$.cloneNode(true);
76
-
77
- _$insert(_el$, () => state.getInjectedStyles());
71
+ return <RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>;
72
+ }
78
73
 
79
- return _el$;
80
- })();
81
- }
74
+ export default RenderContentStyles;
@@ -1,6 +1,8 @@
1
1
  import { createMutable } from "solid-js/store";
2
2
 
3
- export default function RenderStyles(props) {
3
+ import RenderInlinedStyles from "../../render-inlined-styles.lite";
4
+
5
+ function RenderContentStyles(props) {
4
6
  const state = createMutable({
5
7
  getCssFromFont(font: CustomFont) {
6
8
  // TODO: compute what font sizes are used and only load those.......
@@ -57,14 +59,18 @@ export default function RenderStyles(props) {
57
59
  customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || ""
58
60
  );
59
61
  },
60
- getInjectedStyles() {
62
+ get injectedStyles() {
61
63
  return `
62
- ${props.cssCode}
64
+ ${props.cssCode || ""}
63
65
  ${state.getFontCss({
64
66
  customFonts: props.customFonts,
65
67
  })}`;
66
68
  },
67
69
  });
68
70
 
69
- return <style>{state.getInjectedStyles()}</style>;
71
+ return (
72
+ <RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>
73
+ );
70
74
  }
75
+
76
+ export default RenderContentStyles;
@@ -1,30 +1,21 @@
1
- import { template as _$template } from "solid-js/web";
2
- import { delegateEvents as _$delegateEvents } from "solid-js/web";
3
- import { setAttribute as _$setAttribute } from "solid-js/web";
4
- import { effect as _$effect } from "solid-js/web";
5
- import { insert as _$insert } from "solid-js/web";
6
- import { createComponent as _$createComponent } from "solid-js/web";
7
- import { memo as _$memo } from "solid-js/web";
8
-
9
- const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
10
-
11
1
  import { Show, onMount } from "solid-js";
12
2
  import { Dynamic } from "solid-js/web";
13
3
  import { createMutable } from "solid-js/store";
14
- import { isBrowser } from "../../functions/is-browser";
4
+ import { TARGET } from "../../constants/target.js";
15
5
  import BuilderContext from "../../context/builder.context";
16
- import { track } from "../../functions/track";
17
- import { isEditing } from "../../functions/is-editing";
18
- import { isPreviewing } from "../../functions/is-previewing";
19
- import { previewingModelName } from "../../functions/previewing-model-name";
20
- import { getContent } from "../../functions/get-content";
21
- import { convertSearchParamsToQueryObject, getBuilderSearchParams } from "../../functions/get-builder-search-params";
6
+ import { evaluate } from "../../functions/evaluate.js";
7
+ import { convertSearchParamsToQueryObject, getBuilderSearchParams } from "../../functions/get-builder-search-params/index.js";
8
+ import { getContent } from "../../functions/get-content/index.js";
9
+ import { getFetch } from "../../functions/get-fetch.js";
10
+ import { isBrowser } from "../../functions/is-browser.js";
11
+ import { isEditing } from "../../functions/is-editing.js";
12
+ import { isPreviewing } from "../../functions/is-previewing.js";
13
+ import { previewingModelName } from "../../functions/previewing-model-name.js";
14
+ import { track } from "../../functions/track.js";
22
15
  import RenderBlocks from "../render-blocks";
23
- import { evaluate } from "../../functions/evaluate";
24
- import { getFetch } from "../../functions/get-fetch";
25
- import { TARGET } from "../../constants/target";
26
- import RenderStyles from "./components/render-styles";
27
- export default function RenderContent(props) {
16
+ import RenderContentStyles from "./components/render-styles";
17
+
18
+ function RenderContent(props) {
28
19
  const state = createMutable({
29
20
  get useContent() {
30
21
  const mergedContent = { ...props.content,
@@ -41,7 +32,7 @@ export default function RenderContent(props) {
41
32
  update: 0,
42
33
  overrideState: {},
43
34
 
44
- get state() {
35
+ get contentState() {
45
36
  return { ...props.content?.data?.state,
46
37
  ...props.data,
47
38
  ...state.overrideState
@@ -89,7 +80,7 @@ export default function RenderContent(props) {
89
80
  evaluate({
90
81
  code: jsCode,
91
82
  context: state.context,
92
- state: state.state
83
+ state: state.contentState
93
84
  });
94
85
  }
95
86
  },
@@ -102,7 +93,7 @@ export default function RenderContent(props) {
102
93
  return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
103
94
  code: group,
104
95
  context: state.context,
105
- state: state.state
96
+ state: state.contentState
106
97
  }));
107
98
  },
108
99
 
@@ -111,7 +102,8 @@ export default function RenderContent(props) {
111
102
  key
112
103
  }) {
113
104
  const fetchAndSetState = async () => {
114
- const response = await getFetch()(url);
105
+ const fetch = await getFetch();
106
+ const response = await fetch(url);
115
107
  const json = await response.json();
116
108
  const newOverrideState = { ...state.overrideState,
117
109
  [key]: json
@@ -138,7 +130,7 @@ export default function RenderContent(props) {
138
130
  emitStateUpdate() {
139
131
  window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
140
132
  detail: {
141
- state: state.state,
133
+ state: state.contentState,
142
134
  ref: {
143
135
  name: props.model
144
136
  }
@@ -185,79 +177,35 @@ export default function RenderContent(props) {
185
177
  state.emitStateUpdate();
186
178
  }
187
179
  });
188
- return _$createComponent(Dynamic, {
189
- value: {
190
- get content() {
191
- return state.useContent;
192
- },
193
-
194
- get state() {
195
- return state.state;
196
- },
197
-
198
- get context() {
199
- return state.context;
200
- },
201
-
202
- get apiKey() {
203
- return props.apiKey;
204
- }
205
-
180
+ return <Dynamic value={{
181
+ get content() {
182
+ return state.useContent;
206
183
  },
207
184
 
208
- get component() {
209
- return BuilderContext.Provider;
185
+ get state() {
186
+ return state.contentState;
210
187
  },
211
188
 
212
- get children() {
213
- return _$createComponent(Show, {
214
- get when() {
215
- return state.useContent;
216
- },
217
-
218
- get children() {
219
- const _el$ = _tmpl$.cloneNode(true);
220
-
221
- _el$.$$click = event => track("click", {
222
- contentId: state.useContent.id
223
- });
224
-
225
- _$insert(_el$, _$createComponent(Show, {
226
- get when() {
227
- return (state.useContent?.data?.cssCode || state.useContent?.data?.customFonts?.length) && TARGET !== "reactNative";
228
- },
229
-
230
- get children() {
231
- return _$createComponent(RenderStyles, {
232
- get cssCode() {
233
- return state.useContent.data.cssCode;
234
- },
235
-
236
- get customFonts() {
237
- return state.useContent.data.customFonts;
238
- }
239
-
240
- });
241
- }
242
-
243
- }), null);
244
-
245
- _$insert(_el$, _$createComponent(RenderBlocks, {
246
- get blocks() {
247
- return state.useContent?.data?.blocks;
248
- }
249
-
250
- }), null);
251
-
252
- _$effect(() => _$setAttribute(_el$, "data-builder-content-id", state.useContent?.id));
253
-
254
- return _el$;
255
- }
189
+ get context() {
190
+ return state.context;
191
+ },
256
192
 
257
- });
193
+ get apiKey() {
194
+ return props.apiKey;
258
195
  }
259
196
 
260
- });
197
+ }} component={BuilderContext.Provider}>
198
+ <Show when={state.useContent}>
199
+ <div onClick={event => track("click", {
200
+ contentId: state.useContent.id
201
+ })} data-builder-content-id={state.useContent?.id}>
202
+ <Show when={(state.useContent?.data?.cssCode || state.useContent?.data?.customFonts?.length) && TARGET !== "reactNative"}>
203
+ <RenderContentStyles cssCode={state.useContent.data.cssCode} customFonts={state.useContent.data.customFonts}></RenderContentStyles>
204
+ </Show>
205
+ <RenderBlocks blocks={state.useContent?.data?.blocks}></RenderBlocks>
206
+ </div>
207
+ </Show>
208
+ </Dynamic>;
261
209
  }
262
210
 
263
- _$delegateEvents(["click"]);
211
+ export default RenderContent;
@@ -2,24 +2,24 @@ 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 { isBrowser } from "../../functions/is-browser";
5
+ import { TARGET } from "../../constants/target.js";
6
6
  import BuilderContext from "../../context/builder.context";
7
- import { track } from "../../functions/track";
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";
7
+ import { evaluate } from "../../functions/evaluate.js";
12
8
  import {
13
9
  convertSearchParamsToQueryObject,
14
10
  getBuilderSearchParams,
15
- } from "../../functions/get-builder-search-params";
11
+ } from "../../functions/get-builder-search-params/index.js";
12
+ import { getContent } from "../../functions/get-content/index.js";
13
+ import { getFetch } from "../../functions/get-fetch.js";
14
+ import { isBrowser } from "../../functions/is-browser.js";
15
+ import { isEditing } from "../../functions/is-editing.js";
16
+ import { isPreviewing } from "../../functions/is-previewing.js";
17
+ import { previewingModelName } from "../../functions/previewing-model-name.js";
18
+ import { track } from "../../functions/track.js";
16
19
  import RenderBlocks from "../render-blocks.lite";
17
- import { evaluate } from "../../functions/evaluate";
18
- import { getFetch } from "../../functions/get-fetch";
19
- import { TARGET } from "../../constants/target";
20
- import RenderStyles from "./components/render-styles.lite";
20
+ import RenderContentStyles from "./components/render-styles.lite";
21
21
 
22
- export default function RenderContent(props) {
22
+ function RenderContent(props) {
23
23
  const state = createMutable({
24
24
  get useContent() {
25
25
  const mergedContent: BuilderContent = {
@@ -36,7 +36,7 @@ export default function RenderContent(props) {
36
36
  overrideContent: null,
37
37
  update: 0,
38
38
  overrideState: {},
39
- get state() {
39
+ get contentState() {
40
40
  return {
41
41
  ...props.content?.data?.state,
42
42
  ...props.data,
@@ -84,7 +84,7 @@ export default function RenderContent(props) {
84
84
  evaluate({
85
85
  code: jsCode,
86
86
  context: state.context,
87
- state: state.state,
87
+ state: state.contentState,
88
88
  });
89
89
  }
90
90
  },
@@ -96,13 +96,14 @@ export default function RenderContent(props) {
96
96
  evaluate({
97
97
  code: group,
98
98
  context: state.context,
99
- state: state.state,
99
+ state: state.contentState,
100
100
  })
101
101
  );
102
102
  },
103
103
  handleRequest({ url, key }: { key: string; url: string }) {
104
104
  const fetchAndSetState = async () => {
105
- const response = await getFetch()(url);
105
+ const fetch = await getFetch();
106
+ const response = await fetch(url);
106
107
  const json = await response.json();
107
108
  const newOverrideState = { ...state.overrideState, [key]: json };
108
109
  state.overrideState = newOverrideState;
@@ -128,7 +129,7 @@ export default function RenderContent(props) {
128
129
  "builder:component:stateChange",
129
130
  {
130
131
  detail: {
131
- state: state.state,
132
+ state: state.contentState,
132
133
  ref: {
133
134
  name: props.model,
134
135
  },
@@ -189,7 +190,7 @@ export default function RenderContent(props) {
189
190
  return state.useContent;
190
191
  },
191
192
  get state() {
192
- return state.state;
193
+ return state.contentState;
193
194
  },
194
195
  get context() {
195
196
  return state.context;
@@ -216,10 +217,10 @@ export default function RenderContent(props) {
216
217
  TARGET !== "reactNative"
217
218
  }
218
219
  >
219
- <RenderStyles
220
+ <RenderContentStyles
220
221
  cssCode={state.useContent.data.cssCode}
221
222
  customFonts={state.useContent.data.customFonts}
222
- ></RenderStyles>
223
+ ></RenderContentStyles>
223
224
  </Show>
224
225
  <RenderBlocks blocks={state.useContent?.data?.blocks}></RenderBlocks>
225
226
  </div>
@@ -227,3 +228,5 @@ export default function RenderContent(props) {
227
228
  </Dynamic>
228
229
  );
229
230
  }
231
+
232
+ export default RenderContent;
@@ -0,0 +1,23 @@
1
+ import { Show } from "solid-js";
2
+ import { createMutable } from "solid-js/store";
3
+ import { TARGET } from "../constants/target.js";
4
+
5
+ function RenderInlinedStyles(props) {
6
+ const state = createMutable({
7
+ get injectedStyleScript() {
8
+ return `<${state.tagName}>${props.styles}</${state.tagName}>`;
9
+ },
10
+
11
+ get tagName() {
12
+ // NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
13
+ // https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
14
+ return "sty" + "le";
15
+ }
16
+
17
+ });
18
+ return <Show when={TARGET === "svelte"}>
19
+ <div innerHTML={state.injectedStyleScript}></div>
20
+ </Show>;
21
+ }
22
+
23
+ export default RenderInlinedStyles;
@@ -0,0 +1,26 @@
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 when={TARGET === "svelte"}>
21
+ <div innerHTML={state.injectedStyleScript}></div>
22
+ </Show>
23
+ );
24
+ }
25
+
26
+ export default RenderInlinedStyles;
@@ -1,5 +1,5 @@
1
- import { isBrowser } from "./is-browser";
2
- import { isEditing } from "./is-editing";
1
+ import { isBrowser } from "./is-browser.js";
2
+ import { isEditing } from "./is-editing.js";
3
3
  function evaluate({
4
4
  code,
5
5
  context,
@@ -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,4 @@
1
- import { getBuilderSearchParams, convertSearchParamsToQueryObject } from ".";
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);