@builder.io/sdk-react 0.2.3-4 → 0.3.1

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 (288) hide show
  1. package/README.md +72 -3
  2. package/dist/sdk/blocks/columns/columns.js +5 -5
  3. package/dist/sdk/blocks/image/image.js +8 -7
  4. package/dist/sdk/blocks/symbol/symbol.js +3 -2
  5. package/dist/sdk/blocks/video/video.js +4 -1
  6. package/dist/sdk/components/render-block/block-styles.js +3 -1
  7. package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -1
  8. package/dist/sdk/components/render-block/render-block.helpers.js +8 -20
  9. package/dist/sdk/components/render-block/render-block.js +24 -15
  10. package/dist/sdk/components/render-block/render-repeated-block.js +3 -2
  11. package/dist/sdk/components/render-content/render-content.js +31 -12
  12. package/dist/sdk/components/render-content-variants/helpers.d.ts +12 -0
  13. package/dist/sdk/components/render-content-variants/helpers.js +154 -0
  14. package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +5 -0
  15. package/dist/sdk/components/render-content-variants/render-content-variants.js +29 -0
  16. package/dist/sdk/components/render-inlined-styles.js +2 -2
  17. package/dist/sdk/constants/sdk-version.d.ts +1 -0
  18. package/dist/sdk/constants/sdk-version.js +1 -0
  19. package/dist/sdk/context/builder.context.js +3 -2
  20. package/dist/sdk/context/types.d.ts +17 -2
  21. package/dist/sdk/functions/evaluate.d.ts +4 -3
  22. package/dist/sdk/functions/evaluate.js +23 -2
  23. package/dist/sdk/functions/evaluate.test.d.ts +1 -0
  24. package/dist/sdk/functions/evaluate.test.js +17 -0
  25. package/dist/sdk/functions/get-block-actions-handler.d.ts +1 -1
  26. package/dist/sdk/functions/get-block-actions-handler.js +3 -1
  27. package/dist/sdk/functions/get-block-actions.d.ts +1 -1
  28. package/dist/sdk/functions/get-processed-block.d.ts +2 -2
  29. package/dist/sdk/functions/get-processed-block.js +16 -4
  30. package/dist/sdk/functions/get-processed-block.test.js +3 -1
  31. package/dist/sdk/helpers/canTrack.d.ts +1 -0
  32. package/dist/sdk/helpers/canTrack.js +2 -0
  33. package/dist/sdk/index.d.ts +1 -0
  34. package/dist/sdk/scripts/init-editing.js +2 -0
  35. package/package.json +5 -5
  36. package/CHANGELOG.md +0 -25
  37. package/packages/react/src/blocks/BaseText.tsx +0 -19
  38. package/packages/react/src/blocks/button/button.tsx +0 -45
  39. package/packages/react/src/blocks/button/component-info.ts +0 -42
  40. package/packages/react/src/blocks/columns/columns.tsx +0 -211
  41. package/packages/react/src/blocks/columns/component-info.ts +0 -254
  42. package/packages/react/src/blocks/custom-code/component-info.ts +0 -31
  43. package/packages/react/src/blocks/custom-code/custom-code.tsx +0 -76
  44. package/packages/react/src/blocks/embed/component-info.ts +0 -55
  45. package/packages/react/src/blocks/embed/embed.tsx +0 -59
  46. package/packages/react/src/blocks/embed/helpers.ts +0 -8
  47. package/packages/react/src/blocks/form/component-info.ts +0 -282
  48. package/packages/react/src/blocks/form/form.tsx +0 -320
  49. package/packages/react/src/blocks/fragment/component-info.ts +0 -10
  50. package/packages/react/src/blocks/fragment/fragment.tsx +0 -14
  51. package/packages/react/src/blocks/image/component-info.ts +0 -172
  52. package/packages/react/src/blocks/image/image.helpers.ts +0 -75
  53. package/packages/react/src/blocks/image/image.tsx +0 -144
  54. package/packages/react/src/blocks/img/component-info.ts +0 -21
  55. package/packages/react/src/blocks/img/img.tsx +0 -40
  56. package/packages/react/src/blocks/input/component-info.ts +0 -78
  57. package/packages/react/src/blocks/input/input.tsx +0 -33
  58. package/packages/react/src/blocks/raw-text/component-info.ts +0 -15
  59. package/packages/react/src/blocks/raw-text/raw-text.tsx +0 -18
  60. package/packages/react/src/blocks/section/component-info.ts +0 -50
  61. package/packages/react/src/blocks/section/section.tsx +0 -33
  62. package/packages/react/src/blocks/select/component-info.ts +0 -61
  63. package/packages/react/src/blocks/select/select.tsx +0 -35
  64. package/packages/react/src/blocks/submit-button/component-info.ts +0 -32
  65. package/packages/react/src/blocks/submit-button/submit-button.tsx +0 -17
  66. package/packages/react/src/blocks/symbol/component-info.ts +0 -43
  67. package/packages/react/src/blocks/symbol/symbol.tsx +0 -111
  68. package/packages/react/src/blocks/text/component-info.ts +0 -24
  69. package/packages/react/src/blocks/text/text.tsx +0 -20
  70. package/packages/react/src/blocks/textarea/component-info.ts +0 -48
  71. package/packages/react/src/blocks/textarea/textarea.tsx +0 -24
  72. package/packages/react/src/blocks/util.ts +0 -18
  73. package/packages/react/src/blocks/video/component-info.ts +0 -109
  74. package/packages/react/src/blocks/video/video.tsx +0 -84
  75. package/packages/react/src/components/render-block/block-styles.tsx +0 -98
  76. package/packages/react/src/components/render-block/render-block.helpers.ts +0 -138
  77. package/packages/react/src/components/render-block/render-block.tsx +0 -216
  78. package/packages/react/src/components/render-block/render-component.tsx +0 -52
  79. package/packages/react/src/components/render-block/render-repeated-block.tsx +0 -43
  80. package/packages/react/src/components/render-block/types.ts +0 -7
  81. package/packages/react/src/components/render-blocks.tsx +0 -97
  82. package/packages/react/src/components/render-content/builder-editing.tsx +0 -8
  83. package/packages/react/src/components/render-content/components/render-styles.helpers.ts +0 -79
  84. package/packages/react/src/components/render-content/components/render-styles.tsx +0 -45
  85. package/packages/react/src/components/render-content/index.ts +0 -1
  86. package/packages/react/src/components/render-content/render-content.helpers.ts +0 -48
  87. package/packages/react/src/components/render-content/render-content.tsx +0 -410
  88. package/packages/react/src/components/render-content/render-content.types.ts +0 -33
  89. package/packages/react/src/components/render-inlined-styles.tsx +0 -36
  90. package/packages/react/src/constants/builder-registered-components.ts +0 -42
  91. package/packages/react/src/constants/device-sizes.ts +0 -65
  92. package/packages/react/src/constants/target.ts +0 -2
  93. package/packages/react/src/context/builder.context.ts +0 -12
  94. package/packages/react/src/context/types.ts +0 -26
  95. package/packages/react/src/functions/camel-to-kebab-case.ts +0 -2
  96. package/packages/react/src/functions/evaluate.ts +0 -57
  97. package/packages/react/src/functions/event-handler-name.ts +0 -6
  98. package/packages/react/src/functions/extract-text-styles.ts +0 -39
  99. package/packages/react/src/functions/fast-clone.ts +0 -5
  100. package/packages/react/src/functions/get-block-actions-handler.ts +0 -20
  101. package/packages/react/src/functions/get-block-actions.ts +0 -25
  102. package/packages/react/src/functions/get-block-component-options.ts +0 -12
  103. package/packages/react/src/functions/get-block-properties.ts +0 -75
  104. package/packages/react/src/functions/get-builder-search-params/fn.test.ts +0 -19
  105. package/packages/react/src/functions/get-builder-search-params/index.ts +0 -50
  106. package/packages/react/src/functions/get-content/ab-testing.ts +0 -132
  107. package/packages/react/src/functions/get-content/generate-content-url.test.ts +0 -95
  108. package/packages/react/src/functions/get-content/generate-content-url.ts +0 -59
  109. package/packages/react/src/functions/get-content/index.ts +0 -62
  110. package/packages/react/src/functions/get-content/types.ts +0 -53
  111. package/packages/react/src/functions/get-fetch.ts +0 -18
  112. package/packages/react/src/functions/get-global-this.ts +0 -17
  113. package/packages/react/src/functions/get-processed-block.test.ts +0 -33
  114. package/packages/react/src/functions/get-processed-block.ts +0 -54
  115. package/packages/react/src/functions/get-react-native-block-styles.ts +0 -33
  116. package/packages/react/src/functions/if-target.ts +0 -20
  117. package/packages/react/src/functions/is-browser.ts +0 -3
  118. package/packages/react/src/functions/is-editing.ts +0 -10
  119. package/packages/react/src/functions/is-iframe.ts +0 -5
  120. package/packages/react/src/functions/is-previewing.ts +0 -14
  121. package/packages/react/src/functions/on-change.test.ts +0 -23
  122. package/packages/react/src/functions/on-change.ts +0 -29
  123. package/packages/react/src/functions/register-component.ts +0 -50
  124. package/packages/react/src/functions/register.ts +0 -46
  125. package/packages/react/src/functions/sanitize-react-native-block-styles.ts +0 -65
  126. package/packages/react/src/functions/set-editor-settings.ts +0 -16
  127. package/packages/react/src/functions/set.test.ts +0 -19
  128. package/packages/react/src/functions/set.ts +0 -26
  129. package/packages/react/src/functions/track/helpers.ts +0 -67
  130. package/packages/react/src/functions/track/index.ts +0 -136
  131. package/packages/react/src/functions/track/interaction.ts +0 -80
  132. package/packages/react/src/functions/transform-block-properties.ts +0 -3
  133. package/packages/react/src/functions/transform-block.ts +0 -6
  134. package/packages/react/src/helpers/ab-tests.ts +0 -22
  135. package/packages/react/src/helpers/cookie.ts +0 -107
  136. package/packages/react/src/helpers/css.ts +0 -42
  137. package/packages/react/src/helpers/flatten.ts +0 -24
  138. package/packages/react/src/helpers/localStorage.ts +0 -40
  139. package/packages/react/src/helpers/logger.ts +0 -6
  140. package/packages/react/src/helpers/nullable.ts +0 -4
  141. package/packages/react/src/helpers/sessionId.ts +0 -38
  142. package/packages/react/src/helpers/time.ts +0 -4
  143. package/packages/react/src/helpers/url.test.ts +0 -23
  144. package/packages/react/src/helpers/url.ts +0 -16
  145. package/packages/react/src/helpers/uuid.ts +0 -17
  146. package/packages/react/src/helpers/visitorId.ts +0 -40
  147. package/packages/react/src/index-helpers/blocks-exports.ts +0 -10
  148. package/packages/react/src/index-helpers/top-of-file.ts +0 -4
  149. package/packages/react/src/index.ts +0 -14
  150. package/packages/react/src/scripts/init-editing.ts +0 -123
  151. package/packages/react/src/types/api-version.ts +0 -2
  152. package/packages/react/src/types/builder-block.ts +0 -69
  153. package/packages/react/src/types/builder-content.ts +0 -46
  154. package/packages/react/src/types/can-track.ts +0 -3
  155. package/packages/react/src/types/components.ts +0 -117
  156. package/packages/react/src/types/deep-partial.ts +0 -7
  157. package/packages/react/src/types/element.ts +0 -60
  158. package/packages/react/src/types/input.ts +0 -125
  159. package/packages/react/src/types/targets.ts +0 -6
  160. package/packages/react/src/types/typescript.ts +0 -7
  161. package/packages/rsc/src/blocks/BaseText.jsx +0 -12
  162. package/packages/rsc/src/blocks/button/button.jsx +0 -37
  163. package/packages/rsc/src/blocks/button/component-info.js +0 -40
  164. package/packages/rsc/src/blocks/columns/columns.jsx +0 -172
  165. package/packages/rsc/src/blocks/columns/component-info.js +0 -241
  166. package/packages/rsc/src/blocks/custom-code/component-info.js +0 -30
  167. package/packages/rsc/src/blocks/custom-code/custom-code.jsx +0 -57
  168. package/packages/rsc/src/blocks/embed/component-info.js +0 -43
  169. package/packages/rsc/src/blocks/embed/embed.jsx +0 -45
  170. package/packages/rsc/src/blocks/embed/helpers.js +0 -9
  171. package/packages/rsc/src/blocks/form/component-info.js +0 -261
  172. package/packages/rsc/src/blocks/form/form.jsx +0 -260
  173. package/packages/rsc/src/blocks/fragment/component-info.js +0 -10
  174. package/packages/rsc/src/blocks/fragment/fragment.jsx +0 -9
  175. package/packages/rsc/src/blocks/image/component-info.js +0 -150
  176. package/packages/rsc/src/blocks/image/image.helpers.js +0 -48
  177. package/packages/rsc/src/blocks/image/image.jsx +0 -122
  178. package/packages/rsc/src/blocks/img/component-info.js +0 -19
  179. package/packages/rsc/src/blocks/img/img.jsx +0 -21
  180. package/packages/rsc/src/blocks/input/component-info.js +0 -73
  181. package/packages/rsc/src/blocks/input/input.jsx +0 -23
  182. package/packages/rsc/src/blocks/raw-text/component-info.js +0 -15
  183. package/packages/rsc/src/blocks/raw-text/raw-text.jsx +0 -14
  184. package/packages/rsc/src/blocks/section/component-info.js +0 -48
  185. package/packages/rsc/src/blocks/section/section.jsx +0 -27
  186. package/packages/rsc/src/blocks/select/component-info.js +0 -58
  187. package/packages/rsc/src/blocks/select/select.jsx +0 -24
  188. package/packages/rsc/src/blocks/submit-button/component-info.js +0 -27
  189. package/packages/rsc/src/blocks/submit-button/submit-button.jsx +0 -13
  190. package/packages/rsc/src/blocks/symbol/component-info.js +0 -42
  191. package/packages/rsc/src/blocks/symbol/symbol.jsx +0 -89
  192. package/packages/rsc/src/blocks/text/component-info.js +0 -23
  193. package/packages/rsc/src/blocks/text/text.jsx +0 -17
  194. package/packages/rsc/src/blocks/textarea/component-info.js +0 -46
  195. package/packages/rsc/src/blocks/textarea/textarea.jsx +0 -17
  196. package/packages/rsc/src/blocks/util.js +0 -8
  197. package/packages/rsc/src/blocks/video/component-info.js +0 -105
  198. package/packages/rsc/src/blocks/video/video.jsx +0 -63
  199. package/packages/rsc/src/components/render-block/block-styles.jsx +0 -88
  200. package/packages/rsc/src/components/render-block/render-block.helpers.js +0 -129
  201. package/packages/rsc/src/components/render-block/render-block.jsx +0 -201
  202. package/packages/rsc/src/components/render-block/render-component.jsx +0 -39
  203. package/packages/rsc/src/components/render-block/render-repeated-block.jsx +0 -27
  204. package/packages/rsc/src/components/render-block/types.js +0 -0
  205. package/packages/rsc/src/components/render-blocks.jsx +0 -92
  206. package/packages/rsc/src/components/render-content/builder-editing.jsx +0 -64
  207. package/packages/rsc/src/components/render-content/components/render-styles.helpers.js +0 -57
  208. package/packages/rsc/src/components/render-content/components/render-styles.jsx +0 -39
  209. package/packages/rsc/src/components/render-content/index.js +0 -4
  210. package/packages/rsc/src/components/render-content/render-content.helpers.js +0 -48
  211. package/packages/rsc/src/components/render-content/render-content.jsx +0 -253
  212. package/packages/rsc/src/components/render-content/render-content.types.js +0 -0
  213. package/packages/rsc/src/components/render-inlined-styles.jsx +0 -33
  214. package/packages/rsc/src/constants/builder-registered-components.js +0 -54
  215. package/packages/rsc/src/constants/device-sizes.js +0 -48
  216. package/packages/rsc/src/constants/target.js +0 -4
  217. package/packages/rsc/src/context/builder.context.js +0 -14
  218. package/packages/rsc/src/context/types.js +0 -0
  219. package/packages/rsc/src/functions/camel-to-kebab-case.js +0 -4
  220. package/packages/rsc/src/functions/evaluate.js +0 -6
  221. package/packages/rsc/src/functions/event-handler-name.js +0 -7
  222. package/packages/rsc/src/functions/extract-text-styles.js +0 -22
  223. package/packages/rsc/src/functions/fast-clone.js +0 -4
  224. package/packages/rsc/src/functions/get-block-actions-handler.js +0 -11
  225. package/packages/rsc/src/functions/get-block-actions.js +0 -18
  226. package/packages/rsc/src/functions/get-block-component-options.js +0 -28
  227. package/packages/rsc/src/functions/get-block-properties.js +0 -53
  228. package/packages/rsc/src/functions/get-builder-search-params/fn.test.js +0 -13
  229. package/packages/rsc/src/functions/get-builder-search-params/index.js +0 -38
  230. package/packages/rsc/src/functions/get-content/ab-testing.js +0 -99
  231. package/packages/rsc/src/functions/get-content/generate-content-url.js +0 -60
  232. package/packages/rsc/src/functions/get-content/generate-content-url.test.js +0 -82
  233. package/packages/rsc/src/functions/get-content/index.js +0 -83
  234. package/packages/rsc/src/functions/get-content/types.js +0 -0
  235. package/packages/rsc/src/functions/get-fetch.js +0 -14
  236. package/packages/rsc/src/functions/get-global-this.js +0 -18
  237. package/packages/rsc/src/functions/get-processed-block.js +0 -59
  238. package/packages/rsc/src/functions/get-processed-block.test.js +0 -32
  239. package/packages/rsc/src/functions/get-react-native-block-styles.js +0 -33
  240. package/packages/rsc/src/functions/if-target.js +0 -15
  241. package/packages/rsc/src/functions/is-browser.js +0 -6
  242. package/packages/rsc/src/functions/is-editing.js +0 -8
  243. package/packages/rsc/src/functions/is-iframe.js +0 -7
  244. package/packages/rsc/src/functions/is-previewing.js +0 -14
  245. package/packages/rsc/src/functions/on-change.js +0 -27
  246. package/packages/rsc/src/functions/on-change.test.js +0 -19
  247. package/packages/rsc/src/functions/register-component.js +0 -68
  248. package/packages/rsc/src/functions/register.js +0 -29
  249. package/packages/rsc/src/functions/sanitize-react-native-block-styles.js +0 -66
  250. package/packages/rsc/src/functions/set-editor-settings.js +0 -15
  251. package/packages/rsc/src/functions/set.js +0 -11
  252. package/packages/rsc/src/functions/set.test.js +0 -16
  253. package/packages/rsc/src/functions/track/helpers.js +0 -50
  254. package/packages/rsc/src/functions/track/index.js +0 -129
  255. package/packages/rsc/src/functions/track/interaction.js +0 -53
  256. package/packages/rsc/src/functions/transform-block-properties.js +0 -6
  257. package/packages/rsc/src/functions/transform-block.js +0 -6
  258. package/packages/rsc/src/helpers/ab-tests.js +0 -16
  259. package/packages/rsc/src/helpers/cookie.js +0 -81
  260. package/packages/rsc/src/helpers/css.js +0 -34
  261. package/packages/rsc/src/helpers/flatten.js +0 -34
  262. package/packages/rsc/src/helpers/localStorage.js +0 -35
  263. package/packages/rsc/src/helpers/logger.js +0 -9
  264. package/packages/rsc/src/helpers/nullable.js +0 -4
  265. package/packages/rsc/src/helpers/sessionId.js +0 -52
  266. package/packages/rsc/src/helpers/time.js +0 -5
  267. package/packages/rsc/src/helpers/url.js +0 -13
  268. package/packages/rsc/src/helpers/url.test.js +0 -21
  269. package/packages/rsc/src/helpers/uuid.js +0 -13
  270. package/packages/rsc/src/helpers/visitorId.js +0 -34
  271. package/packages/rsc/src/index-helpers/blocks-exports.js +0 -22
  272. package/packages/rsc/src/index-helpers/top-of-file.js +0 -2
  273. package/packages/rsc/src/index.js +0 -13
  274. package/packages/rsc/src/scripts/init-editing.js +0 -93
  275. package/packages/rsc/src/types/api-version.js +0 -4
  276. package/packages/rsc/src/types/builder-block.js +0 -0
  277. package/packages/rsc/src/types/builder-content.js +0 -0
  278. package/packages/rsc/src/types/can-track.js +0 -0
  279. package/packages/rsc/src/types/components.js +0 -0
  280. package/packages/rsc/src/types/deep-partial.js +0 -0
  281. package/packages/rsc/src/types/element.js +0 -0
  282. package/packages/rsc/src/types/input.js +0 -0
  283. package/packages/rsc/src/types/targets.js +0 -0
  284. package/packages/rsc/src/types/typescript.js +0 -0
  285. package/tsconfig.json +0 -28
  286. package/tsconfig.sdk.json +0 -10
  287. package/tsconfig.server.json +0 -10
  288. package/vite.config.ts +0 -91
@@ -1,54 +0,0 @@
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";
18
- import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info.js";
19
- import { default as Columns } from "../blocks/columns/columns";
20
- import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info.js";
21
- import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info.js";
22
- import { default as Fragment } from "../blocks/fragment/fragment";
23
- import { componentInfo as imageComponentInfo } from "../blocks/image/component-info.js";
24
- import { default as Image } from "../blocks/image/image";
25
- import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info.js";
26
- import { default as Section } from "../blocks/section/section";
27
- import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info.js";
28
- import { default as Symbol } from "../blocks/symbol/symbol";
29
- import { componentInfo as textComponentInfo } from "../blocks/text/component-info.js";
30
- import { default as Text } from "../blocks/text/text";
31
- import { componentInfo as videoComponentInfo } from "../blocks/video/component-info.js";
32
- import { default as Video } from "../blocks/video/video";
33
- import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info.js";
34
- import { default as embed } from "../blocks/embed/embed";
35
- import { default as Img } from "../blocks/img/img";
36
- import { componentInfo as imgComponentInfo } from "../blocks/img/component-info.js";
37
- import { default as customCode } from "../blocks/custom-code/custom-code";
38
- import { componentInfo as customCodeInfo } from "../blocks/custom-code/component-info.js";
39
- const getDefaultRegisteredComponents = () => [
40
- __spreadValues({ component: Button }, buttonComponentInfo),
41
- __spreadValues({ component: Columns }, columnsComponentInfo),
42
- __spreadValues({ component: customCode }, customCodeInfo),
43
- __spreadValues({ component: embed }, embedComponentInfo),
44
- __spreadValues({ component: Fragment }, fragmentComponentInfo),
45
- __spreadValues({ component: Image }, imageComponentInfo),
46
- __spreadValues({ component: Img }, imgComponentInfo),
47
- __spreadValues({ component: Section }, sectionComponentInfo),
48
- __spreadValues({ component: Symbol }, symbolComponentInfo),
49
- __spreadValues({ component: Text }, textComponentInfo),
50
- __spreadValues({ component: Video }, videoComponentInfo)
51
- ];
52
- export {
53
- getDefaultRegisteredComponents
54
- };
@@ -1,48 +0,0 @@
1
- import { fastClone } from "../functions/fast-clone";
2
- const SIZES = {
3
- small: {
4
- min: 320,
5
- default: 321,
6
- max: 640
7
- },
8
- medium: {
9
- min: 641,
10
- default: 642,
11
- max: 991
12
- },
13
- large: {
14
- min: 990,
15
- default: 991,
16
- max: 1200
17
- }
18
- };
19
- const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
20
- const getSizesForBreakpoints = ({ small, medium }) => {
21
- const newSizes = fastClone(SIZES);
22
- if (!small || !medium) {
23
- return newSizes;
24
- }
25
- const smallMin = Math.floor(small / 2);
26
- newSizes.small = {
27
- max: small,
28
- min: smallMin,
29
- default: smallMin + 1
30
- };
31
- const mediumMin = newSizes.small.max + 1;
32
- newSizes.medium = {
33
- max: medium,
34
- min: mediumMin,
35
- default: mediumMin + 1
36
- };
37
- const largeMin = newSizes.medium.max + 1;
38
- newSizes.large = {
39
- max: 2e3,
40
- min: largeMin,
41
- default: largeMin + 1
42
- };
43
- return newSizes;
44
- };
45
- export {
46
- getMaxWidthQueryForSize,
47
- getSizesForBreakpoints
48
- };
@@ -1,4 +0,0 @@
1
- const TARGET = "rsc";
2
- export {
3
- TARGET
4
- };
@@ -1,14 +0,0 @@
1
- var stdin_default = {
2
- content: null,
3
- context: {},
4
- state: {},
5
- setState() {
6
- },
7
- apiKey: null,
8
- apiVersion: void 0,
9
- registeredComponents: {},
10
- inheritedStyles: {}
11
- };
12
- export {
13
- stdin_default as default
14
- };
File without changes
@@ -1,4 +0,0 @@
1
- const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
2
- export {
3
- camelToKebabCase
4
- };
@@ -1,6 +0,0 @@
1
- function evaluate() {
2
- return null;
3
- }
4
- export {
5
- evaluate
6
- };
@@ -1,7 +0,0 @@
1
- function capitalizeFirstLetter(string) {
2
- return string.charAt(0).toUpperCase() + string.slice(1);
3
- }
4
- const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
5
- export {
6
- getEventHandlerName
7
- };
@@ -1,22 +0,0 @@
1
- const TEXT_STYLE_KEYS = [
2
- "color",
3
- "whiteSpace",
4
- "direction",
5
- "hyphens",
6
- "overflowWrap"
7
- ];
8
- const isTextStyle = (key) => {
9
- return TEXT_STYLE_KEYS.includes(key) || key.startsWith("font") || key.startsWith("text") || key.startsWith("letter") || key.startsWith("line") || key.startsWith("word") || key.startsWith("writing");
10
- };
11
- const extractTextStyles = (styles) => {
12
- const textStyles = {};
13
- Object.entries(styles).forEach(([key, value]) => {
14
- if (isTextStyle(key)) {
15
- textStyles[key] = value;
16
- }
17
- });
18
- return textStyles;
19
- };
20
- export {
21
- extractTextStyles
22
- };
@@ -1,4 +0,0 @@
1
- const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
2
- export {
3
- fastClone
4
- };
@@ -1,11 +0,0 @@
1
- import { evaluate } from "./evaluate.js";
2
- const createEventHandler = (value, options) => (event) => evaluate({
3
- code: value,
4
- context: options.context,
5
- state: options.state,
6
- event,
7
- isExpression: false
8
- });
9
- export {
10
- createEventHandler
11
- };
@@ -1,18 +0,0 @@
1
- import { getEventHandlerName } from "./event-handler-name.js";
2
- import { createEventHandler } from "./get-block-actions-handler.js";
3
- function getBlockActions(options) {
4
- var _a;
5
- const obj = {};
6
- const optionActions = (_a = options.block.actions) != null ? _a : {};
7
- for (const key in optionActions) {
8
- if (!optionActions.hasOwnProperty(key)) {
9
- continue;
10
- }
11
- const value = optionActions[key];
12
- obj[getEventHandlerName(key)] = createEventHandler(value, options);
13
- }
14
- return obj;
15
- }
16
- export {
17
- getBlockActions
18
- };
@@ -1,28 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- function getBlockComponentOptions(block) {
21
- var _a;
22
- return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
23
- builderBlock: block
24
- });
25
- }
26
- export {
27
- getBlockComponentOptions
28
- };
@@ -1,53 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { TARGET } from "../constants/target.js";
21
- import { convertStyleMapToCSSArray } from "../helpers/css.js";
22
- import { transformBlockProperties } from "./transform-block-properties.js";
23
- const extractRelevantRootBlockProperties = (block) => {
24
- return { href: block.href };
25
- };
26
- function getBlockProperties(block) {
27
- var _a;
28
- const properties = __spreadProps(__spreadValues(__spreadValues({}, extractRelevantRootBlockProperties(block)), block.properties), {
29
- "builder-id": block.id,
30
- style: getStyleAttribute(block.style),
31
- class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
32
- });
33
- return transformBlockProperties(properties);
34
- }
35
- function getStyleAttribute(style) {
36
- if (!style) {
37
- return void 0;
38
- }
39
- switch (TARGET) {
40
- case "svelte":
41
- case "vue2":
42
- case "vue3":
43
- case "solid":
44
- return convertStyleMapToCSSArray(style).join(" ");
45
- case "qwik":
46
- case "reactNative":
47
- case "react":
48
- return style;
49
- }
50
- }
51
- export {
52
- getBlockProperties
53
- };
@@ -1,13 +0,0 @@
1
- import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
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
- const url = new URL(`localhost:3000/about-us?${querystring}`);
4
- describe("Get Builder SearchParams", () => {
5
- test("correctly converts URLSearchParams to object", () => {
6
- const output = convertSearchParamsToQueryObject(url.searchParams);
7
- expect(output).toMatchSnapshot();
8
- });
9
- test("correctly extracts all builder params from a query object", () => {
10
- const output = getBuilderSearchParams(convertSearchParamsToQueryObject(url.searchParams));
11
- expect(output).toMatchSnapshot();
12
- });
13
- });
@@ -1,38 +0,0 @@
1
- import { isBrowser } from "../is-browser.js";
2
- const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
3
- const BUILDER_OPTIONS_PREFIX = "options.";
4
- const convertSearchParamsToQueryObject = (searchParams) => {
5
- const options = {};
6
- searchParams.forEach((value, key) => {
7
- options[key] = value;
8
- });
9
- return options;
10
- };
11
- const getBuilderSearchParams = (_options) => {
12
- if (!_options) {
13
- return {};
14
- }
15
- const options = normalizeSearchParams(_options);
16
- const newOptions = {};
17
- Object.keys(options).forEach((key) => {
18
- if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
19
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
20
- newOptions[trimmedKey] = options[key];
21
- }
22
- });
23
- return newOptions;
24
- };
25
- const getBuilderSearchParamsFromWindow = () => {
26
- if (!isBrowser()) {
27
- return {};
28
- }
29
- const searchParams = new URLSearchParams(window.location.search);
30
- return getBuilderSearchParams(searchParams);
31
- };
32
- const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
33
- export {
34
- convertSearchParamsToQueryObject,
35
- getBuilderSearchParams,
36
- getBuilderSearchParamsFromWindow,
37
- normalizeSearchParams
38
- };
@@ -1,99 +0,0 @@
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 {
22
- getContentVariationCookie,
23
- setContentVariationCookie
24
- } from "../../helpers/ab-tests.js";
25
- import { checkIsDefined } from "../../helpers/nullable.js";
26
- const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
27
- const getRandomVariationId = ({
28
- id,
29
- variations
30
- }) => {
31
- var _a;
32
- let n = 0;
33
- const random = Math.random();
34
- for (const id2 in variations) {
35
- const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
36
- n += testRatio;
37
- if (random < n) {
38
- return id2;
39
- }
40
- }
41
- return id;
42
- };
43
- const getTestFields = ({
44
- item,
45
- testGroupId
46
- }) => {
47
- const variationValue = item.variations[testGroupId];
48
- if (testGroupId === item.id || !variationValue) {
49
- return {
50
- testVariationId: item.id,
51
- testVariationName: "Default"
52
- };
53
- } else {
54
- return {
55
- data: variationValue.data,
56
- testVariationId: variationValue.id,
57
- testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
58
- };
59
- }
60
- };
61
- const getContentVariation = (_0) => __async(void 0, [_0], function* ({
62
- item,
63
- canTrack
64
- }) {
65
- const testGroupId = yield getContentVariationCookie({
66
- canTrack,
67
- contentId: item.id
68
- });
69
- const testFields = testGroupId ? getTestFields({ item, testGroupId }) : void 0;
70
- if (testFields) {
71
- return testFields;
72
- } else {
73
- const randomVariationId = getRandomVariationId({
74
- variations: item.variations,
75
- id: item.id
76
- });
77
- setContentVariationCookie({
78
- contentId: item.id,
79
- value: randomVariationId,
80
- canTrack
81
- }).catch((err) => {
82
- console.error("could not store A/B test variation: ", err);
83
- });
84
- return getTestFields({ item, testGroupId: randomVariationId });
85
- }
86
- });
87
- const handleABTesting = (_0) => __async(void 0, [_0], function* ({
88
- item,
89
- canTrack
90
- }) {
91
- if (!checkIsBuilderContentWithVariations(item)) {
92
- return;
93
- }
94
- const variationValue = yield getContentVariation({ item, canTrack });
95
- Object.assign(item, variationValue);
96
- });
97
- export {
98
- handleABTesting
99
- };
@@ -1,60 +0,0 @@
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 { flatten } from "../../helpers/flatten.js";
18
- import {
19
- getBuilderSearchParamsFromWindow,
20
- normalizeSearchParams
21
- } from "../get-builder-search-params/index.js";
22
- import { DEFAULT_API_VERSION } from "../../types/api-version";
23
- const generateContentUrl = (options) => {
24
- const {
25
- limit = 30,
26
- userAttributes,
27
- query,
28
- noTraverse = false,
29
- model,
30
- apiKey,
31
- includeRefs = true,
32
- locale,
33
- apiVersion = DEFAULT_API_VERSION
34
- } = options;
35
- if (!apiKey) {
36
- throw new Error("Missing API key");
37
- }
38
- if (!["v2", "v3"].includes(apiVersion)) {
39
- throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
40
- }
41
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
42
- const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
43
- const flattened = flatten(queryOptions);
44
- for (const key in flattened) {
45
- url.searchParams.set(key, String(flattened[key]));
46
- }
47
- if (userAttributes) {
48
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
49
- }
50
- if (query) {
51
- const flattened2 = flatten({ query });
52
- for (const key in flattened2) {
53
- url.searchParams.set(key, JSON.stringify(flattened2[key]));
54
- }
55
- }
56
- return url;
57
- };
58
- export {
59
- generateContentUrl
60
- };
@@ -1,82 +0,0 @@
1
- import { generateContentUrl } from "./generate-content-url";
2
- const testKey = "YJIGb4i01jvw0SRdL5Bt";
3
- const testModel = "page";
4
- const testId = "c1b81bab59704599b997574eb0736def";
5
- const options = {
6
- cachebust: "true",
7
- noCache: "true",
8
- "overrides.037948e52eaf4743afed464f02c70da4": "037948e52eaf4743afed464f02c70da4",
9
- "overrides.page": "037948e52eaf4743afed464f02c70da4",
10
- "overrides.page:/": "037948e52eaf4743afed464f02c70da4",
11
- preview: "page"
12
- };
13
- describe("Generate Content URL", () => {
14
- test("generates the proper value for a simple query", () => {
15
- const output = generateContentUrl({
16
- apiKey: testKey,
17
- model: testModel,
18
- query: { id: testId }
19
- });
20
- expect(output).toMatchSnapshot();
21
- });
22
- test("Handles overrides correctly", () => {
23
- const output = generateContentUrl({
24
- apiKey: testKey,
25
- model: testModel,
26
- query: { id: testId },
27
- options
28
- });
29
- expect(output).toMatchSnapshot();
30
- });
31
- test("generate content url with apiVersion as default", () => {
32
- const output = generateContentUrl({
33
- apiKey: testKey,
34
- model: testModel,
35
- query: { id: testId },
36
- options
37
- });
38
- expect(output).toMatchSnapshot();
39
- });
40
- test("generate content url with apiVersion as v2", () => {
41
- const output = generateContentUrl({
42
- apiKey: testKey,
43
- model: testModel,
44
- query: { id: testId },
45
- options,
46
- apiVersion: "v2"
47
- });
48
- expect(output).toMatchSnapshot();
49
- });
50
- test("generate content url with apiVersion as v3", () => {
51
- const output = generateContentUrl({
52
- apiKey: testKey,
53
- model: testModel,
54
- query: { id: testId },
55
- options,
56
- apiVersion: "v3"
57
- });
58
- expect(output).toMatchSnapshot();
59
- });
60
- test("throw error when trying to generate content url with apiVersion as v1", () => {
61
- expect(() => {
62
- generateContentUrl({
63
- apiKey: testKey,
64
- model: testModel,
65
- query: { id: testId },
66
- options,
67
- apiVersion: "v1"
68
- });
69
- }).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'v1'`);
70
- });
71
- test("throw error when trying to generate content url with an invalid apiVersion value", () => {
72
- expect(() => {
73
- generateContentUrl({
74
- apiKey: testKey,
75
- model: testModel,
76
- query: { id: testId },
77
- options,
78
- apiVersion: "INVALID_API_VERSION"
79
- });
80
- }).toThrow(`Invalid apiVersion: expected 'v2' or 'v3', received 'INVALID_API_VERSION'`);
81
- });
82
- });
@@ -1,83 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __async = (__this, __arguments, generator) => {
21
- return new Promise((resolve, reject) => {
22
- var fulfilled = (value) => {
23
- try {
24
- step(generator.next(value));
25
- } catch (e) {
26
- reject(e);
27
- }
28
- };
29
- var rejected = (value) => {
30
- try {
31
- step(generator.throw(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- };
36
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
- step((generator = generator.apply(__this, __arguments)).next());
38
- });
39
- };
40
- import { logger } from "../../helpers/logger.js";
41
- import { fetch } from "../get-fetch.js";
42
- import { handleABTesting } from "./ab-testing.js";
43
- import { generateContentUrl } from "./generate-content-url.js";
44
- function getContent(options) {
45
- return __async(this, null, function* () {
46
- const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
47
- if (allContent && "results" in allContent) {
48
- return (allContent == null ? void 0 : allContent.results[0]) || null;
49
- }
50
- return null;
51
- });
52
- }
53
- function getAllContent(options) {
54
- return __async(this, null, function* () {
55
- try {
56
- const url = generateContentUrl(options);
57
- const res = yield fetch(url.href);
58
- const content = yield res.json();
59
- if ("status" in content && !("results" in content)) {
60
- logger.error("Error fetching data. ", { url, content, options });
61
- return content;
62
- }
63
- const canTrack = options.canTrack !== false;
64
- try {
65
- if (canTrack && Array.isArray(content.results)) {
66
- for (const item of content.results) {
67
- yield handleABTesting({ item, canTrack });
68
- }
69
- }
70
- } catch (e) {
71
- logger.error("Could not setup A/B testing. ", e);
72
- }
73
- return content;
74
- } catch (error) {
75
- logger.error("Error fetching data. ", error);
76
- return null;
77
- }
78
- });
79
- }
80
- export {
81
- getAllContent,
82
- getContent
83
- };
File without changes