@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,304 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blockToSwift = void 0;
4
+ const helpers_1 = require("./helpers");
5
+ // Helper function to sanitize text content for SwiftUI
6
+ const sanitizeTextForSwift = (text) => {
7
+ if (!text)
8
+ return '""';
9
+ // Check if text contains newlines
10
+ if (text.includes('\n')) {
11
+ // Use triple quotes for multiline strings
12
+ return `"""${text}"""`;
13
+ }
14
+ // Escape double quotes in the text
15
+ return `"${text.replace(/"/g, '\\"')}"`;
16
+ };
17
+ const blockToSwift = ({ json, options, parentComponent, }) => {
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
19
+ if (json.properties._text) {
20
+ return `Text(${sanitizeTextForSwift(json.properties._text)})`;
21
+ }
22
+ const tag = json.name;
23
+ // For fragments, render children without a wrapper
24
+ if (tag === 'Fragment') {
25
+ return json.children
26
+ .map((child) => (0, exports.blockToSwift)({ json: child, options, parentComponent }))
27
+ .join('\n');
28
+ }
29
+ // Process bindings and properties - use parentComponent here instead of json
30
+ const processCode = (0, helpers_1.stripStateAndProps)({ json: parentComponent, options });
31
+ // Handle ForEach blocks - use bindings.each pattern like other generators
32
+ if ((_a = json.bindings.each) === null || _a === void 0 ? void 0 : _a.code) {
33
+ const { collection, itemName, indexName } = (0, helpers_1.getForEachParams)(json, processCode);
34
+ const forEachContent = json.children
35
+ .map((child) => (0, exports.blockToSwift)({ json: child, options, parentComponent }))
36
+ .join('\n');
37
+ // Check if the collection is using Array.from({length: X}) pattern
38
+ const arrayFromMatch = collection.match(/Array\.from\(\s*\{\s*length:\s*(\d+)\s*\}\s*\)/);
39
+ if (arrayFromMatch) {
40
+ // Convert to SwiftUI's ForEach with a range
41
+ const length = arrayFromMatch[1];
42
+ if (indexName) {
43
+ // With index
44
+ return `ForEach(0..<${length}, id: \\.self) { ${indexName} in
45
+ let ${itemName} = ${indexName}
46
+ ${forEachContent}
47
+ }`;
48
+ }
49
+ else {
50
+ // Without index
51
+ return `ForEach(0..<${length}, id: \\.self) { ${itemName} in
52
+ ${forEachContent}
53
+ }`;
54
+ }
55
+ }
56
+ else {
57
+ // Standard collection-based ForEach
58
+ if (indexName) {
59
+ return `ForEach(Array(zip(${collection}.indices, ${collection})), id: \\.0) { ${indexName}, ${itemName} in
60
+ ${forEachContent}
61
+ }`;
62
+ }
63
+ else {
64
+ return `ForEach(${collection}, id: \\.self) { ${itemName} in
65
+ ${forEachContent}
66
+ }`;
67
+ }
68
+ }
69
+ }
70
+ // Determine the SwiftUI component name
71
+ const component = (0, helpers_1.jsxElementToSwiftUIView)(tag);
72
+ // Handle children
73
+ const hasChildren = json.children && json.children.length > 0;
74
+ // Handle event handlers
75
+ const eventHandlers = Object.entries(json.bindings)
76
+ .filter(([key]) => { var _a; return key.startsWith('on') && ((_a = json.bindings[key]) === null || _a === void 0 ? void 0 : _a.code); })
77
+ .map(([key, binding]) => {
78
+ const swiftEventName = (0, helpers_1.getEventHandlerName)(key);
79
+ return `.${swiftEventName}(${processCode((binding === null || binding === void 0 ? void 0 : binding.code) || '')})`;
80
+ });
81
+ // Handle data bindings (like bind:value)
82
+ const dataBindings = Object.entries(json.bindings)
83
+ .filter(([key]) => { var _a; return key.startsWith('bind:') && ((_a = json.bindings[key]) === null || _a === void 0 ? void 0 : _a.code); })
84
+ .map(([key, binding]) => {
85
+ const bindingType = (0, helpers_1.getBindingType)(key);
86
+ const bindingValue = processCode((binding === null || binding === void 0 ? void 0 : binding.code) || '');
87
+ return { type: bindingType, value: bindingValue };
88
+ });
89
+ // Handle style properties
90
+ const styleModifiers = [];
91
+ if (json.bindings.style) {
92
+ // Dynamic styles
93
+ styleModifiers.push(`// Dynamic styles not fully implemented`);
94
+ styleModifiers.push(`.modifier(/* Dynamic style handling needed here */)"`);
95
+ }
96
+ else if (json.properties.style) {
97
+ // Static styles
98
+ try {
99
+ const styleObj = JSON.parse(json.properties.style);
100
+ styleModifiers.push(...(0, helpers_1.cssToSwiftUIModifiers)(styleObj));
101
+ }
102
+ catch (e) {
103
+ styleModifiers.push(`// Could not parse style: ${json.properties.style}`);
104
+ }
105
+ }
106
+ // Check if we need a ScrollView
107
+ const needsScroll = (0, helpers_1.needsScrollView)(json);
108
+ // Conditional rendering
109
+ let result = '';
110
+ if ((_b = json.bindings.if) === null || _b === void 0 ? void 0 : _b.code) {
111
+ result += `if ${processCode(json.bindings.if.code)} {\n`;
112
+ }
113
+ else if ((_c = json.bindings.show) === null || _c === void 0 ? void 0 : _c.code) {
114
+ // In SwiftUI we can use opacity for show/hide
115
+ styleModifiers.push(`.opacity(${processCode(json.bindings.show.code)} ? 1 : 0)`);
116
+ }
117
+ // Start building the component
118
+ let componentCode = '';
119
+ switch (component) {
120
+ case 'Text':
121
+ // Text components in SwiftUI need their content as a parameter
122
+ let textContent = '';
123
+ if (json.properties._text) {
124
+ textContent = sanitizeTextForSwift(json.properties._text);
125
+ }
126
+ else if ((_d = json.bindings.innerHTML) === null || _d === void 0 ? void 0 : _d.code) {
127
+ // For dynamic content, we'll need to handle it as an expression
128
+ textContent = processCode(json.bindings.innerHTML.code);
129
+ }
130
+ else {
131
+ textContent = '""';
132
+ }
133
+ componentCode = `Text(${textContent})`;
134
+ break;
135
+ case 'Button':
136
+ // Find the action from eventHandlers or create an empty one
137
+ let buttonAction = '{}';
138
+ const onClickHandler = eventHandlers.find((h) => h.includes('onTapGesture'));
139
+ if (onClickHandler) {
140
+ buttonAction = onClickHandler.replace('.onTapGesture(', '').replace(')', '');
141
+ // Remove this handler from the list since we're using it directly
142
+ eventHandlers.splice(eventHandlers.indexOf(onClickHandler), 1);
143
+ }
144
+ const buttonLabel = hasChildren
145
+ ? json.children
146
+ .map((child) => (0, exports.blockToSwift)({ json: child, options, parentComponent }))
147
+ .join('\n')
148
+ : `Text("${json.properties._text || 'Button'}")`;
149
+ componentCode = `Button(action: { ${buttonAction} }) {\n${buttonLabel}\n}`;
150
+ break;
151
+ case 'TextField':
152
+ // TextField can have either bind:value or direct value binding
153
+ let bindingExpression = '';
154
+ // First check for explicit bind:value
155
+ const textBinding = dataBindings.find((b) => b.type === 'value');
156
+ // If not found, check for direct value binding
157
+ const directValueBinding = ((_e = json.bindings.value) === null || _e === void 0 ? void 0 : _e.code)
158
+ ? processCode(json.bindings.value.code)
159
+ : null;
160
+ if (textBinding) {
161
+ // Use the explicit binding from dataBindings
162
+ bindingExpression = textBinding.value;
163
+ }
164
+ else if (directValueBinding) {
165
+ // Use direct value binding
166
+ bindingExpression = directValueBinding;
167
+ }
168
+ if (bindingExpression) {
169
+ // Convert to SwiftUI binding syntax
170
+ bindingExpression = bindingExpression.replace(/self\.(\w+)/g, '$$$1');
171
+ // If it still doesn't start with $, add it
172
+ if (!bindingExpression.startsWith('$')) {
173
+ bindingExpression = `$${bindingExpression}`;
174
+ }
175
+ componentCode = `TextField("${json.properties.placeholder || ''}", text: ${bindingExpression})`;
176
+ }
177
+ else {
178
+ // No binding found, use constant value
179
+ componentCode = `TextField("${json.properties.placeholder || ''}", text: .constant("${json.properties.value || ''}"))`;
180
+ }
181
+ break;
182
+ case 'Image':
183
+ // Determine if using system image, URL, or asset
184
+ if ((_f = json.properties.src) === null || _f === void 0 ? void 0 : _f.startsWith('system-')) {
185
+ // System image
186
+ const systemName = json.properties.src.replace('system-', '');
187
+ componentCode = `Image(systemName: "${systemName}")`;
188
+ }
189
+ else if ((_g = json.properties.src) === null || _g === void 0 ? void 0 : _g.startsWith('http')) {
190
+ // URL image (requires AsyncImage)
191
+ componentCode = `AsyncImage(url: URL(string: "${json.properties.src}")!) { image in
192
+ image.resizable()
193
+ } placeholder: {
194
+ ProgressView()
195
+ }`;
196
+ }
197
+ else {
198
+ // Asset image
199
+ componentCode = `Image("${json.properties.src || 'placeholder'}")`;
200
+ }
201
+ if (json.properties.resizeMode) {
202
+ componentCode += `.resizable().aspectRatio(contentMode: .${json.properties.resizeMode})`;
203
+ }
204
+ else if (!((_h = json.properties.src) === null || _h === void 0 ? void 0 : _h.startsWith('http'))) {
205
+ // Add resizable for non-async images without specific mode
206
+ componentCode += `.resizable().aspectRatio(contentMode: .fit)`;
207
+ }
208
+ break;
209
+ case 'VStack':
210
+ case 'HStack':
211
+ case 'ZStack':
212
+ // Stacks with children
213
+ const alignment = json.properties.alignment || 'leading';
214
+ const spacing = json.properties.spacing || '8';
215
+ componentCode = `${component}(alignment: .${alignment}, spacing: ${spacing}) {\n`;
216
+ if (hasChildren) {
217
+ componentCode += json.children
218
+ .map((child) => {
219
+ return (0, exports.blockToSwift)({ json: child, options, parentComponent });
220
+ })
221
+ .join('\n');
222
+ }
223
+ componentCode += '\n}';
224
+ break;
225
+ case 'List':
226
+ // Lists in SwiftUI
227
+ componentCode = `List {\n`;
228
+ if (hasChildren) {
229
+ componentCode += json.children
230
+ .map((child) => {
231
+ return (0, exports.blockToSwift)({ json: child, options, parentComponent });
232
+ })
233
+ .join('\n');
234
+ }
235
+ componentCode += '\n}';
236
+ break;
237
+ case 'Picker':
238
+ // Handle select element
239
+ // Pickers in SwiftUI need a selection binding, a label, and content
240
+ const selectBinding = dataBindings.find((b) => b.type === 'value');
241
+ const selectionVar = selectBinding ? selectBinding.value : '.constant("")';
242
+ // Create label from the "label" property or a default
243
+ const pickerLabel = json.properties.label
244
+ ? `Text("${json.properties.label}")`
245
+ : 'Text("Select")';
246
+ // Start building the picker
247
+ componentCode = `Picker(selection: Binding(get: { ${selectionVar} }, set: { ${selectionVar} = $0 }), label: { ${pickerLabel} }) {`;
248
+ // Add options as children
249
+ if (hasChildren) {
250
+ json.children.forEach((child) => {
251
+ var _a;
252
+ // For option elements, extract the value and text
253
+ if (((_a = child.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'option') {
254
+ const optionValue = child.properties.value || '';
255
+ const optionText = child.properties._text || optionValue;
256
+ componentCode += `\nText("${optionText}").tag("${optionValue}")`;
257
+ }
258
+ else {
259
+ // Handle non-option children (unusual but possible)
260
+ componentCode += `\n${(0, exports.blockToSwift)({ json: child, options, parentComponent })}`;
261
+ }
262
+ });
263
+ }
264
+ componentCode += '\n}';
265
+ break;
266
+ default:
267
+ // Custom components or other SwiftUI views
268
+ if (hasChildren) {
269
+ componentCode = `${component} {\n`;
270
+ componentCode += json.children
271
+ .map((child) => {
272
+ return (0, exports.blockToSwift)({ json: child, options, parentComponent });
273
+ })
274
+ .join('\n');
275
+ componentCode += '\n}';
276
+ }
277
+ else {
278
+ componentCode = `${component}()`;
279
+ }
280
+ }
281
+ // Apply modifiers
282
+ styleModifiers.forEach((modifier) => {
283
+ componentCode += `\n${modifier}`;
284
+ });
285
+ // Add event handlers that weren't specifically handled above
286
+ eventHandlers
287
+ .filter((handler) => !componentCode.includes(handler))
288
+ .forEach((handler) => {
289
+ componentCode += `\n${handler}`;
290
+ });
291
+ // Wrap with ScrollView if needed
292
+ if (needsScroll) {
293
+ componentCode = `ScrollView {\n${componentCode}\n}`;
294
+ }
295
+ // Close conditional rendering block if needed
296
+ if ((_j = json.bindings.if) === null || _j === void 0 ? void 0 : _j.code) {
297
+ result += componentCode + '\n}';
298
+ }
299
+ else {
300
+ result += componentCode;
301
+ }
302
+ return result;
303
+ };
304
+ exports.blockToSwift = blockToSwift;
@@ -0,0 +1,3 @@
1
+ import { TranspilerGenerator } from '../../types/transpiler';
2
+ import { ToSwiftOptions } from './types';
3
+ export declare const componentToSwift: TranspilerGenerator<ToSwiftOptions>;
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.componentToSwift = void 0;
4
+ const dedent_1 = require("../../helpers/dedent");
5
+ const fast_clone_1 = require("../../helpers/fast-clone");
6
+ const generic_format_1 = require("../../helpers/generic-format");
7
+ const get_props_1 = require("../../helpers/get-props");
8
+ const get_refs_1 = require("../../helpers/get-refs");
9
+ const getters_to_functions_1 = require("../../helpers/getters-to-functions");
10
+ const merge_options_1 = require("../../helpers/merge-options");
11
+ const on_event_1 = require("../../helpers/on-event");
12
+ const patterns_1 = require("../../helpers/patterns");
13
+ const process_code_1 = require("../../helpers/plugins/process-code");
14
+ const slots_1 = require("../../helpers/slots");
15
+ const strip_meta_properties_1 = require("../../helpers/strip-meta-properties");
16
+ const plugins_1 = require("../../modules/plugins");
17
+ const blocks_1 = require("./blocks");
18
+ const helpers_1 = require("./helpers");
19
+ const DEFAULT_OPTIONS = {
20
+ stateType: 'state',
21
+ formatCode: true,
22
+ includeTypes: true,
23
+ includePreview: true,
24
+ classPrefix: '',
25
+ };
26
+ const componentToSwift = (userProvidedOptions) => ({ component }) => {
27
+ var _a, _b;
28
+ const options = (0, merge_options_1.initializeOptions)({
29
+ target: 'swift',
30
+ component,
31
+ defaults: DEFAULT_OPTIONS,
32
+ userOptions: userProvidedOptions,
33
+ });
34
+ options.plugins = [
35
+ ...(options.plugins || []),
36
+ (0, on_event_1.processOnEventHooksPlugin)(),
37
+ (0, process_code_1.CODE_PROCESSOR_PLUGIN)((codeType) => {
38
+ switch (codeType) {
39
+ case 'bindings':
40
+ case 'properties':
41
+ case 'hooks':
42
+ case 'hooks-deps':
43
+ case 'hooks-deps-array':
44
+ case 'state':
45
+ case 'context-set':
46
+ case 'dynamic-jsx-elements':
47
+ case 'types':
48
+ return (x) => (0, helpers_1.convertConsoleLogToPrint)(x);
49
+ }
50
+ }),
51
+ (0, process_code_1.CODE_PROCESSOR_PLUGIN)((codeType) => {
52
+ switch (codeType) {
53
+ case 'hooks':
54
+ return (code) => (0, helpers_1.stripStateAndProps)({ json, options })(code);
55
+ case 'bindings':
56
+ case 'hooks-deps':
57
+ case 'state':
58
+ return (code) => (0, patterns_1.stripGetter)((0, helpers_1.stripStateAndProps)({ json, options })(code));
59
+ case 'properties':
60
+ case 'context-set':
61
+ return (code) => (0, helpers_1.stripStateAndProps)({ json, options })(code);
62
+ case 'dynamic-jsx-elements':
63
+ case 'hooks-deps-array':
64
+ case 'types':
65
+ return (x) => (0, helpers_1.convertConsoleLogToPrint)(x);
66
+ }
67
+ }),
68
+ ];
69
+ // Make a copy we can safely mutate
70
+ let json = (0, fast_clone_1.fastClone)(component);
71
+ json = (0, plugins_1.runPreJsonPlugins)({ json, plugins: options.plugins });
72
+ (0, getters_to_functions_1.gettersToFunctions)(json);
73
+ const componentName = options.classPrefix + (json.name || ((_a = json.meta.useMetadata) === null || _a === void 0 ? void 0 : _a.name) || 'MitosisComponent');
74
+ // Process props
75
+ const filteredProps = Array.from((0, get_props_1.getProps)(json)).filter((prop) => !(0, slots_1.isSlotProperty)(prop));
76
+ const props = Array.from(new Set(filteredProps));
77
+ // Process refs (not directly applicable in SwiftUI, will be converted to @State)
78
+ const refs = Array.from((0, get_refs_1.getRefs)(json))
79
+ .map((0, helpers_1.stripStateAndProps)({ json, options }))
80
+ .filter((x) => !props.includes(x));
81
+ json = (0, plugins_1.runPostJsonPlugins)({ json, plugins: options.plugins });
82
+ (0, strip_meta_properties_1.stripMetaProperties)(json);
83
+ // Generate state variables
84
+ const stateProperties = Object.entries(json.state)
85
+ .filter(([_, value]) => {
86
+ // Skip methods - they'll be handled separately
87
+ return !((value === null || value === void 0 ? void 0 : value.type) === 'method' ||
88
+ ((value === null || value === void 0 ? void 0 : value.code) && (value.code.includes('function') || value.code.includes('=>'))));
89
+ })
90
+ .map(([key, value]) => {
91
+ var _a, _b, _c, _d, _e;
92
+ // Check for value properties safely
93
+ const propertyType = value === null || value === void 0 ? void 0 : value.propertyType;
94
+ // Determine Swift type - handle missing type property
95
+ let valueType = 'Any';
96
+ if (value === null || value === void 0 ? void 0 : value.typeParameter) {
97
+ valueType = value.typeParameter;
98
+ }
99
+ else {
100
+ // Try to infer type from code if possible
101
+ if (((_a = value === null || value === void 0 ? void 0 : value.code) === null || _a === void 0 ? void 0 : _a.includes('"')) || ((_b = value === null || value === void 0 ? void 0 : value.code) === null || _b === void 0 ? void 0 : _b.includes("'"))) {
102
+ valueType = 'string';
103
+ }
104
+ else if ((_c = value === null || value === void 0 ? void 0 : value.code) === null || _c === void 0 ? void 0 : _c.match(/^[0-9]+(\.[0-9]+)?$/)) {
105
+ valueType = 'number';
106
+ }
107
+ else if ((value === null || value === void 0 ? void 0 : value.code) === 'true' || (value === null || value === void 0 ? void 0 : value.code) === 'false') {
108
+ valueType = 'boolean';
109
+ }
110
+ else if (((_d = value === null || value === void 0 ? void 0 : value.code) === null || _d === void 0 ? void 0 : _d.startsWith('[')) || ((_e = value === null || value === void 0 ? void 0 : value.code) === null || _e === void 0 ? void 0 : _e.startsWith('Array'))) {
111
+ valueType = 'Array<Any>';
112
+ }
113
+ }
114
+ const typeAnnotation = (0, helpers_1.getStatePropertyTypeAnnotation)(propertyType, valueType);
115
+ const swiftType = (0, helpers_1.getSwiftType)(valueType);
116
+ let stateDeclaration = `${typeAnnotation} ${key}: ${swiftType}`;
117
+ // Add default value if present
118
+ if (value === null || value === void 0 ? void 0 : value.code) {
119
+ stateDeclaration += ` = ${value.code}`;
120
+ }
121
+ else {
122
+ // Add default initialization based on type
123
+ switch (swiftType) {
124
+ case 'String':
125
+ stateDeclaration += ' = ""';
126
+ break;
127
+ case 'Bool':
128
+ stateDeclaration += ' = false';
129
+ break;
130
+ case 'Double':
131
+ case 'Int':
132
+ stateDeclaration += ' = 0';
133
+ break;
134
+ case 'Array<String>':
135
+ case '[String]':
136
+ stateDeclaration += ' = []';
137
+ break;
138
+ default:
139
+ if (swiftType.includes('Array') || swiftType.includes('[')) {
140
+ stateDeclaration += ' = []';
141
+ }
142
+ else if (swiftType !== 'Any' && swiftType !== 'Void') {
143
+ stateDeclaration += '/* initialize with appropriate default */';
144
+ }
145
+ }
146
+ }
147
+ return stateDeclaration;
148
+ })
149
+ .join('\n ');
150
+ // Generate state function variables with inline closure assignment
151
+ const functionStateProperties = [];
152
+ Object.entries(json.state)
153
+ .filter(([_, value]) => {
154
+ return ((value === null || value === void 0 ? void 0 : value.type) === 'method' ||
155
+ ((value === null || value === void 0 ? void 0 : value.code) && (value.code.includes('function') || value.code.includes('=>'))));
156
+ })
157
+ .forEach(([key, value]) => {
158
+ if (!(value === null || value === void 0 ? void 0 : value.code)) {
159
+ // Handle empty function with inline closure
160
+ functionStateProperties.push(`private var ${key}: () -> Void = { () in /* Empty function */ }`);
161
+ return;
162
+ }
163
+ // Convert the JS function to Swift
164
+ const processedCode = (0, helpers_1.stripStateAndProps)({ json, options })(value.code);
165
+ const { swiftCode, signature } = (0, helpers_1.convertJsFunctionToSwift)(processedCode, `_${key}`);
166
+ // Parse signature to get parameter list and return type
167
+ const signatureMatch = signature.match(/func _([^(]+)\(([^)]*)\) -> ([^{]+)/);
168
+ if (signatureMatch) {
169
+ const [, funcName, params, returnType] = signatureMatch;
170
+ // Create the function type for the state variable
171
+ const paramTypes = params
172
+ ? params
173
+ .split(',')
174
+ .map((p) => { var _a; return ((_a = p.trim().split(':')[1]) === null || _a === void 0 ? void 0 : _a.trim()) || 'Any'; })
175
+ .join(', ')
176
+ : '';
177
+ const functionType = params
178
+ ? `(${paramTypes}) -> ${returnType.trim()}`
179
+ : `() -> ${returnType.trim()}`;
180
+ // Extract function body from swiftCode
181
+ const bodyMatch = swiftCode.match(/{\s*([\s\S]*?)\s*}/);
182
+ const functionBody = bodyMatch ? bodyMatch[1].trim() : '/* Empty function body */';
183
+ // Build closure syntax for inline assignment
184
+ const closureSyntax = params
185
+ ? `{ (${params}) -> ${returnType.trim()} in\n ${functionBody}\n }`
186
+ : `{ () -> ${returnType.trim()} in\n ${functionBody}\n }`;
187
+ // Add the state variable declaration with inline closure assignment
188
+ functionStateProperties.push(`var ${key}: ${functionType} = ${closureSyntax}`);
189
+ }
190
+ else {
191
+ // Fallback if signature parsing fails
192
+ functionStateProperties.push(`var ${key}: () -> Void = { () in /* Could not parse function */ }`);
193
+ }
194
+ });
195
+ // Process lifecycle methods
196
+ const lifecycleMethods = [];
197
+ // Only add onInit if needed and if there are no function state properties
198
+ // (to avoid duplicate initializers)
199
+ if ((_b = json.hooks.onInit) === null || _b === void 0 ? void 0 : _b.code) {
200
+ lifecycleMethods.push((0, dedent_1.dedent) `
201
+ init() {
202
+ ${json.hooks.onInit.code}
203
+ }
204
+ `);
205
+ }
206
+ // Generate SwiftUI component
207
+ let str = (0, dedent_1.dedent) `
208
+ import SwiftUI
209
+
210
+ struct ${componentName}: View {
211
+ ${props
212
+ .map((prop) => {
213
+ var _a, _b, _c, _d;
214
+ const propType = ((_b = (_a = json.props) === null || _a === void 0 ? void 0 : _a[prop]) === null || _b === void 0 ? void 0 : _b.propertyType) || 'Any';
215
+ const swiftType = (0, helpers_1.getSwiftType)(propType);
216
+ return `let ${prop}: ${swiftType}${((_d = (_c = json.props) === null || _c === void 0 ? void 0 : _c[prop]) === null || _d === void 0 ? void 0 : _d.optional) ? '?' : ''}`;
217
+ })
218
+ .join('\n ')}
219
+
220
+ ${stateProperties}
221
+ ${functionStateProperties.length > 0
222
+ ? '\n // Function state variables\n ' + functionStateProperties.join('\n ')
223
+ : ''}
224
+
225
+ var body: some View {
226
+ ${json.children
227
+ .map((item) => (0, blocks_1.blockToSwift)({
228
+ json: item,
229
+ options: options,
230
+ parentComponent: json,
231
+ }))
232
+ .join('\n')}
233
+ ${lifecycleMethods.filter((method) => method.startsWith('.')).join('\n ')}
234
+ }
235
+
236
+ ${lifecycleMethods.filter((method) => !method.startsWith('.')).join('\n ')}
237
+ }
238
+ `;
239
+ // Add preview if enabled
240
+ if (options.includePreview) {
241
+ str += (0, dedent_1.dedent) `
242
+ \n
243
+ #if DEBUG
244
+ struct ${componentName}_Previews: PreviewProvider {
245
+ static var previews: some View {
246
+ ${componentName}(
247
+ ${props
248
+ .map((prop) => {
249
+ var _a, _b, _c, _d;
250
+ const propType = ((_b = (_a = json.props) === null || _a === void 0 ? void 0 : _a[prop]) === null || _b === void 0 ? void 0 : _b.propertyType) || 'Any';
251
+ const swiftType = (0, helpers_1.getSwiftType)(propType);
252
+ // Generate appropriate preview values based on type
253
+ let previewValue = '';
254
+ switch (swiftType) {
255
+ case 'String':
256
+ previewValue = '"Preview"';
257
+ break;
258
+ case 'Bool':
259
+ previewValue = 'false';
260
+ break;
261
+ case 'Double':
262
+ case 'Int':
263
+ previewValue = '0';
264
+ break;
265
+ default:
266
+ if ((_d = (_c = json.props) === null || _c === void 0 ? void 0 : _c[prop]) === null || _d === void 0 ? void 0 : _d.optional) {
267
+ previewValue = 'nil';
268
+ }
269
+ else {
270
+ previewValue = '/* provide preview value */';
271
+ }
272
+ }
273
+ return `${prop}: ${previewValue}`;
274
+ })
275
+ .join(',\n ')}
276
+ )
277
+ }
278
+ }
279
+ #endif
280
+ `;
281
+ }
282
+ str = (0, plugins_1.runPreCodePlugins)({ json, code: str, plugins: options.plugins });
283
+ str = (0, generic_format_1.format)(str);
284
+ str = (0, plugins_1.runPostCodePlugins)({ json, code: str, plugins: options.plugins });
285
+ return str;
286
+ };
287
+ exports.componentToSwift = componentToSwift;
@@ -0,0 +1,42 @@
1
+ import { MitosisComponent } from '../../types/mitosis-component';
2
+ import { MitosisNode } from '../../types/mitosis-node';
3
+ import { ToSwiftOptions } from './types';
4
+ export declare const convertConsoleLogToPrint: (code: string) => string;
5
+ export declare const ensureSwiftStringFormat: (code: string) => string;
6
+ export declare const stripStateAndProps: ({ json, options, }: {
7
+ json: MitosisComponent;
8
+ options: ToSwiftOptions;
9
+ }) => (code: string) => string;
10
+ export declare const getSwiftType: (type: string | undefined) => string;
11
+ export declare const jsxElementToSwiftUIView: (tagName: string) => string;
12
+ export declare const cssToSwiftUIModifiers: (style: Record<string, string>) => string[];
13
+ export declare const getStatePropertyTypeAnnotation: (propertyType: string | undefined, type: string | undefined) => string;
14
+ export declare const getEventHandlerName: (eventName: string) => string;
15
+ export declare const needsScrollView: (json: MitosisNode) => boolean;
16
+ export declare const isForEachBlock: (json: MitosisNode) => boolean;
17
+ export declare const getForEachParams: (json: MitosisNode, processCode: (code: string) => string) => {
18
+ collection: string;
19
+ itemName: string;
20
+ indexName: string | null;
21
+ };
22
+ export declare const camelToSnakeCase: (str: string) => string;
23
+ export declare const getBindingType: (key: string) => string;
24
+ /**
25
+ * Extract function signature information from JavaScript function code
26
+ */
27
+ export declare const extractFunctionSignature: (code: string) => {
28
+ name: string;
29
+ params: {
30
+ name: string;
31
+ type: string;
32
+ }[];
33
+ returnType: string;
34
+ body: string;
35
+ };
36
+ /**
37
+ * Convert JavaScript function code to Swift function syntax
38
+ */
39
+ export declare const convertJsFunctionToSwift: (code: string, functionName?: string) => {
40
+ swiftCode: string;
41
+ signature: string;
42
+ };