@builder.io/mitosis 0.0.0-dev-20260605060721

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 (582) hide show
  1. package/dist/src/constants/hooks.d.ts +16 -0
  2. package/dist/src/constants/hooks.js +19 -0
  3. package/dist/src/constants/html_tags.d.ts +2 -0
  4. package/dist/src/constants/html_tags.js +198 -0
  5. package/dist/src/constants/media-sizes.d.ts +22 -0
  6. package/dist/src/constants/media-sizes.js +34 -0
  7. package/dist/src/constants/method-literal-prefix.d.ts +1 -0
  8. package/dist/src/constants/method-literal-prefix.js +2 -0
  9. package/dist/src/flow.d.ts +26 -0
  10. package/dist/src/flow.js +27 -0
  11. package/dist/src/generators/alpine/generate.d.ts +11 -0
  12. package/dist/src/generators/alpine/generate.js +201 -0
  13. package/dist/src/generators/alpine/index.d.ts +2 -0
  14. package/dist/src/generators/alpine/index.js +18 -0
  15. package/dist/src/generators/alpine/render-mount-hook.d.ts +2 -0
  16. package/dist/src/generators/alpine/render-mount-hook.js +17 -0
  17. package/dist/src/generators/alpine/render-update-hooks.d.ts +5 -0
  18. package/dist/src/generators/alpine/render-update-hooks.js +44 -0
  19. package/dist/src/generators/alpine/types.d.ts +12 -0
  20. package/dist/src/generators/alpine/types.js +2 -0
  21. package/dist/src/generators/angular/classic/blocks.d.ts +10 -0
  22. package/dist/src/generators/angular/classic/blocks.js +409 -0
  23. package/dist/src/generators/angular/classic/component.d.ts +3 -0
  24. package/dist/src/generators/angular/classic/component.js +356 -0
  25. package/dist/src/generators/angular/classic/plugins/get-class-properties-plugin.d.ts +2 -0
  26. package/dist/src/generators/angular/classic/plugins/get-class-properties-plugin.js +138 -0
  27. package/dist/src/generators/angular/classic/plugins/get-code-processor-plugins.d.ts +8 -0
  28. package/dist/src/generators/angular/classic/plugins/get-code-processor-plugins.js +60 -0
  29. package/dist/src/generators/angular/component.d.ts +3 -0
  30. package/dist/src/generators/angular/component.js +27 -0
  31. package/dist/src/generators/angular/helpers/format.d.ts +1 -0
  32. package/dist/src/generators/angular/helpers/format.js +24 -0
  33. package/dist/src/generators/angular/helpers/get-inputs.d.ts +7 -0
  34. package/dist/src/generators/angular/helpers/get-inputs.js +18 -0
  35. package/dist/src/generators/angular/helpers/get-outputs.d.ts +7 -0
  36. package/dist/src/generators/angular/helpers/get-outputs.js +23 -0
  37. package/dist/src/generators/angular/helpers/get-refs.d.ts +8 -0
  38. package/dist/src/generators/angular/helpers/get-refs.js +40 -0
  39. package/dist/src/generators/angular/helpers/get-styles.d.ts +6 -0
  40. package/dist/src/generators/angular/helpers/get-styles.js +17 -0
  41. package/dist/src/generators/angular/helpers/hooks.d.ts +25 -0
  42. package/dist/src/generators/angular/helpers/hooks.js +59 -0
  43. package/dist/src/generators/angular/helpers/index.d.ts +33 -0
  44. package/dist/src/generators/angular/helpers/index.js +221 -0
  45. package/dist/src/generators/angular/helpers/parse-selector.d.ts +5 -0
  46. package/dist/src/generators/angular/helpers/parse-selector.js +19 -0
  47. package/dist/src/generators/angular/index.d.ts +2 -0
  48. package/dist/src/generators/angular/index.js +18 -0
  49. package/dist/src/generators/angular/signals/blocks.d.ts +10 -0
  50. package/dist/src/generators/angular/signals/blocks.js +379 -0
  51. package/dist/src/generators/angular/signals/component.d.ts +3 -0
  52. package/dist/src/generators/angular/signals/component.js +377 -0
  53. package/dist/src/generators/angular/signals/helpers/get-computed.d.ts +6 -0
  54. package/dist/src/generators/angular/signals/helpers/get-computed.js +79 -0
  55. package/dist/src/generators/angular/signals/helpers/get-dynamic-template-refs.d.ts +2 -0
  56. package/dist/src/generators/angular/signals/helpers/get-dynamic-template-refs.js +25 -0
  57. package/dist/src/generators/angular/signals/helpers/get-inputs.d.ts +7 -0
  58. package/dist/src/generators/angular/signals/helpers/get-inputs.js +15 -0
  59. package/dist/src/generators/angular/signals/helpers/index.d.ts +16 -0
  60. package/dist/src/generators/angular/signals/helpers/index.js +30 -0
  61. package/dist/src/generators/angular/signals/plugins/get-code-processor-plugins.d.ts +4 -0
  62. package/dist/src/generators/angular/signals/plugins/get-code-processor-plugins.js +547 -0
  63. package/dist/src/generators/angular/types.d.ts +72 -0
  64. package/dist/src/generators/angular/types.js +12 -0
  65. package/dist/src/generators/builder/generator.d.ts +12 -0
  66. package/dist/src/generators/builder/generator.js +876 -0
  67. package/dist/src/generators/builder/index.d.ts +2 -0
  68. package/dist/src/generators/builder/index.js +18 -0
  69. package/dist/src/generators/builder/types.d.ts +6 -0
  70. package/dist/src/generators/builder/types.js +2 -0
  71. package/dist/src/generators/context/angular.d.ts +9 -0
  72. package/dist/src/generators/context/angular.js +40 -0
  73. package/dist/src/generators/context/helpers/context-with-symbol-key.d.ts +5 -0
  74. package/dist/src/generators/context/helpers/context-with-symbol-key.js +33 -0
  75. package/dist/src/generators/context/qwik.d.ts +8 -0
  76. package/dist/src/generators/context/qwik.js +29 -0
  77. package/dist/src/generators/context/react.d.ts +10 -0
  78. package/dist/src/generators/context/react.js +30 -0
  79. package/dist/src/generators/context/rsc.d.ts +12 -0
  80. package/dist/src/generators/context/rsc.js +32 -0
  81. package/dist/src/generators/context/solid.d.ts +8 -0
  82. package/dist/src/generators/context/solid.js +30 -0
  83. package/dist/src/generators/context/svelte.d.ts +11 -0
  84. package/dist/src/generators/context/svelte.js +44 -0
  85. package/dist/src/generators/context/vue.d.ts +3 -0
  86. package/dist/src/generators/context/vue.js +5 -0
  87. package/dist/src/generators/helpers/context.d.ts +8 -0
  88. package/dist/src/generators/helpers/context.js +15 -0
  89. package/dist/src/generators/helpers/functions.d.ts +2 -0
  90. package/dist/src/generators/helpers/functions.js +31 -0
  91. package/dist/src/generators/helpers/minify.d.ts +1 -0
  92. package/dist/src/generators/helpers/minify.js +20 -0
  93. package/dist/src/generators/helpers/on-mount.d.ts +5 -0
  94. package/dist/src/generators/helpers/on-mount.js +25 -0
  95. package/dist/src/generators/helpers/rsc.d.ts +2 -0
  96. package/dist/src/generators/helpers/rsc.js +38 -0
  97. package/dist/src/generators/html/generator.d.ts +4 -0
  98. package/dist/src/generators/html/generator.js +1232 -0
  99. package/dist/src/generators/html/index.d.ts +2 -0
  100. package/dist/src/generators/html/index.js +18 -0
  101. package/dist/src/generators/html/types.d.ts +6 -0
  102. package/dist/src/generators/html/types.js +2 -0
  103. package/dist/src/generators/liquid/generator.d.ts +9 -0
  104. package/dist/src/generators/liquid/generator.js +161 -0
  105. package/dist/src/generators/liquid/index.d.ts +2 -0
  106. package/dist/src/generators/liquid/index.js +18 -0
  107. package/dist/src/generators/liquid/types.d.ts +5 -0
  108. package/dist/src/generators/liquid/types.js +2 -0
  109. package/dist/src/generators/lit/collect-class-string.d.ts +2 -0
  110. package/dist/src/generators/lit/collect-class-string.js +41 -0
  111. package/dist/src/generators/lit/generate.d.ts +3 -0
  112. package/dist/src/generators/lit/generate.js +271 -0
  113. package/dist/src/generators/lit/index.d.ts +2 -0
  114. package/dist/src/generators/lit/index.js +18 -0
  115. package/dist/src/generators/lit/types.d.ts +8 -0
  116. package/dist/src/generators/lit/types.js +2 -0
  117. package/dist/src/generators/marko/generate.d.ts +20 -0
  118. package/dist/src/generators/marko/generate.js +316 -0
  119. package/dist/src/generators/marko/index.d.ts +2 -0
  120. package/dist/src/generators/marko/index.js +18 -0
  121. package/dist/src/generators/marko/types.d.ts +4 -0
  122. package/dist/src/generators/marko/types.js +2 -0
  123. package/dist/src/generators/mitosis/generator.d.ts +7 -0
  124. package/dist/src/generators/mitosis/generator.js +367 -0
  125. package/dist/src/generators/mitosis/index.d.ts +2 -0
  126. package/dist/src/generators/mitosis/index.js +18 -0
  127. package/dist/src/generators/mitosis/types.d.ts +8 -0
  128. package/dist/src/generators/mitosis/types.js +2 -0
  129. package/dist/src/generators/qwik/component-generator.d.ts +3 -0
  130. package/dist/src/generators/qwik/component-generator.js +337 -0
  131. package/dist/src/generators/qwik/component.d.ts +21 -0
  132. package/dist/src/generators/qwik/component.js +170 -0
  133. package/dist/src/generators/qwik/directives.d.ts +24 -0
  134. package/dist/src/generators/qwik/directives.js +152 -0
  135. package/dist/src/generators/qwik/helpers/add-prevent-default.d.ts +7 -0
  136. package/dist/src/generators/qwik/helpers/add-prevent-default.js +33 -0
  137. package/dist/src/generators/qwik/helpers/convert-method-to-function.d.ts +2 -0
  138. package/dist/src/generators/qwik/helpers/convert-method-to-function.js +161 -0
  139. package/dist/src/generators/qwik/helpers/handlers.d.ts +3 -0
  140. package/dist/src/generators/qwik/helpers/handlers.js +60 -0
  141. package/dist/src/generators/qwik/helpers/stable-inject.d.ts +5 -0
  142. package/dist/src/generators/qwik/helpers/stable-inject.js +49 -0
  143. package/dist/src/generators/qwik/helpers/stable-serialize.d.ts +6 -0
  144. package/dist/src/generators/qwik/helpers/stable-serialize.js +50 -0
  145. package/dist/src/generators/qwik/helpers/state.d.ts +32 -0
  146. package/dist/src/generators/qwik/helpers/state.js +111 -0
  147. package/dist/src/generators/qwik/helpers/styles.d.ts +7 -0
  148. package/dist/src/generators/qwik/helpers/styles.js +70 -0
  149. package/dist/src/generators/qwik/index.d.ts +5 -0
  150. package/dist/src/generators/qwik/index.js +26 -0
  151. package/dist/src/generators/qwik/jsx.d.ts +17 -0
  152. package/dist/src/generators/qwik/jsx.js +223 -0
  153. package/dist/src/generators/qwik/src-generator.d.ts +83 -0
  154. package/dist/src/generators/qwik/src-generator.js +575 -0
  155. package/dist/src/generators/qwik/types.d.ts +14 -0
  156. package/dist/src/generators/qwik/types.js +2 -0
  157. package/dist/src/generators/react/blocks.d.ts +4 -0
  158. package/dist/src/generators/react/blocks.js +332 -0
  159. package/dist/src/generators/react/generator.d.ts +5 -0
  160. package/dist/src/generators/react/generator.js +399 -0
  161. package/dist/src/generators/react/helpers/default-props.d.ts +2 -0
  162. package/dist/src/generators/react/helpers/default-props.js +21 -0
  163. package/dist/src/generators/react/helpers/hooks.d.ts +20 -0
  164. package/dist/src/generators/react/helpers/hooks.js +67 -0
  165. package/dist/src/generators/react/helpers/index.d.ts +11 -0
  166. package/dist/src/generators/react/helpers/index.js +97 -0
  167. package/dist/src/generators/react/helpers/state.d.ts +17 -0
  168. package/dist/src/generators/react/helpers/state.js +198 -0
  169. package/dist/src/generators/react/index.d.ts +3 -0
  170. package/dist/src/generators/react/index.js +21 -0
  171. package/dist/src/generators/react/types.d.ts +22 -0
  172. package/dist/src/generators/react/types.js +2 -0
  173. package/dist/src/generators/react-native/extract-css-var-default-value.d.ts +1 -0
  174. package/dist/src/generators/react-native/extract-css-var-default-value.js +15 -0
  175. package/dist/src/generators/react-native/helpers.d.ts +3 -0
  176. package/dist/src/generators/react-native/helpers.js +133 -0
  177. package/dist/src/generators/react-native/index.d.ts +8 -0
  178. package/dist/src/generators/react-native/index.js +286 -0
  179. package/dist/src/generators/react-native/sanitize-react-native-block-styles.d.ts +4 -0
  180. package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +57 -0
  181. package/dist/src/generators/react-native/types.d.ts +9 -0
  182. package/dist/src/generators/react-native/types.js +2 -0
  183. package/dist/src/generators/rsc/generator.d.ts +3 -0
  184. package/dist/src/generators/rsc/generator.js +77 -0
  185. package/dist/src/generators/rsc/index.d.ts +2 -0
  186. package/dist/src/generators/rsc/index.js +18 -0
  187. package/dist/src/generators/rsc/types.d.ts +5 -0
  188. package/dist/src/generators/rsc/types.js +2 -0
  189. package/dist/src/generators/solid/blocks.d.ts +4 -0
  190. package/dist/src/generators/solid/blocks.js +138 -0
  191. package/dist/src/generators/solid/helpers/styles.d.ts +3 -0
  192. package/dist/src/generators/solid/helpers/styles.js +47 -0
  193. package/dist/src/generators/solid/index.d.ts +4 -0
  194. package/dist/src/generators/solid/index.js +264 -0
  195. package/dist/src/generators/solid/state/helpers.d.ts +13 -0
  196. package/dist/src/generators/solid/state/helpers.js +88 -0
  197. package/dist/src/generators/solid/state/index.d.ts +1 -0
  198. package/dist/src/generators/solid/state/index.js +5 -0
  199. package/dist/src/generators/solid/state/signals.d.ts +7 -0
  200. package/dist/src/generators/solid/state/signals.js +53 -0
  201. package/dist/src/generators/solid/state/state.d.ts +14 -0
  202. package/dist/src/generators/solid/state/state.js +55 -0
  203. package/dist/src/generators/solid/state/store.d.ts +7 -0
  204. package/dist/src/generators/solid/state/store.js +76 -0
  205. package/dist/src/generators/solid/types.d.ts +10 -0
  206. package/dist/src/generators/solid/types.js +2 -0
  207. package/dist/src/generators/stencil/blocks.d.ts +9 -0
  208. package/dist/src/generators/stencil/blocks.js +122 -0
  209. package/dist/src/generators/stencil/component.d.ts +3 -0
  210. package/dist/src/generators/stencil/component.js +199 -0
  211. package/dist/src/generators/stencil/helpers/collect-class-string.d.ts +2 -0
  212. package/dist/src/generators/stencil/helpers/collect-class-string.js +43 -0
  213. package/dist/src/generators/stencil/helpers/index.d.ts +37 -0
  214. package/dist/src/generators/stencil/helpers/index.js +129 -0
  215. package/dist/src/generators/stencil/index.d.ts +2 -0
  216. package/dist/src/generators/stencil/index.js +18 -0
  217. package/dist/src/generators/stencil/plugins/get-code-processor-plugins.d.ts +4 -0
  218. package/dist/src/generators/stencil/plugins/get-code-processor-plugins.js +25 -0
  219. package/dist/src/generators/stencil/types.d.ts +37 -0
  220. package/dist/src/generators/stencil/types.js +2 -0
  221. package/dist/src/generators/svelte/blocks.d.ts +10 -0
  222. package/dist/src/generators/svelte/blocks.js +280 -0
  223. package/dist/src/generators/svelte/helpers.d.ts +6 -0
  224. package/dist/src/generators/svelte/helpers.js +14 -0
  225. package/dist/src/generators/svelte/index.d.ts +2 -0
  226. package/dist/src/generators/svelte/index.js +20 -0
  227. package/dist/src/generators/svelte/svelte.d.ts +3 -0
  228. package/dist/src/generators/svelte/svelte.js +412 -0
  229. package/dist/src/generators/svelte/types.d.ts +5 -0
  230. package/dist/src/generators/svelte/types.js +2 -0
  231. package/dist/src/generators/swift/blocks.d.ts +8 -0
  232. package/dist/src/generators/swift/blocks.js +304 -0
  233. package/dist/src/generators/swift/generator.d.ts +3 -0
  234. package/dist/src/generators/swift/generator.js +287 -0
  235. package/dist/src/generators/swift/helpers.d.ts +42 -0
  236. package/dist/src/generators/swift/helpers.js +412 -0
  237. package/dist/src/generators/swift/index.d.ts +2 -0
  238. package/dist/src/generators/swift/index.js +18 -0
  239. package/dist/src/generators/swift/types.d.ts +29 -0
  240. package/dist/src/generators/swift/types.js +2 -0
  241. package/dist/src/generators/taro/generator.d.ts +8 -0
  242. package/dist/src/generators/taro/generator.js +168 -0
  243. package/dist/src/generators/taro/index.d.ts +2 -0
  244. package/dist/src/generators/taro/index.js +18 -0
  245. package/dist/src/generators/taro/types.d.ts +3 -0
  246. package/dist/src/generators/taro/types.js +2 -0
  247. package/dist/src/generators/template/generator.d.ts +3 -0
  248. package/dist/src/generators/template/generator.js +131 -0
  249. package/dist/src/generators/template/index.d.ts +2 -0
  250. package/dist/src/generators/template/index.js +18 -0
  251. package/dist/src/generators/template/types.d.ts +4 -0
  252. package/dist/src/generators/template/types.js +2 -0
  253. package/dist/src/generators/vue/blocks.d.ts +8 -0
  254. package/dist/src/generators/vue/blocks.js +217 -0
  255. package/dist/src/generators/vue/compositionApi.d.ts +3 -0
  256. package/dist/src/generators/vue/compositionApi.js +128 -0
  257. package/dist/src/generators/vue/helpers.d.ts +25 -0
  258. package/dist/src/generators/vue/helpers.js +179 -0
  259. package/dist/src/generators/vue/index.d.ts +2 -0
  260. package/dist/src/generators/vue/index.js +18 -0
  261. package/dist/src/generators/vue/optionsApi.d.ts +3 -0
  262. package/dist/src/generators/vue/optionsApi.js +210 -0
  263. package/dist/src/generators/vue/types.d.ts +33 -0
  264. package/dist/src/generators/vue/types.js +2 -0
  265. package/dist/src/generators/vue/vue.d.ts +3 -0
  266. package/dist/src/generators/vue/vue.js +272 -0
  267. package/dist/src/helpers/apply-meta-tagname.d.ts +2 -0
  268. package/dist/src/helpers/apply-meta-tagname.js +20 -0
  269. package/dist/src/helpers/babel-transform.d.ts +7 -0
  270. package/dist/src/helpers/babel-transform.js +130 -0
  271. package/dist/src/helpers/bindings.d.ts +6 -0
  272. package/dist/src/helpers/bindings.js +9 -0
  273. package/dist/src/helpers/camel-case.d.ts +8 -0
  274. package/dist/src/helpers/camel-case.js +17 -0
  275. package/dist/src/helpers/capitalize.d.ts +1 -0
  276. package/dist/src/helpers/capitalize.js +10 -0
  277. package/dist/src/helpers/class-components.d.ts +13 -0
  278. package/dist/src/helpers/class-components.js +51 -0
  279. package/dist/src/helpers/component-file-extensions.d.ts +50 -0
  280. package/dist/src/helpers/component-file-extensions.js +141 -0
  281. package/dist/src/helpers/create-mitosis-component.d.ts +7 -0
  282. package/dist/src/helpers/create-mitosis-component.js +27 -0
  283. package/dist/src/helpers/create-mitosis-context.d.ts +4 -0
  284. package/dist/src/helpers/create-mitosis-context.js +11 -0
  285. package/dist/src/helpers/create-mitosis-node.d.ts +2 -0
  286. package/dist/src/helpers/create-mitosis-node.js +14 -0
  287. package/dist/src/helpers/dash-case.d.ts +1 -0
  288. package/dist/src/helpers/dash-case.js +6 -0
  289. package/dist/src/helpers/dedent.d.ts +1 -0
  290. package/dist/src/helpers/dedent.js +83 -0
  291. package/dist/src/helpers/event-handlers.d.ts +3 -0
  292. package/dist/src/helpers/event-handlers.js +115 -0
  293. package/dist/src/helpers/fast-clone.d.ts +1 -0
  294. package/dist/src/helpers/fast-clone.js +5 -0
  295. package/dist/src/helpers/filter-empty-text-nodes.d.ts +3 -0
  296. package/dist/src/helpers/filter-empty-text-nodes.js +9 -0
  297. package/dist/src/helpers/generic-format.d.ts +6 -0
  298. package/dist/src/helpers/generic-format.js +35 -0
  299. package/dist/src/helpers/get-bindings.d.ts +2 -0
  300. package/dist/src/helpers/get-bindings.js +16 -0
  301. package/dist/src/helpers/get-child-components.d.ts +2 -0
  302. package/dist/src/helpers/get-child-components.js +26 -0
  303. package/dist/src/helpers/get-components-used.d.ts +2 -0
  304. package/dist/src/helpers/get-components-used.js +18 -0
  305. package/dist/src/helpers/get-components.d.ts +2 -0
  306. package/dist/src/helpers/get-components.js +21 -0
  307. package/dist/src/helpers/get-custom-imports.d.ts +15 -0
  308. package/dist/src/helpers/get-custom-imports.js +38 -0
  309. package/dist/src/helpers/get-function-string.d.ts +1 -0
  310. package/dist/src/helpers/get-function-string.js +5 -0
  311. package/dist/src/helpers/get-prop-functions.d.ts +5 -0
  312. package/dist/src/helpers/get-prop-functions.js +28 -0
  313. package/dist/src/helpers/get-props-ref.d.ts +2 -0
  314. package/dist/src/helpers/get-props-ref.js +32 -0
  315. package/dist/src/helpers/get-props.d.ts +5 -0
  316. package/dist/src/helpers/get-props.js +41 -0
  317. package/dist/src/helpers/get-refs.d.ts +2 -0
  318. package/dist/src/helpers/get-refs.js +21 -0
  319. package/dist/src/helpers/get-state-object-string.d.ts +20 -0
  320. package/dist/src/helpers/get-state-object-string.js +86 -0
  321. package/dist/src/helpers/get-state-used.d.ts +5 -0
  322. package/dist/src/helpers/get-state-used.js +28 -0
  323. package/dist/src/helpers/get-styles.d.ts +4 -0
  324. package/dist/src/helpers/get-styles.js +34 -0
  325. package/dist/src/helpers/get-tag-name.d.ts +2 -0
  326. package/dist/src/helpers/get-tag-name.js +7 -0
  327. package/dist/src/helpers/get-typed-function.d.ts +4 -0
  328. package/dist/src/helpers/get-typed-function.js +20 -0
  329. package/dist/src/helpers/getters-to-functions.d.ts +5 -0
  330. package/dist/src/helpers/getters-to-functions.js +36 -0
  331. package/dist/src/helpers/handle-missing-state.d.ts +2 -0
  332. package/dist/src/helpers/handle-missing-state.js +13 -0
  333. package/dist/src/helpers/has-bindings-text.d.ts +2 -0
  334. package/dist/src/helpers/has-bindings-text.js +21 -0
  335. package/dist/src/helpers/has-component.d.ts +2 -0
  336. package/dist/src/helpers/has-component.js +21 -0
  337. package/dist/src/helpers/has-props.d.ts +2 -0
  338. package/dist/src/helpers/has-props.js +19 -0
  339. package/dist/src/helpers/has-stateful-dom.d.ts +2 -0
  340. package/dist/src/helpers/has-stateful-dom.js +21 -0
  341. package/dist/src/helpers/has.d.ts +9 -0
  342. package/dist/src/helpers/has.js +27 -0
  343. package/dist/src/helpers/html-escape.d.ts +1 -0
  344. package/dist/src/helpers/html-escape.js +7 -0
  345. package/dist/src/helpers/indent.d.ts +1 -0
  346. package/dist/src/helpers/indent.js +7 -0
  347. package/dist/src/helpers/is-children.d.ts +6 -0
  348. package/dist/src/helpers/is-children.js +14 -0
  349. package/dist/src/helpers/is-component.d.ts +5 -0
  350. package/dist/src/helpers/is-component.js +8 -0
  351. package/dist/src/helpers/is-hook-empty.d.ts +2 -0
  352. package/dist/src/helpers/is-hook-empty.js +14 -0
  353. package/dist/src/helpers/is-html-attribute.d.ts +4 -0
  354. package/dist/src/helpers/is-html-attribute.js +371 -0
  355. package/dist/src/helpers/is-mitosis-node.d.ts +2 -0
  356. package/dist/src/helpers/is-mitosis-node.js +7 -0
  357. package/dist/src/helpers/is-root-text-node.d.ts +4 -0
  358. package/dist/src/helpers/is-root-text-node.js +12 -0
  359. package/dist/src/helpers/is-upper-case.d.ts +1 -0
  360. package/dist/src/helpers/is-upper-case.js +5 -0
  361. package/dist/src/helpers/is-valid-attribute-name.d.ts +1 -0
  362. package/dist/src/helpers/is-valid-attribute-name.js +7 -0
  363. package/dist/src/helpers/json.d.ts +3 -0
  364. package/dist/src/helpers/json.js +17 -0
  365. package/dist/src/helpers/map-refs.d.ts +9 -0
  366. package/dist/src/helpers/map-refs.js +91 -0
  367. package/dist/src/helpers/merge-options.d.ts +19 -0
  368. package/dist/src/helpers/merge-options.js +35 -0
  369. package/dist/src/helpers/mitosis-imports.d.ts +5 -0
  370. package/dist/src/helpers/mitosis-imports.js +48 -0
  371. package/dist/src/helpers/nodes/for.d.ts +4 -0
  372. package/dist/src/helpers/nodes/for.js +12 -0
  373. package/dist/src/helpers/nullable.d.ts +2 -0
  374. package/dist/src/helpers/nullable.js +5 -0
  375. package/dist/src/helpers/on-event.d.ts +14 -0
  376. package/dist/src/helpers/on-event.js +52 -0
  377. package/dist/src/helpers/output.d.ts +5 -0
  378. package/dist/src/helpers/output.js +10 -0
  379. package/dist/src/helpers/parse-node.d.ts +2 -0
  380. package/dist/src/helpers/parse-node.js +20 -0
  381. package/dist/src/helpers/parsers.d.ts +9 -0
  382. package/dist/src/helpers/parsers.js +66 -0
  383. package/dist/src/helpers/patterns.d.ts +8 -0
  384. package/dist/src/helpers/patterns.js +17 -0
  385. package/dist/src/helpers/plugins/process-code/index.d.ts +12 -0
  386. package/dist/src/helpers/plugins/process-code/index.js +169 -0
  387. package/dist/src/helpers/plugins/process-code/types.d.ts +7 -0
  388. package/dist/src/helpers/plugins/process-code/types.js +2 -0
  389. package/dist/src/helpers/plugins/process-signals.d.ts +22 -0
  390. package/dist/src/helpers/plugins/process-signals.js +179 -0
  391. package/dist/src/helpers/plugins/process-target-blocks.d.ts +6 -0
  392. package/dist/src/helpers/plugins/process-target-blocks.js +59 -0
  393. package/dist/src/helpers/process-http-requests.d.ts +2 -0
  394. package/dist/src/helpers/process-http-requests.js +25 -0
  395. package/dist/src/helpers/remove-surrounding-block.d.ts +6 -0
  396. package/dist/src/helpers/remove-surrounding-block.js +25 -0
  397. package/dist/src/helpers/render-imports.d.ts +42 -0
  398. package/dist/src/helpers/render-imports.js +169 -0
  399. package/dist/src/helpers/replace-identifiers.d.ts +27 -0
  400. package/dist/src/helpers/replace-identifiers.js +187 -0
  401. package/dist/src/helpers/replace-new-lines-in-strings.d.ts +1 -0
  402. package/dist/src/helpers/replace-new-lines-in-strings.js +26 -0
  403. package/dist/src/helpers/set.d.ts +7 -0
  404. package/dist/src/helpers/set.js +24 -0
  405. package/dist/src/helpers/signals/index.d.ts +1 -0
  406. package/dist/src/helpers/signals/index.js +17 -0
  407. package/dist/src/helpers/signals/signals.d.ts +22 -0
  408. package/dist/src/helpers/signals/signals.js +109 -0
  409. package/dist/src/helpers/slots.d.ts +5 -0
  410. package/dist/src/helpers/slots.js +26 -0
  411. package/dist/src/helpers/state.d.ts +2 -0
  412. package/dist/src/helpers/state.js +5 -0
  413. package/dist/src/helpers/strip-meta-properties.d.ts +2 -0
  414. package/dist/src/helpers/strip-meta-properties.js +26 -0
  415. package/dist/src/helpers/strip-state-and-props-refs.d.ts +38 -0
  416. package/dist/src/helpers/strip-state-and-props-refs.js +86 -0
  417. package/dist/src/helpers/styles/collect-css.d.ts +7 -0
  418. package/dist/src/helpers/styles/collect-css.js +113 -0
  419. package/dist/src/helpers/styles/collect-styled-components.d.ts +2 -0
  420. package/dist/src/helpers/styles/collect-styled-components.js +64 -0
  421. package/dist/src/helpers/styles/helpers.d.ts +31 -0
  422. package/dist/src/helpers/styles/helpers.js +90 -0
  423. package/dist/src/helpers/trace-reference-to-module-path.d.ts +2 -0
  424. package/dist/src/helpers/trace-reference-to-module-path.js +13 -0
  425. package/dist/src/helpers/transform-state-setters.d.ts +14 -0
  426. package/dist/src/helpers/transform-state-setters.js +24 -0
  427. package/dist/src/helpers/transform-to-jsx.d.ts +4 -0
  428. package/dist/src/helpers/transform-to-jsx.js +13 -0
  429. package/dist/src/helpers/traverse-nodes.d.ts +4 -0
  430. package/dist/src/helpers/traverse-nodes.js +16 -0
  431. package/dist/src/helpers/try-prettier-format.d.ts +1 -0
  432. package/dist/src/helpers/try-prettier-format.js +24 -0
  433. package/dist/src/helpers/typescript-project.d.ts +7 -0
  434. package/dist/src/helpers/typescript-project.js +63 -0
  435. package/dist/src/helpers/typescript.d.ts +9 -0
  436. package/dist/src/helpers/typescript.js +5 -0
  437. package/dist/src/helpers/web-components/attribute-passing.d.ts +6 -0
  438. package/dist/src/helpers/web-components/attribute-passing.js +47 -0
  439. package/dist/src/index.d.ts +96 -0
  440. package/dist/src/index.js +74 -0
  441. package/dist/src/modules/plugins.d.ts +25 -0
  442. package/dist/src/modules/plugins.js +51 -0
  443. package/dist/src/parsers/angular.d.ts +5 -0
  444. package/dist/src/parsers/angular.js +154 -0
  445. package/dist/src/parsers/builder/builder.d.ts +55 -0
  446. package/dist/src/parsers/builder/builder.js +1198 -0
  447. package/dist/src/parsers/builder/helpers.d.ts +3 -0
  448. package/dist/src/parsers/builder/helpers.js +26 -0
  449. package/dist/src/parsers/builder/index.d.ts +1 -0
  450. package/dist/src/parsers/builder/index.js +17 -0
  451. package/dist/src/parsers/context.d.ts +6 -0
  452. package/dist/src/parsers/context.js +82 -0
  453. package/dist/src/parsers/jsx/ast.d.ts +5 -0
  454. package/dist/src/parsers/jsx/ast.js +74 -0
  455. package/dist/src/parsers/jsx/component-types.d.ts +8 -0
  456. package/dist/src/parsers/jsx/component-types.js +82 -0
  457. package/dist/src/parsers/jsx/context.d.ts +6 -0
  458. package/dist/src/parsers/jsx/context.js +68 -0
  459. package/dist/src/parsers/jsx/element-parser.d.ts +9 -0
  460. package/dist/src/parsers/jsx/element-parser.js +418 -0
  461. package/dist/src/parsers/jsx/exports.d.ts +5 -0
  462. package/dist/src/parsers/jsx/exports.js +76 -0
  463. package/dist/src/parsers/jsx/function-parser.d.ts +9 -0
  464. package/dist/src/parsers/jsx/function-parser.js +360 -0
  465. package/dist/src/parsers/jsx/helpers.d.ts +17 -0
  466. package/dist/src/parsers/jsx/helpers.js +85 -0
  467. package/dist/src/parsers/jsx/hooks/helpers.d.ts +5 -0
  468. package/dist/src/parsers/jsx/hooks/helpers.js +54 -0
  469. package/dist/src/parsers/jsx/hooks/index.d.ts +16 -0
  470. package/dist/src/parsers/jsx/hooks/index.js +96 -0
  471. package/dist/src/parsers/jsx/hooks/use-metadata.d.ts +9 -0
  472. package/dist/src/parsers/jsx/hooks/use-metadata.js +184 -0
  473. package/dist/src/parsers/jsx/hooks/use-target.d.ts +13 -0
  474. package/dist/src/parsers/jsx/hooks/use-target.js +135 -0
  475. package/dist/src/parsers/jsx/imports.d.ts +7 -0
  476. package/dist/src/parsers/jsx/imports.js +23 -0
  477. package/dist/src/parsers/jsx/index.d.ts +2 -0
  478. package/dist/src/parsers/jsx/index.js +5 -0
  479. package/dist/src/parsers/jsx/jsx.d.ts +10 -0
  480. package/dist/src/parsers/jsx/jsx.js +227 -0
  481. package/dist/src/parsers/jsx/props-types.d.ts +5 -0
  482. package/dist/src/parsers/jsx/props-types.js +22 -0
  483. package/dist/src/parsers/jsx/props.d.ts +2 -0
  484. package/dist/src/parsers/jsx/props.js +64 -0
  485. package/dist/src/parsers/jsx/signals.d.ts +9 -0
  486. package/dist/src/parsers/jsx/signals.js +99 -0
  487. package/dist/src/parsers/jsx/state.d.ts +17 -0
  488. package/dist/src/parsers/jsx/state.js +274 -0
  489. package/dist/src/parsers/jsx/types.d.ts +29 -0
  490. package/dist/src/parsers/jsx/types.js +2 -0
  491. package/dist/src/parsers/svelte/css/index.d.ts +3 -0
  492. package/dist/src/parsers/svelte/css/index.js +8 -0
  493. package/dist/src/parsers/svelte/helpers/bindings.d.ts +3 -0
  494. package/dist/src/parsers/svelte/helpers/bindings.js +75 -0
  495. package/dist/src/parsers/svelte/helpers/children.d.ts +5 -0
  496. package/dist/src/parsers/svelte/helpers/children.js +22 -0
  497. package/dist/src/parsers/svelte/helpers/expressions.d.ts +3 -0
  498. package/dist/src/parsers/svelte/helpers/expressions.js +20 -0
  499. package/dist/src/parsers/svelte/helpers/hooks.d.ts +2 -0
  500. package/dist/src/parsers/svelte/helpers/hooks.js +15 -0
  501. package/dist/src/parsers/svelte/helpers/mitosis-node.d.ts +2 -0
  502. package/dist/src/parsers/svelte/helpers/mitosis-node.js +16 -0
  503. package/dist/src/parsers/svelte/helpers/post-process.d.ts +15 -0
  504. package/dist/src/parsers/svelte/helpers/post-process.js +174 -0
  505. package/dist/src/parsers/svelte/helpers/string.d.ts +3 -0
  506. package/dist/src/parsers/svelte/helpers/string.js +26 -0
  507. package/dist/src/parsers/svelte/html/actions.d.ts +3 -0
  508. package/dist/src/parsers/svelte/html/actions.js +46 -0
  509. package/dist/src/parsers/svelte/html/each.d.ts +4 -0
  510. package/dist/src/parsers/svelte/html/each.js +20 -0
  511. package/dist/src/parsers/svelte/html/element.d.ts +3 -0
  512. package/dist/src/parsers/svelte/html/element.js +224 -0
  513. package/dist/src/parsers/svelte/html/fragment.d.ts +3 -0
  514. package/dist/src/parsers/svelte/html/fragment.js +16 -0
  515. package/dist/src/parsers/svelte/html/if-else.d.ts +3 -0
  516. package/dist/src/parsers/svelte/html/if-else.js +31 -0
  517. package/dist/src/parsers/svelte/html/index.d.ts +5 -0
  518. package/dist/src/parsers/svelte/html/index.js +80 -0
  519. package/dist/src/parsers/svelte/html/mustache-tag.d.ts +3 -0
  520. package/dist/src/parsers/svelte/html/mustache-tag.js +24 -0
  521. package/dist/src/parsers/svelte/html/slot.d.ts +3 -0
  522. package/dist/src/parsers/svelte/html/slot.js +20 -0
  523. package/dist/src/parsers/svelte/html/text.d.ts +66 -0
  524. package/dist/src/parsers/svelte/html/text.js +14 -0
  525. package/dist/src/parsers/svelte/index.d.ts +2 -0
  526. package/dist/src/parsers/svelte/index.js +59 -0
  527. package/dist/src/parsers/svelte/instance/context.d.ts +5 -0
  528. package/dist/src/parsers/svelte/instance/context.js +59 -0
  529. package/dist/src/parsers/svelte/instance/expressions.d.ts +3 -0
  530. package/dist/src/parsers/svelte/instance/expressions.js +11 -0
  531. package/dist/src/parsers/svelte/instance/functions.d.ts +3 -0
  532. package/dist/src/parsers/svelte/instance/functions.js +66 -0
  533. package/dist/src/parsers/svelte/instance/hooks.d.ts +5 -0
  534. package/dist/src/parsers/svelte/instance/hooks.js +32 -0
  535. package/dist/src/parsers/svelte/instance/imports.d.ts +3 -0
  536. package/dist/src/parsers/svelte/instance/imports.js +32 -0
  537. package/dist/src/parsers/svelte/instance/index.d.ts +3 -0
  538. package/dist/src/parsers/svelte/instance/index.js +123 -0
  539. package/dist/src/parsers/svelte/instance/properties.d.ts +3 -0
  540. package/dist/src/parsers/svelte/instance/properties.js +22 -0
  541. package/dist/src/parsers/svelte/instance/reactive.d.ts +3 -0
  542. package/dist/src/parsers/svelte/instance/reactive.js +33 -0
  543. package/dist/src/parsers/svelte/instance/references.d.ts +4 -0
  544. package/dist/src/parsers/svelte/instance/references.js +68 -0
  545. package/dist/src/parsers/svelte/instance/statements.d.ts +3 -0
  546. package/dist/src/parsers/svelte/instance/statements.js +10 -0
  547. package/dist/src/parsers/svelte/module/index.d.ts +3 -0
  548. package/dist/src/parsers/svelte/module/index.js +34 -0
  549. package/dist/src/parsers/svelte/types/index.d.ts +4 -0
  550. package/dist/src/parsers/svelte/types/index.js +2 -0
  551. package/dist/src/parsers/svelte/typescript/index.d.ts +7 -0
  552. package/dist/src/parsers/svelte/typescript/index.js +121 -0
  553. package/dist/src/plugins/compile-away-builder-components.d.ts +15 -0
  554. package/dist/src/plugins/compile-away-builder-components.js +609 -0
  555. package/dist/src/plugins/compile-away-components.d.ts +33 -0
  556. package/dist/src/plugins/compile-away-components.js +50 -0
  557. package/dist/src/plugins/map-styles.d.ts +12 -0
  558. package/dist/src/plugins/map-styles.js +16 -0
  559. package/dist/src/symbols/symbol-processor.d.ts +20 -0
  560. package/dist/src/symbols/symbol-processor.js +202 -0
  561. package/dist/src/targets.d.ts +25 -0
  562. package/dist/src/targets.js +46 -0
  563. package/dist/src/types/config.d.ts +103 -0
  564. package/dist/src/types/config.js +2 -0
  565. package/dist/src/types/json.d.ts +13 -0
  566. package/dist/src/types/json.js +2 -0
  567. package/dist/src/types/metadata.d.ts +55 -0
  568. package/dist/src/types/metadata.js +2 -0
  569. package/dist/src/types/mitosis-component.d.ts +162 -0
  570. package/dist/src/types/mitosis-component.js +2 -0
  571. package/dist/src/types/mitosis-context.d.ts +6 -0
  572. package/dist/src/types/mitosis-context.js +2 -0
  573. package/dist/src/types/mitosis-node.d.ts +117 -0
  574. package/dist/src/types/mitosis-node.js +12 -0
  575. package/dist/src/types/mitosis-styles.d.ts +1 -0
  576. package/dist/src/types/mitosis-styles.js +2 -0
  577. package/dist/src/types/plugins.d.ts +19 -0
  578. package/dist/src/types/plugins.js +2 -0
  579. package/dist/src/types/transpiler.d.ts +48 -0
  580. package/dist/src/types/transpiler.js +2 -0
  581. package/jsx-runtime.d.ts +2143 -0
  582. package/package.json +106 -0
@@ -0,0 +1,1198 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.builderContentToMitosisComponent = exports.isBuilderElement = exports.createBuilderElement = exports.convertExportDefaultToReturn = exports.extractMitosisStateFromBuilderState = exports.extractStateHook = exports.getMetaFromBlock = exports.builderElementToMitosisNode = exports.symbolBlocksAsChildren = exports.getStyleStringFromBlock = void 0;
30
+ const generator_1 = require("../../generators/builder/generator");
31
+ const symbol_processor_1 = require("../../symbols/symbol-processor");
32
+ const babel = __importStar(require("@babel/core"));
33
+ const generator_2 = __importDefault(require("@babel/generator"));
34
+ const traverse_1 = __importDefault(require("@babel/traverse"));
35
+ const t = __importStar(require("@babel/types"));
36
+ const json5_1 = __importDefault(require("json5"));
37
+ const lodash_1 = require("lodash");
38
+ const legacy_1 = __importDefault(require("neotraverse/legacy"));
39
+ const media_sizes_1 = require("../../constants/media-sizes");
40
+ const bindings_1 = require("../../helpers/bindings");
41
+ const capitalize_1 = require("../../helpers/capitalize");
42
+ const create_mitosis_component_1 = require("../../helpers/create-mitosis-component");
43
+ const create_mitosis_node_1 = require("../../helpers/create-mitosis-node");
44
+ const fast_clone_1 = require("../../helpers/fast-clone");
45
+ const parsers_1 = require("../../helpers/parsers");
46
+ const jsx_1 = require("../jsx");
47
+ const state_1 = require("../jsx/state");
48
+ const helpers_1 = require("./helpers");
49
+ // Omit some superflous styles that can come from Builder's web importer
50
+ const styleOmitList = [
51
+ 'backgroundRepeatX',
52
+ 'backgroundRepeatY',
53
+ 'backgroundPositionX',
54
+ 'backgroundPositionY',
55
+ ];
56
+ const getCssFromBlock = (block) => {
57
+ var _a;
58
+ const blockSizes = Object.keys(block.responsiveStyles || {}).filter((size) => media_sizes_1.sizeNames.includes(size));
59
+ let css = {};
60
+ for (const size of blockSizes) {
61
+ if (size === 'large') {
62
+ css = (0, lodash_1.omit)({
63
+ ...css,
64
+ ...(_a = block.responsiveStyles) === null || _a === void 0 ? void 0 : _a.large,
65
+ }, styleOmitList);
66
+ }
67
+ else if (block.responsiveStyles && block.responsiveStyles[size]) {
68
+ const mediaQueryKey = `@media (max-width: ${media_sizes_1.sizes[size].max}px)`;
69
+ css[mediaQueryKey] = (0, lodash_1.omit)({
70
+ ...css[mediaQueryKey],
71
+ ...block.responsiveStyles[size],
72
+ }, styleOmitList);
73
+ }
74
+ }
75
+ return css;
76
+ };
77
+ const verifyIsValid = (code) => {
78
+ try {
79
+ if (babel.parse(code)) {
80
+ return { valid: true, error: null };
81
+ }
82
+ }
83
+ catch (err) {
84
+ return { valid: false, error: null };
85
+ }
86
+ return { valid: false, error: null };
87
+ };
88
+ const getActionBindingsFromBlock = (block, options) => {
89
+ var _a;
90
+ const actions = {
91
+ ...block.actions,
92
+ ...(_a = block.code) === null || _a === void 0 ? void 0 : _a.actions,
93
+ };
94
+ const bindings = {};
95
+ const actionKeys = Object.keys(actions);
96
+ if (actionKeys.length) {
97
+ for (const key of actionKeys) {
98
+ let value = actions[key];
99
+ // Skip empty values
100
+ if (!value.trim()) {
101
+ continue;
102
+ }
103
+ const { error, valid } = verifyIsValid(value);
104
+ if (!valid) {
105
+ console.warn('Skipping invalid binding', error);
106
+ continue;
107
+ }
108
+ const useKey = `on${(0, lodash_1.upperFirst)(key)}`;
109
+ const asyncPrefix = `(async () =>`;
110
+ const asyncSuffix = ')()';
111
+ const isAsync = value.startsWith(asyncPrefix) && value.endsWith(asyncSuffix);
112
+ if (isAsync) {
113
+ value = value.slice(asyncPrefix.length, -asyncSuffix.length);
114
+ }
115
+ bindings[useKey] = (0, bindings_1.createSingleBinding)({
116
+ code: `${wrapBindingIfNeeded(value, options)}`,
117
+ async: isAsync ? true : undefined,
118
+ });
119
+ }
120
+ }
121
+ return bindings;
122
+ };
123
+ const getStyleStringFromBlock = (block, options) => {
124
+ var _a, _b;
125
+ const styleBindings = {};
126
+ const responsiveStyles = {};
127
+ let styleString = '';
128
+ if (block.bindings) {
129
+ for (const key in block.bindings) {
130
+ if (!key.includes('.')) {
131
+ continue;
132
+ }
133
+ let code = ((_b = (_a = block.code) === null || _a === void 0 ? void 0 : _a.bindings) === null || _b === void 0 ? void 0 : _b[key]) || block.bindings[key];
134
+ const verifyCode = verifyIsValid(code);
135
+ if (verifyCode.valid) {
136
+ code = processBoundLogic(code);
137
+ }
138
+ else {
139
+ if (options.escapeInvalidCode) {
140
+ code = '`' + code + ' [INVALID CODE]`';
141
+ }
142
+ else {
143
+ console.warn(`Dropping binding "${key}" due to invalid code: ${code}`);
144
+ continue;
145
+ }
146
+ }
147
+ if (key.includes('style')) {
148
+ const styleProperty = key.split('.')[1];
149
+ styleBindings[styleProperty] = convertExportDefaultToReturn(code);
150
+ /**
151
+ * responsiveStyles that are bound need to be merged into media queries.
152
+ * Example:
153
+ * responsiveStyles.large.color: "state.color"
154
+ * responsiveStyles.large.background: "state.background"
155
+ * Should get mapped to:
156
+ * @media (max-width: 1200px): {
157
+ * color: state.color,
158
+ * background: state.background
159
+ * }
160
+ */
161
+ }
162
+ else if (key.includes('responsiveStyles')) {
163
+ const parts = key.split('.');
164
+ const size = parts[parts.length - 2];
165
+ const prop = parts[parts.length - 1];
166
+ const mediaKey = `@media (max-width: ${media_sizes_1.sizes[size].max}px)`;
167
+ /**
168
+ * The media query key has spaces/special characters so we need to ensure
169
+ * that the key is always a string otherwise there will be runtime errors.
170
+ */
171
+ const objKey = `"${mediaKey}"`;
172
+ responsiveStyles[objKey] = {
173
+ ...responsiveStyles[objKey],
174
+ [prop]: code,
175
+ };
176
+ }
177
+ }
178
+ /**
179
+ * All binding values are strings, but we don't want to stringify the values
180
+ * within the style object otherwise the bindings will be evaluated as strings.
181
+ * As a result, do not use JSON.stringify here.
182
+ */
183
+ for (const key in responsiveStyles) {
184
+ const styles = Object.keys(responsiveStyles[key]);
185
+ const keyValues = styles.map((prop) => `${prop}: ${responsiveStyles[key][prop]}`);
186
+ const stringifiedObject = `{ ${keyValues.join(', ')} }`;
187
+ styleBindings[key] = stringifiedObject;
188
+ }
189
+ }
190
+ const styleKeys = Object.keys(styleBindings);
191
+ if (styleKeys.length) {
192
+ styleString = '{';
193
+ styleKeys.forEach((key) => {
194
+ // TODO: figure out how to have multiline style bindings here
195
+ // I tried (function{binding code})() and that did not work
196
+ styleString += ` ${key}: ${(options.includeBuilderExtras
197
+ ? wrapBinding(styleBindings[key])
198
+ : styleBindings[key]
199
+ .replace(/var _virtual_index\s*=\s*/g, '')
200
+ .replace(/;*\s*return _virtual_index;*/, '')).replace(/;$/, '')},`;
201
+ });
202
+ styleString += ' }';
203
+ }
204
+ return styleString;
205
+ };
206
+ exports.getStyleStringFromBlock = getStyleStringFromBlock;
207
+ const hasComponent = (block) => {
208
+ var _a;
209
+ return Boolean((_a = block.component) === null || _a === void 0 ? void 0 : _a.name);
210
+ };
211
+ const hasProperties = (block) => {
212
+ return Boolean(block.properties && Object.keys(block.properties).length);
213
+ };
214
+ const hasBindings = (block) => {
215
+ return Boolean(block.bindings && Object.keys(block.bindings).length);
216
+ };
217
+ const hasStyles = (block) => {
218
+ if (block.responsiveStyles) {
219
+ for (const key in block.responsiveStyles) {
220
+ if (Object.keys(block.responsiveStyles[key]).length) {
221
+ return true;
222
+ }
223
+ }
224
+ }
225
+ return false;
226
+ };
227
+ const wrapBindingIfNeeded = (value, options) => {
228
+ if (options.includeBuilderExtras) {
229
+ return wrapBinding(value);
230
+ }
231
+ if ((value === null || value === void 0 ? void 0 : value.includes(';')) && !(value === null || value === void 0 ? void 0 : value.trim().startsWith('{'))) {
232
+ return `{ ${value} }`;
233
+ }
234
+ return value;
235
+ };
236
+ /**
237
+ * Sanitizes a symbol name to be a valid JSX component name.
238
+ * - Converts to PascalCase
239
+ * - Removes invalid characters
240
+ * - Adds "Symbol" prefix to avoid collisions
241
+ * - Returns "Symbol" if no valid name can be generated
242
+ */
243
+ const sanitizeSymbolName = (name) => {
244
+ if (!name || typeof name !== 'string') {
245
+ return 'Symbol';
246
+ }
247
+ // Remove special characters and split into words
248
+ const words = name
249
+ .replace(/[^a-zA-Z0-9\s]/g, ' ')
250
+ .split(/\s+/)
251
+ .filter(Boolean);
252
+ if (words.length === 0) {
253
+ return 'Symbol';
254
+ }
255
+ // Convert to PascalCase
256
+ const pascalCase = words
257
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
258
+ .join('');
259
+ // Add Symbol prefix to avoid collisions with other components
260
+ return `Symbol${pascalCase}`;
261
+ };
262
+ const getBlockActions = (block, options) => {
263
+ var _a;
264
+ const obj = {
265
+ ...block.actions,
266
+ ...(_a = block.code) === null || _a === void 0 ? void 0 : _a.actions,
267
+ };
268
+ if (options.includeBuilderExtras) {
269
+ for (const key in obj) {
270
+ const value = obj[key];
271
+ // TODO: plugin/option for for this
272
+ obj[key] = wrapBinding(value);
273
+ }
274
+ }
275
+ return obj;
276
+ };
277
+ const getBlockActionsAsBindings = (block, options) => {
278
+ return (0, lodash_1.mapKeys)(getBlockActions(block, options), (value, key) => `on${(0, capitalize_1.capitalize)(key)}`);
279
+ };
280
+ const isValidBindingKey = (str) => {
281
+ return Boolean(str && /^[a-z0-9_\.]$/i.test(str));
282
+ };
283
+ const getBlockNonActionBindings = (block, options) => {
284
+ var _a;
285
+ const obj = {
286
+ ...block.bindings,
287
+ ...(_a = block.code) === null || _a === void 0 ? void 0 : _a.bindings,
288
+ };
289
+ if (options.includeBuilderExtras) {
290
+ for (const key in obj) {
291
+ if (!isValidBindingKey(key)) {
292
+ console.warn('Skipping invalid binding key:', key);
293
+ continue;
294
+ }
295
+ const value = obj[key];
296
+ // TODO: verify the bindings are valid
297
+ let { valid, error } = verifyIsValid(value);
298
+ if (!valid) {
299
+ ({ valid, error } = verifyIsValid(`function () { ${value} }`));
300
+ }
301
+ if (valid) {
302
+ obj[key] = wrapBinding(value);
303
+ }
304
+ else {
305
+ console.warn('Skipping invalid code:', error);
306
+ delete obj[key];
307
+ }
308
+ }
309
+ }
310
+ return obj;
311
+ };
312
+ function wrapBinding(value) {
313
+ if (!value) {
314
+ return value;
315
+ }
316
+ if (!(value.includes(';') || value.match(/(^|\s|;)return[^a-z0-9A-Z]/))) {
317
+ return value;
318
+ }
319
+ return `(() => {
320
+ try { ${(0, parsers_1.isExpression)(value) ? 'return ' : ''}${value} }
321
+ catch (err) {
322
+ console.warn('Builder code error', err);
323
+ }
324
+ })()`;
325
+ }
326
+ const getBlockBindings = (block, options) => {
327
+ const obj = {
328
+ ...getBlockNonActionBindings(block, options),
329
+ ...getBlockActionsAsBindings(block, options),
330
+ };
331
+ return obj;
332
+ };
333
+ // add back if this direction (blocks as children not prop) is desired
334
+ exports.symbolBlocksAsChildren = false;
335
+ const componentMappers = {
336
+ Symbol(block, options) {
337
+ var _a, _b, _c, _d, _e;
338
+ let css = getCssFromBlock(block);
339
+ const styleString = (0, exports.getStyleStringFromBlock)(block, options);
340
+ const actionBindings = getActionBindingsFromBlock(block, options);
341
+ const symbolOptions = (_b = (_a = block.component) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.symbol;
342
+ const symbolName = ((_c = symbolOptions === null || symbolOptions === void 0 ? void 0 : symbolOptions.content) === null || _c === void 0 ? void 0 : _c.name) || (symbolOptions === null || symbolOptions === void 0 ? void 0 : symbolOptions.name);
343
+ const componentName = ((_d = block.component) === null || _d === void 0 ? void 0 : _d.name) !== 'Symbol'
344
+ ? (_e = block.component) === null || _e === void 0 ? void 0 : _e.name // Use name already set by extractSymbols
345
+ : sanitizeSymbolName(symbolName);
346
+ // Extract inputs from symbol.data to make them visible as top-level JSX props
347
+ //
348
+ // In Builder.io, Symbol components can receive inputs through symbol.options.data,
349
+ // which contains key-value pairs for props passed to the symbol instance.
350
+ //
351
+ // We extract these from the nested data structure and create individual bindings
352
+ // for each input so they become first-class props in the generated code
353
+ // (e.g., <MySymbol title="Hello" count={5} />) instead of being buried in metadata
354
+ // (e.g., <MySymbol symbol={{ data: { title: "Hello", count: 5 } }} />).
355
+ //
356
+ // This transformation enables proper prop passing and makes the component usage
357
+ // more idiomatic in the target framework.
358
+ const symbolData = (symbolOptions === null || symbolOptions === void 0 ? void 0 : symbolOptions.data) || {};
359
+ const inputBindings = {};
360
+ const hasInputs = Object.keys(symbolData).length > 0;
361
+ // Only extract inputs if there are any to avoid data loss
362
+ if (hasInputs) {
363
+ // Create individual bindings for each input
364
+ for (const key in symbolData) {
365
+ inputBindings[key] = (0, bindings_1.createSingleBinding)({
366
+ code: json5_1.default.stringify(symbolData[key]),
367
+ });
368
+ }
369
+ }
370
+ // Keep symbol metadata - only omit data if we extracted inputs
371
+ const symbolMetadata = hasInputs ? (0, lodash_1.omit)(symbolOptions, 'data') : symbolOptions;
372
+ const bindings = {
373
+ symbol: (0, bindings_1.createSingleBinding)({
374
+ code: JSON.stringify(symbolMetadata),
375
+ }),
376
+ ...inputBindings,
377
+ ...actionBindings,
378
+ ...(styleString && {
379
+ style: (0, bindings_1.createSingleBinding)({ code: styleString }),
380
+ }),
381
+ ...(Object.keys(css).length && {
382
+ css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
383
+ }),
384
+ };
385
+ return (0, create_mitosis_node_1.createMitosisNode)({
386
+ name: componentName,
387
+ type: 'user-symbol',
388
+ bindings: bindings,
389
+ meta: (0, exports.getMetaFromBlock)(block, options),
390
+ });
391
+ },
392
+ ...(!exports.symbolBlocksAsChildren
393
+ ? {}
394
+ : {
395
+ Symbol(block, options) {
396
+ var _a, _b, _c;
397
+ let css = getCssFromBlock(block);
398
+ const styleString = (0, exports.getStyleStringFromBlock)(block, options);
399
+ const actionBindings = getActionBindingsFromBlock(block, options);
400
+ const content = (_a = block.component) === null || _a === void 0 ? void 0 : _a.options.symbol.content;
401
+ const blocks = (_b = content === null || content === void 0 ? void 0 : content.data) === null || _b === void 0 ? void 0 : _b.blocks;
402
+ if (blocks) {
403
+ content.data.blocks = null;
404
+ }
405
+ return (0, create_mitosis_node_1.createMitosisNode)({
406
+ name: 'Symbol',
407
+ bindings: {
408
+ // TODO: this doesn't use all attrs
409
+ symbol: (0, bindings_1.createSingleBinding)({
410
+ code: JSON.stringify({
411
+ data: (_c = block.component) === null || _c === void 0 ? void 0 : _c.options.symbol.content.data,
412
+ content: content, // TODO: convert to <SymbolInternal>...</SymbolInternal> so can be parsed
413
+ }),
414
+ }),
415
+ ...actionBindings,
416
+ ...(styleString && {
417
+ style: (0, bindings_1.createSingleBinding)({ code: styleString }),
418
+ }),
419
+ ...(Object.keys(css).length && {
420
+ css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
421
+ }),
422
+ },
423
+ meta: (0, exports.getMetaFromBlock)(block, options),
424
+ children: !blocks
425
+ ? []
426
+ : [
427
+ (0, create_mitosis_node_1.createMitosisNode)({
428
+ // TODO: the Builder generator side of this converting to blocks
429
+ name: 'BuilderSymbolContents',
430
+ children: blocks.map((item) => (0, exports.builderElementToMitosisNode)(item, options)),
431
+ }),
432
+ ],
433
+ });
434
+ },
435
+ }),
436
+ Columns(block, options) {
437
+ var _a, _b;
438
+ const node = (0, exports.builderElementToMitosisNode)(block, options, {
439
+ skipMapper: true,
440
+ });
441
+ delete node.bindings.columns;
442
+ delete node.properties.columns;
443
+ node.children =
444
+ ((_b = (_a = block.component) === null || _a === void 0 ? void 0 : _a.options.columns) === null || _b === void 0 ? void 0 : _b.map((col, index) => (0, create_mitosis_node_1.createMitosisNode)({
445
+ name: 'Column',
446
+ /**
447
+ * If width if undefined, do not create a binding otherwise its JSX will
448
+ * be <Column width={} /> which is not valid due to the empty expression.
449
+ */
450
+ ...(col.width != null && {
451
+ bindings: {
452
+ width: { code: col.width.toString() },
453
+ },
454
+ }),
455
+ ...(col.link && {
456
+ properties: {
457
+ link: col.link,
458
+ },
459
+ }),
460
+ meta: (0, exports.getMetaFromBlock)(block, options),
461
+ children: col.blocks.map((col) => (0, exports.builderElementToMitosisNode)(col, options)),
462
+ }))) || [];
463
+ return node;
464
+ },
465
+ PersonalizationContainer(block, options) {
466
+ var _a, _b;
467
+ const node = (0, exports.builderElementToMitosisNode)(block, options, {
468
+ skipMapper: true,
469
+ });
470
+ delete node.bindings.variants;
471
+ delete node.properties.variants;
472
+ const newChildren = ((_b = (_a = block.component) === null || _a === void 0 ? void 0 : _a.options.variants) === null || _b === void 0 ? void 0 : _b.map((variant) => {
473
+ const variantNode = (0, create_mitosis_node_1.createMitosisNode)({
474
+ name: 'Variant',
475
+ properties: {
476
+ name: variant.name,
477
+ startDate: variant.startDate,
478
+ endDate: variant.endDate,
479
+ },
480
+ meta: (0, exports.getMetaFromBlock)(block, options),
481
+ children: variant.blocks.map((col) => (0, exports.builderElementToMitosisNode)(col, options)),
482
+ });
483
+ const queryOptions = variant.query;
484
+ if (Array.isArray(queryOptions)) {
485
+ variantNode.bindings.query = (0, bindings_1.createSingleBinding)({
486
+ code: JSON.stringify(queryOptions.map((q) => (0, lodash_1.omit)(q, '@type'))),
487
+ });
488
+ }
489
+ else if (queryOptions) {
490
+ variantNode.bindings.query = (0, bindings_1.createSingleBinding)({
491
+ code: JSON.stringify((0, lodash_1.omit)(queryOptions, '@type')),
492
+ });
493
+ }
494
+ return variantNode;
495
+ })) || [];
496
+ const defaultVariant = (0, create_mitosis_node_1.createMitosisNode)({
497
+ name: 'Variant',
498
+ properties: {
499
+ default: '',
500
+ },
501
+ children: node.children,
502
+ });
503
+ newChildren.push(defaultVariant);
504
+ node.children = newChildren;
505
+ return node;
506
+ },
507
+ 'Shopify:For': (block, options) => {
508
+ return (0, create_mitosis_node_1.createMitosisNode)({
509
+ name: 'For',
510
+ bindings: {
511
+ each: (0, bindings_1.createSingleBinding)({
512
+ code: `state.${block.component.options.repeat.collection}`,
513
+ }),
514
+ },
515
+ scope: {
516
+ forName: block.component.options.repeat.itemName,
517
+ },
518
+ meta: (0, exports.getMetaFromBlock)(block, options),
519
+ children: (block.children || []).map((child) => (0, exports.builderElementToMitosisNode)(updateBindings(child, 'state.$index', 'index'), options)),
520
+ });
521
+ },
522
+ };
523
+ const processBoundLogic = (code) => {
524
+ const ast = babel.parse(code);
525
+ if (!ast)
526
+ return code;
527
+ let replacedWithReturn = false;
528
+ (0, traverse_1.default)(ast, {
529
+ ExportDefaultDeclaration(path) {
530
+ const exportedNode = path.node.declaration;
531
+ if (t.isExpression(exportedNode)) {
532
+ const returnStatement = t.returnStatement(exportedNode);
533
+ path.replaceWith(returnStatement);
534
+ replacedWithReturn = true;
535
+ }
536
+ },
537
+ });
538
+ if (replacedWithReturn) {
539
+ return (0, generator_2.default)(ast).code;
540
+ }
541
+ return code;
542
+ };
543
+ const builderElementToMitosisNode = (block, options, _internalOptions = {}) => {
544
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
545
+ const { includeSpecialBindings = true } = options;
546
+ const localizedValues = {};
547
+ if (((_a = block.component) === null || _a === void 0 ? void 0 : _a.name) === 'Core:Fragment') {
548
+ block.component.name = 'Fragment';
549
+ }
550
+ const forBinding = (_b = block.repeat) === null || _b === void 0 ? void 0 : _b.collection;
551
+ if (forBinding) {
552
+ const isFragment = ((_c = block.component) === null || _c === void 0 ? void 0 : _c.name) === 'Fragment';
553
+ // TODO: handle having other things, like a repeat too
554
+ if (isFragment) {
555
+ return (0, create_mitosis_node_1.createMitosisNode)({
556
+ name: 'For',
557
+ bindings: {
558
+ each: (0, bindings_1.createSingleBinding)({
559
+ code: wrapBindingIfNeeded((_d = block.repeat) === null || _d === void 0 ? void 0 : _d.collection, options),
560
+ }),
561
+ },
562
+ scope: {
563
+ forName: ((_e = block.repeat) === null || _e === void 0 ? void 0 : _e.itemName) || 'item',
564
+ },
565
+ meta: (0, exports.getMetaFromBlock)(block, options),
566
+ children: ((_f = block.children) === null || _f === void 0 ? void 0 : _f.map((child) => (0, exports.builderElementToMitosisNode)(updateBindings(child, 'state.$index', 'index'), options))) || [],
567
+ });
568
+ }
569
+ else {
570
+ const useBlock = ((_g = block.component) === null || _g === void 0 ? void 0 : _g.name) === 'Core:Fragment' && ((_h = block.children) === null || _h === void 0 ? void 0 : _h.length) === 1
571
+ ? block.children[0]
572
+ : block;
573
+ return (0, create_mitosis_node_1.createMitosisNode)({
574
+ name: 'For',
575
+ bindings: {
576
+ each: (0, bindings_1.createSingleBinding)({
577
+ code: wrapBindingIfNeeded((_j = block.repeat) === null || _j === void 0 ? void 0 : _j.collection, options),
578
+ }),
579
+ },
580
+ scope: {
581
+ forName: ((_k = block.repeat) === null || _k === void 0 ? void 0 : _k.itemName) || 'item',
582
+ indexName: '$index',
583
+ },
584
+ meta: (0, exports.getMetaFromBlock)(block, options),
585
+ children: [(0, exports.builderElementToMitosisNode)((0, lodash_1.omit)(useBlock, 'repeat'), options)],
586
+ });
587
+ }
588
+ }
589
+ // Special builder properties
590
+ // TODO: support hide and repeat
591
+ const blockBindings = getBlockBindings(block, options);
592
+ let code = undefined;
593
+ if (blockBindings.show) {
594
+ code = wrapBindingIfNeeded(blockBindings.show, options);
595
+ }
596
+ else if (blockBindings.hide) {
597
+ code = `!(${wrapBindingIfNeeded(blockBindings.hide, options)})`;
598
+ }
599
+ if (code) {
600
+ const isFragment = ((_l = block.component) === null || _l === void 0 ? void 0 : _l.name) === 'Fragment';
601
+ // TODO: handle having other things, like a repeat too
602
+ if (isFragment) {
603
+ return (0, create_mitosis_node_1.createMitosisNode)({
604
+ name: 'Show',
605
+ bindings: { when: (0, bindings_1.createSingleBinding)({ code }) },
606
+ meta: (0, exports.getMetaFromBlock)(block, options),
607
+ children: ((_m = block.children) === null || _m === void 0 ? void 0 : _m.map((child) => (0, exports.builderElementToMitosisNode)(child, options))) || [],
608
+ });
609
+ }
610
+ else {
611
+ return (0, create_mitosis_node_1.createMitosisNode)({
612
+ name: 'Show',
613
+ bindings: { when: (0, bindings_1.createSingleBinding)({ code }) },
614
+ meta: (0, exports.getMetaFromBlock)(block, options),
615
+ children: [
616
+ (0, exports.builderElementToMitosisNode)({
617
+ ...block,
618
+ code: {
619
+ ...block.code,
620
+ bindings: (0, lodash_1.omit)(blockBindings, 'show', 'hide'),
621
+ },
622
+ bindings: (0, lodash_1.omit)(blockBindings, 'show', 'hide'),
623
+ }, options),
624
+ ],
625
+ });
626
+ }
627
+ }
628
+ const mapper = !_internalOptions.skipMapper &&
629
+ block.component &&
630
+ (componentMappers[block.component.name] ||
631
+ // Handle symbols that were renamed by extractSymbols (e.g., "SymbolButtonComponent")
632
+ // Check for symbol options or exact 'Symbol' name instead of name pattern
633
+ (((_p = (_o = block.component) === null || _o === void 0 ? void 0 : _o.options) === null || _p === void 0 ? void 0 : _p.symbol) || ((_q = block.component) === null || _q === void 0 ? void 0 : _q.name) === 'Symbol'
634
+ ? componentMappers['Symbol']
635
+ : undefined));
636
+ if (mapper) {
637
+ return mapper(block, options);
638
+ }
639
+ const bindings = {};
640
+ const children = [];
641
+ const slots = {};
642
+ const blocksSlots = {};
643
+ if (blockBindings) {
644
+ for (const key in blockBindings) {
645
+ if (key === 'css') {
646
+ continue;
647
+ }
648
+ const useKey = key.replace(/^(component\.)?options\./, '');
649
+ if (!useKey.includes('.')) {
650
+ let code = blockBindings[key].code || blockBindings[key];
651
+ const verifyCode = verifyIsValid(code);
652
+ if (verifyCode.valid) {
653
+ code = processBoundLogic(code);
654
+ }
655
+ else {
656
+ if (options.escapeInvalidCode) {
657
+ code = '`' + code + ' [INVALID CODE]`';
658
+ }
659
+ else {
660
+ console.warn(`Dropping binding "${key}" due to invalid code: ${code}`);
661
+ continue;
662
+ }
663
+ }
664
+ bindings[useKey] = (0, bindings_1.createSingleBinding)({
665
+ code,
666
+ });
667
+ }
668
+ else if (useKey.includes('style') && useKey.includes('.')) {
669
+ const styleProperty = useKey.split('.')[1];
670
+ // TODO: add me in
671
+ // styleBindings[styleProperty] =
672
+ // block.code?.bindings?.[key] || blockBindings[key];
673
+ }
674
+ }
675
+ }
676
+ const properties = {
677
+ ...block.properties,
678
+ ...(options.includeBuilderExtras && {
679
+ ['builder-id']: block.id,
680
+ // class: `builder-block ${block.id} ${block.properties?.class || ''}`,
681
+ }),
682
+ ...(options.includeBuilderExtras && getBuilderPropsForSymbol(block)),
683
+ };
684
+ for (const key in properties) {
685
+ if (typeof properties[key] === 'object' &&
686
+ properties[key] !== null &&
687
+ properties[key]['@type'] === '@builder.io/core:LocalizedValue') {
688
+ const localizedValue = properties[key];
689
+ localizedValues[`properties.${key}`] = localizedValue;
690
+ properties[key] = localizedValue.Default;
691
+ }
692
+ }
693
+ if (block.layerName) {
694
+ properties.$name = block.layerName;
695
+ }
696
+ const linkUrl = block.linkUrl;
697
+ if (linkUrl) {
698
+ if (typeof linkUrl === 'object' &&
699
+ linkUrl !== null &&
700
+ linkUrl['@type'] === '@builder.io/core:LocalizedValue') {
701
+ properties.href = linkUrl.Default;
702
+ localizedValues['linkUrl'] = linkUrl;
703
+ }
704
+ else {
705
+ properties.href = linkUrl;
706
+ }
707
+ }
708
+ if ((_r = block.component) === null || _r === void 0 ? void 0 : _r.options) {
709
+ for (const key in block.component.options) {
710
+ const value = block.component.options[key];
711
+ const valueIsArrayOfBuilderElements = Array.isArray(value) && value.every(exports.isBuilderElement);
712
+ const transformBldrElementToMitosisNode = (item) => {
713
+ const node = (0, exports.builderElementToMitosisNode)(item, {
714
+ ...options,
715
+ includeSpecialBindings: false,
716
+ });
717
+ return node;
718
+ };
719
+ if ((0, exports.isBuilderElement)(value)) {
720
+ slots[key] = [transformBldrElementToMitosisNode(value)];
721
+ }
722
+ else if (typeof value === 'string') {
723
+ properties[key] = value;
724
+ }
725
+ else if (typeof value === 'object' &&
726
+ value !== null &&
727
+ value['@type'] === '@builder.io/core:LocalizedValue') {
728
+ properties[key] = value.Default;
729
+ localizedValues[`component.options.${key}`] = value;
730
+ }
731
+ else if (valueIsArrayOfBuilderElements) {
732
+ const childrenElements = value
733
+ .filter((item) => {
734
+ var _a, _b;
735
+ if ((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a.src) === null || _b === void 0 ? void 0 : _b.includes('/api/v1/pixel')) {
736
+ return false;
737
+ }
738
+ return true;
739
+ })
740
+ .map(transformBldrElementToMitosisNode);
741
+ slots[key] = childrenElements;
742
+ }
743
+ else if (options.enableBlocksSlots &&
744
+ !componentMappers[(_s = block.component) === null || _s === void 0 ? void 0 : _s.name] &&
745
+ (Array.isArray(value) || (typeof value === 'object' && value !== null))) {
746
+ /**
747
+ * Builder Elements that have their own mappers should not use blocksSlots
748
+ * even if the mapper is disabled via _internalOptions as it will cause
749
+ * problems when trying to use the mapper in the future.
750
+ */
751
+ const data = Array.isArray(value) ? [...value] : { ...value };
752
+ let hasElement = false;
753
+ (0, legacy_1.default)(data).forEach(function (d) {
754
+ if ((0, exports.isBuilderElement)(d)) {
755
+ /**
756
+ * Replacing the Builder element with a Mitosis node in-place
757
+ * allows us to assign to blockSlots while preserving the structure
758
+ * of this deeply nested data.
759
+ */
760
+ this.update((0, exports.builderElementToMitosisNode)(d, options, _internalOptions));
761
+ hasElement = true;
762
+ }
763
+ });
764
+ // If no elements were updated then this is just a regular binding
765
+ if (hasElement) {
766
+ blocksSlots[key] = data;
767
+ }
768
+ else {
769
+ bindings[key] = (0, bindings_1.createSingleBinding)({ code: json5_1.default.stringify(value) });
770
+ }
771
+ }
772
+ else {
773
+ bindings[key] = (0, bindings_1.createSingleBinding)({ code: json5_1.default.stringify(value) });
774
+ }
775
+ }
776
+ }
777
+ const css = getCssFromBlock(block);
778
+ let styleString = (0, exports.getStyleStringFromBlock)(block, options);
779
+ const actionBindings = getActionBindingsFromBlock(block, options);
780
+ for (const binding in blockBindings) {
781
+ if (binding.startsWith('component.options') || binding.startsWith('options')) {
782
+ const value = blockBindings[binding];
783
+ const useKey = binding.replace(/^(component\.options\.|options\.)/, '');
784
+ bindings[useKey] = (0, bindings_1.createSingleBinding)({ code: value });
785
+ }
786
+ }
787
+ // Add data attributes for Builder layer properties
788
+ const dataAttributes = {};
789
+ if (block.layerLocked !== undefined) {
790
+ dataAttributes['data-builder-layerLocked'] = String(block.layerLocked);
791
+ }
792
+ if (block.groupLocked !== undefined) {
793
+ dataAttributes['data-builder-groupLocked'] = String(block.groupLocked);
794
+ }
795
+ if (((_t = block.component) === null || _t === void 0 ? void 0 : _t.name) &&
796
+ /:/.test((_u = block.component) === null || _u === void 0 ? void 0 : _u.name) &&
797
+ !generator_1.builderBlockPrefixes.includes((_v = block.component) === null || _v === void 0 ? void 0 : _v.name.split(':')[0])) {
798
+ dataAttributes['data-builder-originalName'] = (_w = block.component) === null || _w === void 0 ? void 0 : _w.name;
799
+ }
800
+ const node = (0, create_mitosis_node_1.createMitosisNode)({
801
+ name: ((_y = (_x = block.component) === null || _x === void 0 ? void 0 : _x.name) === null || _y === void 0 ? void 0 : _y.replace(/[^a-z0-9]/gi, '')) ||
802
+ block.tagName ||
803
+ (block.linkUrl ? 'a' : 'div'),
804
+ properties: {
805
+ ...(block.component && includeSpecialBindings && { $tagName: block.tagName }),
806
+ ...(block.class && { class: block.class }),
807
+ ...properties,
808
+ ...dataAttributes,
809
+ },
810
+ bindings: {
811
+ ...bindings,
812
+ ...actionBindings,
813
+ ...(styleString && {
814
+ style: (0, bindings_1.createSingleBinding)({ code: styleString }),
815
+ }),
816
+ ...(css &&
817
+ Object.keys(css).length && {
818
+ css: (0, bindings_1.createSingleBinding)({ code: JSON.stringify(css) }),
819
+ }),
820
+ },
821
+ slots: {
822
+ ...slots,
823
+ },
824
+ ...(Object.keys(blocksSlots).length > 0 && { blocksSlots }),
825
+ meta: {
826
+ ...(0, exports.getMetaFromBlock)(block, options),
827
+ },
828
+ ...(Object.keys(localizedValues).length && { localizedValues }),
829
+ });
830
+ node.children = children.concat((block.children || []).map((item) => (0, exports.builderElementToMitosisNode)(item, options)));
831
+ return node;
832
+ };
833
+ exports.builderElementToMitosisNode = builderElementToMitosisNode;
834
+ const getBuilderPropsForSymbol = (block) => {
835
+ var _a, _b;
836
+ if (((_a = block.children) === null || _a === void 0 ? void 0 : _a.length) === 1) {
837
+ const child = block.children[0];
838
+ const builderContentId = (_b = child.properties) === null || _b === void 0 ? void 0 : _b['builder-content-id'];
839
+ if (builderContentId) {
840
+ return { 'builder-content-id': builderContentId };
841
+ }
842
+ }
843
+ return undefined;
844
+ };
845
+ const getMetaFromBlock = (block, options) => {
846
+ const { includeMeta = false } = options;
847
+ return includeMeta
848
+ ? {
849
+ 'builder-id': block.id,
850
+ ...block.meta,
851
+ }
852
+ : {};
853
+ };
854
+ exports.getMetaFromBlock = getMetaFromBlock;
855
+ const getHooks = (content) => {
856
+ var _a, _b;
857
+ const code = convertExportDefaultToReturn(((_a = content.data) === null || _a === void 0 ? void 0 : _a.tsCode) || ((_b = content.data) === null || _b === void 0 ? void 0 : _b.jsCode) || '');
858
+ try {
859
+ return (0, jsx_1.parseJsx)(`
860
+ export default function TemporaryComponent() {
861
+ ${
862
+ // Mitosis parser looks for useStore to be a variable assignment,
863
+ // but in Builder that's not how it works. For now do a replace to
864
+ // easily resuse the same parsing code as this is the only difference
865
+ code.replace(`useStore(`, `var state = useStore(`)}
866
+ }`);
867
+ }
868
+ catch (err) {
869
+ console.warn('Could not parse js code as a Mitosis component body', err, code);
870
+ return null;
871
+ }
872
+ };
873
+ /**
874
+ * Take Builder custom jsCode and extract the contents of the useStore hook
875
+ * and return it as a JS object along with the inputted code with the hook
876
+ * code extracted
877
+ */
878
+ function extractStateHook(code) {
879
+ const { types } = babel;
880
+ let state = {};
881
+ const body = (0, parsers_1.parseCode)(code);
882
+ const newBody = body.slice();
883
+ for (let i = 0; i < body.length; i++) {
884
+ const statement = body[i];
885
+ if (types.isExpressionStatement(statement)) {
886
+ const { expression } = statement;
887
+ // Check for useStore
888
+ if (types.isCallExpression(expression)) {
889
+ if (types.isIdentifier(expression.callee) && expression.callee.name === 'useStore') {
890
+ const arg = expression.arguments[0];
891
+ if (types.isObjectExpression(arg)) {
892
+ state = (0, state_1.parseStateObjectToMitosisState)(arg);
893
+ newBody.splice(i, 1);
894
+ }
895
+ }
896
+ if (types.isMemberExpression(expression.callee)) {
897
+ if (types.isIdentifier(expression.callee.object) &&
898
+ expression.callee.object.name === 'Object') {
899
+ if (types.isIdentifier(expression.callee.property) &&
900
+ expression.callee.property.name === 'assign') {
901
+ const arg = expression.arguments[1];
902
+ if (types.isObjectExpression(arg)) {
903
+ state = (0, state_1.parseStateObjectToMitosisState)(arg);
904
+ newBody.splice(i, 1);
905
+ }
906
+ }
907
+ }
908
+ }
909
+ }
910
+ }
911
+ }
912
+ const newCode = (0, generator_2.default)(types.program(newBody)).code || '';
913
+ return { code: newCode, state };
914
+ }
915
+ exports.extractStateHook = extractStateHook;
916
+ /**
917
+ * Extracts Mitosis state from Builder state.
918
+ * @param mitosisState Mitosis state to update
919
+ * @param builderState Builder state to extract from
920
+ * @returns
921
+ */
922
+ function extractMitosisStateFromBuilderState(mitosisState, builderState) {
923
+ if (!builderState)
924
+ return;
925
+ for (const key in builderState) {
926
+ let value = builderState[key];
927
+ if (typeof value === 'function' && !mitosisState[key]) {
928
+ mitosisState[key] = {
929
+ type: 'function',
930
+ code: value.toString(),
931
+ };
932
+ continue;
933
+ }
934
+ if (!mitosisState[key]) {
935
+ mitosisState[key] = {
936
+ type: 'property',
937
+ propertyType: 'normal',
938
+ code: JSON.stringify(value),
939
+ };
940
+ }
941
+ }
942
+ }
943
+ exports.extractMitosisStateFromBuilderState = extractMitosisStateFromBuilderState;
944
+ function convertExportDefaultToReturn(code) {
945
+ try {
946
+ const { types } = babel;
947
+ const body = (0, parsers_1.parseCode)(code);
948
+ if (body.length === 0)
949
+ return code;
950
+ const newBody = body.slice();
951
+ for (let i = 0; i < body.length; i++) {
952
+ const statement = body[i];
953
+ if (types.isExportDefaultDeclaration(statement)) {
954
+ if (types.isCallExpression(statement.declaration) ||
955
+ types.isExpression(statement.declaration)) {
956
+ newBody[i] = types.returnStatement(statement.declaration);
957
+ }
958
+ }
959
+ }
960
+ return (0, generator_2.default)(types.program(newBody)).code || '';
961
+ }
962
+ catch (e) {
963
+ const error = e;
964
+ if (error.code === 'BABEL_PARSE_ERROR') {
965
+ return code;
966
+ }
967
+ else {
968
+ throw e;
969
+ }
970
+ }
971
+ }
972
+ exports.convertExportDefaultToReturn = convertExportDefaultToReturn;
973
+ const updateBindings = (node, from, to) => {
974
+ (0, legacy_1.default)(node).forEach(function (item) {
975
+ if ((0, exports.isBuilderElement)(item)) {
976
+ if (item.bindings) {
977
+ for (const [key, value] of Object.entries(item.bindings)) {
978
+ if (value === null || value === void 0 ? void 0 : value.includes(from)) {
979
+ item.bindings[key] = value.replaceAll(from, to);
980
+ }
981
+ }
982
+ }
983
+ if (item.actions) {
984
+ for (const [key, value] of Object.entries(item.actions)) {
985
+ if (value === null || value === void 0 ? void 0 : value.includes(from)) {
986
+ item.actions[key] = value.replaceAll(from, to);
987
+ }
988
+ }
989
+ }
990
+ }
991
+ });
992
+ return node;
993
+ };
994
+ // TODO: maybe this should be part of the builder -> Mitosis part
995
+ function extractSymbols(json) {
996
+ var _a, _b, _c, _d;
997
+ const subComponents = [];
998
+ const symbols = [];
999
+ (0, legacy_1.default)(json).forEach(function (item) {
1000
+ var _a;
1001
+ if ((0, exports.isBuilderElement)(item)) {
1002
+ if (((_a = item.component) === null || _a === void 0 ? void 0 : _a.name) === 'Symbol') {
1003
+ symbols.push({ element: item, depth: this.path.length, id: item.id });
1004
+ }
1005
+ }
1006
+ });
1007
+ const symbolsSortedDeepestFirst = (0, lodash_1.sortBy)(symbols, (info) => info.depth)
1008
+ .reverse()
1009
+ .map((el) => el.element);
1010
+ let symbolsFound = 0;
1011
+ for (const el of symbolsSortedDeepestFirst) {
1012
+ const symbolValue = (_b = (_a = el.component) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.symbol;
1013
+ const elContent = symbolValue === null || symbolValue === void 0 ? void 0 : symbolValue.content;
1014
+ if (!elContent) {
1015
+ console.warn('Symbol missing content', el.id);
1016
+ if ((_c = el.component) === null || _c === void 0 ? void 0 : _c.options.symbol.content) {
1017
+ delete el.component.options.symbol.content;
1018
+ }
1019
+ continue;
1020
+ }
1021
+ const symbolName = elContent.name || (symbolValue === null || symbolValue === void 0 ? void 0 : symbolValue.name);
1022
+ const componentName = sanitizeSymbolName(symbolName);
1023
+ el.component.name = componentName;
1024
+ if ((_d = el.component) === null || _d === void 0 ? void 0 : _d.options.symbol.content) {
1025
+ delete el.component.options.symbol.content;
1026
+ }
1027
+ subComponents.push({
1028
+ content: elContent,
1029
+ name: componentName,
1030
+ });
1031
+ }
1032
+ return {
1033
+ content: json,
1034
+ subComponents,
1035
+ };
1036
+ }
1037
+ const createBuilderElement = (options) => ({
1038
+ '@type': '@builder.io/sdk:Element',
1039
+ id: 'builder-' + (0, symbol_processor_1.hashCodeAsString)(options),
1040
+ ...options,
1041
+ });
1042
+ exports.createBuilderElement = createBuilderElement;
1043
+ const isBuilderElement = (el) => (el === null || el === void 0 ? void 0 : el['@type']) === '@builder.io/sdk:Element';
1044
+ exports.isBuilderElement = isBuilderElement;
1045
+ const builderContentPartToMitosisComponent = (builderContent, options = {}) => {
1046
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1047
+ builderContent = (0, fast_clone_1.fastClone)(builderContent);
1048
+ (0, legacy_1.default)(builderContent).forEach(function (elem) {
1049
+ var _a, _b;
1050
+ if ((0, exports.isBuilderElement)(elem)) {
1051
+ // Try adding self-closing tags to void elements, since Builder Text
1052
+ // blocks can contain arbitrary HTML
1053
+ // List taken from https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
1054
+ // TODO: Maybe this should be using something more robust than a regular expression
1055
+ const voidElemRegex = /(<area|base|br|col|embed|hr|img|input|keygen|link|meta|param|source|track|wbr[^>]+)>/gm;
1056
+ try {
1057
+ if (((_a = elem.component) === null || _a === void 0 ? void 0 : _a.name) === 'Text') {
1058
+ const text = elem.component.options.text;
1059
+ elem.component.options.text = text.replace(voidElemRegex, '$1 />');
1060
+ // Remove broken emojis
1061
+ const hasUnpairedSurrogate = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
1062
+ if (hasUnpairedSurrogate.test(text)) {
1063
+ elem.component.options.text = text.replace(hasUnpairedSurrogate, '');
1064
+ }
1065
+ }
1066
+ }
1067
+ catch (_error) {
1068
+ // pass
1069
+ }
1070
+ try {
1071
+ if (((_b = elem.component) === null || _b === void 0 ? void 0 : _b.name) === 'Custom Code') {
1072
+ elem.component.options.code = elem.component.options.code.replace(voidElemRegex, '$1 />');
1073
+ }
1074
+ }
1075
+ catch (_error) {
1076
+ // pass
1077
+ }
1078
+ }
1079
+ });
1080
+ const { state, code } = extractStateHook(((_a = builderContent === null || builderContent === void 0 ? void 0 : builderContent.data) === null || _a === void 0 ? void 0 : _a.tsCode) || ((_b = builderContent === null || builderContent === void 0 ? void 0 : builderContent.data) === null || _b === void 0 ? void 0 : _b.jsCode) || '');
1081
+ const customCode = convertExportDefaultToReturn(code);
1082
+ const parsed = getHooks(builderContent);
1083
+ const parsedState = (parsed === null || parsed === void 0 ? void 0 : parsed.state) || {};
1084
+ const mitosisState = Object.keys(parsedState).length > 0
1085
+ ? parsedState
1086
+ : {
1087
+ ...state,
1088
+ ...(0, helpers_1.mapBuilderContentStateToMitosisState)(((_c = builderContent.data) === null || _c === void 0 ? void 0 : _c.state) || {}),
1089
+ };
1090
+ extractMitosisStateFromBuilderState(mitosisState, (_d = builderContent.data) === null || _d === void 0 ? void 0 : _d.state);
1091
+ const componentJson = (0, create_mitosis_component_1.createMitosisComponent)({
1092
+ meta: {
1093
+ useMetadata: {
1094
+ httpRequests: (_e = builderContent.data) === null || _e === void 0 ? void 0 : _e.httpRequests,
1095
+ },
1096
+ // cmp.meta.cssCode exists for backwards compatibility, prefer cmp.style
1097
+ ...(((_f = builderContent.data) === null || _f === void 0 ? void 0 : _f.cssCode) && { cssCode: builderContent.data.cssCode }),
1098
+ },
1099
+ ...(((_g = builderContent.data) === null || _g === void 0 ? void 0 : _g.cssCode) && { style: (_h = builderContent.data) === null || _h === void 0 ? void 0 : _h.cssCode }),
1100
+ inputs: (_k = (_j = builderContent.data) === null || _j === void 0 ? void 0 : _j.inputs) === null || _k === void 0 ? void 0 : _k.map((input) => ({
1101
+ name: input.name,
1102
+ defaultValue: input.defaultValue,
1103
+ })),
1104
+ state: mitosisState,
1105
+ hooks: {
1106
+ onMount: [
1107
+ ...((parsed === null || parsed === void 0 ? void 0 : parsed.hooks.onMount.length)
1108
+ ? parsed === null || parsed === void 0 ? void 0 : parsed.hooks.onMount
1109
+ : customCode
1110
+ ? [{ code: customCode }]
1111
+ : []),
1112
+ ],
1113
+ },
1114
+ children: (((_l = builderContent.data) === null || _l === void 0 ? void 0 : _l.blocks) || [])
1115
+ .filter((item) => {
1116
+ var _a, _b;
1117
+ if ((_b = (_a = item.properties) === null || _a === void 0 ? void 0 : _a.src) === null || _b === void 0 ? void 0 : _b.includes('/api/v1/pixel')) {
1118
+ return false;
1119
+ }
1120
+ return true;
1121
+ })
1122
+ .map((item) => (0, exports.builderElementToMitosisNode)(item, options)),
1123
+ });
1124
+ return componentJson;
1125
+ };
1126
+ const builderContentToMitosisComponent = (builderContent, options = {}) => {
1127
+ builderContent = (0, fast_clone_1.fastClone)(builderContent);
1128
+ const separated = extractSymbols(builderContent);
1129
+ const componentJson = {
1130
+ ...builderContentPartToMitosisComponent(separated.content, options),
1131
+ subComponents: separated.subComponents.map((item) => ({
1132
+ ...builderContentPartToMitosisComponent(item.content, options),
1133
+ name: item.name,
1134
+ })),
1135
+ };
1136
+ return componentJson;
1137
+ };
1138
+ exports.builderContentToMitosisComponent = builderContentToMitosisComponent;
1139
+ function mapBuilderBindingsToMitosisBindingWithCode(bindings, options) {
1140
+ const result = {};
1141
+ bindings &&
1142
+ Object.keys(bindings).forEach((key) => {
1143
+ const value = bindings[key];
1144
+ let code = '';
1145
+ if (typeof value === 'string') {
1146
+ code = value;
1147
+ }
1148
+ else if (value && typeof value === 'object' && value.code) {
1149
+ code = value.code;
1150
+ }
1151
+ else {
1152
+ throw new Error('Unexpected binding value: ' + JSON.stringify(value));
1153
+ }
1154
+ const verifyCode = verifyIsValid(code);
1155
+ if (verifyCode.valid) {
1156
+ code = processBoundLogic(code);
1157
+ }
1158
+ else {
1159
+ if (options === null || options === void 0 ? void 0 : options.escapeInvalidCode) {
1160
+ code = '`' + code + ' [INVALID CODE]`';
1161
+ }
1162
+ else {
1163
+ console.warn(`Dropping binding "${key}" due to invalid code: ${code}`);
1164
+ return;
1165
+ }
1166
+ }
1167
+ result[key] = (0, bindings_1.createSingleBinding)({ code });
1168
+ });
1169
+ return result;
1170
+ }
1171
+ function combineStyles(parent, child) {
1172
+ const marginStyles = ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'];
1173
+ const paddingStyles = ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight'];
1174
+ const distanceStylesToCombine = [...paddingStyles, ...marginStyles];
1175
+ const merged = {
1176
+ ...(0, lodash_1.omit)(child, distanceStylesToCombine),
1177
+ ...parent,
1178
+ };
1179
+ for (const key of distanceStylesToCombine) {
1180
+ // Funky things happen if different alignment
1181
+ if (parent.alignSelf !== child.alignSelf && (key === 'marginLeft' || key === 'marginRight')) {
1182
+ merged[key] = parent[key];
1183
+ continue;
1184
+ }
1185
+ const childNum = parseFloat(child[key]) || 0;
1186
+ const parentKeyToUse = key.replace(/margin/, 'padding');
1187
+ const parentNum = parseFloat(parent[parentKeyToUse]) || 0;
1188
+ if (childNum || parentNum) {
1189
+ merged[parentKeyToUse] = `${childNum + parentNum}px`;
1190
+ }
1191
+ }
1192
+ for (const [key, value] of Object.entries(merged)) {
1193
+ if (value && typeof value === 'object') {
1194
+ merged[key] = combineStyles(parent[key] || {}, child[key] || {});
1195
+ }
1196
+ }
1197
+ return merged;
1198
+ }