@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.
Files changed (114) hide show
  1. package/package.json +16 -5
  2. package/src/blocks/button/button.jsx +13 -0
  3. package/src/blocks/button/button.lite.tsx +23 -0
  4. package/src/blocks/button/component-info.js +41 -0
  5. package/src/blocks/columns/columns.jsx +91 -0
  6. package/src/blocks/{columns.lite.tsx → columns/columns.lite.tsx} +34 -26
  7. package/src/blocks/columns/component-info.js +217 -0
  8. package/src/blocks/custom-code/component-info.js +31 -0
  9. package/src/blocks/{custom-code.jsx → custom-code/custom-code.jsx} +2 -2
  10. package/src/blocks/{custom-code.lite.tsx → custom-code/custom-code.lite.tsx} +2 -0
  11. package/src/blocks/embed/component-info.js +24 -0
  12. package/src/blocks/{embed.jsx → embed/embed.jsx} +3 -3
  13. package/src/blocks/{embed.lite.tsx → embed/embed.lite.tsx} +3 -1
  14. package/src/blocks/form/component-info.js +262 -0
  15. package/src/blocks/{form.jsx → form/form.jsx} +9 -9
  16. package/src/blocks/{form.lite.tsx → form/form.lite.tsx} +15 -11
  17. package/src/blocks/fragment/component-info.js +11 -0
  18. package/src/blocks/fragment/fragment.jsx +5 -0
  19. package/src/blocks/{fragment.lite.tsx → fragment/fragment.lite.tsx} +0 -0
  20. package/src/blocks/image/component-info.js +104 -0
  21. package/src/blocks/image/image.jsx +54 -0
  22. package/src/blocks/image/image.lite.tsx +86 -0
  23. package/src/blocks/img/component-info.js +20 -0
  24. package/src/blocks/img/img.jsx +10 -0
  25. package/src/blocks/{img.lite.tsx → img/img.lite.tsx} +1 -1
  26. package/src/blocks/input/component-info.js +74 -0
  27. package/src/blocks/input/input.jsx +7 -0
  28. package/src/blocks/{input.lite.tsx → input/input.lite.tsx} +1 -1
  29. package/src/blocks/raw-text/component-info.js +16 -0
  30. package/src/blocks/raw-text/raw-text.jsx +5 -0
  31. package/src/blocks/{raw-text.lite.tsx → raw-text/raw-text.lite.tsx} +0 -0
  32. package/src/blocks/section/component-info.js +49 -0
  33. package/src/blocks/section/section.jsx +9 -0
  34. package/src/blocks/{section.lite.tsx → section/section.lite.tsx} +0 -0
  35. package/src/blocks/select/component-info.js +59 -0
  36. package/src/blocks/select/select.jsx +16 -0
  37. package/src/blocks/{select.lite.tsx → select/select.lite.tsx} +1 -1
  38. package/src/blocks/submit-button/component-info.js +28 -0
  39. package/src/blocks/submit-button/submit-button.jsx +7 -0
  40. package/src/blocks/{submit-button.lite.tsx → submit-button/submit-button.lite.tsx} +0 -0
  41. package/src/blocks/symbol/component-info.js +43 -0
  42. package/src/blocks/symbol/symbol.jsx +25 -0
  43. package/src/blocks/{symbol.lite.tsx → symbol/symbol.lite.tsx} +6 -4
  44. package/src/blocks/text/component-info.js +24 -0
  45. package/src/blocks/text/text.jsx +5 -0
  46. package/src/blocks/text/text.lite.tsx +5 -0
  47. package/src/blocks/textarea/component-info.js +47 -0
  48. package/src/blocks/textarea/textarea.jsx +5 -0
  49. package/src/blocks/{textarea.lite.tsx → textarea/textarea.lite.tsx} +0 -0
  50. package/src/blocks/video/component-info.js +106 -0
  51. package/src/blocks/video/video.jsx +14 -0
  52. package/src/blocks/{video.lite.tsx → video/video.lite.tsx} +0 -0
  53. package/src/components/render-block/block-styles.jsx +36 -0
  54. package/src/components/render-block/block-styles.lite.tsx +38 -0
  55. package/src/components/render-block/render-block.helpers.js +23 -0
  56. package/src/components/{render-block.jsx → render-block/render-block.jsx} +40 -22
  57. package/src/components/{render-block.lite.tsx → render-block/render-block.lite.tsx} +57 -19
  58. package/src/components/render-blocks.jsx +2 -2
  59. package/src/components/render-blocks.lite.tsx +2 -2
  60. package/src/components/render-content/components/render-styles.jsx +6 -5
  61. package/src/components/render-content/components/render-styles.lite.tsx +9 -5
  62. package/src/components/render-content/index.js +4 -0
  63. package/src/components/render-content/render-content.jsx +50 -24
  64. package/src/components/render-content/render-content.lite.tsx +64 -33
  65. package/src/components/render-inlined-styles.jsx +24 -0
  66. package/src/components/render-inlined-styles.lite.tsx +29 -0
  67. package/src/constants/builder-registered-components.js +45 -0
  68. package/src/context/builder.context.js +2 -1
  69. package/src/functions/evaluate.js +2 -2
  70. package/src/functions/fast-clone.js +4 -0
  71. package/src/functions/get-block-actions.js +2 -2
  72. package/src/functions/get-block-styles.js +2 -2
  73. package/src/functions/get-builder-search-params/fn.test.js +1 -1
  74. package/src/functions/get-content/index.js +3 -2
  75. package/src/functions/get-fetch.js +29 -7
  76. package/src/functions/get-processed-block.js +3 -3
  77. package/src/functions/get-processed-block.test.js +1 -1
  78. package/src/functions/if-target.js +1 -1
  79. package/src/functions/is-editing.js +1 -1
  80. package/src/functions/is-iframe.js +1 -1
  81. package/src/functions/is-previewing.js +2 -2
  82. package/src/functions/on-change.test.js +1 -1
  83. package/src/functions/previewing-model-name.js +1 -1
  84. package/src/functions/register-component.js +30 -13
  85. package/src/functions/register.js +1 -1
  86. package/src/functions/set-editor-settings.js +1 -1
  87. package/src/functions/set.test.js +1 -1
  88. package/src/functions/track.js +3 -3
  89. package/src/index-helpers/blocks-exports.js +9 -9
  90. package/src/index.js +10 -13
  91. package/src/scripts/init-editing.js +72 -63
  92. package/src/solid-index.jsx +5 -0
  93. package/src/types/components.js +0 -0
  94. package/src/types/element.js +0 -0
  95. package/src/blocks/button.jsx +0 -8
  96. package/src/blocks/button.lite.tsx +0 -14
  97. package/src/blocks/columns.jsx +0 -96
  98. package/src/blocks/fragment.jsx +0 -6
  99. package/src/blocks/image.jsx +0 -120
  100. package/src/blocks/image.lite.tsx +0 -171
  101. package/src/blocks/img.jsx +0 -11
  102. package/src/blocks/input.jsx +0 -8
  103. package/src/blocks/raw-text.jsx +0 -6
  104. package/src/blocks/section.jsx +0 -10
  105. package/src/blocks/select.jsx +0 -17
  106. package/src/blocks/submit-button.jsx +0 -8
  107. package/src/blocks/symbol.jsx +0 -25
  108. package/src/blocks/text.jsx +0 -6
  109. package/src/blocks/text.lite.tsx +0 -5
  110. package/src/blocks/textarea.jsx +0 -6
  111. package/src/blocks/video.jsx +0 -15
  112. package/src/components/block-styles.jsx +0 -5
  113. package/src/components/block-styles.lite.tsx +0 -5
  114. 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 { isBrowser } from "../../functions/is-browser";
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 { 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";
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 { 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";
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 state() {
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
- [index: string]: any;
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.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.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 response = await getFetch()(url);
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
- window.dispatchEvent(
127
- new CustomEvent<BuilderComponentStateChange>(
128
- "builder:component:stateChange",
129
- {
130
- detail: {
131
- state: state.state,
132
- ref: {
133
- name: props.model,
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.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
- <RenderStyles
250
+ <RenderContentStyles
220
251
  cssCode={state.useContent.data.cssCode}
221
252
  customFonts={state.useContent.data.customFonts}
222
- ></RenderStyles>
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
+ };
@@ -3,7 +3,8 @@ var stdin_default = createContext({
3
3
  content: null,
4
4
  context: {},
5
5
  state: {},
6
- apiKey: null
6
+ apiKey: null,
7
+ registeredComponents: {}
7
8
  });
8
9
  export {
9
10
  stdin_default as default
@@ -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,
@@ -0,0 +1,4 @@
1
+ const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
2
+ export {
3
+ fastClone
4
+ };
@@ -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 { 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);
@@ -1,11 +1,33 @@
1
- import { getGlobalThis } from "./get-global-this";
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
- 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
@@ -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);
@@ -1,4 +1,4 @@
1
- import { getProcessedBlock } from "./get-processed-block";
1
+ import { getProcessedBlock } from "./get-processed-block.js";
2
2
  test("Can process bindings", () => {
3
3
  var _a, _b, _c, _d, _e, _f;
4
4
  const block = {
@@ -1,4 +1,4 @@
1
- import { TARGET } from "../constants/target";
1
+ import { TARGET } from "../constants/target.js";
2
2
  function ifTarget({
3
3
  targets,
4
4
  doThing,
@@ -1,4 +1,4 @@
1
- import { isIframe } from "./is-iframe";
1
+ import { isIframe } from "./is-iframe.js";
2
2
  function isEditing() {
3
3
  return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { isBrowser } from "./is-browser";
1
+ import { isBrowser } from "./is-browser.js";
2
2
  function isIframe() {
3
3
  return isBrowser() && window.self !== window.top;
4
4
  }
@@ -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 isPreviewing() {
4
4
  if (!isBrowser()) {
5
5
  return false;
@@ -1,4 +1,4 @@
1
- import { onChange } from "./on-change";
1
+ import { onChange } from "./on-change.js";
2
2
  test("onChange can observe a shallow change", () => {
3
3
  let changeHappend = false;
4
4
  const obj = onChange({ foo: "hi" }, () => changeHappend = true);
@@ -1,4 +1,4 @@
1
- import { isPreviewing } from "./is-previewing";
1
+ import { isPreviewing } from "./is-previewing.js";
2
2
  function previewingModelName() {
3
3
  if (!isPreviewing()) {
4
4
  return null;
@@ -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
- import { isBrowser } from "./is-browser";
21
- const components = {};
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
- var _a;
24
- components[info.name] = { component, info };
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
- if (input[key] && typeof input[key] === "function") {
40
- const fn = input[key];
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
  };
@@ -1,4 +1,4 @@
1
- import { isBrowser } from "./is-browser";
1
+ import { isBrowser } from "./is-browser.js";
2
2
  const registry = {};
3
3
  function register(type, info) {
4
4
  let typeList = registry[type];
@@ -1,4 +1,4 @@
1
- import { isBrowser } from "./is-browser";
1
+ import { isBrowser } from "./is-browser.js";
2
2
  const settings = {};
3
3
  function setEditorSettings(newSettings) {
4
4
  if (isBrowser()) {
@@ -1,4 +1,4 @@
1
- import { set } from "./set";
1
+ import { set } from "./set.js";
2
2
  test("can shallow set a property", () => {
3
3
  const obj = { foo: "bar" };
4
4
  set(obj, "foo", "baz");
@@ -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("./index-helpers/top-of-file");
2
- import { isEditing } from "./functions/is-editing";
3
- if (isEditing()) {
4
- import("./scripts/init-editing");
5
- }
6
- export * from "./index-helpers/blocks-exports";
7
- export * from "./functions/is-editing";
8
- export * from "./functions/is-previewing";
9
- export * from "./functions/register-component";
10
- export * from "./functions/register";
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";