@builder.io/sdk-solid 0.0.6 → 0.0.9

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 (102) hide show
  1. package/package.json +59 -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} +4 -3
  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.jsx → custom-code/custom-code.jsx} +1 -2
  12. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +0 -0
  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.jsx → embed/embed.jsx} +1 -2
  16. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +0 -0
  17. package/src/blocks/embed/index.js +7 -0
  18. package/src/blocks/form/component-info.js +262 -0
  19. package/src/blocks/{form.jsx → form/form.jsx} +8 -8
  20. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +7 -6
  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.lite.tsx → fragment/fragment.lite.tsx} +0 -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} +1 -1
  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} +1 -1
  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} +0 -0
  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} +0 -0
  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} +1 -1
  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} +0 -0
  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} +3 -3
  58. package/src/blocks/text/component-info.js +24 -0
  59. package/src/blocks/text/index.js +7 -0
  60. package/src/blocks/text/text.jsx +5 -0
  61. package/src/blocks/{text.lite.tsx → text/text.lite.tsx} +0 -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} +0 -0
  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} +0 -0
  70. package/src/components/render-block/block-styles.jsx +36 -0
  71. package/src/components/render-block/block-styles.lite.tsx +38 -0
  72. package/src/components/{render-block.jsx → render-block/render-block.jsx} +13 -10
  73. package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +13 -10
  74. package/src/components/render-blocks.jsx +1 -1
  75. package/src/components/render-blocks.lite.tsx +1 -1
  76. package/src/components/render-content/components/render-styles.jsx +6 -5
  77. package/src/components/render-content/components/render-styles.lite.tsx +9 -5
  78. package/src/components/render-content/render-content.jsx +16 -15
  79. package/src/components/render-content/render-content.lite.tsx +19 -18
  80. package/src/functions/get-builder-search-params/fn.test.js +1 -1
  81. package/src/functions/get-content/index.js +2 -1
  82. package/src/functions/get-fetch.js +28 -6
  83. package/src/index.js +2 -5
  84. package/src/scripts/init-editing.js +69 -60
  85. package/src/blocks/button.jsx +0 -8
  86. package/src/blocks/button.lite.tsx +0 -14
  87. package/src/blocks/columns.jsx +0 -91
  88. package/src/blocks/fragment.jsx +0 -6
  89. package/src/blocks/image.jsx +0 -120
  90. package/src/blocks/image.lite.tsx +0 -171
  91. package/src/blocks/img.jsx +0 -11
  92. package/src/blocks/input.jsx +0 -8
  93. package/src/blocks/raw-text.jsx +0 -6
  94. package/src/blocks/section.jsx +0 -10
  95. package/src/blocks/select.jsx +0 -17
  96. package/src/blocks/submit-button.jsx +0 -8
  97. package/src/blocks/symbol.jsx +0 -25
  98. package/src/blocks/text.jsx +0 -6
  99. package/src/blocks/textarea.jsx +0 -6
  100. package/src/blocks/video.jsx +0 -15
  101. package/src/components/block-styles.jsx +0 -5
  102. package/src/components/block-styles.lite.tsx +0 -5
@@ -0,0 +1,106 @@
1
+ const componentInfo = {
2
+ name: "Video",
3
+ canHaveChildren: true,
4
+ builtIn: true,
5
+ defaultStyles: {
6
+ minHeight: "20px",
7
+ minWidth: "20px"
8
+ },
9
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
10
+ inputs: [
11
+ {
12
+ name: "video",
13
+ type: "file",
14
+ allowedFileTypes: ["mp4"],
15
+ bubble: true,
16
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
17
+ required: true
18
+ },
19
+ {
20
+ name: "posterImage",
21
+ type: "file",
22
+ allowedFileTypes: ["jpeg", "png"],
23
+ helperText: "Image to show before the video plays"
24
+ },
25
+ {
26
+ name: "autoPlay",
27
+ type: "boolean",
28
+ defaultValue: true
29
+ },
30
+ {
31
+ name: "controls",
32
+ type: "boolean",
33
+ defaultValue: false
34
+ },
35
+ {
36
+ name: "muted",
37
+ type: "boolean",
38
+ defaultValue: true
39
+ },
40
+ {
41
+ name: "loop",
42
+ type: "boolean",
43
+ defaultValue: true
44
+ },
45
+ {
46
+ name: "playsInline",
47
+ type: "boolean",
48
+ defaultValue: true
49
+ },
50
+ {
51
+ name: "fit",
52
+ type: "text",
53
+ defaultValue: "cover",
54
+ enum: ["contain", "cover", "fill", "auto"]
55
+ },
56
+ {
57
+ name: "fitContent",
58
+ type: "boolean",
59
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
60
+ defaultValue: true,
61
+ advanced: true
62
+ },
63
+ {
64
+ name: "position",
65
+ type: "text",
66
+ defaultValue: "center",
67
+ enum: [
68
+ "center",
69
+ "top",
70
+ "left",
71
+ "right",
72
+ "bottom",
73
+ "top left",
74
+ "top right",
75
+ "bottom left",
76
+ "bottom right"
77
+ ]
78
+ },
79
+ {
80
+ name: "height",
81
+ type: "number",
82
+ advanced: true
83
+ },
84
+ {
85
+ name: "width",
86
+ type: "number",
87
+ advanced: true
88
+ },
89
+ {
90
+ name: "aspectRatio",
91
+ type: "number",
92
+ advanced: true,
93
+ defaultValue: 0.7004048582995948
94
+ },
95
+ {
96
+ name: "lazyLoad",
97
+ type: "boolean",
98
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
99
+ defaultValue: true,
100
+ advanced: true
101
+ }
102
+ ]
103
+ };
104
+ export {
105
+ componentInfo
106
+ };
@@ -0,0 +1,7 @@
1
+ import { registerComponent } from "../../functions/register-component";
2
+ import { componentInfo } from "./component-info";
3
+ import component from "./video";
4
+ var stdin_default = registerComponent(component, componentInfo);
5
+ export {
6
+ stdin_default as default
7
+ };
@@ -0,0 +1,14 @@
1
+ function Video(props) {
2
+ return <video {...props.attributes} preload="none" style={{
3
+ width: "100%",
4
+ height: "100%",
5
+ ...props.attributes?.style,
6
+ "object-fit": props.fit,
7
+ "object-position": props.position,
8
+ // Hack to get object fit to work as expected and
9
+ // not have the video overflow
10
+ "border-radius": 1
11
+ }} key={props.video || "no-src"} poster={props.posterImage} autoPlay={props.autoPlay} muted={props.muted} controls={props.controls} loop={props.loop}></video>;
12
+ }
13
+
14
+ export default Video;
@@ -0,0 +1,36 @@
1
+ import { createMutable } from "solid-js/store";
2
+ import RenderInlinedStyles from "../render-inlined-styles";
3
+
4
+ function BlockStyles(props) {
5
+ const state = createMutable({
6
+ camelToKebabCase(string) {
7
+ return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
8
+ },
9
+
10
+ get css() {
11
+ // TODO: media queries
12
+ const styleObject = props.block.responsiveStyles?.large;
13
+
14
+ if (!styleObject) {
15
+ return "";
16
+ }
17
+
18
+ let str = `.${props.block.id} {`;
19
+
20
+ for (const key in styleObject) {
21
+ const value = styleObject[key];
22
+
23
+ if (typeof value === "string") {
24
+ str += `${state.camelToKebabCase(key)}: ${value};`;
25
+ }
26
+ }
27
+
28
+ str += "}";
29
+ return str;
30
+ }
31
+
32
+ });
33
+ return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
34
+ }
35
+
36
+ export default BlockStyles;
@@ -0,0 +1,38 @@
1
+ import { createMutable } from "solid-js/store";
2
+
3
+ import RenderInlinedStyles from "../render-inlined-styles.lite";
4
+
5
+ function BlockStyles(props) {
6
+ const state = createMutable({
7
+ camelToKebabCase(string: string) {
8
+ return string
9
+ .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2")
10
+ .toLowerCase();
11
+ },
12
+ get css() {
13
+ // TODO: media queries
14
+ const styleObject = props.block.responsiveStyles?.large;
15
+
16
+ if (!styleObject) {
17
+ return "";
18
+ }
19
+
20
+ let str = `.${props.block.id} {`;
21
+
22
+ for (const key in styleObject) {
23
+ const value = styleObject[key];
24
+
25
+ if (typeof value === "string") {
26
+ str += `${state.camelToKebabCase(key)}: ${value};`;
27
+ }
28
+ }
29
+
30
+ str += "}";
31
+ return str;
32
+ },
33
+ });
34
+
35
+ return <RenderInlinedStyles styles={state.css}></RenderInlinedStyles>;
36
+ }
37
+
38
+ export default BlockStyles;
@@ -1,14 +1,15 @@
1
1
  import { useContext, Show, For } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
3
  import { createMutable } from "solid-js/store";
4
- import { getBlockComponentOptions } from "../functions/get-block-component-options";
5
- import { getBlockProperties } from "../functions/get-block-properties";
6
- import { getBlockStyles } from "../functions/get-block-styles";
7
- import { getBlockTag } from "../functions/get-block-tag";
8
- import { components } from "../functions/register-component";
9
- import BuilderContext from "../context/builder.context";
10
- import { getBlockActions } from "../functions/get-block-actions";
11
- import { getProcessedBlock } from "../functions/get-processed-block";
4
+ import { TARGET } from "../../constants/target";
5
+ import BuilderContext from "../../context/builder.context";
6
+ import { getBlockActions } from "../../functions/get-block-actions";
7
+ import { getBlockComponentOptions } from "../../functions/get-block-component-options";
8
+ import { getBlockProperties } from "../../functions/get-block-properties";
9
+ import { getBlockStyles } from "../../functions/get-block-styles";
10
+ import { getBlockTag } from "../../functions/get-block-tag";
11
+ import { getProcessedBlock } from "../../functions/get-processed-block";
12
+ import { components } from "../../functions/register-component";
12
13
  import BlockStyles from "./block-styles";
13
14
 
14
15
  function RenderBlock(props) {
@@ -20,7 +21,7 @@ function RenderBlock(props) {
20
21
  return null;
21
22
  }
22
23
 
23
- const ref = components[state.useBlock.component?.name];
24
+ const ref = components[componentName];
24
25
 
25
26
  if (componentName && !ref) {
26
27
  // TODO: Public doc page with more info about this message
@@ -87,7 +88,9 @@ function RenderBlock(props) {
87
88
  return <>
88
89
  <Show when={!state.componentInfo?.noWrap}>
89
90
  <Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}>
90
- <BlockStyles block={state.useBlock}></BlockStyles>
91
+ <Show when={TARGET === "vue" || TARGET === "svelte"}>
92
+ <BlockStyles block={state.useBlock}></BlockStyles>
93
+ </Show>
91
94
  <Show when={state.componentRef}>
92
95
  <Dynamic {...state.componentOptions} builderBlock={state.useBlock} component={state.componentRef}>
93
96
  <For each={state.children}>
@@ -2,14 +2,15 @@ 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";
6
+ import BuilderContext from "../../context/builder.context";
7
+ import { getBlockActions } from "../../functions/get-block-actions";
8
+ import { getBlockComponentOptions } from "../../functions/get-block-component-options";
9
+ import { getBlockProperties } from "../../functions/get-block-properties";
10
+ import { getBlockStyles } from "../../functions/get-block-styles";
11
+ import { getBlockTag } from "../../functions/get-block-tag";
12
+ import { getProcessedBlock } from "../../functions/get-processed-block";
13
+ import { components } from "../../functions/register-component";
13
14
  import BlockStyles from "./block-styles.lite";
14
15
 
15
16
  function RenderBlock(props) {
@@ -21,7 +22,7 @@ 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 @@ 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}
@@ -2,7 +2,7 @@ import { Show, For } from "solid-js";
2
2
  import { createMutable } from "solid-js/store";
3
3
  import { css } from "solid-styled-components";
4
4
  import { isEditing } from "../functions/is-editing";
5
- import RenderBlock from "./render-block";
5
+ import RenderBlock from "./render-block/render-block";
6
6
 
7
7
  function RenderBlocks(props) {
8
8
  const state = createMutable({
@@ -4,7 +4,7 @@ import { createMutable } from "solid-js/store";
4
4
  import { css } from "solid-styled-components";
5
5
 
6
6
  import { isEditing } from "../functions/is-editing";
7
- import RenderBlock from "./render-block.lite";
7
+ import RenderBlock from "./render-block/render-block.lite";
8
8
 
9
9
  function RenderBlocks(props) {
10
10
  const state = createMutable({
@@ -1,6 +1,7 @@
1
1
  import { createMutable } from "solid-js/store";
2
+ import RenderInlinedStyles from "../../render-inlined-styles";
2
3
 
3
- function RenderStyles(props) {
4
+ function RenderContentStyles(props) {
4
5
  const state = createMutable({
5
6
  getCssFromFont(font) {
6
7
  // TODO: compute what font sizes are used and only load those.......
@@ -58,16 +59,16 @@ function RenderStyles(props) {
58
59
  return customFonts?.map(font => this.getCssFromFont(font))?.join(" ") || "";
59
60
  },
60
61
 
61
- getInjectedStyles() {
62
+ get injectedStyles() {
62
63
  return `
63
- ${props.cssCode}
64
+ ${props.cssCode || ""}
64
65
  ${state.getFontCss({
65
66
  customFonts: props.customFonts
66
67
  })}`;
67
68
  }
68
69
 
69
70
  });
70
- return <style>{state.getInjectedStyles()}</style>;
71
+ return <RenderInlinedStyles styles={state.injectedStyles}></RenderInlinedStyles>;
71
72
  }
72
73
 
73
- export default RenderStyles;
74
+ export default RenderContentStyles;
@@ -1,6 +1,8 @@
1
1
  import { createMutable } from "solid-js/store";
2
2
 
3
- 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,16 +59,18 @@ 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
  }
71
75
 
72
- export default RenderStyles;
76
+ export default RenderContentStyles;
@@ -1,19 +1,19 @@
1
1
  import { Show, onMount } from "solid-js";
2
2
  import { Dynamic } from "solid-js/web";
3
3
  import { createMutable } from "solid-js/store";
4
- import { isBrowser } from "../../functions/is-browser";
4
+ import { TARGET } from "../../constants/target";
5
5
  import BuilderContext from "../../context/builder.context";
6
- import { track } from "../../functions/track";
6
+ import { evaluate } from "../../functions/evaluate";
7
+ import { convertSearchParamsToQueryObject, getBuilderSearchParams } from "../../functions/get-builder-search-params";
8
+ import { getContent } from "../../functions/get-content";
9
+ import { getFetch } from "../../functions/get-fetch";
10
+ import { isBrowser } from "../../functions/is-browser";
7
11
  import { isEditing } from "../../functions/is-editing";
8
12
  import { isPreviewing } from "../../functions/is-previewing";
9
13
  import { previewingModelName } from "../../functions/previewing-model-name";
10
- import { getContent } from "../../functions/get-content";
11
- import { convertSearchParamsToQueryObject, getBuilderSearchParams } from "../../functions/get-builder-search-params";
14
+ import { track } from "../../functions/track";
12
15
  import RenderBlocks from "../render-blocks";
13
- import { evaluate } from "../../functions/evaluate";
14
- import { getFetch } from "../../functions/get-fetch";
15
- import { TARGET } from "../../constants/target";
16
- import RenderStyles from "./components/render-styles";
16
+ import RenderContentStyles from "./components/render-styles";
17
17
 
18
18
  function RenderContent(props) {
19
19
  const state = createMutable({
@@ -32,7 +32,7 @@ function RenderContent(props) {
32
32
  update: 0,
33
33
  overrideState: {},
34
34
 
35
- get state() {
35
+ get contentState() {
36
36
  return { ...props.content?.data?.state,
37
37
  ...props.data,
38
38
  ...state.overrideState
@@ -80,7 +80,7 @@ function RenderContent(props) {
80
80
  evaluate({
81
81
  code: jsCode,
82
82
  context: state.context,
83
- state: state.state
83
+ state: state.contentState
84
84
  });
85
85
  }
86
86
  },
@@ -93,7 +93,7 @@ function RenderContent(props) {
93
93
  return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
94
94
  code: group,
95
95
  context: state.context,
96
- state: state.state
96
+ state: state.contentState
97
97
  }));
98
98
  },
99
99
 
@@ -102,7 +102,8 @@ function RenderContent(props) {
102
102
  key
103
103
  }) {
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,
108
109
  [key]: json
@@ -129,7 +130,7 @@ function RenderContent(props) {
129
130
  emitStateUpdate() {
130
131
  window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
131
132
  detail: {
132
- state: state.state,
133
+ state: state.contentState,
133
134
  ref: {
134
135
  name: props.model
135
136
  }
@@ -182,7 +183,7 @@ function RenderContent(props) {
182
183
  },
183
184
 
184
185
  get state() {
185
- return state.state;
186
+ return state.contentState;
186
187
  },
187
188
 
188
189
  get context() {
@@ -199,7 +200,7 @@ function RenderContent(props) {
199
200
  contentId: state.useContent.id
200
201
  })} data-builder-content-id={state.useContent?.id}>
201
202
  <Show when={(state.useContent?.data?.cssCode || state.useContent?.data?.customFonts?.length) && TARGET !== "reactNative"}>
202
- <RenderStyles cssCode={state.useContent.data.cssCode} customFonts={state.useContent.data.customFonts}></RenderStyles>
203
+ <RenderContentStyles cssCode={state.useContent.data.cssCode} customFonts={state.useContent.data.customFonts}></RenderContentStyles>
203
204
  </Show>
204
205
  <RenderBlocks blocks={state.useContent?.data?.blocks}></RenderBlocks>
205
206
  </div>
@@ -2,22 +2,22 @@ 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";
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";
12
8
  import {
13
9
  convertSearchParamsToQueryObject,
14
10
  getBuilderSearchParams,
15
11
  } from "../../functions/get-builder-search-params";
16
- import RenderBlocks from "../render-blocks.lite";
17
- import { evaluate } from "../../functions/evaluate";
12
+ import { getContent } from "../../functions/get-content";
18
13
  import { getFetch } from "../../functions/get-fetch";
19
- import { TARGET } from "../../constants/target";
20
- import RenderStyles from "./components/render-styles.lite";
14
+ import { isBrowser } from "../../functions/is-browser";
15
+ import { isEditing } from "../../functions/is-editing";
16
+ import { isPreviewing } from "../../functions/is-previewing";
17
+ import { previewingModelName } from "../../functions/previewing-model-name";
18
+ import { track } from "../../functions/track";
19
+ import RenderBlocks from "../render-blocks.lite";
20
+ import RenderContentStyles from "./components/render-styles.lite";
21
21
 
22
22
  function RenderContent(props) {
23
23
  const state = createMutable({
@@ -36,7 +36,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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>
@@ -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", () => {
@@ -38,7 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  });
39
39
  };
40
40
  import { getFetch } from "../get-fetch";
41
- const fetch = getFetch();
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
+ 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
+ };
1
21
  import { getGlobalThis } from "./get-global-this";
2
22
  function getFetch() {
3
- let fetch = getGlobalThis().fetch;
4
- if (typeof fetch === "undefined" && typeof global !== "undefined") {
5
- const _require = eval("require");
6
- fetch = _require("node-fetch");
7
- }
8
- return fetch;
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
package/src/index.js CHANGED
@@ -1,8 +1,5 @@
1
- import("./index-helpers/top-of-file");
2
- import { isEditing } from "./functions/is-editing";
3
- if (isEditing()) {
4
- import("./scripts/init-editing");
5
- }
1
+ import "./index-helpers/top-of-file";
2
+ import "./scripts/init-editing";
6
3
  export * from "./index-helpers/blocks-exports";
7
4
  export * from "./functions/is-editing";
8
5
  export * from "./functions/is-previewing";