@builder.io/sdk-react 0.4.5 → 0.5.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/dist/{sdk/blocks → blocks}/BaseText.d.ts +0 -1
  2. package/dist/{sdk/blocks → blocks}/BaseText.js +2 -2
  3. package/dist/{sdk/blocks → blocks}/button/button.d.ts +3 -2
  4. package/dist/{sdk/blocks → blocks}/button/button.js +3 -5
  5. package/dist/blocks/button/component-info.d.ts +2 -0
  6. package/dist/{sdk/blocks → blocks}/button/component-info.js +9 -13
  7. package/dist/blocks/columns/columns.d.ts +16 -0
  8. package/dist/{sdk/blocks → blocks}/columns/columns.js +13 -19
  9. package/dist/blocks/columns/component-info.d.ts +2 -0
  10. package/dist/{sdk/blocks → blocks}/columns/component-info.js +62 -83
  11. package/dist/blocks/custom-code/component-info.d.ts +2 -0
  12. package/dist/{sdk/blocks → blocks}/custom-code/component-info.js +7 -11
  13. package/dist/{sdk/blocks → blocks}/custom-code/custom-code.d.ts +0 -1
  14. package/dist/{sdk/blocks → blocks}/custom-code/custom-code.js +1 -1
  15. package/dist/blocks/embed/component-info.d.ts +2 -0
  16. package/dist/{sdk/blocks → blocks}/embed/component-info.js +8 -15
  17. package/dist/{sdk/blocks → blocks}/embed/embed.d.ts +0 -1
  18. package/dist/{sdk/blocks → blocks}/embed/embed.js +1 -1
  19. package/dist/blocks/embed/helpers.js +2 -0
  20. package/dist/blocks/form/component-info.d.ts +2 -0
  21. package/dist/{sdk/blocks → blocks}/form/component-info.js +94 -129
  22. package/dist/blocks/form/form.d.ts +2 -0
  23. package/dist/blocks/form/form.js +6 -0
  24. package/dist/blocks/fragment/component-info.d.ts +2 -0
  25. package/dist/{sdk/blocks → blocks}/fragment/component-info.js +1 -1
  26. package/dist/{sdk/blocks → blocks}/fragment/fragment.d.ts +0 -1
  27. package/dist/{sdk/blocks → blocks}/fragment/fragment.js +1 -1
  28. package/dist/blocks/helpers.d.ts +13 -0
  29. package/dist/blocks/helpers.js +40 -0
  30. package/dist/blocks/image/component-info.d.ts +2 -0
  31. package/dist/{sdk/blocks → blocks}/image/component-info.js +33 -63
  32. package/dist/{sdk/blocks → blocks}/image/image.d.ts +0 -1
  33. package/dist/{sdk/blocks → blocks}/image/image.helpers.js +2 -11
  34. package/dist/{sdk/blocks → blocks}/image/image.js +7 -7
  35. package/dist/blocks/img/component-info.d.ts +2 -0
  36. package/dist/{sdk/blocks → blocks}/img/component-info.js +4 -6
  37. package/dist/{sdk/blocks → blocks}/img/img.d.ts +3 -2
  38. package/dist/{sdk/blocks → blocks}/img/img.js +1 -1
  39. package/dist/blocks/input/component-info.d.ts +2 -0
  40. package/dist/{sdk/blocks → blocks}/input/component-info.js +15 -40
  41. package/dist/{sdk/blocks → blocks}/input/input.d.ts +3 -2
  42. package/dist/{sdk/blocks → blocks}/input/input.js +1 -1
  43. package/dist/blocks/raw-text/component-info.d.ts +2 -0
  44. package/dist/{sdk/blocks → blocks}/raw-text/component-info.js +3 -5
  45. package/dist/{sdk/blocks → blocks}/raw-text/raw-text.d.ts +0 -1
  46. package/dist/blocks/raw-text/raw-text.js +6 -0
  47. package/dist/blocks/section/component-info.d.ts +2 -0
  48. package/dist/{sdk/blocks → blocks}/section/component-info.js +13 -18
  49. package/dist/{sdk/blocks → blocks}/section/section.d.ts +3 -2
  50. package/dist/{sdk/blocks → blocks}/section/section.js +1 -1
  51. package/dist/blocks/select/component-info.d.ts +2 -0
  52. package/dist/{sdk/blocks → blocks}/select/component-info.js +22 -34
  53. package/dist/{sdk/blocks → blocks}/select/select.d.ts +3 -2
  54. package/dist/{sdk/blocks → blocks}/select/select.js +1 -1
  55. package/dist/blocks/submit-button/component-info.d.ts +2 -0
  56. package/dist/{sdk/blocks → blocks}/submit-button/component-info.js +5 -7
  57. package/dist/{sdk/blocks → blocks}/submit-button/submit-button.d.ts +3 -2
  58. package/dist/{sdk/blocks → blocks}/submit-button/submit-button.js +1 -1
  59. package/dist/blocks/symbol/component-info.d.ts +2 -0
  60. package/dist/{sdk/blocks → blocks}/symbol/component-info.js +12 -17
  61. package/dist/blocks/symbol/symbol.d.ts +23 -0
  62. package/dist/blocks/symbol/symbol.helpers.d.ts +14 -0
  63. package/dist/blocks/symbol/symbol.helpers.js +31 -0
  64. package/dist/blocks/symbol/symbol.js +45 -0
  65. package/dist/blocks/text/component-info.d.ts +2 -0
  66. package/dist/{sdk/blocks → blocks}/text/component-info.js +6 -7
  67. package/dist/{sdk/blocks → blocks}/text/text.d.ts +0 -1
  68. package/dist/{sdk/blocks → blocks}/text/text.js +2 -2
  69. package/dist/blocks/textarea/component-info.d.ts +2 -0
  70. package/dist/{sdk/blocks → blocks}/textarea/component-info.js +13 -19
  71. package/dist/{sdk/blocks → blocks}/textarea/textarea.d.ts +3 -2
  72. package/dist/{sdk/blocks → blocks}/textarea/textarea.js +1 -1
  73. package/dist/blocks/video/component-info.d.ts +2 -0
  74. package/dist/{sdk/blocks → blocks}/video/component-info.js +35 -55
  75. package/dist/{sdk/blocks → blocks}/video/video.d.ts +1 -1
  76. package/dist/{sdk/blocks → blocks}/video/video.js +2 -2
  77. package/dist/{sdk/components → components}/block/block.d.ts +2 -4
  78. package/dist/components/block/block.helpers.d.ts +13 -0
  79. package/dist/{sdk/components → components}/block/block.helpers.js +12 -29
  80. package/dist/components/block/block.js +94 -0
  81. package/dist/{sdk/components → components}/block/components/block-styles.d.ts +0 -1
  82. package/dist/{sdk/components → components}/block/components/block-styles.js +1 -1
  83. package/dist/components/block/components/block-wrapper.d.ts +16 -0
  84. package/dist/components/block/components/block-wrapper.js +36 -0
  85. package/dist/components/block/components/component-ref/component-ref.d.ts +3 -0
  86. package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
  87. package/dist/components/block/components/component-ref/component-ref.helpers.js +22 -0
  88. package/dist/components/block/components/component-ref/component-ref.js +23 -0
  89. package/dist/components/block/components/interactive-element.d.ts +11 -0
  90. package/dist/components/block/components/interactive-element.js +20 -0
  91. package/dist/components/block/components/repeated-block.d.ts +9 -0
  92. package/dist/{sdk/components → components}/block/components/repeated-block.js +3 -3
  93. package/dist/{sdk/components → components}/blocks/blocks-wrapper.d.ts +2 -5
  94. package/dist/{sdk/components → components}/blocks/blocks-wrapper.js +3 -3
  95. package/dist/components/blocks/blocks.d.ts +8 -0
  96. package/dist/{sdk/components → components}/blocks/blocks.js +9 -3
  97. package/dist/components/content/components/enable-editor.d.ts +9 -0
  98. package/dist/{sdk/components → components}/content/components/enable-editor.js +31 -39
  99. package/dist/{sdk/components/content/components/content-styles.d.ts → components/content/components/styles.d.ts} +1 -2
  100. package/dist/{sdk/components/content/components/content-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
  101. package/dist/{sdk/components/content/components/content-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
  102. package/dist/{sdk/components/content/components/content-styles.js → components/content/components/styles.js} +3 -3
  103. package/dist/components/content/content.d.ts +3 -0
  104. package/dist/components/content/content.helpers.d.ts +7 -0
  105. package/dist/components/content/content.helpers.js +30 -0
  106. package/dist/{sdk/components → components}/content/content.js +26 -40
  107. package/dist/{sdk/components/render-content/render-content.types.d.ts → components/content/content.types.d.ts} +4 -4
  108. package/dist/components/content-variants/content-variants.d.ts +9 -0
  109. package/dist/{sdk/components/render-content-variants/render-content-variants.js → components/content-variants/content-variants.js} +23 -22
  110. package/dist/{sdk/components/render-content-variants/render-content-variants.types.d.ts → components/content-variants/content-variants.types.d.ts} +5 -5
  111. package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.d.ts +7 -7
  112. package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +13 -22
  113. package/dist/{sdk/components → components}/inlined-script.d.ts +0 -1
  114. package/dist/{sdk/components → components}/inlined-script.js +1 -1
  115. package/dist/{sdk/components → components}/inlined-styles.d.ts +0 -1
  116. package/dist/{sdk/components → components}/inlined-styles.js +1 -1
  117. package/dist/{sdk/constants → constants}/builder-registered-components.js +34 -13
  118. package/dist/{sdk/constants → constants}/device-sizes.js +9 -8
  119. package/dist/constants/sdk-version.d.ts +1 -0
  120. package/dist/constants/sdk-version.js +1 -0
  121. package/dist/{sdk/context → context}/builder.context.js +1 -1
  122. package/dist/context/components.context.d.ts +3 -0
  123. package/dist/context/components.context.js +2 -0
  124. package/dist/{sdk/context → context}/types.d.ts +1 -1
  125. package/dist/functions/acorn_interpreter.d.ts +1 -0
  126. package/dist/functions/acorn_interpreter.js +3027 -0
  127. package/dist/functions/apply-patch-with-mutation.d.ts +10 -0
  128. package/dist/functions/apply-patch-with-mutation.js +54 -0
  129. package/dist/functions/apply-patch-with-mutation.test.js +53 -0
  130. package/dist/functions/evaluate/acorn.d.ts +0 -0
  131. package/dist/functions/evaluate/acorn.js +2432 -0
  132. package/dist/{sdk/functions → functions/evaluate}/evaluate.d.ts +5 -2
  133. package/dist/functions/evaluate/evaluate.js +70 -0
  134. package/dist/functions/evaluate/evaluate.test.js +23 -0
  135. package/dist/functions/evaluate/index.d.ts +1 -0
  136. package/dist/functions/evaluate/index.js +1 -0
  137. package/dist/functions/evaluate/interpreter.d.ts +2 -0
  138. package/dist/functions/evaluate/interpreter.js +3853 -0
  139. package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
  140. package/dist/functions/evaluate/non-node-runtime.js +84 -0
  141. package/dist/functions/evaluate/types.d.ts +10 -0
  142. package/dist/functions/evaluate.d.ts +23 -0
  143. package/dist/{sdk/functions → functions}/evaluate.js +28 -9
  144. package/dist/{sdk/functions → functions}/evaluate.test.js +11 -5
  145. package/dist/{sdk/functions → functions}/extract-text-styles.js +2 -14
  146. package/dist/{sdk/functions → functions}/get-block-actions-handler.js +3 -3
  147. package/dist/{sdk/functions → functions}/get-block-actions.d.ts +1 -0
  148. package/dist/functions/get-block-actions.js +28 -0
  149. package/dist/{sdk/functions → functions}/get-block-component-options.js +1 -1
  150. package/dist/functions/get-block-properties.d.ts +6 -0
  151. package/dist/{sdk/functions → functions}/get-block-properties.js +15 -9
  152. package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.js +1 -1
  153. package/dist/{sdk/functions → functions}/get-builder-search-params/index.js +3 -7
  154. package/dist/{sdk/functions → functions}/get-content/generate-content-url.js +7 -5
  155. package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.js +31 -17
  156. package/dist/{sdk/functions → functions}/get-content/index.d.ts +2 -6
  157. package/dist/{sdk/functions → functions}/get-content/index.js +26 -6
  158. package/dist/functions/get-content/processCookies.d.ts +2 -0
  159. package/dist/functions/get-content/processCookies.js +3 -0
  160. package/dist/{sdk/functions → functions}/get-processed-block.d.ts +1 -1
  161. package/dist/{sdk/functions → functions}/get-processed-block.js +11 -7
  162. package/dist/{sdk/functions → functions}/get-processed-block.test.js +8 -6
  163. package/dist/{sdk/functions → functions}/get-react-native-block-styles.d.ts +1 -1
  164. package/dist/{sdk/functions → functions}/get-react-native-block-styles.js +2 -2
  165. package/dist/{sdk/functions → functions}/if-target.d.ts +1 -1
  166. package/dist/{sdk/functions → functions}/if-target.js +1 -1
  167. package/dist/functions/is-editing.js +5 -0
  168. package/dist/functions/is-non-node-server.d.ts +4 -0
  169. package/dist/functions/is-non-node-server.js +8 -0
  170. package/dist/{sdk/functions → functions}/on-change.js +1 -1
  171. package/dist/{sdk/functions → functions}/on-change.test.js +13 -3
  172. package/dist/{sdk/functions → functions}/register-component.d.ts +2 -1
  173. package/dist/functions/register-component.js +38 -0
  174. package/dist/{sdk/functions → functions}/register.js +2 -2
  175. package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.js +13 -5
  176. package/dist/{sdk/functions → functions}/set-editor-settings.js +1 -1
  177. package/dist/functions/set.js +14 -0
  178. package/dist/{sdk/functions → functions}/set.test.js +9 -3
  179. package/dist/{sdk/functions → functions}/track/helpers.js +6 -11
  180. package/dist/{sdk/functions → functions}/track/index.js +26 -14
  181. package/dist/{sdk/functions → functions}/track/interaction.js +15 -16
  182. package/dist/functions/transform-block-properties.d.ts +1 -0
  183. package/dist/{sdk/functions → functions}/transform-block-properties.js +2 -0
  184. package/dist/{sdk/helpers → helpers}/ab-tests.d.ts +2 -2
  185. package/dist/{sdk/helpers → helpers}/ab-tests.js +42 -30
  186. package/dist/{sdk/helpers → helpers}/canTrack.js +1 -1
  187. package/dist/{sdk/helpers → helpers}/cookie.d.ts +2 -2
  188. package/dist/{sdk/helpers → helpers}/cookie.js +13 -26
  189. package/dist/{sdk/helpers → helpers}/css.d.ts +1 -1
  190. package/dist/{sdk/helpers → helpers}/css.js +1 -1
  191. package/dist/{sdk/helpers → helpers}/flatten.js +8 -8
  192. package/dist/{sdk/helpers → helpers}/localStorage.d.ts +2 -2
  193. package/dist/{sdk/helpers → helpers}/localStorage.js +2 -2
  194. package/dist/{sdk/helpers → helpers}/logger.js +1 -1
  195. package/dist/helpers/preview-lru-cache/get.d.ts +1 -0
  196. package/dist/helpers/preview-lru-cache/get.js +7 -0
  197. package/dist/helpers/preview-lru-cache/helpers.d.ts +1 -0
  198. package/dist/helpers/preview-lru-cache/helpers.js +9 -0
  199. package/dist/helpers/preview-lru-cache/init.d.ts +6 -0
  200. package/dist/helpers/preview-lru-cache/init.js +15 -0
  201. package/dist/helpers/preview-lru-cache/set.d.ts +7 -0
  202. package/dist/helpers/preview-lru-cache/set.js +9 -0
  203. package/dist/helpers/preview-lru-cache/types.d.ts +12 -0
  204. package/dist/helpers/preview-lru-cache/types.js +6 -0
  205. package/dist/{sdk/helpers → helpers}/sessionId.d.ts +2 -2
  206. package/dist/{sdk/helpers → helpers}/sessionId.js +11 -4
  207. package/dist/{sdk/helpers → helpers}/uuid.js +1 -1
  208. package/dist/{sdk/helpers → helpers}/visitorId.d.ts +1 -1
  209. package/dist/{sdk/helpers → helpers}/visitorId.js +7 -4
  210. package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.d.ts +2 -2
  211. package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.js +2 -2
  212. package/dist/{sdk/index.d.ts → index.d.ts} +2 -2
  213. package/dist/{sdk/index.js → index.js} +1 -1
  214. package/dist/scripts/init-editing.js +110 -0
  215. package/dist/types/builder-props.d.ts +9 -0
  216. package/dist/{sdk/types → types}/components.d.ts +8 -2
  217. package/dist/{sdk/types → types}/enforced-partials.d.ts +1 -1
  218. package/dist/types/targets.d.ts +1 -0
  219. package/dist/{sdk/types → types}/typescript.d.ts +3 -0
  220. package/package.json +8 -16
  221. package/server/package.json +5 -0
  222. package/dist/sdk/blocks/button/component-info.d.ts +0 -2
  223. package/dist/sdk/blocks/columns/columns.d.ts +0 -16
  224. package/dist/sdk/blocks/columns/component-info.d.ts +0 -2
  225. package/dist/sdk/blocks/custom-code/component-info.d.ts +0 -2
  226. package/dist/sdk/blocks/embed/component-info.d.ts +0 -2
  227. package/dist/sdk/blocks/embed/helpers.js +0 -6
  228. package/dist/sdk/blocks/form/component-info.d.ts +0 -2
  229. package/dist/sdk/blocks/form/form.d.ts +0 -40
  230. package/dist/sdk/blocks/form/form.js +0 -203
  231. package/dist/sdk/blocks/fragment/component-info.d.ts +0 -2
  232. package/dist/sdk/blocks/image/component-info.d.ts +0 -2
  233. package/dist/sdk/blocks/img/component-info.d.ts +0 -2
  234. package/dist/sdk/blocks/input/component-info.d.ts +0 -2
  235. package/dist/sdk/blocks/raw-text/component-info.d.ts +0 -2
  236. package/dist/sdk/blocks/raw-text/raw-text.js +0 -6
  237. package/dist/sdk/blocks/section/component-info.d.ts +0 -2
  238. package/dist/sdk/blocks/select/component-info.d.ts +0 -2
  239. package/dist/sdk/blocks/submit-button/component-info.d.ts +0 -2
  240. package/dist/sdk/blocks/symbol/component-info.d.ts +0 -2
  241. package/dist/sdk/blocks/symbol/symbol.d.ts +0 -21
  242. package/dist/sdk/blocks/symbol/symbol.js +0 -71
  243. package/dist/sdk/blocks/text/component-info.d.ts +0 -2
  244. package/dist/sdk/blocks/textarea/component-info.d.ts +0 -2
  245. package/dist/sdk/blocks/util.d.ts +0 -4
  246. package/dist/sdk/blocks/util.js +0 -13
  247. package/dist/sdk/blocks/video/component-info.d.ts +0 -2
  248. package/dist/sdk/components/block/block.helpers.d.ts +0 -12
  249. package/dist/sdk/components/block/block.js +0 -124
  250. package/dist/sdk/components/block/components/component.d.ts +0 -20
  251. package/dist/sdk/components/block/components/component.js +0 -11
  252. package/dist/sdk/components/block/components/repeated-block.d.ts +0 -11
  253. package/dist/sdk/components/blocks/blocks.d.ts +0 -10
  254. package/dist/sdk/components/content/components/enable-editor.d.ts +0 -13
  255. package/dist/sdk/components/content/content.d.ts +0 -4
  256. package/dist/sdk/components/content/content.helpers.d.ts +0 -7
  257. package/dist/sdk/components/content/content.helpers.js +0 -30
  258. package/dist/sdk/components/content/content.types.d.ts +0 -38
  259. package/dist/sdk/components/content-variants/content-variants.d.ts +0 -5
  260. package/dist/sdk/components/content-variants/content-variants.js +0 -37
  261. package/dist/sdk/components/content-variants/helpers.d.ts +0 -17
  262. package/dist/sdk/components/content-variants/helpers.js +0 -184
  263. package/dist/sdk/components/render-block/block-styles.d.ts +0 -9
  264. package/dist/sdk/components/render-block/block-styles.js +0 -66
  265. package/dist/sdk/components/render-block/render-block.d.ts +0 -9
  266. package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -12
  267. package/dist/sdk/components/render-block/render-block.helpers.js +0 -86
  268. package/dist/sdk/components/render-block/render-block.js +0 -115
  269. package/dist/sdk/components/render-block/render-component.d.ts +0 -17
  270. package/dist/sdk/components/render-block/render-component.js +0 -11
  271. package/dist/sdk/components/render-block/render-repeated-block.d.ts +0 -9
  272. package/dist/sdk/components/render-block/render-repeated-block.js +0 -11
  273. package/dist/sdk/components/render-block/types.d.ts +0 -6
  274. package/dist/sdk/components/render-blocks.d.ts +0 -10
  275. package/dist/sdk/components/render-blocks.js +0 -45
  276. package/dist/sdk/components/render-content/builder-editing.d.ts +0 -3
  277. package/dist/sdk/components/render-content/builder-editing.js +0 -6
  278. package/dist/sdk/components/render-content/components/render-styles.d.ts +0 -9
  279. package/dist/sdk/components/render-content/components/render-styles.helpers.d.ts +0 -15
  280. package/dist/sdk/components/render-content/components/render-styles.helpers.js +0 -59
  281. package/dist/sdk/components/render-content/components/render-styles.js +0 -32
  282. package/dist/sdk/components/render-content/index.d.ts +0 -1
  283. package/dist/sdk/components/render-content/index.js +0 -1
  284. package/dist/sdk/components/render-content/render-content.d.ts +0 -4
  285. package/dist/sdk/components/render-content/render-content.helpers.d.ts +0 -7
  286. package/dist/sdk/components/render-content/render-content.helpers.js +0 -30
  287. package/dist/sdk/components/render-content/render-content.js +0 -343
  288. package/dist/sdk/components/render-content/wrap-component-ref.d.ts +0 -6
  289. package/dist/sdk/components/render-content/wrap-component-ref.js +0 -6
  290. package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -10
  291. package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
  292. package/dist/sdk/components/render-inlined-styles.js +0 -6
  293. package/dist/sdk/constants/sdk-version.d.ts +0 -1
  294. package/dist/sdk/constants/sdk-version.js +0 -1
  295. package/dist/sdk/functions/get-block-actions.js +0 -15
  296. package/dist/sdk/functions/get-block-properties.d.ts +0 -7
  297. package/dist/sdk/functions/get-content/ab-testing.d.ts +0 -5
  298. package/dist/sdk/functions/get-content/ab-testing.js +0 -78
  299. package/dist/sdk/functions/is-editing.js +0 -7
  300. package/dist/sdk/functions/register-component.js +0 -26
  301. package/dist/sdk/functions/set.js +0 -21
  302. package/dist/sdk/functions/transform-block-properties.d.ts +0 -1
  303. package/dist/sdk/scripts/init-editing.js +0 -102
  304. package/dist/sdk/types/builder-props.d.ts +0 -10
  305. package/dist/sdk/types/targets.d.ts +0 -3
  306. package/dist/server/functions/get-builder-search-params/index.d.ts +0 -6
  307. package/dist/server/functions/get-builder-search-params/index.js +0 -36
  308. package/dist/server/functions/get-content/ab-testing.d.ts +0 -5
  309. package/dist/server/functions/get-content/ab-testing.js +0 -78
  310. package/dist/server/functions/get-content/generate-content-url.d.ts +0 -2
  311. package/dist/server/functions/get-content/generate-content-url.js +0 -31
  312. package/dist/server/functions/get-content/generate-content-url.test.d.ts +0 -1
  313. package/dist/server/functions/get-content/generate-content-url.test.js +0 -82
  314. package/dist/server/functions/get-content/index.d.ts +0 -11
  315. package/dist/server/functions/get-content/index.js +0 -40
  316. package/dist/server/functions/get-content/types.d.ts +0 -45
  317. package/dist/server/functions/get-fetch.d.ts +0 -1
  318. package/dist/server/functions/get-fetch.js +0 -11
  319. package/dist/server/functions/get-global-this.d.ts +0 -4
  320. package/dist/server/functions/get-global-this.js +0 -15
  321. package/dist/server/functions/is-browser.d.ts +0 -1
  322. package/dist/server/functions/is-browser.js +0 -3
  323. package/dist/server/helpers/ab-tests.d.ts +0 -8
  324. package/dist/server/helpers/ab-tests.js +0 -5
  325. package/dist/server/helpers/cookie.d.ts +0 -15
  326. package/dist/server/helpers/cookie.js +0 -65
  327. package/dist/server/helpers/flatten.d.ts +0 -6
  328. package/dist/server/helpers/flatten.js +0 -19
  329. package/dist/server/helpers/logger.d.ts +0 -5
  330. package/dist/server/helpers/logger.js +0 -6
  331. package/dist/server/helpers/nullable.d.ts +0 -2
  332. package/dist/server/helpers/nullable.js +0 -1
  333. package/dist/server/helpers/url.d.ts +0 -6
  334. package/dist/server/helpers/url.js +0 -15
  335. package/dist/server/types/api-version.d.ts +0 -2
  336. package/dist/server/types/api-version.js +0 -1
  337. package/dist/server/types/builder-block.d.ts +0 -66
  338. package/dist/server/types/builder-block.js +0 -1
  339. package/dist/server/types/builder-content.d.ts +0 -46
  340. package/dist/server/types/builder-content.js +0 -1
  341. package/dist/server/types/can-track.d.ts +0 -3
  342. package/dist/server/types/can-track.js +0 -1
  343. package/dist/server/types/input.d.ts +0 -121
  344. package/dist/server/types/input.js +0 -1
  345. package/dist/server/types/typescript.d.ts +0 -5
  346. package/dist/server/types/typescript.js +0 -1
  347. /package/dist/{sdk/blocks → blocks}/embed/helpers.d.ts +0 -0
  348. /package/dist/{sdk/blocks → blocks}/image/image.helpers.d.ts +0 -0
  349. /package/dist/{sdk/components → components}/block/types.d.ts +0 -0
  350. /package/dist/{sdk/components → components}/block/types.js +0 -0
  351. /package/dist/{sdk/components/render-block/types.js → components/content/content.types.js} +0 -0
  352. /package/dist/{sdk/components → components}/content/index.d.ts +0 -0
  353. /package/dist/{sdk/components → components}/content/index.js +0 -0
  354. /package/dist/{sdk/components → components}/content/wrap-component-ref.d.ts +0 -0
  355. /package/dist/{sdk/components → components}/content/wrap-component-ref.js +0 -0
  356. /package/dist/{sdk/components/content/content.types.js → components/content-variants/content-variants.types.js} +0 -0
  357. /package/dist/{sdk/constants → constants}/builder-registered-components.d.ts +0 -0
  358. /package/dist/{sdk/constants → constants}/device-sizes.d.ts +0 -0
  359. /package/dist/{sdk/constants → constants}/target.d.ts +0 -0
  360. /package/dist/{sdk/constants → constants}/target.js +0 -0
  361. /package/dist/{sdk/context → context}/builder.context.d.ts +0 -0
  362. /package/dist/{sdk/context → context}/types.js +0 -0
  363. /package/dist/{sdk/components/render-content-variants/render-content-variants.types.js → functions/apply-patch-with-mutation.test.d.ts} +0 -0
  364. /package/dist/{sdk/functions → functions}/camel-to-kebab-case.d.ts +0 -0
  365. /package/dist/{sdk/functions → functions}/camel-to-kebab-case.js +0 -0
  366. /package/dist/{sdk/components/render-content/render-content.types.js → functions/evaluate/evaluate.test.d.ts} +0 -0
  367. /package/dist/{sdk/functions/get-content → functions/evaluate}/types.js +0 -0
  368. /package/dist/{sdk/functions → functions}/evaluate.test.d.ts +0 -0
  369. /package/dist/{sdk/functions → functions}/event-handler-name.d.ts +0 -0
  370. /package/dist/{sdk/functions → functions}/event-handler-name.js +0 -0
  371. /package/dist/{sdk/functions → functions}/extract-text-styles.d.ts +0 -0
  372. /package/dist/{sdk/functions → functions}/fast-clone.d.ts +0 -0
  373. /package/dist/{sdk/functions → functions}/fast-clone.js +0 -0
  374. /package/dist/{sdk/functions → functions}/get-block-actions-handler.d.ts +0 -0
  375. /package/dist/{sdk/functions → functions}/get-block-component-options.d.ts +0 -0
  376. /package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.d.ts +0 -0
  377. /package/dist/{sdk/functions → functions}/get-builder-search-params/index.d.ts +0 -0
  378. /package/dist/{sdk/functions → functions}/get-content/generate-content-url.d.ts +0 -0
  379. /package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.d.ts +0 -0
  380. /package/dist/{sdk/functions → functions}/get-content/types.d.ts +0 -0
  381. /package/dist/{server/functions → functions}/get-content/types.js +0 -0
  382. /package/dist/{sdk/functions → functions}/get-fetch.d.ts +0 -0
  383. /package/dist/{sdk/functions → functions}/get-fetch.js +0 -0
  384. /package/dist/{sdk/functions → functions}/get-global-this.d.ts +0 -0
  385. /package/dist/{sdk/functions → functions}/get-global-this.js +0 -0
  386. /package/dist/{sdk/functions → functions}/get-processed-block.test.d.ts +0 -0
  387. /package/dist/{sdk/functions → functions}/is-browser.d.ts +0 -0
  388. /package/dist/{sdk/functions → functions}/is-browser.js +0 -0
  389. /package/dist/{sdk/functions → functions}/is-editing.d.ts +0 -0
  390. /package/dist/{sdk/functions → functions}/is-iframe.d.ts +0 -0
  391. /package/dist/{sdk/functions → functions}/is-iframe.js +0 -0
  392. /package/dist/{sdk/functions → functions}/is-previewing.d.ts +0 -0
  393. /package/dist/{sdk/functions → functions}/is-previewing.js +0 -0
  394. /package/dist/{sdk/functions → functions}/on-change.d.ts +0 -0
  395. /package/dist/{sdk/functions → functions}/on-change.test.d.ts +0 -0
  396. /package/dist/{sdk/functions → functions}/register.d.ts +0 -0
  397. /package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.d.ts +0 -0
  398. /package/dist/{sdk/functions → functions}/set-editor-settings.d.ts +0 -0
  399. /package/dist/{sdk/functions → functions}/set.d.ts +0 -0
  400. /package/dist/{sdk/functions → functions}/set.test.d.ts +0 -0
  401. /package/dist/{sdk/functions → functions}/track/helpers.d.ts +0 -0
  402. /package/dist/{sdk/functions → functions}/track/index.d.ts +0 -0
  403. /package/dist/{sdk/functions → functions}/track/interaction.d.ts +0 -0
  404. /package/dist/{sdk/functions → functions}/transform-block.d.ts +0 -0
  405. /package/dist/{sdk/functions → functions}/transform-block.js +0 -0
  406. /package/dist/{sdk/helpers → helpers}/canTrack.d.ts +0 -0
  407. /package/dist/{sdk/helpers → helpers}/flatten.d.ts +0 -0
  408. /package/dist/{sdk/helpers → helpers}/logger.d.ts +0 -0
  409. /package/dist/{sdk/helpers → helpers}/nullable.d.ts +0 -0
  410. /package/dist/{sdk/helpers → helpers}/nullable.js +0 -0
  411. /package/dist/{sdk/helpers → helpers}/time.d.ts +0 -0
  412. /package/dist/{sdk/helpers → helpers}/time.js +0 -0
  413. /package/dist/{sdk/helpers → helpers}/url.d.ts +0 -0
  414. /package/dist/{sdk/helpers → helpers}/url.js +0 -0
  415. /package/dist/{sdk/helpers → helpers}/url.test.d.ts +0 -0
  416. /package/dist/{sdk/helpers → helpers}/url.test.js +0 -0
  417. /package/dist/{sdk/helpers → helpers}/uuid.d.ts +0 -0
  418. /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.d.ts +0 -0
  419. /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.js +0 -0
  420. /package/dist/{sdk/scripts → scripts}/init-editing.d.ts +0 -0
  421. /package/dist/{sdk/types → types}/api-version.d.ts +0 -0
  422. /package/dist/{sdk/types → types}/api-version.js +0 -0
  423. /package/dist/{sdk/types → types}/builder-block.d.ts +0 -0
  424. /package/dist/{sdk/types → types}/builder-block.js +0 -0
  425. /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
  426. /package/dist/{sdk/types → types}/builder-content.js +0 -0
  427. /package/dist/{sdk/types → types}/builder-props.js +0 -0
  428. /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
  429. /package/dist/{sdk/types → types}/can-track.js +0 -0
  430. /package/dist/{sdk/types → types}/components.js +0 -0
  431. /package/dist/{sdk/types → types}/deep-partial.d.ts +0 -0
  432. /package/dist/{sdk/types → types}/deep-partial.js +0 -0
  433. /package/dist/{sdk/types → types}/element.d.ts +0 -0
  434. /package/dist/{sdk/types → types}/element.js +0 -0
  435. /package/dist/{sdk/types → types}/enforced-partials.js +0 -0
  436. /package/dist/{sdk/types → types}/input.d.ts +0 -0
  437. /package/dist/{sdk/types → types}/input.js +0 -0
  438. /package/dist/{sdk/types → types}/targets.js +0 -0
  439. /package/dist/{sdk/types → types}/typescript.js +0 -0
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ block: BuilderBlock;
3
+ repeatContext: BuilderContextInterface;
4
+ registeredComponents: RegisteredComponents;
5
+ };
6
+ import type { BuilderContextInterface, RegisteredComponents } from "../../../context/types.js";
7
+ import type { BuilderBlock } from "../../../types/builder-block.js";
8
+ declare function RepeatedBlock(props: Props): JSX.Element;
9
+ export default RepeatedBlock;
@@ -1,11 +1,11 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import { useState } from "react";
4
- import BuilderContext from "../../../context/builder.context.js";
4
+ import BuilderContext from "../../../context/builder.context";
5
5
  import Block from "../block";
6
6
  function RepeatedBlock(props) {
7
7
  const [store, setStore] = useState(() => props.repeatContext);
8
8
  return (React.createElement(BuilderContext.Provider, { value: store },
9
- React.createElement(Block, { block: props.block, context: store, components: props.components })));
9
+ React.createElement(Block, { block: props.block, context: store, registeredComponents: props.registeredComponents })));
10
10
  }
11
11
  export default RepeatedBlock;
@@ -1,13 +1,10 @@
1
- /// <reference types="react" />
2
1
  export type BlocksWrapperProps = {
3
2
  blocks: BuilderBlock[] | undefined;
4
3
  parent: string | undefined;
5
4
  path: string | undefined;
6
5
  styleProp: Record<string, any> | undefined;
7
6
  };
8
- type PropsWithChildren = BlocksWrapperProps & {
9
- children?: any;
10
- };
11
7
  import type { BuilderBlock } from "../../types/builder-block.js";
12
- declare function BlocksWrapper(props: PropsWithChildren): JSX.Element;
8
+ import type { PropsWithChildren } from "../../types/typescript.js";
9
+ declare function BlocksWrapper(props: PropsWithChildren<BlocksWrapperProps>): JSX.Element;
13
10
  export default BlocksWrapper;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import { isEditing } from "../../functions/is-editing.js";
4
4
  function BlocksWrapper(props) {
@@ -28,8 +28,8 @@ function BlocksWrapper(props) {
28
28
  }
29
29
  }
30
30
  return (React.createElement(React.Fragment, null,
31
- React.createElement("div", { className: className() + " div-7cb52693", "builder-path": props.path, "builder-parent-id": props.parent, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
32
- React.createElement("style", null, `.div-7cb52693 {
31
+ React.createElement("div", { className: className() + " div-b2473120", "builder-path": props.path, "builder-parent-id": props.parent, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
32
+ React.createElement("style", null, `.div-b2473120 {
33
33
  display: flex;
34
34
  flex-direction: column;
35
35
  align-items: stretch;
@@ -0,0 +1,8 @@
1
+ export type BlocksProps = Partial<BlocksWrapperProps> & {
2
+ context?: BuilderContextInterface;
3
+ registeredComponents?: RegisteredComponents;
4
+ };
5
+ import type { BlocksWrapperProps } from "./blocks-wrapper";
6
+ import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
7
+ declare function Blocks(props: BlocksProps): JSX.Element;
8
+ export default Blocks;
@@ -1,11 +1,17 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
+ import { useContext } from "react";
3
4
  import BlockStyles from "../block/components/block-styles";
4
5
  import Block from "../block/block";
5
6
  import BlocksWrapper from "./blocks-wrapper";
7
+ import BuilderContext from "../../context/builder.context";
8
+ import ComponentsContext from "../../context/components.context";
6
9
  function Blocks(props) {
10
+ const builderContext = useContext(BuilderContext);
11
+ const componentsContext = useContext(ComponentsContext);
7
12
  return (React.createElement(BlocksWrapper, { blocks: props.blocks, parent: props.parent, path: props.path, styleProp: props.styleProp },
8
- props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context, components: props.components }))))) : null,
9
- props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: props.context }))))) : null));
13
+ props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context || builderContext, registeredComponents: props.registeredComponents ||
14
+ componentsContext.registeredComponents }))))) : null,
15
+ props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: props.context || builderContext }))))) : null));
10
16
  }
11
17
  export default Blocks;
@@ -0,0 +1,9 @@
1
+ type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest"> & {
2
+ builderContextSignal: BuilderContextInterface;
3
+ setBuilderContextSignal?: (signal: any) => any;
4
+ children?: any;
5
+ };
6
+ import type { BuilderContextInterface } from "../../../context/types.js";
7
+ import type { ContentProps } from "../content.types.js";
8
+ declare function EnableEditor(props: BuilderEditorProps): JSX.Element;
9
+ export default EnableEditor;
@@ -1,43 +1,45 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import { useState, useRef, useEffect } from "react";
4
- import { evaluate } from "../../../functions/evaluate.js";
5
- import { getContent } from "../../../functions/get-content/index.js";
4
+ import { evaluate } from "../../../functions/evaluate";
6
5
  import { fetch } from "../../../functions/get-fetch.js";
7
6
  import { isBrowser } from "../../../functions/is-browser.js";
8
7
  import { isEditing } from "../../../functions/is-editing.js";
9
- import { isPreviewing } from "../../../functions/is-previewing.js";
10
8
  import { createRegisterComponentMessage } from "../../../functions/register-component.js";
11
9
  import { _track } from "../../../functions/track/index.js";
12
- import builderContext from "../../../context/builder.context.js";
10
+ import builderContext from "../../../context/builder.context";
13
11
  import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
14
12
  import { checkIsDefined } from "../../../helpers/nullable.js";
15
13
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
16
- import { TARGET } from "../../../constants/target.js";
17
14
  import { logger } from "../../../helpers/logger.js";
15
+ import { getContent } from "../../../functions/get-content/index.js";
16
+ import { isPreviewing } from "../../../functions/is-previewing.js";
18
17
  function EnableEditor(props) {
19
18
  const elementRef = useRef(null);
19
+ const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
20
20
  const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
21
21
  function mergeNewContent(newContent) {
22
+ const newContentValue = {
23
+ ...props.builderContextSignal.content,
24
+ ...newContent,
25
+ data: {
26
+ ...props.builderContextSignal.content?.data,
27
+ ...newContent?.data,
28
+ },
29
+ meta: {
30
+ ...props.builderContextSignal.content?.meta,
31
+ ...newContent?.meta,
32
+ breakpoints: newContent?.meta?.breakpoints ||
33
+ props.builderContextSignal.content?.meta?.breakpoints,
34
+ },
35
+ };
22
36
  props.setBuilderContextSignal((PREVIOUS_VALUE) => ({
23
37
  ...PREVIOUS_VALUE,
24
- content: {
25
- ...props.builderContextSignal.content,
26
- ...newContent,
27
- data: {
28
- ...props.builderContextSignal.content?.data,
29
- ...newContent?.data,
30
- },
31
- meta: {
32
- ...props.builderContextSignal.content?.meta,
33
- ...newContent?.meta,
34
- breakpoints: newContent?.meta?.breakpoints ||
35
- props.builderContextSignal.content?.meta?.breakpoints,
36
- },
37
- },
38
+ content: newContentValue,
38
39
  }));
39
40
  }
40
- const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
41
+ const [lastUpdated, setLastUpdated] = useState(() => 0);
42
+ const [shouldSendResetCookie, setShouldSendResetCookie] = useState(() => false);
41
43
  function processMessage(event) {
42
44
  const { data } = event;
43
45
  if (data) {
@@ -72,10 +74,6 @@ function EnableEditor(props) {
72
74
  }
73
75
  break;
74
76
  }
75
- case "builder.patchUpdates": {
76
- // TODO
77
- break;
78
- }
79
77
  }
80
78
  }
81
79
  }
@@ -167,6 +165,7 @@ function EnableEditor(props) {
167
165
  if (isBrowser()) {
168
166
  if (isEditing()) {
169
167
  setForceReRenderCount(forceReRenderCount + 1);
168
+ window.addEventListener("message", processMessage);
170
169
  registerInsertMenu();
171
170
  setupBrowserForEditing({
172
171
  ...(props.locale
@@ -185,11 +184,10 @@ function EnableEditor(props) {
185
184
  }
186
185
  : {}),
187
186
  });
188
- Object.values(props.builderContextSignal.registeredComponents).forEach((registeredComponent) => {
187
+ Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
189
188
  const message = createRegisterComponentMessage(registeredComponent);
190
189
  window.parent?.postMessage(message, "*");
191
190
  });
192
- window.addEventListener("message", processMessage);
193
191
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
194
192
  }
195
193
  if (props.builderContextSignal.content) {
@@ -222,7 +220,7 @@ function EnableEditor(props) {
222
220
  getContent({
223
221
  model: props.model,
224
222
  apiKey: props.apiKey,
225
- apiVersion: props.apiVersion,
223
+ apiVersion: props.builderContextSignal.apiVersion,
226
224
  }).then((content) => {
227
225
  if (content) {
228
226
  mergeNewContent(content);
@@ -240,6 +238,7 @@ function EnableEditor(props) {
240
238
  mergeNewContent(props.content);
241
239
  }
242
240
  }, [props.content]);
241
+ useEffect(() => { }, [shouldSendResetCookie]);
243
242
  useEffect(() => {
244
243
  evaluateJsCode();
245
244
  }, [
@@ -261,18 +260,11 @@ function EnableEditor(props) {
261
260
  };
262
261
  }, []);
263
262
  return (React.createElement(builderContext.Provider, { value: props.builderContextSignal }, props.builderContextSignal.content ? (React.createElement(React.Fragment, null,
264
- React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, key: forceReRenderCount, ...(TARGET === "reactNative"
265
- ? {
266
- dataSet: {
267
- // currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
268
- "builder-content-id": "",
269
- },
270
- }
271
- : {}), ...(props.hideContent
272
- ? {
263
+ React.createElement("div", { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, ...(props.showContent
264
+ ? {}
265
+ : {
273
266
  hidden: true,
274
267
  "aria-hidden": true,
275
- }
276
- : {}), className: props.classNameProp }, props.children))) : null));
268
+ }), className: props.classNameProp }, props.children))) : null));
277
269
  }
278
270
  export default EnableEditor;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  interface Props {
3
2
  cssCode?: string;
4
3
  customFonts?: CustomFont[];
5
4
  contentId?: string;
6
5
  }
7
- import type { CustomFont } from "./content-styles.helpers";
6
+ import type { CustomFont } from "./styles.helpers.js";
8
7
  declare function ContentStyles(props: Props): JSX.Element;
9
8
  export default ContentStyles;
@@ -9,7 +9,7 @@ export interface CustomFont {
9
9
  export declare const getFontCss: ({ customFonts }: {
10
10
  customFonts?: CustomFont[];
11
11
  }) => string;
12
- export declare const getCss: ({ cssCode, contentId, }: {
12
+ export declare const getCss: ({ cssCode, contentId }: {
13
13
  cssCode?: string;
14
14
  contentId?: string;
15
15
  }) => string;
@@ -1,7 +1,6 @@
1
1
  const getCssFromFont = (font) => {
2
2
  // TODO: compute what font sizes are used and only load those.......
3
- const family = font.family +
4
- (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
3
+ const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
5
4
  const name = family.split(',')[0];
6
5
  const url = font.fileUrl ?? font?.files?.regular;
7
6
  let str = '';
@@ -43,9 +42,9 @@ export const getFontCss = ({ customFonts }) => {
43
42
  // return '';
44
43
  // }
45
44
  // TODO: separate internal data from external
46
- return customFonts?.map((font) => getCssFromFont(font))?.join(' ') || '';
45
+ return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
47
46
  };
48
- export const getCss = ({ cssCode, contentId, }) => {
47
+ export const getCss = ({ cssCode, contentId }) => {
49
48
  if (!cssCode) {
50
49
  return '';
51
50
  }
@@ -1,9 +1,9 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import { useState } from "react";
4
4
  import InlinedStyles from "../../inlined-styles";
5
- import { getCss } from "./content-styles.helpers";
6
- import { getFontCss } from "./content-styles.helpers";
5
+ import { getCss } from "./styles.helpers.js";
6
+ import { getFontCss } from "./styles.helpers.js";
7
7
  function ContentStyles(props) {
8
8
  const [injectedStyles, setInjectedStyles] = useState(() => `
9
9
  ${getCss({
@@ -0,0 +1,3 @@
1
+ import type { ContentProps } from "./content.types.js";
2
+ declare function ContentComponent(props: ContentProps): JSX.Element;
3
+ export default ContentComponent;
@@ -0,0 +1,7 @@
1
+ import type { BuilderContent } from '../../types/builder-content.js';
2
+ import type { Nullable } from '../../types/typescript.js';
3
+ import type { ContentProps } from './content.types.js';
4
+ export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
5
+ [x: string]: unknown;
6
+ };
7
+ export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
@@ -0,0 +1,30 @@
1
+ export const getContextStateInitialValue = ({ content, data, locale }) => {
2
+ const defaultValues = {};
3
+ // set default values for content state inputs
4
+ content?.data?.inputs?.forEach(input => {
5
+ if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
6
+ defaultValues[input.name] = input.defaultValue;
7
+ }
8
+ });
9
+ const stateToUse = {
10
+ ...content?.data?.state,
11
+ ...data,
12
+ ...(locale ? {
13
+ locale
14
+ } : {})
15
+ };
16
+ return {
17
+ ...defaultValues,
18
+ ...stateToUse
19
+ };
20
+ };
21
+ export const getContentInitialValue = ({ content, data }) => {
22
+ return !content ? undefined : {
23
+ ...content,
24
+ data: {
25
+ ...content?.data,
26
+ ...data
27
+ },
28
+ meta: content?.meta
29
+ };
30
+ };
@@ -1,20 +1,22 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
- import { useState, useEffect } from "react";
3
+ import { useState } from "react";
4
4
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
5
- import { components } from "../../functions/register-component.js";
5
+ import { components, serializeComponentInfo, } from "../../functions/register-component.js";
6
6
  import Blocks from "../blocks/blocks";
7
- import ContentStyles from "./components/content-styles";
7
+ import ContentStyles from "./components/styles";
8
8
  import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
9
9
  import { TARGET } from "../../constants/target.js";
10
10
  import { getRenderContentScriptString } from "../content-variants/helpers.js";
11
- import { wrapComponentRef } from "./wrap-component-ref.js";
12
11
  import EnableEditor from "./components/enable-editor";
13
- function Content(props) {
12
+ import InlinedScript from "../inlined-script";
13
+ import ComponentsContext from "../../context/components.context";
14
+ function ContentComponent(props) {
14
15
  const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
16
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
17
+ variationId: props.content?.testVariationId,
15
18
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
16
19
  contentId: props.content?.id,
17
- parentContentId: props.parentContentId,
18
20
  }));
19
21
  function contentSetState(newRootState) {
20
22
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -22,7 +24,7 @@ function Content(props) {
22
24
  rootState: newRootState,
23
25
  }));
24
26
  }
25
- const [customComps, setCustomComps] = useState(() => [
27
+ const [registeredComponents, setRegisteredComponents] = useState(() => [
26
28
  ...getDefaultRegisteredComponents(),
27
29
  // While this `components` object is deprecated, we must maintain support for it.
28
30
  // Since users are able to override our default components, we need to make sure that we do not break such
@@ -31,20 +33,13 @@ function Content(props) {
31
33
  // which is the new standard way of providing custom components, and must therefore take precedence.
32
34
  ...components,
33
35
  ...(props.customComponents || []),
34
- ].reduce((acc, info) => ({
36
+ ].reduce((acc, { component, ...info }) => ({
35
37
  ...acc,
36
- [info.name]: info,
38
+ [info.name]: {
39
+ component: component,
40
+ ...serializeComponentInfo(info),
41
+ },
37
42
  }), {}));
38
- function customComponentsInfo() {
39
- // TO-DO: fix once we remove `useStore<any>` hack in Qwik generator.
40
- return Object.values(customComps).reduce((acc, { component: _, ...info }) => ({
41
- ...acc,
42
- [info.name]: info,
43
- }), {});
44
- }
45
- function tempContextSignalSetter() {
46
- return setBuilderContextSignal;
47
- }
48
43
  const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
49
44
  content: getContentInitialValue({
50
45
  content: props.content,
@@ -56,11 +51,11 @@ function Content(props) {
56
51
  data: props.data,
57
52
  locale: props.locale,
58
53
  }),
59
- rootSetState: undefined,
54
+ rootSetState: contentSetState,
60
55
  context: props.context || {},
61
56
  apiKey: props.apiKey,
62
57
  apiVersion: props.apiVersion,
63
- registeredComponents: [
58
+ componentInfos: [
64
59
  ...getDefaultRegisteredComponents(),
65
60
  // While this `components` object is deprecated, we must maintain support for it.
66
61
  // Since users are able to override our default components, we need to make sure that we do not break such
@@ -69,29 +64,20 @@ function Content(props) {
69
64
  // which is the new standard way of providing custom components, and must therefore take precedence.
70
65
  ...components,
71
66
  ...(props.customComponents || []),
72
- ].reduce((acc, { component, ...curr }) => ({
67
+ ].reduce((acc, { component: _, ...info }) => ({
73
68
  ...acc,
74
- [curr.name]: {
75
- component: TARGET === "vue3" ? wrapComponentRef(component) : component,
76
- ...curr,
77
- },
69
+ [info.name]: serializeComponentInfo(info),
78
70
  }), {}),
79
71
  inheritedStyles: {},
80
72
  }));
81
- useEffect(() => {
82
- if (!builderContextSignal.content) {
83
- builderContextSignal.content = getContentInitialValue({
84
- content: props.content,
85
- data: props.data,
86
- });
87
- }
88
- }, [props.content, props.data, props.locale]);
89
- return (React.createElement(React.Fragment, null, builderContextSignal.content ? (React.createElement(React.Fragment, null,
90
- React.createElement(EnableEditor, { content: props.content, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: customComponentsInfo(), canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, hideContent: props.hideContent, parentContentId: props.parentContentId, isSsrAbTest: props.isSsrAbTest, builderContextSignal: builderContextSignal, setBuilderContextSignal: tempContextSignalSetter() },
73
+ return (React.createElement(ComponentsContext.Provider, { value: {
74
+ registeredComponents: registeredComponents,
75
+ } },
76
+ React.createElement(EnableEditor, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
91
77
  props.isSsrAbTest ? (React.createElement(React.Fragment, null,
92
- React.createElement("script", { dangerouslySetInnerHTML: { __html: scriptStr } }))) : null,
78
+ React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
93
79
  TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
94
80
  React.createElement(ContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
95
- React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal, components: customComps })))) : null));
81
+ React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal, registeredComponents: registeredComponents }))));
96
82
  }
97
- export default Content;
83
+ export default ContentComponent;
@@ -1,6 +1,6 @@
1
- import type { BuilderRenderState } from '../../context/types';
2
- import type { EnforcePartials } from '../../types/enforced-partials';
3
- import type { RenderContentVariantsProps } from '../render-content-variants/render-content-variants.types';
1
+ import type { BuilderRenderState } from '../../context/types.js';
2
+ import type { EnforcePartials } from '../../types/enforced-partials.js';
3
+ import type { ContentVariantsProps } from '../content-variants/content-variants.types.js';
4
4
  interface InternalRenderProps {
5
5
  /**
6
6
  * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
@@ -9,7 +9,7 @@ interface InternalRenderProps {
9
9
  showContent: boolean;
10
10
  isSsrAbTest: boolean;
11
11
  }
12
- export type RenderContentProps = InternalRenderProps & EnforcePartials<RenderContentVariantsProps>;
12
+ export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsProps>;
13
13
  export interface BuilderComponentStateChange {
14
14
  state: BuilderRenderState;
15
15
  ref: {
@@ -0,0 +1,9 @@
1
+ type VariantsProviderProps = ContentVariantsProps & {
2
+ /**
3
+ * For internal use only. Do not provide this prop.
4
+ */
5
+ __isNestedRender?: boolean;
6
+ };
7
+ import type { ContentVariantsProps } from "./content-variants.types.js";
8
+ declare function ContentVariants(props: VariantsProviderProps): JSX.Element;
9
+ export default ContentVariants;
@@ -1,45 +1,46 @@
1
- 'use client';
1
+ "use client";
2
2
  import * as React from "react";
3
3
  import { useState, useEffect } from "react";
4
- import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers";
5
- import RenderContent from "../render-content/render-content";
6
- import { getDefaultCanTrack } from "../../helpers/canTrack";
4
+ import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers.js";
5
+ import ContentComponent from "../content/content";
6
+ import { getDefaultCanTrack } from "../../helpers/canTrack.js";
7
7
  import InlinedStyles from "../inlined-styles";
8
- import { handleABTestingSync } from "../../helpers/ab-tests";
8
+ import { handleABTestingSync } from "../../helpers/ab-tests.js";
9
9
  import InlinedScript from "../inlined-script";
10
- import { TARGET } from "../../constants/target";
11
- function RenderContentVariants(props) {
10
+ import { TARGET } from "../../constants/target.js";
11
+ function ContentVariants(props) {
12
12
  const [shouldRenderVariants, setShouldRenderVariants] = useState(() => checkShouldRunVariants({
13
13
  canTrack: getDefaultCanTrack(props.canTrack),
14
14
  content: props.content,
15
15
  }));
16
- const [variantScriptStr, setVariantScriptStr] = useState(() => getVariantsScriptString(getVariants(props.content).map((value) => ({
17
- id: value.testVariationId,
18
- testRatio: value.testRatio,
19
- })), props.content?.id || ""));
20
- const [hideVariantsStyleString, setHideVariantsStyleString] = useState(() => getVariants(props.content)
21
- .map((value) => `.variant-${value.testVariationId} { display: none; } `)
22
- .join(""));
16
+ function variantScriptStr() {
17
+ return getVariantsScriptString(getVariants(props.content).map((value) => ({
18
+ id: value.testVariationId,
19
+ testRatio: value.testRatio,
20
+ })), props.content?.id || "");
21
+ }
22
+ function hideVariantsStyleString() {
23
+ return getVariants(props.content)
24
+ .map((value) => `.variant-${value.testVariationId} { display: none; } `)
25
+ .join("");
26
+ }
23
27
  useEffect(() => {
24
28
  /**
25
29
  * We unmount the non-winning variants post-hydration in Vue.
26
30
  */
27
- if (TARGET === "vue2" || TARGET === "vue3") {
28
- setShouldRenderVariants(false);
29
- }
30
31
  }, []);
31
32
  return (React.createElement(React.Fragment, null,
32
33
  !props.__isNestedRender && TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
33
34
  React.createElement(InlinedScript, { scriptStr: getScriptString() }))) : null,
34
35
  shouldRenderVariants ? (React.createElement(React.Fragment, null,
35
- React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString }),
36
- React.createElement(InlinedScript, { scriptStr: variantScriptStr }),
37
- getVariants(props.content)?.map((variant) => (React.createElement(RenderContent, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
38
- React.createElement(RenderContent, { ...{}, content: shouldRenderVariants
36
+ React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString() }),
37
+ React.createElement(InlinedScript, { scriptStr: variantScriptStr() }),
38
+ getVariants(props.content)?.map((variant) => (React.createElement(ContentComponent, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
39
+ React.createElement(ContentComponent, { content: shouldRenderVariants
39
40
  ? props.content
40
41
  : handleABTestingSync({
41
42
  item: props.content,
42
43
  canTrack: getDefaultCanTrack(props.canTrack),
43
44
  }), classNameProp: `variant-${props.content?.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
44
45
  }
45
- export default RenderContentVariants;
46
+ export default ContentVariants;
@@ -1,8 +1,8 @@
1
- import type { BuilderRenderContext, RegisteredComponent } from '../../context/types';
2
- import type { ApiVersion } from '../../types/api-version';
3
- import type { BuilderContent } from '../../types/builder-content';
4
- import type { Nullable } from '../../types/typescript';
5
- export interface RenderContentVariantsProps {
1
+ import type { BuilderRenderContext, RegisteredComponent } from '../../context/types.js';
2
+ import type { ApiVersion } from '../../types/api-version.js';
3
+ import type { BuilderContent } from '../../types/builder-content.js';
4
+ import type { Nullable } from '../../types/typescript.js';
5
+ export interface ContentVariantsProps {
6
6
  content?: Nullable<BuilderContent>;
7
7
  model?: string;
8
8
  data?: {
@@ -1,13 +1,13 @@
1
- import type { Nullable } from '../../helpers/nullable';
2
- import type { BuilderContent } from '../../types/builder-content';
1
+ import type { Nullable } from '../../helpers/nullable.js';
2
+ import type { BuilderContent } from '../../types/builder-content.js';
3
3
  export declare const getVariants: (content: Nullable<BuilderContent>) => {
4
4
  testVariationId: string;
5
5
  id: string;
6
6
  data?: {
7
7
  [key: string]: any;
8
8
  title?: string;
9
- blocks?: import("../../types/builder-block").BuilderBlock[];
10
- inputs?: import("../../types/input").Input[];
9
+ blocks?: import("../../types/builder-block.js").BuilderBlock[];
10
+ inputs?: import("../../types/input.js").Input[];
11
11
  state?: {
12
12
  [key: string]: any;
13
13
  };
@@ -21,10 +21,10 @@ export declare const getVariants: (content: Nullable<BuilderContent>) => {
21
21
  testRatio?: number;
22
22
  meta?: {
23
23
  [key: string]: any;
24
- breakpoints?: import("../../types/builder-content").Breakpoints;
24
+ breakpoints?: import("../../types/builder-content.js").Breakpoints;
25
25
  };
26
26
  }[];
27
- export declare const checkShouldRunVariants: ({ canTrack, content, }: {
27
+ export declare const checkShouldRunVariants: ({ canTrack, content }: {
28
28
  canTrack: Nullable<boolean>;
29
29
  content: Nullable<BuilderContent>;
30
30
  }) => boolean;
@@ -34,7 +34,7 @@ type VariantData = {
34
34
  };
35
35
  export declare const getScriptString: () => string;
36
36
  export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
37
- export declare const getRenderContentScriptString: ({ contentId, variationId, }: {
37
+ export declare const getRenderContentScriptString: ({ contentId, variationId }: {
38
38
  variationId: string;
39
39
  contentId: string;
40
40
  }) => string;