@builder.io/sdk-svelte 0.0.1-9 → 0.0.2

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 (359) hide show
  1. package/README.md +4 -0
  2. package/package/CHANGELOG.md +19 -0
  3. package/package/README.md +19 -0
  4. package/{src/types/builder-block.js → package/blocks/button/button.lite.d.ts} +0 -0
  5. package/package/blocks/button/button.lite.tsx +36 -0
  6. package/package/blocks/button/button.svelte +28 -0
  7. package/package/blocks/button/button.svelte.d.ts +25 -0
  8. package/package/blocks/button/component-info.d.ts +2 -0
  9. package/package/blocks/button/component-info.js +39 -0
  10. package/{src/types/builder-content.js → package/blocks/columns/columns.lite.d.ts} +0 -0
  11. package/package/blocks/columns/columns.lite.tsx +139 -0
  12. package/package/blocks/columns/columns.svelte +109 -0
  13. package/package/blocks/columns/columns.svelte.d.ts +33 -0
  14. package/package/blocks/columns/component-info.d.ts +2 -0
  15. package/package/blocks/columns/component-info.js +241 -0
  16. package/package/blocks/custom-code/component-info.d.ts +2 -0
  17. package/package/blocks/custom-code/component-info.js +28 -0
  18. package/{src/types/components.js → package/blocks/custom-code/custom-code.lite.d.ts} +0 -0
  19. package/package/blocks/custom-code/custom-code.lite.tsx +70 -0
  20. package/package/blocks/custom-code/custom-code.svelte +55 -0
  21. package/package/blocks/custom-code/custom-code.svelte.d.ts +21 -0
  22. package/package/blocks/embed/component-info.d.ts +2 -0
  23. package/package/blocks/embed/component-info.js +47 -0
  24. package/{src/types/deep-partial.js → package/blocks/embed/embed.lite.d.ts} +0 -0
  25. package/package/blocks/embed/embed.lite.tsx +52 -0
  26. package/package/blocks/embed/embed.svelte +41 -0
  27. package/package/blocks/embed/embed.svelte.d.ts +19 -0
  28. package/package/blocks/embed/helpers.d.ts +1 -0
  29. package/package/blocks/embed/helpers.js +6 -0
  30. package/package/blocks/form/component-info.d.ts +2 -0
  31. package/package/blocks/form/component-info.js +268 -0
  32. package/{src/types/element.js → package/blocks/form/form.lite.d.ts} +0 -0
  33. package/package/blocks/form/form.lite.tsx +351 -0
  34. package/package/blocks/form/form.svelte +259 -0
  35. package/package/blocks/form/form.svelte.d.ts +70 -0
  36. package/package/blocks/fragment/component-info.d.ts +2 -0
  37. package/package/blocks/fragment/component-info.js +8 -0
  38. package/{src/types/targets.js → package/blocks/fragment/fragment.lite.d.ts} +0 -0
  39. package/package/blocks/fragment/fragment.lite.tsx +12 -0
  40. package/package/blocks/fragment/fragment.svelte +5 -0
  41. package/package/blocks/fragment/fragment.svelte.d.ts +21 -0
  42. package/package/blocks/image/component-info.d.ts +2 -0
  43. package/package/blocks/image/component-info.js +153 -0
  44. package/package/blocks/image/image.helpers.d.ts +1 -0
  45. package/package/blocks/image/image.helpers.js +56 -0
  46. package/{src/types/typescript.js → package/blocks/image/image.lite.d.ts} +0 -0
  47. package/package/blocks/image/image.lite.tsx +148 -0
  48. package/package/blocks/image/image.svelte +119 -0
  49. package/package/blocks/image/image.svelte.d.ts +48 -0
  50. package/package/blocks/img/component-info.d.ts +2 -0
  51. package/package/blocks/img/component-info.js +18 -0
  52. package/package/blocks/img/img.lite.d.ts +0 -0
  53. package/package/blocks/img/img.lite.tsx +48 -0
  54. package/package/blocks/img/img.svelte +26 -0
  55. package/package/blocks/img/img.svelte.d.ts +29 -0
  56. package/package/blocks/input/component-info.d.ts +2 -0
  57. package/package/blocks/input/component-info.js +72 -0
  58. package/package/blocks/input/input.lite.d.ts +0 -0
  59. package/package/blocks/input/input.lite.tsx +34 -0
  60. package/package/blocks/input/input.svelte +22 -0
  61. package/package/blocks/input/input.svelte.d.ts +31 -0
  62. package/package/blocks/raw-text/component-info.d.ts +2 -0
  63. package/package/blocks/raw-text/component-info.js +13 -0
  64. package/package/blocks/raw-text/raw-text.lite.d.ts +0 -0
  65. package/package/blocks/raw-text/raw-text.lite.tsx +15 -0
  66. package/package/blocks/raw-text/raw-text.svelte +9 -0
  67. package/package/blocks/raw-text/raw-text.svelte.d.ts +21 -0
  68. package/package/blocks/section/component-info.d.ts +2 -0
  69. package/package/blocks/section/component-info.js +46 -0
  70. package/package/blocks/section/section.lite.d.ts +0 -0
  71. package/package/blocks/section/section.lite.tsx +30 -0
  72. package/package/blocks/section/section.svelte +21 -0
  73. package/package/blocks/section/section.svelte.d.ts +25 -0
  74. package/package/blocks/select/component-info.d.ts +2 -0
  75. package/package/blocks/select/component-info.js +56 -0
  76. package/package/blocks/select/select.lite.d.ts +0 -0
  77. package/package/blocks/select/select.lite.tsx +34 -0
  78. package/package/blocks/select/select.svelte +21 -0
  79. package/package/blocks/select/select.svelte.d.ts +30 -0
  80. package/package/blocks/submit-button/component-info.d.ts +2 -0
  81. package/package/blocks/submit-button/component-info.js +29 -0
  82. package/package/blocks/submit-button/submit-button.lite.d.ts +0 -0
  83. package/package/blocks/submit-button/submit-button.lite.tsx +15 -0
  84. package/package/blocks/submit-button/submit-button.svelte +9 -0
  85. package/package/blocks/submit-button/submit-button.svelte.d.ts +21 -0
  86. package/package/blocks/symbol/component-info.d.ts +2 -0
  87. package/package/blocks/symbol/component-info.js +40 -0
  88. package/package/blocks/symbol/symbol.lite.d.ts +0 -0
  89. package/package/blocks/symbol/symbol.lite.tsx +92 -0
  90. package/package/blocks/symbol/symbol.svelte +66 -0
  91. package/package/blocks/symbol/symbol.svelte.d.ts +35 -0
  92. package/package/blocks/text/component-info.d.ts +2 -0
  93. package/package/blocks/text/component-info.js +21 -0
  94. package/package/blocks/text/text.lite.d.ts +0 -0
  95. package/package/blocks/text/text.lite.tsx +11 -0
  96. package/package/blocks/text/text.svelte +6 -0
  97. package/package/blocks/text/text.svelte.d.ts +19 -0
  98. package/package/blocks/textarea/component-info.d.ts +2 -0
  99. package/package/blocks/textarea/component-info.js +44 -0
  100. package/package/blocks/textarea/textarea.lite.d.ts +0 -0
  101. package/package/blocks/textarea/textarea.lite.tsx +19 -0
  102. package/package/blocks/textarea/textarea.svelte +10 -0
  103. package/package/blocks/textarea/textarea.svelte.d.ts +27 -0
  104. package/package/blocks/util.d.ts +1 -0
  105. package/package/blocks/util.js +4 -0
  106. package/package/blocks/video/component-info.d.ts +2 -0
  107. package/package/blocks/video/component-info.js +103 -0
  108. package/package/blocks/video/video.lite.d.ts +0 -0
  109. package/package/blocks/video/video.lite.tsx +92 -0
  110. package/package/blocks/video/video.svelte +63 -0
  111. package/package/blocks/video/video.svelte.d.ts +41 -0
  112. package/package/components/render-block/block-styles.lite.d.ts +0 -0
  113. package/package/components/render-block/block-styles.lite.tsx +60 -0
  114. package/package/components/render-block/block-styles.svelte +45 -0
  115. package/package/components/render-block/block-styles.svelte.d.ts +23 -0
  116. package/package/components/render-block/render-block.helpers.d.ts +1 -0
  117. package/package/components/render-block/render-block.helpers.js +24 -0
  118. package/package/components/render-block/render-block.lite.d.ts +0 -0
  119. package/package/components/render-block/render-block.lite.tsx +216 -0
  120. package/package/components/render-block/render-block.svelte +185 -0
  121. package/package/components/render-block/render-block.svelte.d.ts +23 -0
  122. package/package/components/render-block/render-component.lite.d.ts +0 -0
  123. package/package/components/render-block/render-component.lite.tsx +33 -0
  124. package/package/components/render-block/render-component.svelte +24 -0
  125. package/package/components/render-block/render-component.svelte.d.ts +27 -0
  126. package/package/components/render-block/render-repeated-block.lite.d.ts +0 -0
  127. package/package/components/render-block/render-repeated-block.lite.tsx +49 -0
  128. package/package/components/render-block/render-repeated-block.svelte +36 -0
  129. package/package/components/render-block/render-repeated-block.svelte.d.ts +23 -0
  130. package/package/components/render-block/types.d.ts +6 -0
  131. package/package/components/render-block/types.js +2 -0
  132. package/package/components/render-blocks.lite.d.ts +0 -0
  133. package/package/components/render-blocks.lite.tsx +91 -0
  134. package/package/components/render-blocks.svelte +73 -0
  135. package/package/components/render-blocks.svelte.d.ts +24 -0
  136. package/package/components/render-content/components/render-styles.lite.d.ts +0 -0
  137. package/package/components/render-content/components/render-styles.lite.tsx +86 -0
  138. package/package/components/render-content/components/render-styles.svelte +61 -0
  139. package/package/components/render-content/components/render-styles.svelte.d.ts +29 -0
  140. package/package/components/render-content/index.d.ts +1 -0
  141. package/package/components/render-content/index.js +1 -0
  142. package/package/components/render-content/render-content.lite.d.ts +0 -0
  143. package/package/components/render-content/render-content.lite.tsx +356 -0
  144. package/package/components/render-content/render-content.svelte +260 -0
  145. package/package/components/render-content/render-content.svelte.d.ts +36 -0
  146. package/package/components/render-inlined-styles.lite.d.ts +0 -0
  147. package/package/components/render-inlined-styles.lite.tsx +27 -0
  148. package/package/components/render-inlined-styles.svelte +19 -0
  149. package/package/components/render-inlined-styles.svelte.d.ts +19 -0
  150. package/package/constants/builder-registered-components.d.ts +6 -0
  151. package/package/constants/builder-registered-components.js +36 -0
  152. package/package/constants/device-sizes.d.ts +2 -0
  153. package/package/constants/device-sizes.js +18 -0
  154. package/package/constants/target.d.ts +2 -0
  155. package/package/constants/target.js +2 -0
  156. package/package/context/builder.context.d.ts +11 -0
  157. package/package/context/builder.context.js +11 -0
  158. package/package/context/types.d.ts +16 -0
  159. package/package/context/types.js +3 -0
  160. package/package/functions/camel-to-kebab-case.d.ts +1 -0
  161. package/package/functions/camel-to-kebab-case.js +1 -0
  162. package/package/functions/convert-style-object.d.ts +1 -0
  163. package/package/functions/convert-style-object.js +3 -0
  164. package/package/functions/evaluate.d.ts +5 -0
  165. package/package/functions/evaluate.js +25 -0
  166. package/package/functions/event-handler-name.d.ts +1 -0
  167. package/package/functions/event-handler-name.js +4 -0
  168. package/package/functions/get-block-actions.d.ts +9 -0
  169. package/package/functions/get-block-actions.js +21 -0
  170. package/package/functions/get-block-component-options.d.ts +2 -0
  171. package/package/functions/get-block-component-options.js +11 -0
  172. package/package/functions/get-block-properties.d.ts +5 -0
  173. package/package/functions/get-block-properties.js +10 -0
  174. package/package/functions/get-block-styles.d.ts +2 -0
  175. package/package/functions/get-block-styles.js +21 -0
  176. package/package/functions/get-block-tag.d.ts +3 -0
  177. package/package/functions/get-block-tag.js +4 -0
  178. package/package/functions/get-builder-search-params/fn.test.d.ts +1 -0
  179. package/package/functions/get-builder-search-params/fn.test.js +13 -0
  180. package/package/functions/get-builder-search-params/index.d.ts +6 -0
  181. package/package/functions/get-builder-search-params/index.js +29 -0
  182. package/package/functions/get-content/ab-testing.d.ts +3 -0
  183. package/package/functions/get-content/ab-testing.js +40 -0
  184. package/package/functions/get-content/fn.test.d.ts +1 -0
  185. package/package/functions/get-content/fn.test.js +31 -0
  186. package/package/functions/get-content/index.d.ts +9 -0
  187. package/package/functions/get-content/index.js +42 -0
  188. package/package/functions/get-content/types.d.ts +26 -0
  189. package/package/functions/get-content/types.js +1 -0
  190. package/package/functions/get-fetch.d.ts +1 -0
  191. package/package/functions/get-fetch.js +9 -0
  192. package/package/functions/get-global-this.d.ts +1 -0
  193. package/package/functions/get-global-this.js +15 -0
  194. package/package/functions/get-processed-block.d.ts +10 -0
  195. package/package/functions/get-processed-block.js +29 -0
  196. package/package/functions/get-processed-block.test.d.ts +1 -0
  197. package/package/functions/get-processed-block.test.js +32 -0
  198. package/package/functions/if-target.d.ts +7 -0
  199. package/package/functions/if-target.js +10 -0
  200. package/package/functions/is-browser.d.ts +1 -0
  201. package/package/functions/is-browser.js +3 -0
  202. package/package/functions/is-editing.d.ts +1 -0
  203. package/package/functions/is-editing.js +4 -0
  204. package/package/functions/is-iframe.d.ts +1 -0
  205. package/package/functions/is-iframe.js +4 -0
  206. package/package/functions/is-previewing.d.ts +1 -0
  207. package/package/functions/is-previewing.js +11 -0
  208. package/package/functions/mark-mutable.d.ts +2 -0
  209. package/package/functions/mark-mutable.js +6 -0
  210. package/package/functions/on-change.d.ts +7 -0
  211. package/package/functions/on-change.js +28 -0
  212. package/package/functions/on-change.test.d.ts +1 -0
  213. package/package/functions/on-change.test.js +20 -0
  214. package/package/functions/register-component.d.ts +14 -0
  215. package/package/functions/register-component.js +42 -0
  216. package/package/functions/register.d.ts +16 -0
  217. package/package/functions/register.js +29 -0
  218. package/package/functions/sanitize-styles.d.ts +4 -0
  219. package/package/functions/sanitize-styles.js +6 -0
  220. package/package/functions/set-editor-settings.d.ts +4 -0
  221. package/package/functions/set-editor-settings.js +12 -0
  222. package/package/functions/set.d.ts +7 -0
  223. package/package/functions/set.js +21 -0
  224. package/package/functions/set.test.d.ts +1 -0
  225. package/package/functions/set.test.js +16 -0
  226. package/package/functions/track.d.ts +21 -0
  227. package/package/functions/track.js +49 -0
  228. package/package/functions/transform-block.d.ts +2 -0
  229. package/package/functions/transform-block.js +5 -0
  230. package/package/helpers/cookie.d.ts +9 -0
  231. package/package/helpers/cookie.js +55 -0
  232. package/package/helpers/css.d.ts +1 -0
  233. package/package/helpers/css.js +9 -0
  234. package/package/helpers/flatten.d.ts +6 -0
  235. package/package/helpers/flatten.js +19 -0
  236. package/package/helpers/localStorage.d.ts +9 -0
  237. package/package/helpers/localStorage.js +23 -0
  238. package/package/helpers/nullable.d.ts +2 -0
  239. package/package/helpers/nullable.js +1 -0
  240. package/package/helpers/sessionId.d.ts +7 -0
  241. package/package/helpers/sessionId.js +20 -0
  242. package/package/helpers/time.d.ts +1 -0
  243. package/package/helpers/time.js +2 -0
  244. package/package/helpers/url.d.ts +6 -0
  245. package/package/helpers/url.js +12 -0
  246. package/package/helpers/url.test.d.ts +1 -0
  247. package/package/helpers/url.test.js +15 -0
  248. package/package/helpers/uuid.d.ts +8 -0
  249. package/package/helpers/uuid.js +15 -0
  250. package/package/helpers/visitorId.d.ts +8 -0
  251. package/package/helpers/visitorId.js +26 -0
  252. package/package/index-helpers/blocks-exports.d.ts +10 -0
  253. package/package/index-helpers/blocks-exports.js +10 -0
  254. package/package/index-helpers/top-of-file.d.ts +1 -0
  255. package/package/index-helpers/top-of-file.js +4 -0
  256. package/package/index.d.ts +10 -0
  257. package/package/index.js +10 -0
  258. package/package/scripts/init-editing.d.ts +2 -0
  259. package/package/scripts/init-editing.js +84 -0
  260. package/package/types/builder-block.d.ts +57 -0
  261. package/package/types/builder-block.js +1 -0
  262. package/package/types/builder-content.d.ts +38 -0
  263. package/package/types/builder-content.js +1 -0
  264. package/package/types/can-track.d.ts +3 -0
  265. package/package/types/can-track.js +1 -0
  266. package/package/types/components.d.ts +177 -0
  267. package/package/types/components.js +1 -0
  268. package/package/types/deep-partial.d.ts +3 -0
  269. package/package/types/deep-partial.js +1 -0
  270. package/package/types/element.d.ts +59 -0
  271. package/package/types/element.js +1 -0
  272. package/package/types/targets.d.ts +3 -0
  273. package/package/types/targets.js +1 -0
  274. package/package/types/typescript.d.ts +4 -0
  275. package/package/types/typescript.js +1 -0
  276. package/package.json +31 -8
  277. package/src/blocks/button/button.svelte +0 -49
  278. package/src/blocks/button/component-info.js +0 -41
  279. package/src/blocks/columns/columns.svelte +0 -103
  280. package/src/blocks/columns/component-info.js +0 -217
  281. package/src/blocks/custom-code/component-info.js +0 -31
  282. package/src/blocks/custom-code/custom-code.svelte +0 -64
  283. package/src/blocks/embed/component-info.js +0 -24
  284. package/src/blocks/embed/embed.svelte +0 -63
  285. package/src/blocks/form/component-info.js +0 -262
  286. package/src/blocks/form/form.svelte +0 -333
  287. package/src/blocks/fragment/component-info.js +0 -11
  288. package/src/blocks/fragment/fragment.svelte +0 -28
  289. package/src/blocks/image/component-info.js +0 -104
  290. package/src/blocks/image/image.svelte +0 -117
  291. package/src/blocks/img/component-info.js +0 -20
  292. package/src/blocks/img/img.svelte +0 -36
  293. package/src/blocks/input/component-info.js +0 -74
  294. package/src/blocks/input/input.svelte +0 -35
  295. package/src/blocks/raw-text/component-info.js +0 -16
  296. package/src/blocks/raw-text/raw-text.svelte +0 -29
  297. package/src/blocks/section/component-info.js +0 -49
  298. package/src/blocks/section/section.svelte +0 -36
  299. package/src/blocks/select/component-info.js +0 -59
  300. package/src/blocks/select/select.svelte +0 -41
  301. package/src/blocks/submit-button/component-info.js +0 -28
  302. package/src/blocks/submit-button/submit-button.svelte +0 -33
  303. package/src/blocks/symbol/component-info.js +0 -42
  304. package/src/blocks/symbol/symbol.svelte +0 -54
  305. package/src/blocks/text/component-info.js +0 -24
  306. package/src/blocks/text/text.svelte +0 -28
  307. package/src/blocks/textarea/component-info.js +0 -47
  308. package/src/blocks/textarea/textarea.svelte +0 -32
  309. package/src/blocks/video/component-info.js +0 -106
  310. package/src/blocks/video/video.svelte +0 -45
  311. package/src/components/error-boundary.svelte +0 -26
  312. package/src/components/render-block/block-styles.svelte +0 -51
  313. package/src/components/render-block/render-block.helpers.js +0 -23
  314. package/src/components/render-block/render-block.svelte +0 -174
  315. package/src/components/render-blocks.svelte +0 -82
  316. package/src/components/render-content/components/render-styles.svelte +0 -90
  317. package/src/components/render-content/index.js +0 -4
  318. package/src/components/render-content/render-content.svelte +0 -252
  319. package/src/components/render-inlined-styles.svelte +0 -51
  320. package/src/constants/builder-registered-components.js +0 -45
  321. package/src/constants/device-sizes.js +0 -39
  322. package/src/constants/target.js +0 -4
  323. package/src/context/builder.context.js +0 -8
  324. package/src/functions/evaluate.js +0 -28
  325. package/src/functions/event-handler-name.js +0 -7
  326. package/src/functions/fast-clone.js +0 -4
  327. package/src/functions/get-block-actions.js +0 -23
  328. package/src/functions/get-block-component-options.js +0 -23
  329. package/src/functions/get-block-properties.js +0 -29
  330. package/src/functions/get-block-styles.js +0 -31
  331. package/src/functions/get-block-tag.js +0 -6
  332. package/src/functions/get-builder-search-params/fn.test.js +0 -13
  333. package/src/functions/get-builder-search-params/index.js +0 -22
  334. package/src/functions/get-content/fn.test.js +0 -31
  335. package/src/functions/get-content/index.js +0 -138
  336. package/src/functions/get-fetch.js +0 -34
  337. package/src/functions/get-global-this.js +0 -18
  338. package/src/functions/get-processed-block.js +0 -46
  339. package/src/functions/get-processed-block.test.js +0 -31
  340. package/src/functions/if-target.js +0 -15
  341. package/src/functions/is-browser.js +0 -6
  342. package/src/functions/is-editing.js +0 -7
  343. package/src/functions/is-iframe.js +0 -7
  344. package/src/functions/is-previewing.js +0 -14
  345. package/src/functions/macro-eval.js +0 -5
  346. package/src/functions/on-change.js +0 -27
  347. package/src/functions/on-change.test.js +0 -19
  348. package/src/functions/previewing-model-name.js +0 -11
  349. package/src/functions/register-component.js +0 -70
  350. package/src/functions/register.js +0 -29
  351. package/src/functions/set-editor-settings.js +0 -15
  352. package/src/functions/set.js +0 -11
  353. package/src/functions/set.test.js +0 -16
  354. package/src/functions/track.js +0 -22
  355. package/src/functions/transform-block.js +0 -6
  356. package/src/index-helpers/blocks-exports.js +0 -20
  357. package/src/index-helpers/top-of-file.js +0 -4
  358. package/src/index.js +0 -10
  359. package/src/scripts/init-editing.js +0 -80
@@ -1,82 +0,0 @@
1
- <script>
2
-
3
-
4
-
5
-
6
- import { isEditing } from '../functions/is-editing.js';
7
- import RenderBlock, { } from './render-block/render-block.svelte';
8
-
9
-
10
-
11
-
12
-
13
-
14
- export let blocks;
15
- export let parent;
16
- export let path;
17
-
18
- function onClick() {
19
- if (isEditing() && !blocks?.length) {
20
- window.parent?.postMessage({
21
- type: 'builder.clickEmptyBlocks',
22
- data: {
23
- parentElementId: parent,
24
- dataPath: path
25
- }
26
- }, '*');
27
- }
28
- }
29
-
30
- function onMouseEnter() {
31
- if (isEditing() && !blocks?.length) {
32
- window.parent?.postMessage({
33
- type: 'builder.hoverEmptyBlocks',
34
- data: {
35
- parentElementId: parent,
36
- dataPath: path
37
- }
38
- }, '*');
39
- }
40
- }
41
- $: className = () => {
42
- return 'builder-blocks' + (!blocks?.length ? ' no-blocks' : '');
43
- };
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
- </script>
55
-
56
- <div builder-path={path} builder-parent-id={parent} dataSet={{
57
- class: className()
58
- }} on:click="{event => onClick()}" on:mouseenter="{event => onMouseEnter()}" class={className()} >
59
-
60
-
61
- {#if blocks }
62
-
63
-
64
-
65
- {#each blocks as block, index }
66
- <RenderBlock key={block.id} block={block} ></RenderBlock>
67
- {/each}
68
-
69
-
70
-
71
-
72
-
73
- {/if}
74
-
75
- </div>
76
-
77
- <style>
78
- .div {
79
- display: flex;
80
- flex-direction: column;
81
- align-items: stretch; }
82
- </style>
@@ -1,90 +0,0 @@
1
- <script>
2
-
3
-
4
-
5
-
6
- import RenderInlinedStyles, { } from '../../render-inlined-styles.svelte';
7
-
8
-
9
-
10
-
11
-
12
-
13
- export let cssCode;
14
- export let customFonts;
15
-
16
- function getCssFromFont(font) {
17
- // TODO: compute what font sizes are used and only load those.......
18
- const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
19
- const name = family.split(',')[0];
20
- const url = font.fileUrl ?? font?.files?.regular;
21
- let str = '';
22
-
23
- if (url && family && name) {
24
- str += `
25
- @font-face {
26
- font-family: "${family}";
27
- src: local("${name}"), url('${url}') format('woff2');
28
- font-display: fallback;
29
- font-weight: 400;
30
- }
31
- `.trim();
32
- }
33
-
34
- if (font.files) {
35
- for (const weight in font.files) {
36
- const isNumber = String(Number(weight)) === weight;
37
-
38
- if (!isNumber) {
39
- continue;
40
- } // TODO: maybe limit number loaded
41
-
42
-
43
- const weightUrl = font.files[weight];
44
-
45
- if (weightUrl && weightUrl !== url) {
46
- str += `
47
- @font-face {
48
- font-family: "${family}";
49
- src: url('${weightUrl}') format('woff2');
50
- font-display: fallback;
51
- font-weight: ${weight};
52
- }
53
- `.trim();
54
- }
55
- }
56
- }
57
-
58
- return str;
59
- }
60
-
61
- function getFontCss({
62
- customFonts
63
- }) {
64
- // TODO: flag for this
65
- // if (!builder.allowCustomFonts) {
66
- // return '';
67
- // }
68
- // TODO: separate internal data from external
69
- return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
70
- }
71
- $: injectedStyles = () => {
72
- return `
73
- ${cssCode || ''}
74
- ${getFontCss({
75
- customFonts: customFonts
76
- })}`;
77
- };
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
- </script>
89
-
90
- <RenderInlinedStyles styles={injectedStyles()} ></RenderInlinedStyles>
@@ -1,4 +0,0 @@
1
- import { default as default2 } from "./render-content.svelte";
2
- export {
3
- default2 as default
4
- };
@@ -1,252 +0,0 @@
1
- <script>
2
- import { onMount } from 'svelte'
3
- import { afterUpdate } from 'svelte'
4
- import { onDestroy } from 'svelte'
5
-
6
- import { getDefaultRegisteredComponents } from '../../constants/builder-registered-components.js';
7
- import { TARGET } from '../../constants/target.js';
8
- import BuilderContext, { } from '../../context/builder.context';
9
- import { evaluate } from '../../functions/evaluate.js';
10
- import { convertSearchParamsToQueryObject , getBuilderSearchParams } from '../../functions/get-builder-search-params/index.js';
11
- import { getContent } from '../../functions/get-content/index.js';
12
- import { getFetch } from '../../functions/get-fetch.js';
13
- import { isBrowser } from '../../functions/is-browser.js';
14
- import { isEditing } from '../../functions/is-editing.js';
15
- import { isPreviewing } from '../../functions/is-previewing.js';
16
- import { previewingModelName } from '../../functions/previewing-model-name.js';
17
- import { components , createRegisterComponentMessage } from '../../functions/register-component.js';
18
- import { track } from '../../functions/track.js';
19
- import RenderBlocks, { } from '../render-blocks.svelte';
20
- import RenderContentStyles, { } from './components/render-styles.svelte';
21
-
22
-
23
-
24
- import { getContext, setContext } from "svelte";
25
-
26
-
27
- export let content;
28
- export let data;
29
- export let customComponents;
30
- export let model;
31
- export let apiKey;
32
-
33
- function processMessage(event) {
34
- const {
35
- data
36
- } = event;
37
-
38
- if (data) {
39
- switch (data.type) {
40
- case 'builder.contentUpdate':
41
- {
42
- const messageContent = data.data;
43
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
44
- const contentData = messageContent.data;
45
-
46
- if (key === model) {
47
- overrideContent = contentData;
48
- }
49
-
50
- break;
51
- }
52
-
53
- case 'builder.patchUpdates':
54
- {
55
- // TODO
56
- break;
57
- }
58
- }
59
- }
60
- }
61
-
62
- function evaluateJsCode() {
63
- // run any dynamic JS code attached to content
64
- const jsCode = useContent?.()?.data?.jsCode;
65
-
66
- if (jsCode) {
67
- evaluate({
68
- code: jsCode,
69
- context: context(),
70
- state: contentState()
71
- });
72
- }
73
- }
74
-
75
- function evalExpression(expression) {
76
- return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
77
- code: group,
78
- context: context(),
79
- state: contentState()
80
- }));
81
- }
82
-
83
- function handleRequest({
84
- url,
85
- key
86
- }) {
87
- const fetchAndSetState = async () => {
88
- const fetch = await getFetch();
89
- const response = await fetch(url);
90
- const json = await response.json();
91
- const newOverrideState = { ...overrideState,
92
- [key]: json
93
- };
94
- overrideState = newOverrideState;
95
- };
96
-
97
- fetchAndSetState();
98
- }
99
-
100
- function runHttpRequests() {
101
- const requests = useContent?.()?.data?.httpRequests ?? {};
102
- Object.entries(requests).forEach(([key, url]) => {
103
- if (url && (!httpReqsData()[key] || isEditing())) {
104
- const evaluatedUrl = evalExpression(url);
105
- handleRequest({
106
- url: evaluatedUrl,
107
- key
108
- });
109
- }
110
- });
111
- }
112
-
113
- function emitStateUpdate() {
114
- if (isEditing()) {
115
- window.dispatchEvent(new CustomEvent('builder:component:stateChange', {
116
- detail: {
117
- state: contentState(),
118
- ref: {
119
- name: model
120
- }
121
- }
122
- }));
123
- }
124
- }
125
- $: useContent = () => {
126
- const mergedContent = { ...content,
127
- ...overrideContent,
128
- data: { ...content?.data,
129
- ...data,
130
- ...overrideContent?.data
131
- }
132
- };
133
- return mergedContent;
134
- };
135
-
136
- $: contentState = () => {
137
- return { ...content?.data?.state,
138
- ...data,
139
- ...overrideState
140
- };
141
- };
142
-
143
- $: context = () => {
144
- return {};
145
- };
146
-
147
- $: allRegisteredComponents = () => {
148
- const allComponentsArray = [...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
149
- // Since users are able to override our default components, we need to make sure that we do not break such
150
- // existing usage.
151
- // This is why we spread `components` after the default Builder.io components, but before the `customComponents`,
152
- // which is the new standard way of providing custom components, and must therefore take precedence.
153
- ...components, ...(customComponents || [])];
154
- const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
155
- [curr.name]: curr
156
- }), {});
157
- return allComponents;
158
- };
159
-
160
- $: httpReqsData = () => {
161
- return {};
162
- };
163
-
164
-
165
- setContext(BuilderContext.key, { get content() {
166
- return useContent();
167
- }, get state() {
168
- return contentState();
169
- }, get context() {
170
- return context();
171
- }, get apiKey() {
172
- return apiKey;
173
- }, get registeredComponents() {
174
- return allRegisteredComponents();
175
- },});
176
- let overrideContent = null;
177
- let update = 0;
178
- let overrideState = {};
179
-
180
- onMount(() => { if (isBrowser()) {
181
- if (isEditing()) {
182
- Object.values(allRegisteredComponents()).forEach(registeredComponent => {
183
- const message = createRegisterComponentMessage(registeredComponent);
184
- window.parent?.postMessage(message, '*');
185
- });
186
- window.addEventListener('message', processMessage);
187
- window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
188
- }
189
-
190
- if (useContent()) {
191
- track('impression', {
192
- contentId: useContent().id
193
- });
194
- } // override normal content in preview mode
195
-
196
-
197
- if (isPreviewing()) {
198
- if (model && previewingModelName() === model) {
199
- const currentUrl = new URL(location.href);
200
- const previewApiKey = currentUrl.searchParams.get('apiKey');
201
-
202
- if (previewApiKey) {
203
- getContent({
204
- model: model,
205
- apiKey: previewApiKey,
206
- options: getBuilderSearchParams(convertSearchParamsToQueryObject(currentUrl.searchParams))
207
- }).then(content => {
208
- if (content) {
209
- overrideContent = content;
210
- }
211
- });
212
- }
213
- }
214
- }
215
-
216
- evaluateJsCode();
217
- runHttpRequests();
218
- emitStateUpdate();
219
- } });
220
-
221
- afterUpdate(() => { evaluateJsCode(); });afterUpdate(() => { runHttpRequests(); });afterUpdate(() => { emitStateUpdate(); })
222
-
223
- onDestroy(() => { if (isBrowser()) {
224
- window.removeEventListener('message', processMessage);
225
- window.removeEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate);
226
- } });
227
- </script>
228
-
229
-
230
- {#if useContent() }
231
-
232
-
233
- <div on:click="{event => track('click', {
234
- contentId: useContent().id
235
- })}" data-builder-content-id={useContent?.()?.id} >
236
-
237
-
238
- {#if (useContent?.()?.data?.cssCode || useContent?.()?.data?.customFonts?.length) && TARGET !== 'reactNative' }
239
- <RenderContentStyles cssCode={useContent().data.cssCode} customFonts={useContent().data.customFonts} ></RenderContentStyles>
240
-
241
-
242
- {/if}
243
-
244
-
245
- <RenderBlocks blocks={useContent?.()?.data?.blocks} ></RenderBlocks>
246
-
247
- </div>
248
-
249
-
250
-
251
-
252
- {/if}
@@ -1,51 +0,0 @@
1
- <script>
2
-
3
-
4
-
5
-
6
- import { TARGET } from '../constants/target.js';
7
-
8
-
9
-
10
-
11
-
12
-
13
- export let styles;
14
-
15
-
16
- $: injectedStyleScript = () => {
17
- return `<${tagName()}>${styles}</${tagName()}>`;
18
- };
19
-
20
- $: tagName = () => {
21
- // NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
22
- // https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
23
- return 'sty' + 'le';
24
- };
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
- </script>
36
-
37
-
38
- {#if TARGET === 'svelte' }
39
-
40
-
41
-
42
-
43
- {@html injectedStyleScript()}
44
-
45
-
46
-
47
-
48
- {:else}
49
- <svelte:component this={tagName()} >{styles}</svelte:component>
50
-
51
- {/if}
@@ -1,45 +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.svelte";
18
- import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
19
- import { default as Columns } from "../blocks/columns/columns.svelte";
20
- import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
21
- import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
22
- import { default as Fragment } from "../blocks/fragment/fragment.svelte";
23
- import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
24
- import { default as Image } from "../blocks/image/image.svelte";
25
- import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
26
- import { default as Section } from "../blocks/section/section.svelte";
27
- import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
28
- import { default as Symbol } from "../blocks/symbol/symbol.svelte";
29
- import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
30
- import { default as Text } from "../blocks/text/text.svelte";
31
- import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
32
- import { default as Video } from "../blocks/video/video.svelte";
33
- const getDefaultRegisteredComponents = () => [
34
- __spreadValues({ component: Columns }, columnsComponentInfo),
35
- __spreadValues({ component: Image }, imageComponentInfo),
36
- __spreadValues({ component: Text }, textComponentInfo),
37
- __spreadValues({ component: Video }, videoComponentInfo),
38
- __spreadValues({ component: Symbol }, symbolComponentInfo),
39
- __spreadValues({ component: Button }, buttonComponentInfo),
40
- __spreadValues({ component: Section }, sectionComponentInfo),
41
- __spreadValues({ component: Fragment }, fragmentComponentInfo)
42
- ];
43
- export {
44
- getDefaultRegisteredComponents
45
- };
@@ -1,39 +0,0 @@
1
- const sizeNames = ["xsmall", "small", "medium", "large"];
2
- const sizes = {
3
- xsmall: {
4
- min: 0,
5
- default: 0,
6
- max: 0
7
- },
8
- small: {
9
- min: 320,
10
- default: 321,
11
- max: 640
12
- },
13
- medium: {
14
- min: 641,
15
- default: 642,
16
- max: 991
17
- },
18
- large: {
19
- min: 990,
20
- default: 991,
21
- max: 1200
22
- },
23
- getWidthForSize(size) {
24
- return this[size].default;
25
- },
26
- getSizeForWidth(width) {
27
- for (const size of sizeNames) {
28
- const value = this[size];
29
- if (width <= value.max) {
30
- return size;
31
- }
32
- }
33
- return "large";
34
- }
35
- };
36
- export {
37
- sizeNames,
38
- sizes
39
- };
@@ -1,4 +0,0 @@
1
- const TARGET = "svelte";
2
- export {
3
- TARGET
4
- };
@@ -1,8 +0,0 @@
1
- const key = Symbol();
2
- var stdin_default = {
3
- Builder: { content: null, context: {}, state: {}, apiKey: null, registeredComponents: {} },
4
- key
5
- };
6
- export {
7
- stdin_default as default
8
- };
@@ -1,28 +0,0 @@
1
- import { isBrowser } from "./is-browser.js";
2
- import { isEditing } from "./is-editing.js";
3
- function evaluate({
4
- code,
5
- context,
6
- state,
7
- event
8
- }) {
9
- if (code === "") {
10
- console.warn("Skipping evaluation of empty code block.");
11
- return;
12
- }
13
- const builder = {
14
- isEditing: isEditing(),
15
- isBrowser: isBrowser(),
16
- isServer: !isBrowser()
17
- };
18
- const useReturn = !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
19
- const useCode = useReturn ? `return (${code});` : code;
20
- try {
21
- return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
22
- } catch (e) {
23
- console.warn("Builder custom code error: ", e);
24
- }
25
- }
26
- export {
27
- evaluate
28
- };
@@ -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,4 +0,0 @@
1
- const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
2
- export {
3
- fastClone
4
- };
@@ -1,23 +0,0 @@
1
- import { evaluate } from "./evaluate.js";
2
- import { getEventHandlerName } from "./event-handler-name.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)] = (event) => evaluate({
13
- code: value,
14
- context: options.context,
15
- state: options.state,
16
- event
17
- });
18
- }
19
- return obj;
20
- }
21
- export {
22
- getBlockActions
23
- };
@@ -1,23 +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
- function getBlockComponentOptions(block) {
18
- var _a;
19
- return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options);
20
- }
21
- export {
22
- getBlockComponentOptions
23
- };
@@ -1,29 +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 getBlockProperties(block) {
21
- var _a;
22
- return __spreadProps(__spreadValues({}, block.properties), {
23
- "builder-id": block.id,
24
- class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
25
- });
26
- }
27
- export {
28
- getBlockProperties
29
- };