@builder.io/sdk-react 0.5.8 → 0.6.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 (321) hide show
  1. package/README.md +0 -4
  2. package/lib/browser/index.cjs +97 -0
  3. package/lib/browser/index.mjs +2598 -0
  4. package/lib/browser/server-entry-2e639417.js +2 -0
  5. package/lib/browser/server-entry-f7504f89.mjs +534 -0
  6. package/lib/browser/server-entry.cjs +1 -0
  7. package/lib/browser/server-entry.mjs +16 -0
  8. package/lib/edge/index.cjs +117 -0
  9. package/lib/edge/index.mjs +5042 -0
  10. package/lib/edge/server-entry-2e639417.js +2 -0
  11. package/lib/edge/server-entry-f7504f89.mjs +534 -0
  12. package/lib/edge/server-entry.cjs +1 -0
  13. package/lib/edge/server-entry.mjs +16 -0
  14. package/lib/node/index.cjs +97 -0
  15. package/lib/node/index.mjs +2598 -0
  16. package/lib/node/server-entry-2e639417.js +2 -0
  17. package/lib/node/server-entry-f7504f89.mjs +534 -0
  18. package/lib/node/server-entry.cjs +1 -0
  19. package/lib/node/server-entry.mjs +16 -0
  20. package/package.json +97 -11
  21. package/{dist → types}/components/content/content.types.d.ts +2 -2
  22. package/{dist → types}/components/content-variants/content-variants.d.ts +2 -2
  23. package/{dist → types}/components/content-variants/content-variants.types.d.ts +1 -1
  24. package/types/constants/sdk-version.d.ts +1 -0
  25. package/types/functions/deopt.d.ts +4 -0
  26. package/types/functions/evaluate/browser-runtime/browser.d.ts +4 -0
  27. package/types/functions/evaluate/browser-runtime/index.d.ts +1 -0
  28. package/types/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  29. package/types/functions/evaluate/edge-runtime/index.d.ts +1 -0
  30. package/types/functions/evaluate/evaluate.d.ts +6 -0
  31. package/types/functions/evaluate/helpers.d.ts +18 -0
  32. package/types/functions/evaluate/index.d.ts +1 -0
  33. package/types/functions/evaluate/node-runtime/index.d.ts +1 -0
  34. package/types/functions/evaluate/placeholder-runtime.d.ts +2 -0
  35. package/{dist → types}/functions/fetch-builder-props.d.ts +4 -3
  36. package/{dist → types}/functions/get-content/index.d.ts +4 -5
  37. package/types/functions/is-edge-runtime.d.ts +4 -0
  38. package/{dist → types}/index-helpers/blocks-exports.d.ts +2 -2
  39. package/types/index.d.ts +7 -0
  40. package/{dist/index.d.ts → types/server-index.d.ts} +0 -1
  41. package/dist/blocks/BaseText.js +0 -9
  42. package/dist/blocks/button/button.js +0 -12
  43. package/dist/blocks/button/component-info.js +0 -34
  44. package/dist/blocks/columns/columns.js +0 -121
  45. package/dist/blocks/columns/component-info.js +0 -219
  46. package/dist/blocks/custom-code/component-info.js +0 -23
  47. package/dist/blocks/custom-code/custom-code.js +0 -51
  48. package/dist/blocks/embed/component-info.js +0 -39
  49. package/dist/blocks/embed/embed.js +0 -42
  50. package/dist/blocks/embed/helpers.js +0 -2
  51. package/dist/blocks/form/component-info.js +0 -232
  52. package/dist/blocks/form/form.js +0 -6
  53. package/dist/blocks/fragment/component-info.js +0 -7
  54. package/dist/blocks/fragment/fragment.js +0 -6
  55. package/dist/blocks/helpers.js +0 -40
  56. package/dist/blocks/image/component-info.js +0 -122
  57. package/dist/blocks/image/image.helpers.js +0 -47
  58. package/dist/blocks/image/image.js +0 -82
  59. package/dist/blocks/img/component-info.js +0 -15
  60. package/dist/blocks/img/img.js +0 -10
  61. package/dist/blocks/input/component-info.js +0 -46
  62. package/dist/blocks/input/input.js +0 -7
  63. package/dist/blocks/raw-text/component-info.js +0 -10
  64. package/dist/blocks/raw-text/raw-text.js +0 -6
  65. package/dist/blocks/section/component-info.js +0 -40
  66. package/dist/blocks/section/section.js +0 -17
  67. package/dist/blocks/select/component-info.js +0 -43
  68. package/dist/blocks/select/select.js +0 -7
  69. package/dist/blocks/submit-button/component-info.js +0 -26
  70. package/dist/blocks/submit-button/submit-button.js +0 -6
  71. package/dist/blocks/symbol/component-info.js +0 -34
  72. package/dist/blocks/symbol/symbol.helpers.js +0 -31
  73. package/dist/blocks/symbol/symbol.js +0 -45
  74. package/dist/blocks/text/component-info.js +0 -19
  75. package/dist/blocks/text/text.js +0 -8
  76. package/dist/blocks/textarea/component-info.js +0 -37
  77. package/dist/blocks/textarea/textarea.js +0 -6
  78. package/dist/blocks/video/component-info.js +0 -82
  79. package/dist/blocks/video/video.js +0 -50
  80. package/dist/components/block/block.helpers.js +0 -69
  81. package/dist/components/block/block.js +0 -94
  82. package/dist/components/block/components/block-styles.js +0 -65
  83. package/dist/components/block/components/block-wrapper.js +0 -36
  84. package/dist/components/block/components/component-ref/component-ref.helpers.js +0 -22
  85. package/dist/components/block/components/component-ref/component-ref.js +0 -23
  86. package/dist/components/block/components/interactive-element.js +0 -20
  87. package/dist/components/block/components/repeated-block.js +0 -11
  88. package/dist/components/block/types.js +0 -1
  89. package/dist/components/blocks/blocks-wrapper.js +0 -38
  90. package/dist/components/blocks/blocks.js +0 -17
  91. package/dist/components/content/components/enable-editor.js +0 -271
  92. package/dist/components/content/components/styles.helpers.js +0 -58
  93. package/dist/components/content/components/styles.js +0 -32
  94. package/dist/components/content/content.helpers.js +0 -30
  95. package/dist/components/content/content.js +0 -85
  96. package/dist/components/content/content.types.js +0 -1
  97. package/dist/components/content/index.js +0 -1
  98. package/dist/components/content/wrap-component-ref.js +0 -6
  99. package/dist/components/content-variants/content-variants.js +0 -52
  100. package/dist/components/content-variants/content-variants.types.js +0 -1
  101. package/dist/components/content-variants/helpers.js +0 -189
  102. package/dist/components/inlined-script.js +0 -6
  103. package/dist/components/inlined-styles.js +0 -6
  104. package/dist/constants/builder-registered-components.js +0 -60
  105. package/dist/constants/device-sizes.js +0 -45
  106. package/dist/constants/sdk-version.d.ts +0 -1
  107. package/dist/constants/sdk-version.js +0 -1
  108. package/dist/constants/target.js +0 -2
  109. package/dist/context/builder.context.js +0 -12
  110. package/dist/context/components.context.js +0 -2
  111. package/dist/context/types.js +0 -1
  112. package/dist/functions/apply-patch-with-mutation.js +0 -54
  113. package/dist/functions/camel-to-kebab-case.js +0 -1
  114. package/dist/functions/evaluate/acorn-interpreter.js +0 -3111
  115. package/dist/functions/evaluate/evaluate.d.ts +0 -10
  116. package/dist/functions/evaluate/evaluate.js +0 -70
  117. package/dist/functions/evaluate/index.d.ts +0 -1
  118. package/dist/functions/evaluate/index.js +0 -1
  119. package/dist/functions/evaluate/non-node-runtime/index.d.ts +0 -1
  120. package/dist/functions/evaluate/non-node-runtime/index.js +0 -2
  121. package/dist/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +0 -2
  122. package/dist/functions/evaluate/non-node-runtime/non-node-runtime.js +0 -84
  123. package/dist/functions/evaluate/types.d.ts +0 -11
  124. package/dist/functions/evaluate/types.js +0 -1
  125. package/dist/functions/event-handler-name.js +0 -4
  126. package/dist/functions/extract-text-styles.js +0 -22
  127. package/dist/functions/fast-clone.js +0 -4
  128. package/dist/functions/fetch-builder-props.js +0 -25
  129. package/dist/functions/get-block-actions-handler.js +0 -10
  130. package/dist/functions/get-block-actions.js +0 -28
  131. package/dist/functions/get-block-component-options.js +0 -10
  132. package/dist/functions/get-block-properties.js +0 -72
  133. package/dist/functions/get-builder-search-params/index.js +0 -38
  134. package/dist/functions/get-content/generate-content-url.js +0 -33
  135. package/dist/functions/get-content/index.js +0 -100
  136. package/dist/functions/get-content/types.js +0 -1
  137. package/dist/functions/get-fetch.js +0 -11
  138. package/dist/functions/get-global-this.js +0 -15
  139. package/dist/functions/get-processed-block.js +0 -46
  140. package/dist/functions/get-react-native-block-styles.js +0 -17
  141. package/dist/functions/is-browser.js +0 -3
  142. package/dist/functions/is-editing.js +0 -5
  143. package/dist/functions/is-iframe.js +0 -4
  144. package/dist/functions/is-non-node-server.d.ts +0 -4
  145. package/dist/functions/is-non-node-server.js +0 -8
  146. package/dist/functions/is-previewing.js +0 -11
  147. package/dist/functions/on-change.js +0 -28
  148. package/dist/functions/register-component.js +0 -38
  149. package/dist/functions/register.js +0 -27
  150. package/dist/functions/sanitize-react-native-block-styles.js +0 -61
  151. package/dist/functions/set-editor-settings.js +0 -12
  152. package/dist/functions/set.js +0 -14
  153. package/dist/functions/track/helpers.js +0 -51
  154. package/dist/functions/track/index.js +0 -71
  155. package/dist/functions/track/interaction.js +0 -53
  156. package/dist/functions/transform-block-properties.js +0 -5
  157. package/dist/functions/transform-block.js +0 -4
  158. package/dist/helpers/ab-tests.js +0 -122
  159. package/dist/helpers/canTrack.js +0 -2
  160. package/dist/helpers/cookie.js +0 -55
  161. package/dist/helpers/css.js +0 -27
  162. package/dist/helpers/flatten.js +0 -19
  163. package/dist/helpers/localStorage.js +0 -24
  164. package/dist/helpers/logger.js +0 -7
  165. package/dist/helpers/nullable.js +0 -1
  166. package/dist/helpers/preview-lru-cache/get.js +0 -3
  167. package/dist/helpers/preview-lru-cache/helpers.js +0 -0
  168. package/dist/helpers/preview-lru-cache/init.js +0 -6
  169. package/dist/helpers/preview-lru-cache/set.js +0 -5
  170. package/dist/helpers/preview-lru-cache/types.js +0 -0
  171. package/dist/helpers/sessionId.js +0 -30
  172. package/dist/helpers/time.js +0 -2
  173. package/dist/helpers/url.js +0 -15
  174. package/dist/helpers/uuid.js +0 -15
  175. package/dist/helpers/visitorId.js +0 -30
  176. package/dist/index-helpers/blocks-exports.js +0 -19
  177. package/dist/index-helpers/top-of-file.js +0 -4
  178. package/dist/index.js +0 -11
  179. package/dist/scripts/init-editing.js +0 -110
  180. package/dist/types/api-version.js +0 -1
  181. package/dist/types/builder-block.js +0 -1
  182. package/dist/types/builder-content.js +0 -1
  183. package/dist/types/builder-props.js +0 -1
  184. package/dist/types/can-track.js +0 -1
  185. package/dist/types/components.js +0 -1
  186. package/dist/types/deep-partial.js +0 -1
  187. package/dist/types/element.js +0 -1
  188. package/dist/types/enforced-partials.js +0 -1
  189. package/dist/types/input.js +0 -1
  190. package/dist/types/targets.js +0 -1
  191. package/dist/types/typescript.js +0 -1
  192. /package/{dist → types}/blocks/BaseText.d.ts +0 -0
  193. /package/{dist → types}/blocks/button/button.d.ts +0 -0
  194. /package/{dist → types}/blocks/button/component-info.d.ts +0 -0
  195. /package/{dist → types}/blocks/columns/columns.d.ts +0 -0
  196. /package/{dist → types}/blocks/columns/component-info.d.ts +0 -0
  197. /package/{dist → types}/blocks/custom-code/component-info.d.ts +0 -0
  198. /package/{dist → types}/blocks/custom-code/custom-code.d.ts +0 -0
  199. /package/{dist → types}/blocks/embed/component-info.d.ts +0 -0
  200. /package/{dist → types}/blocks/embed/embed.d.ts +0 -0
  201. /package/{dist → types}/blocks/embed/helpers.d.ts +0 -0
  202. /package/{dist → types}/blocks/form/component-info.d.ts +0 -0
  203. /package/{dist → types}/blocks/form/form.d.ts +0 -0
  204. /package/{dist → types}/blocks/fragment/component-info.d.ts +0 -0
  205. /package/{dist → types}/blocks/fragment/fragment.d.ts +0 -0
  206. /package/{dist → types}/blocks/helpers.d.ts +0 -0
  207. /package/{dist → types}/blocks/image/component-info.d.ts +0 -0
  208. /package/{dist → types}/blocks/image/image.d.ts +0 -0
  209. /package/{dist → types}/blocks/image/image.helpers.d.ts +0 -0
  210. /package/{dist → types}/blocks/img/component-info.d.ts +0 -0
  211. /package/{dist → types}/blocks/img/img.d.ts +0 -0
  212. /package/{dist → types}/blocks/input/component-info.d.ts +0 -0
  213. /package/{dist → types}/blocks/input/input.d.ts +0 -0
  214. /package/{dist → types}/blocks/raw-text/component-info.d.ts +0 -0
  215. /package/{dist → types}/blocks/raw-text/raw-text.d.ts +0 -0
  216. /package/{dist → types}/blocks/section/component-info.d.ts +0 -0
  217. /package/{dist → types}/blocks/section/section.d.ts +0 -0
  218. /package/{dist → types}/blocks/select/component-info.d.ts +0 -0
  219. /package/{dist → types}/blocks/select/select.d.ts +0 -0
  220. /package/{dist → types}/blocks/submit-button/component-info.d.ts +0 -0
  221. /package/{dist → types}/blocks/submit-button/submit-button.d.ts +0 -0
  222. /package/{dist → types}/blocks/symbol/component-info.d.ts +0 -0
  223. /package/{dist → types}/blocks/symbol/symbol.d.ts +0 -0
  224. /package/{dist → types}/blocks/symbol/symbol.helpers.d.ts +0 -0
  225. /package/{dist → types}/blocks/text/component-info.d.ts +0 -0
  226. /package/{dist → types}/blocks/text/text.d.ts +0 -0
  227. /package/{dist → types}/blocks/textarea/component-info.d.ts +0 -0
  228. /package/{dist → types}/blocks/textarea/textarea.d.ts +0 -0
  229. /package/{dist → types}/blocks/video/component-info.d.ts +0 -0
  230. /package/{dist → types}/blocks/video/video.d.ts +0 -0
  231. /package/{dist → types}/components/block/block.d.ts +0 -0
  232. /package/{dist → types}/components/block/block.helpers.d.ts +0 -0
  233. /package/{dist → types}/components/block/components/block-styles.d.ts +0 -0
  234. /package/{dist → types}/components/block/components/block-wrapper.d.ts +0 -0
  235. /package/{dist → types}/components/block/components/component-ref/component-ref.d.ts +0 -0
  236. /package/{dist → types}/components/block/components/component-ref/component-ref.helpers.d.ts +0 -0
  237. /package/{dist → types}/components/block/components/interactive-element.d.ts +0 -0
  238. /package/{dist → types}/components/block/components/repeated-block.d.ts +0 -0
  239. /package/{dist → types}/components/block/types.d.ts +0 -0
  240. /package/{dist → types}/components/blocks/blocks-wrapper.d.ts +0 -0
  241. /package/{dist → types}/components/blocks/blocks.d.ts +0 -0
  242. /package/{dist → types}/components/content/components/enable-editor.d.ts +0 -0
  243. /package/{dist → types}/components/content/components/styles.d.ts +0 -0
  244. /package/{dist → types}/components/content/components/styles.helpers.d.ts +0 -0
  245. /package/{dist → types}/components/content/content.d.ts +0 -0
  246. /package/{dist → types}/components/content/content.helpers.d.ts +0 -0
  247. /package/{dist → types}/components/content/index.d.ts +0 -0
  248. /package/{dist → types}/components/content/wrap-component-ref.d.ts +0 -0
  249. /package/{dist → types}/components/content-variants/helpers.d.ts +0 -0
  250. /package/{dist → types}/components/inlined-script.d.ts +0 -0
  251. /package/{dist → types}/components/inlined-styles.d.ts +0 -0
  252. /package/{dist → types}/constants/builder-registered-components.d.ts +0 -0
  253. /package/{dist → types}/constants/device-sizes.d.ts +0 -0
  254. /package/{dist → types}/constants/target.d.ts +0 -0
  255. /package/{dist → types}/context/builder.context.d.ts +0 -0
  256. /package/{dist → types}/context/components.context.d.ts +0 -0
  257. /package/{dist → types}/context/types.d.ts +0 -0
  258. /package/{dist → types}/functions/apply-patch-with-mutation.d.ts +0 -0
  259. /package/{dist → types}/functions/camel-to-kebab-case.d.ts +0 -0
  260. /package/{dist/functions/evaluate → types/functions/evaluate/edge-runtime}/acorn-interpreter.d.ts +0 -0
  261. /package/{dist → types}/functions/event-handler-name.d.ts +0 -0
  262. /package/{dist → types}/functions/extract-text-styles.d.ts +0 -0
  263. /package/{dist → types}/functions/fast-clone.d.ts +0 -0
  264. /package/{dist → types}/functions/get-block-actions-handler.d.ts +0 -0
  265. /package/{dist → types}/functions/get-block-actions.d.ts +0 -0
  266. /package/{dist → types}/functions/get-block-component-options.d.ts +0 -0
  267. /package/{dist → types}/functions/get-block-properties.d.ts +0 -0
  268. /package/{dist → types}/functions/get-builder-search-params/index.d.ts +0 -0
  269. /package/{dist → types}/functions/get-content/generate-content-url.d.ts +0 -0
  270. /package/{dist → types}/functions/get-content/types.d.ts +0 -0
  271. /package/{dist → types}/functions/get-fetch.d.ts +0 -0
  272. /package/{dist → types}/functions/get-global-this.d.ts +0 -0
  273. /package/{dist → types}/functions/get-processed-block.d.ts +0 -0
  274. /package/{dist → types}/functions/get-react-native-block-styles.d.ts +0 -0
  275. /package/{dist → types}/functions/is-browser.d.ts +0 -0
  276. /package/{dist → types}/functions/is-editing.d.ts +0 -0
  277. /package/{dist → types}/functions/is-iframe.d.ts +0 -0
  278. /package/{dist → types}/functions/is-previewing.d.ts +0 -0
  279. /package/{dist → types}/functions/on-change.d.ts +0 -0
  280. /package/{dist → types}/functions/register-component.d.ts +0 -0
  281. /package/{dist → types}/functions/register.d.ts +0 -0
  282. /package/{dist → types}/functions/sanitize-react-native-block-styles.d.ts +0 -0
  283. /package/{dist → types}/functions/set-editor-settings.d.ts +0 -0
  284. /package/{dist → types}/functions/set.d.ts +0 -0
  285. /package/{dist → types}/functions/track/helpers.d.ts +0 -0
  286. /package/{dist → types}/functions/track/index.d.ts +0 -0
  287. /package/{dist → types}/functions/track/interaction.d.ts +0 -0
  288. /package/{dist → types}/functions/transform-block-properties.d.ts +0 -0
  289. /package/{dist → types}/functions/transform-block.d.ts +0 -0
  290. /package/{dist → types}/helpers/ab-tests.d.ts +0 -0
  291. /package/{dist → types}/helpers/canTrack.d.ts +0 -0
  292. /package/{dist → types}/helpers/cookie.d.ts +0 -0
  293. /package/{dist → types}/helpers/css.d.ts +0 -0
  294. /package/{dist → types}/helpers/flatten.d.ts +0 -0
  295. /package/{dist → types}/helpers/localStorage.d.ts +0 -0
  296. /package/{dist → types}/helpers/logger.d.ts +0 -0
  297. /package/{dist → types}/helpers/nullable.d.ts +0 -0
  298. /package/{dist → types}/helpers/preview-lru-cache/get.d.ts +0 -0
  299. /package/{dist → types}/helpers/preview-lru-cache/helpers.d.ts +0 -0
  300. /package/{dist → types}/helpers/preview-lru-cache/init.d.ts +0 -0
  301. /package/{dist → types}/helpers/preview-lru-cache/set.d.ts +0 -0
  302. /package/{dist → types}/helpers/preview-lru-cache/types.d.ts +0 -0
  303. /package/{dist → types}/helpers/sessionId.d.ts +0 -0
  304. /package/{dist → types}/helpers/time.d.ts +0 -0
  305. /package/{dist → types}/helpers/url.d.ts +0 -0
  306. /package/{dist → types}/helpers/uuid.d.ts +0 -0
  307. /package/{dist → types}/helpers/visitorId.d.ts +0 -0
  308. /package/{dist → types}/index-helpers/top-of-file.d.ts +0 -0
  309. /package/{dist → types}/scripts/init-editing.d.ts +0 -0
  310. /package/{dist → types}/types/api-version.d.ts +0 -0
  311. /package/{dist → types}/types/builder-block.d.ts +0 -0
  312. /package/{dist → types}/types/builder-content.d.ts +0 -0
  313. /package/{dist → types}/types/builder-props.d.ts +0 -0
  314. /package/{dist → types}/types/can-track.d.ts +0 -0
  315. /package/{dist → types}/types/components.d.ts +0 -0
  316. /package/{dist → types}/types/deep-partial.d.ts +0 -0
  317. /package/{dist → types}/types/element.d.ts +0 -0
  318. /package/{dist → types}/types/enforced-partials.d.ts +0 -0
  319. /package/{dist → types}/types/input.d.ts +0 -0
  320. /package/{dist → types}/types/targets.d.ts +0 -0
  321. /package/{dist → types}/types/typescript.d.ts +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";const m=t=>JSON.parse(JSON.stringify(t)),g="react",f="[Builder.io]: ",c={log:(...t)=>console.log(f,...t),error:(...t)=>console.error(f,...t),warn:(...t)=>console.warn(f,...t),debug:(...t)=>console.debug(f,...t)};function s(){return typeof window<"u"&&typeof document<"u"}function q(){return s()&&window.self!==window.top}function w(){return q()&&window.location.search.indexOf("builder.frameEditing=")!==-1}const H=()=>{if(s()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Y=()=>typeof navigator=="object"&&navigator.userAgent||"",R=()=>{const t=Y(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||g==="reactNative"}},n=t.match(/Tablet|iPad/i),r=H();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},u=t=>t!=null,Q=[],Z=t=>({type:"builder.registerComponent",data:B(t)}),tt=t=>{const e=t.toString().trim();return`return (${!e.startsWith("function")&&!e.startsWith("(")?"function ":""}${e}).apply(this, arguments)`},et=t=>typeof t=="function"?tt(t):m(t),B=({inputs:t,...e})=>({...m(e),inputs:t==null?void 0:t.map(n=>Object.entries(n).reduce((r,[o,i])=>({...r,[o]:et(i)}),{}))});function nt(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:globalThis}function rt(){const t=nt().fetch;if(typeof t>"u")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const V=rt(),ot=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},L=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){c.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},$=async t=>L(t),it=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(u).join("; "),st=[["secure",""],["SameSite","None"]],at=({name:t,value:e,expires:n})=>{const o=(s()?location.protocol==="https:":!0)?st:[[]],i=n?[["expires",n.toUTCString()]]:[[]],a=[[t,e],...i,["path","/"],["domain",ot(window.location.hostname)],...o];return it(a)},j=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const o=at({name:t,value:e,expires:n});document.cookie=o}catch(o){c.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ct(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function D(){return ct().replace(/-/g,"")}const F="builderSessionId",ut=async({canTrack:t})=>{if(!t)return;const e=await $({name:F,canTrack:t});if(u(e))return e;{const n=lt();return dt({id:n,canTrack:t}),n}},lt=()=>D(),dt=({id:t,canTrack:e})=>j({name:F,value:t,canTrack:e}),K=()=>s()&&typeof localStorage<"u"?localStorage:void 0,ft=({key:t,canTrack:e})=>{var n;try{return e?(n=K())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},gt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=K())==null||r.setItem(t,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},M="builderVisitorId",ht=({canTrack:t})=>{if(!t)return;const e=ft({key:M,canTrack:t});if(u(e))return e;{const n=pt();return yt({id:n,canTrack:t}),n}},pt=()=>D(),yt=({id:t,canTrack:e})=>gt({key:M,value:t,canTrack:e}),mt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await ut({canTrack:t}),n=ht({canTrack:t});return{sessionId:e,visitorId:n}},wt=async({type:t,canTrack:e,apiKey:n,metadata:r,...o})=>({type:t,data:{...o,metadata:{url:location.href,...r},...await mt({canTrack:e}),userAttributes:R(),ownerId:n}});async function N(t){if(!t.apiKey){c.error("Missing API key for track call. Please provide your API key.");return}if(t.canTrack&&!w()&&(s()||g==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await wt(t)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(e=>{console.error("Failed to track: ",e)})}const St=t=>N({...t,canTrack:!0}),x={};function It(t,e){let n=x[t];if(n||(n=x[t]=[]),n.push(e),s()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const vt="builder.tests",S=t=>`${vt}.${t}`,bt=({contentId:t})=>$({name:S(t),canTrack:!0}),Ct=({contentId:t})=>L({name:S(t),canTrack:!0}),Et=({contentId:t,value:e})=>j({name:S(t),value:e,canTrack:!0}),U=t=>u(t.id)&&u(t.variations)&&Object.keys(t.variations).length>0,kt=({id:t,variations:e})=>{var o;let n=0;const r=Math.random();for(const i in e){const a=(o=e[i])==null?void 0:o.testRatio;if(n+=a,r<n)return i}return t},_=t=>{const e=kt(t);return Et({contentId:t.id,value:e}).catch(n=>{c.error("could not store A/B test variation: ",n)}),e},G=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Ot=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!U(t))return t;const n=Ct({contentId:t.id})||_({variations:t.variations,id:t.id}),r=G({item:t,testGroupId:n});return{...t,...r}},At=async({item:t,canTrack:e})=>{if(!e||!U(t))return t;const r=await bt({contentId:t.id})||_({variations:t.variations,id:t.id}),o=G({item:t,testGroupId:r});return{...t,...o}},W=t=>u(t)?t:!0;function y(t,e=null,n="."){return Object.keys(t).reduce((r,o)=>{const i=t[o],a=[e,o].filter(Boolean).join(n);return[typeof i=="object",i!==null,!(Array.isArray(i)&&i.length===0)].every(Boolean)?{...r,...y(i,a,n)}:{...r,[a]:i}},{})}const P="builder.",xt="options.",Pt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},I=t=>{if(!t)return{};const e=z(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(P)){const o=r.replace(P,"").replace(xt,"");n[o]=e[r]}}),n},Tt=()=>{if(!s())return{};const t=new URLSearchParams(window.location.search);return I(t)},z=t=>t instanceof URLSearchParams?Pt(t):t,Rt="v3",v=t=>{const{limit:e=30,userAttributes:n,query:r,noTraverse:o=!1,model:i,apiKey:a,includeRefs:h=!0,enrich:E,locale:k,apiVersion:p=Rt}=t;if(!a)throw new Error("Missing API key");if(!["v2","v3"].includes(p))throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${p}'`);const d=new URL(`https://cdn.builder.io/api/${p}/content/${i}?apiKey=${a}&limit=${e}&noTraverse=${o}&includeRefs=${h}${k?`&locale=${k}`:""}${E?`&enrich=${E}`:""}`),X={...Tt(),...z(t.options||{})},O=y(X);for(const l in O)d.searchParams.set(l,String(O[l]));if(n&&d.searchParams.set("userAttributes",JSON.stringify(n)),r){const l=y({query:r});for(const A in l)d.searchParams.set(A,JSON.stringify(l[A]))}return d},Bt=t=>"results"in t;async function b(t){const e=await C({...t,limit:1});return e&&e.results[0]||null}const Vt=b,Lt=async t=>{const e=v(t);return await(await V(e.href)).json()},J=async(t,e,n=v(t))=>{const r=W(t.canTrack);if(n.search.includes("preview="),!r||!(s()||g==="reactNative"))return e;try{const o=[];for(const i of e.results)o.push(await At({item:i,canTrack:r}));e.results=o}catch(o){c.error("Could not process A/B tests. ",o)}return e};async function C(t){try{const e=v(t),n=await Lt(t);return Bt(n)?J(t,n):(c.error("Error fetching data. ",{url:e,content:n,options:t}),null)}catch(e){return c.error("Error fetching data. ",e),null}}const $t=C;function jt(){return!s()||w()?!1:location.search.indexOf("builder.preview=")!==-1}const T={};function Dt(t){if(s()){Object.assign(T,t);const e={type:"builder.settingsChange",data:T};parent.postMessage(e,"*")}}const Ft=async t=>{var r,o,i;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((o=t.userAttributes)==null?void 0:o.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:I(t.searchParams||((i=t.url)==null?void 0:i.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await b(n)}};exports.TARGET=g;exports._processContentResult=J;exports._track=N;exports.checkIsDefined=u;exports.components=Q;exports.createRegisterComponentMessage=Z;exports.fastClone=m;exports.fetch=V;exports.fetchBuilderProps=Ft;exports.fetchEntries=C;exports.fetchOneEntry=b;exports.getAllContent=$t;exports.getBuilderSearchParams=I;exports.getContent=Vt;exports.getDefaultCanTrack=W;exports.getUserAttributes=R;exports.handleABTestingSync=Ot;exports.isBrowser=s;exports.isEditing=w;exports.isPreviewing=jt;exports.logger=c;exports.register=It;exports.serializeComponentInfo=B;exports.setEditorSettings=Dt;exports.track=St;
@@ -0,0 +1,534 @@
1
+ const C = (t) => JSON.parse(JSON.stringify(t)), y = "react", f = "[Builder.io]: ", c = {
2
+ log: (...t) => console.log(f, ...t),
3
+ error: (...t) => console.error(f, ...t),
4
+ warn: (...t) => console.warn(f, ...t),
5
+ debug: (...t) => console.debug(f, ...t)
6
+ };
7
+ function i() {
8
+ return typeof window < "u" && typeof document < "u";
9
+ }
10
+ function _() {
11
+ return i() && window.self !== window.top;
12
+ }
13
+ function x() {
14
+ return _() && window.location.search.indexOf("builder.frameEditing=") !== -1;
15
+ }
16
+ const G = () => {
17
+ if (i()) {
18
+ const t = new URL(location.href);
19
+ return t.pathname === "" && (t.pathname = "/"), t;
20
+ } else
21
+ return console.warn("Cannot get location for tracking in non-browser environment"), null;
22
+ }, W = () => typeof navigator == "object" && navigator.userAgent || "", J = () => {
23
+ const t = W(), e = {
24
+ Android() {
25
+ return t.match(/Android/i);
26
+ },
27
+ BlackBerry() {
28
+ return t.match(/BlackBerry/i);
29
+ },
30
+ iOS() {
31
+ return t.match(/iPhone|iPod/i);
32
+ },
33
+ Opera() {
34
+ return t.match(/Opera Mini/i);
35
+ },
36
+ Windows() {
37
+ return t.match(/IEMobile/i) || t.match(/WPDesktop/i);
38
+ },
39
+ any() {
40
+ return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || y === "reactNative";
41
+ }
42
+ }, n = t.match(/Tablet|iPad/i), r = G();
43
+ return {
44
+ urlPath: r == null ? void 0 : r.pathname,
45
+ host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
46
+ device: n ? "tablet" : e.any() ? "mobile" : "desktop"
47
+ };
48
+ }, u = (t) => t != null, Pt = [], Tt = (t) => ({
49
+ type: "builder.registerComponent",
50
+ data: q(t)
51
+ }), z = (t) => {
52
+ const e = t.toString().trim();
53
+ return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
54
+ }, X = (t) => typeof t == "function" ? z(t) : C(t), q = ({
55
+ inputs: t,
56
+ ...e
57
+ }) => ({
58
+ ...C(e),
59
+ inputs: t == null ? void 0 : t.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
60
+ ...r,
61
+ [o]: X(s)
62
+ }), {}))
63
+ });
64
+ function H() {
65
+ return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis;
66
+ }
67
+ function Y() {
68
+ const t = H().fetch;
69
+ if (typeof t > "u")
70
+ throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
71
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
72
+ return t;
73
+ }
74
+ const Q = Y(), Z = (t) => {
75
+ if (t === "localhost" || t === "127.0.0.1")
76
+ return t;
77
+ const e = t.split(".");
78
+ return e.length > 2 ? e.slice(1).join(".") : t;
79
+ }, A = ({
80
+ name: t,
81
+ canTrack: e
82
+ }) => {
83
+ var n;
84
+ try {
85
+ return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
86
+ } catch (r) {
87
+ c.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
88
+ return;
89
+ }
90
+ }, P = async (t) => A(t), tt = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(u).join("; "), et = [["secure", ""], ["SameSite", "None"]], nt = ({
91
+ name: t,
92
+ value: e,
93
+ expires: n
94
+ }) => {
95
+ const o = (i() ? location.protocol === "https:" : !0) ? et : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", Z(window.location.hostname)], ...o];
96
+ return tt(a);
97
+ }, T = async ({
98
+ name: t,
99
+ value: e,
100
+ expires: n,
101
+ canTrack: r
102
+ }) => {
103
+ try {
104
+ if (!r)
105
+ return;
106
+ const o = nt({
107
+ name: t,
108
+ value: e,
109
+ expires: n
110
+ });
111
+ document.cookie = o;
112
+ } catch (o) {
113
+ c.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
114
+ }
115
+ };
116
+ function rt() {
117
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
118
+ const e = Math.random() * 16 | 0;
119
+ return (t == "x" ? e : e & 3 | 8).toString(16);
120
+ });
121
+ }
122
+ function R() {
123
+ return rt().replace(/-/g, "");
124
+ }
125
+ const V = "builderSessionId", ot = async ({
126
+ canTrack: t
127
+ }) => {
128
+ if (!t)
129
+ return;
130
+ const e = await P({
131
+ name: V,
132
+ canTrack: t
133
+ });
134
+ if (u(e))
135
+ return e;
136
+ {
137
+ const n = st();
138
+ return it({
139
+ id: n,
140
+ canTrack: t
141
+ }), n;
142
+ }
143
+ }, st = () => R(), it = ({
144
+ id: t,
145
+ canTrack: e
146
+ }) => T({
147
+ name: V,
148
+ value: t,
149
+ canTrack: e
150
+ }), B = () => i() && typeof localStorage < "u" ? localStorage : void 0, at = ({
151
+ key: t,
152
+ canTrack: e
153
+ }) => {
154
+ var n;
155
+ try {
156
+ return e ? (n = B()) == null ? void 0 : n.getItem(t) : void 0;
157
+ } catch (r) {
158
+ console.debug("[LocalStorage] GET error: ", r);
159
+ return;
160
+ }
161
+ }, ct = ({
162
+ key: t,
163
+ canTrack: e,
164
+ value: n
165
+ }) => {
166
+ var r;
167
+ try {
168
+ e && ((r = B()) == null || r.setItem(t, n));
169
+ } catch (o) {
170
+ console.debug("[LocalStorage] SET error: ", o);
171
+ }
172
+ }, L = "builderVisitorId", ut = ({
173
+ canTrack: t
174
+ }) => {
175
+ if (!t)
176
+ return;
177
+ const e = at({
178
+ key: L,
179
+ canTrack: t
180
+ });
181
+ if (u(e))
182
+ return e;
183
+ {
184
+ const n = lt();
185
+ return dt({
186
+ id: n,
187
+ canTrack: t
188
+ }), n;
189
+ }
190
+ }, lt = () => R(), dt = ({
191
+ id: t,
192
+ canTrack: e
193
+ }) => ct({
194
+ key: L,
195
+ value: t,
196
+ canTrack: e
197
+ }), ft = async ({
198
+ canTrack: t
199
+ }) => {
200
+ if (!t)
201
+ return {
202
+ visitorId: void 0,
203
+ sessionId: void 0
204
+ };
205
+ const e = await ot({
206
+ canTrack: t
207
+ }), n = ut({
208
+ canTrack: t
209
+ });
210
+ return {
211
+ sessionId: e,
212
+ visitorId: n
213
+ };
214
+ }, ht = async ({
215
+ type: t,
216
+ canTrack: e,
217
+ apiKey: n,
218
+ metadata: r,
219
+ ...o
220
+ }) => ({
221
+ type: t,
222
+ data: {
223
+ ...o,
224
+ metadata: {
225
+ url: location.href,
226
+ ...r
227
+ },
228
+ ...await ft({
229
+ canTrack: e
230
+ }),
231
+ userAttributes: J(),
232
+ ownerId: n
233
+ }
234
+ });
235
+ async function gt(t) {
236
+ if (!t.apiKey) {
237
+ c.error("Missing API key for track call. Please provide your API key.");
238
+ return;
239
+ }
240
+ if (t.canTrack && !x() && (i() || y === "reactNative"))
241
+ return fetch("https://cdn.builder.io/api/v1/track", {
242
+ method: "POST",
243
+ body: JSON.stringify({
244
+ events: [await ht(t)]
245
+ }),
246
+ headers: {
247
+ "content-type": "application/json"
248
+ },
249
+ mode: "cors"
250
+ }).catch((e) => {
251
+ console.error("Failed to track: ", e);
252
+ });
253
+ }
254
+ const Rt = (t) => gt({
255
+ ...t,
256
+ canTrack: !0
257
+ }), O = {};
258
+ function Vt(t, e) {
259
+ let n = O[t];
260
+ if (n || (n = O[t] = []), n.push(e), i()) {
261
+ const r = {
262
+ type: "builder.register",
263
+ data: {
264
+ type: t,
265
+ info: e
266
+ }
267
+ };
268
+ try {
269
+ parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
270
+ } catch (o) {
271
+ console.debug("Could not postmessage", o);
272
+ }
273
+ }
274
+ }
275
+ const pt = "builder.tests", m = (t) => `${pt}.${t}`, yt = ({
276
+ contentId: t
277
+ }) => P({
278
+ name: m(t),
279
+ canTrack: !0
280
+ }), mt = ({
281
+ contentId: t
282
+ }) => A({
283
+ name: m(t),
284
+ canTrack: !0
285
+ }), wt = ({
286
+ contentId: t,
287
+ value: e
288
+ }) => T({
289
+ name: m(t),
290
+ value: e,
291
+ canTrack: !0
292
+ }), $ = (t) => u(t.id) && u(t.variations) && Object.keys(t.variations).length > 0, It = ({
293
+ id: t,
294
+ variations: e
295
+ }) => {
296
+ var o;
297
+ let n = 0;
298
+ const r = Math.random();
299
+ for (const s in e) {
300
+ const a = (o = e[s]) == null ? void 0 : o.testRatio;
301
+ if (n += a, r < n)
302
+ return s;
303
+ }
304
+ return t;
305
+ }, j = (t) => {
306
+ const e = It(t);
307
+ return wt({
308
+ contentId: t.id,
309
+ value: e
310
+ }).catch((n) => {
311
+ c.error("could not store A/B test variation: ", n);
312
+ }), e;
313
+ }, F = ({
314
+ item: t,
315
+ testGroupId: e
316
+ }) => {
317
+ const n = t.variations[e];
318
+ return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
319
+ !n ? {
320
+ testVariationId: t.id,
321
+ testVariationName: "Default"
322
+ } : {
323
+ data: n.data,
324
+ testVariationId: n.id,
325
+ testVariationName: n.name || (n.id === t.id ? "Default" : "")
326
+ };
327
+ }, Bt = ({
328
+ item: t,
329
+ canTrack: e
330
+ }) => {
331
+ if (!e)
332
+ return t;
333
+ if (!t)
334
+ return;
335
+ if (!$(t))
336
+ return t;
337
+ const n = mt({
338
+ contentId: t.id
339
+ }) || j({
340
+ variations: t.variations,
341
+ id: t.id
342
+ }), r = F({
343
+ item: t,
344
+ testGroupId: n
345
+ });
346
+ return {
347
+ ...t,
348
+ ...r
349
+ };
350
+ }, St = async ({
351
+ item: t,
352
+ canTrack: e
353
+ }) => {
354
+ if (!e || !$(t))
355
+ return t;
356
+ const r = await yt({
357
+ contentId: t.id
358
+ }) || j({
359
+ variations: t.variations,
360
+ id: t.id
361
+ }), o = F({
362
+ item: t,
363
+ testGroupId: r
364
+ });
365
+ return {
366
+ ...t,
367
+ ...o
368
+ };
369
+ }, vt = (t) => u(t) ? t : !0;
370
+ function p(t, e = null, n = ".") {
371
+ return Object.keys(t).reduce((r, o) => {
372
+ const s = t[o], a = [e, o].filter(Boolean).join(n);
373
+ return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
374
+ ...r,
375
+ ...p(s, a, n)
376
+ } : {
377
+ ...r,
378
+ [a]: s
379
+ };
380
+ }, {});
381
+ }
382
+ const k = "builder.", bt = "options.", Ot = (t) => {
383
+ const e = {};
384
+ return t.forEach((n, r) => {
385
+ e[r] = n;
386
+ }), e;
387
+ }, K = (t) => {
388
+ if (!t)
389
+ return {};
390
+ const e = N(t), n = {};
391
+ return Object.keys(e).forEach((r) => {
392
+ if (r.startsWith(k)) {
393
+ const o = r.replace(k, "").replace(bt, "");
394
+ n[o] = e[r];
395
+ }
396
+ }), n;
397
+ }, kt = () => {
398
+ if (!i())
399
+ return {};
400
+ const t = new URLSearchParams(window.location.search);
401
+ return K(t);
402
+ }, N = (t) => t instanceof URLSearchParams ? Ot(t) : t, Et = "v3", w = (t) => {
403
+ const {
404
+ limit: e = 30,
405
+ userAttributes: n,
406
+ query: r,
407
+ noTraverse: o = !1,
408
+ model: s,
409
+ apiKey: a,
410
+ includeRefs: h = !0,
411
+ enrich: I,
412
+ locale: S,
413
+ apiVersion: g = Et
414
+ } = t;
415
+ if (!a)
416
+ throw new Error("Missing API key");
417
+ if (!["v2", "v3"].includes(g))
418
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${g}'`);
419
+ const d = new URL(`https://cdn.builder.io/api/${g}/content/${s}?apiKey=${a}&limit=${e}&noTraverse=${o}&includeRefs=${h}${S ? `&locale=${S}` : ""}${I ? `&enrich=${I}` : ""}`), U = {
420
+ ...kt(),
421
+ ...N(t.options || {})
422
+ }, v = p(U);
423
+ for (const l in v)
424
+ d.searchParams.set(l, String(v[l]));
425
+ if (n && d.searchParams.set("userAttributes", JSON.stringify(n)), r) {
426
+ const l = p({
427
+ query: r
428
+ });
429
+ for (const b in l)
430
+ d.searchParams.set(b, JSON.stringify(l[b]));
431
+ }
432
+ return d;
433
+ }, Ct = (t) => "results" in t;
434
+ async function M(t) {
435
+ const e = await D({
436
+ ...t,
437
+ limit: 1
438
+ });
439
+ return e && e.results[0] || null;
440
+ }
441
+ const Lt = M, xt = async (t) => {
442
+ const e = w(t);
443
+ return await (await Q(e.href)).json();
444
+ }, At = async (t, e, n = w(t)) => {
445
+ const r = vt(t.canTrack);
446
+ if (n.search.includes("preview="), !r || !(i() || y === "reactNative"))
447
+ return e;
448
+ try {
449
+ const o = [];
450
+ for (const s of e.results)
451
+ o.push(await St({
452
+ item: s,
453
+ canTrack: r
454
+ }));
455
+ e.results = o;
456
+ } catch (o) {
457
+ c.error("Could not process A/B tests. ", o);
458
+ }
459
+ return e;
460
+ };
461
+ async function D(t) {
462
+ try {
463
+ const e = w(t), n = await xt(t);
464
+ return Ct(n) ? At(t, n) : (c.error("Error fetching data. ", {
465
+ url: e,
466
+ content: n,
467
+ options: t
468
+ }), null);
469
+ } catch (e) {
470
+ return c.error("Error fetching data. ", e), null;
471
+ }
472
+ }
473
+ const $t = D;
474
+ function jt() {
475
+ return !i() || x() ? !1 : location.search.indexOf("builder.preview=") !== -1;
476
+ }
477
+ const E = {};
478
+ function Ft(t) {
479
+ if (i()) {
480
+ Object.assign(E, t);
481
+ const e = {
482
+ type: "builder.settingsChange",
483
+ data: E
484
+ };
485
+ parent.postMessage(e, "*");
486
+ }
487
+ }
488
+ const Kt = async (t) => {
489
+ var r, o, s;
490
+ const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((o = t.userAttributes) == null ? void 0 : o.urlPath), n = {
491
+ ...t,
492
+ apiKey: t.apiKey,
493
+ model: t.model || "page",
494
+ userAttributes: {
495
+ ...t.userAttributes,
496
+ ...e ? {
497
+ urlPath: e
498
+ } : {}
499
+ },
500
+ options: K(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
501
+ };
502
+ return {
503
+ apiKey: n.apiKey,
504
+ model: n.model,
505
+ content: await M(n)
506
+ };
507
+ };
508
+ export {
509
+ y as T,
510
+ At as _,
511
+ jt as a,
512
+ M as b,
513
+ Tt as c,
514
+ Lt as d,
515
+ K as e,
516
+ D as f,
517
+ $t as g,
518
+ Kt as h,
519
+ x as i,
520
+ C as j,
521
+ i as k,
522
+ c as l,
523
+ J as m,
524
+ u as n,
525
+ gt as o,
526
+ Q as p,
527
+ Pt as q,
528
+ Vt as r,
529
+ Ft as s,
530
+ Rt as t,
531
+ q as u,
532
+ vt as v,
533
+ Bt as w
534
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-2e639417.js");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;
@@ -0,0 +1,16 @@
1
+ import { _ as t, c as a, h as r, f as i, b as n, g, e as o, d as c, i as d, a as f, r as h, s as l, t as p } from "./server-entry-f7504f89.mjs";
2
+ export {
3
+ t as _processContentResult,
4
+ a as createRegisterComponentMessage,
5
+ r as fetchBuilderProps,
6
+ i as fetchEntries,
7
+ n as fetchOneEntry,
8
+ g as getAllContent,
9
+ o as getBuilderSearchParams,
10
+ c as getContent,
11
+ d as isEditing,
12
+ f as isPreviewing,
13
+ h as register,
14
+ l as setEditorSettings,
15
+ p as track
16
+ };
package/package.json CHANGED
@@ -1,33 +1,119 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.5.8",
4
+ "version": "0.6.0",
5
5
  "files": [
6
- "dist"
6
+ "lib",
7
+ "types"
7
8
  ],
8
- "types": "./dist/index.d.ts",
9
+ "types": "./types/index.d.ts",
10
+ "main": "./lib/node/index.cjs",
11
+ "module": "./lib/node/index.mjs",
9
12
  "exports": {
10
- ".": "./dist/index.js",
11
- "./server": "./dist/functions/get-content/index.js"
13
+ ".": {
14
+ "node": {
15
+ "types": "./types/index.d.ts",
16
+ "import": "./lib/node/index.mjs",
17
+ "require": "./lib/node/index.cjs"
18
+ },
19
+ "browser": {
20
+ "types": "./types/index.d.ts",
21
+ "import": "./lib/browser/index.mjs",
22
+ "require": "./lib/browser/index.cjs"
23
+ },
24
+ "edge-routine": {
25
+ "types": "./types/index.d.ts",
26
+ "import": "./lib/edge/index.mjs",
27
+ "require": "./lib/edge/index.cjs"
28
+ },
29
+ "workerd": {
30
+ "types": "./types/index.d.ts",
31
+ "import": "./lib/edge/index.mjs",
32
+ "require": "./lib/edge/index.cjs"
33
+ },
34
+ "deno": {
35
+ "types": "./types/index.d.ts",
36
+ "import": "./lib/edge/index.mjs",
37
+ "require": "./lib/edge/index.cjs"
38
+ },
39
+ "lagon": {
40
+ "types": "./types/index.d.ts",
41
+ "import": "./lib/edge/index.mjs",
42
+ "require": "./lib/edge/index.cjs"
43
+ },
44
+ "netlify": {
45
+ "types": "./types/index.d.ts",
46
+ "import": "./lib/edge/index.mjs",
47
+ "require": "./lib/edge/index.cjs"
48
+ },
49
+ "edge-light": {
50
+ "types": "./types/index.d.ts",
51
+ "import": "./lib/edge/index.mjs",
52
+ "require": "./lib/edge/index.cjs"
53
+ },
54
+ "bun": {
55
+ "types": "./types/index.d.ts",
56
+ "import": "./lib/edge/index.mjs",
57
+ "require": "./lib/edge/index.cjs"
58
+ },
59
+ "react-native": {
60
+ "types": "./types/index.d.ts",
61
+ "import": "./lib/node/index.mjs",
62
+ "require": "./lib/node/index.cjs"
63
+ },
64
+ "electron": {
65
+ "types": "./types/index.d.ts",
66
+ "import": "./lib/node/index.mjs",
67
+ "require": "./lib/node/index.cjs"
68
+ },
69
+ "default": {
70
+ "types": "./types/index.d.ts",
71
+ "import": "./lib/browser/index.mjs",
72
+ "require": "./lib/browser/index.cjs"
73
+ }
74
+ },
75
+ "./edge": {
76
+ "types": "./types/index.d.ts",
77
+ "import": "./lib/edge/index.mjs",
78
+ "require": "./lib/edge/index.cjs"
79
+ },
80
+ "./node": {
81
+ "types": "./types/index.d.ts",
82
+ "import": "./lib/node/index.mjs",
83
+ "require": "./lib/node/index.cjs"
84
+ },
85
+ "./browser": {
86
+ "types": "./types/index.d.ts",
87
+ "import": "./lib/browser/index.mjs",
88
+ "require": "./lib/browser/index.cjs"
89
+ },
90
+ "./server": {
91
+ "types": "./types/functions/get-content/index.d.ts",
92
+ "import": "./lib/node/server-entry.mjs",
93
+ "require": "./lib/node/server-entry.cjs"
94
+ }
12
95
  },
13
96
  "scripts": {
14
- "clean": "rimraf dist",
15
- "build": "yarn clean && tsc"
97
+ "types": "tsc",
98
+ "build": "nx run-many -p @builder.io/sdk-react -t types build:node build:edge build:browser",
99
+ "build:node": "SDK_ENV=node vite build --mode lib",
100
+ "build:edge": "SDK_ENV=edge vite build --mode lib",
101
+ "build:browser": "SDK_ENV=browser vite build --mode lib"
16
102
  },
17
103
  "peerDependencies": {
18
104
  "react": "^18.2.0"
19
105
  },
20
106
  "devDependencies": {
107
+ "@builder.io/sdks": "workspace:*",
108
+ "@vitejs/plugin-react": "^4.0.4",
21
109
  "nx": "^16.6.0",
22
110
  "nx-cloud": "^16.2.0",
23
111
  "react": "^18.2.0",
24
112
  "rimraf": "^3.0.2",
25
- "typescript": "^4.9.4"
113
+ "typescript": "^4.9.4",
114
+ "vite": "^4.4.9"
26
115
  },
27
116
  "nx": {
28
- "implicitDependencies": [
29
- "@builder.io/sdks"
30
- ],
31
117
  "targets": {
32
118
  "build": {
33
119
  "dependsOn": [