@builder.io/mitosis 0.0.56-1 → 0.0.56-101

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 (394) hide show
  1. package/dist/src/__tests__/angular.test.js +5 -13
  2. package/dist/src/__tests__/builder.test.js +3 -3
  3. package/dist/src/__tests__/data/advanced-ref.raw.d.ts +4 -0
  4. package/dist/src/__tests__/data/advanced-ref.raw.jsx +39 -0
  5. package/dist/src/__tests__/data/basic-child-component.raw.d.ts +1 -0
  6. package/dist/src/__tests__/data/basic-child-component.raw.jsx +21 -0
  7. package/dist/src/__tests__/data/basic-context.raw.d.ts +1 -0
  8. package/dist/src/__tests__/data/basic-context.raw.jsx +29 -0
  9. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.d.ts +1 -0
  10. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.jsx +10 -0
  11. package/dist/src/__tests__/data/basic-for-show.raw.d.ts +1 -0
  12. package/dist/src/__tests__/data/basic-for-show.raw.jsx +20 -0
  13. package/dist/src/__tests__/data/basic-for.raw.d.ts +1 -0
  14. package/dist/src/__tests__/data/basic-for.raw.jsx +23 -0
  15. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.d.ts +5 -0
  16. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.jsx +17 -0
  17. package/dist/src/__tests__/data/basic-forwardRef.raw.d.ts +5 -0
  18. package/dist/src/__tests__/data/basic-forwardRef.raw.jsx +14 -0
  19. package/dist/src/__tests__/data/basic-onChange.raw.d.ts +1 -0
  20. package/dist/src/__tests__/data/basic-onChange.raw.jsx +17 -0
  21. package/dist/src/__tests__/data/basic-onMount-update.raw.d.ts +5 -0
  22. package/dist/src/__tests__/data/basic-onMount-update.raw.jsx +17 -0
  23. package/dist/src/__tests__/data/basic-onUpdate-return.raw.d.ts +1 -0
  24. package/dist/src/__tests__/data/basic-onUpdate-return.raw.jsx +24 -0
  25. package/dist/src/__tests__/data/basic-outputs-meta.raw.d.ts +1 -0
  26. package/dist/src/__tests__/data/basic-outputs-meta.raw.jsx +17 -0
  27. package/dist/src/__tests__/data/basic-outputs.raw.d.ts +1 -0
  28. package/dist/src/__tests__/data/basic-outputs.raw.jsx +14 -0
  29. package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.d.ts +6 -0
  30. package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.jsx +14 -0
  31. package/dist/src/__tests__/data/basic-props-destructure.raw.d.ts +6 -0
  32. package/dist/src/__tests__/data/basic-props-destructure.raw.jsx +14 -0
  33. package/dist/src/__tests__/data/basic-props.raw.d.ts +6 -0
  34. package/dist/src/__tests__/data/basic-props.raw.jsx +13 -0
  35. package/dist/src/__tests__/data/basic-ref-assignment.raw.d.ts +4 -0
  36. package/dist/src/__tests__/data/basic-ref-assignment.raw.jsx +15 -0
  37. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.d.ts +5 -0
  38. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.jsx +35 -0
  39. package/dist/src/__tests__/data/basic-ref.raw.d.ts +4 -0
  40. package/dist/src/__tests__/data/basic-ref.raw.jsx +36 -0
  41. package/dist/src/__tests__/data/basic.raw.d.ts +6 -1
  42. package/dist/src/__tests__/data/basic.raw.jsx +13 -4
  43. package/dist/src/__tests__/data/blocks/button-with-metadata.raw.d.ts +1 -1
  44. package/dist/src/__tests__/data/blocks/button.raw.d.ts +1 -1
  45. package/dist/src/__tests__/data/blocks/classname-jsx.raw.d.ts +7 -0
  46. package/dist/src/__tests__/data/blocks/classname-jsx.raw.jsx +15 -0
  47. package/dist/src/__tests__/data/blocks/columns.raw.d.ts +1 -1
  48. package/dist/src/__tests__/data/blocks/columns.raw.jsx +1 -1
  49. package/dist/src/__tests__/data/blocks/content-slot-html.raw.d.ts +7 -0
  50. package/dist/src/__tests__/data/blocks/content-slot-html.raw.jsx +15 -0
  51. package/dist/src/__tests__/data/blocks/content-slot-jsx.raw.d.ts +6 -0
  52. package/dist/src/__tests__/data/blocks/content-slot-jsx.raw.jsx +12 -0
  53. package/dist/src/__tests__/data/blocks/custom-code.raw.d.ts +1 -1
  54. package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -7
  55. package/dist/src/__tests__/data/blocks/embed.raw.d.ts +1 -1
  56. package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -7
  57. package/dist/src/__tests__/data/blocks/form.raw.d.ts +1 -1
  58. package/dist/src/__tests__/data/blocks/form.raw.jsx +8 -8
  59. package/dist/src/__tests__/data/blocks/image.raw.d.ts +2 -2
  60. package/dist/src/__tests__/data/blocks/image.raw.jsx +9 -10
  61. package/dist/src/__tests__/data/blocks/img-state.raw.d.ts +1 -0
  62. package/dist/src/__tests__/data/blocks/img-state.raw.jsx +17 -0
  63. package/dist/src/__tests__/data/blocks/img.raw.d.ts +1 -1
  64. package/dist/src/__tests__/data/blocks/input.raw.d.ts +1 -1
  65. package/dist/src/__tests__/data/blocks/input.raw.jsx +1 -3
  66. package/dist/src/__tests__/data/blocks/multiple-onUpdate.raw.d.ts +1 -1
  67. package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.d.ts +1 -1
  68. package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.jsx +7 -1
  69. package/dist/src/__tests__/data/blocks/onInit-onMount.raw.d.ts +1 -0
  70. package/dist/src/__tests__/data/blocks/onInit-onMount.raw.jsx +13 -0
  71. package/dist/src/__tests__/data/blocks/onInit.raw.d.ts +8 -0
  72. package/dist/src/__tests__/data/blocks/onInit.raw.jsx +20 -0
  73. package/dist/src/__tests__/data/blocks/onMount.raw.d.ts +1 -1
  74. package/dist/src/__tests__/data/blocks/onUpdate.raw.d.ts +1 -1
  75. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +1 -1
  76. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +1 -1
  77. package/dist/src/__tests__/data/blocks/raw-text.raw.d.ts +1 -1
  78. package/dist/src/__tests__/data/blocks/rootShow.raw.d.ts +1 -1
  79. package/dist/src/__tests__/data/blocks/section-state.raw.d.ts +6 -0
  80. package/dist/src/__tests__/data/blocks/section-state.raw.jsx +17 -0
  81. package/dist/src/__tests__/data/blocks/section.raw.d.ts +1 -1
  82. package/dist/src/__tests__/data/blocks/select.raw.d.ts +1 -1
  83. package/dist/src/__tests__/data/blocks/select.raw.jsx +1 -3
  84. package/dist/src/__tests__/data/blocks/self-referencing-component-with-children.raw.d.ts +1 -1
  85. package/dist/src/__tests__/data/blocks/self-referencing-component.raw.d.ts +1 -1
  86. package/dist/src/__tests__/data/blocks/shadow-dom.raw.d.ts +1 -1
  87. package/dist/src/__tests__/data/blocks/shadow-dom.raw.jsx +2 -4
  88. package/dist/src/__tests__/data/blocks/slot-html.raw.d.ts +5 -0
  89. package/dist/src/__tests__/data/blocks/slot-html.raw.jsx +15 -0
  90. package/dist/src/__tests__/data/blocks/slot-jsx.raw.d.ts +5 -0
  91. package/dist/src/__tests__/data/blocks/slot-jsx.raw.jsx +12 -0
  92. package/dist/src/__tests__/data/blocks/stamped-io.raw.d.ts +1 -1
  93. package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -5
  94. package/dist/src/__tests__/data/blocks/submit-button.raw.d.ts +1 -1
  95. package/dist/src/__tests__/data/blocks/text.raw.d.ts +1 -1
  96. package/dist/src/__tests__/data/blocks/text.raw.jsx +3 -1
  97. package/dist/src/__tests__/data/blocks/textarea.raw.d.ts +1 -1
  98. package/dist/src/__tests__/data/blocks/video.raw.d.ts +1 -1
  99. package/dist/src/__tests__/data/blocks/video.raw.jsx +1 -1
  100. package/dist/src/__tests__/data/context/component-with-context.lite.d.ts +3 -1
  101. package/dist/src/__tests__/data/context/component-with-context.lite.jsx +7 -2
  102. package/dist/src/__tests__/data/default-props/default-props.raw.d.ts +7 -0
  103. package/dist/src/__tests__/data/default-props/default-props.raw.jsx +23 -0
  104. package/dist/src/__tests__/data/jsx-json.spec.d.ts +2 -0
  105. package/dist/src/__tests__/data/jsx-json.spec.js +10226 -0
  106. package/dist/src/__tests__/data/nested-styles.lite.d.ts +1 -0
  107. package/dist/src/__tests__/data/nested-styles.lite.jsx +20 -0
  108. package/dist/src/__tests__/data/show/nested-show.raw.d.ts +6 -0
  109. package/dist/src/__tests__/data/show/nested-show.raw.jsx +11 -0
  110. package/dist/src/__tests__/data/show/show-with-for.raw.d.ts +6 -0
  111. package/dist/src/__tests__/data/show/show-with-for.raw.jsx +9 -0
  112. package/dist/src/__tests__/data/styles/class-and-className.raw.d.ts +1 -0
  113. package/dist/src/__tests__/data/styles/class-and-className.raw.jsx +10 -0
  114. package/dist/src/__tests__/data/styles/class.raw.d.ts +1 -0
  115. package/dist/src/__tests__/data/styles/class.raw.jsx +10 -0
  116. package/dist/src/__tests__/data/styles/className.raw.d.ts +1 -0
  117. package/dist/src/__tests__/data/styles/className.raw.jsx +10 -0
  118. package/dist/src/__tests__/data/styles/classState.raw.d.ts +1 -0
  119. package/dist/src/__tests__/data/styles/classState.raw.jsx +13 -0
  120. package/dist/src/__tests__/data/types/component-props-interface.raw.d.ts +6 -0
  121. package/dist/src/__tests__/data/types/component-props-interface.raw.jsx +6 -0
  122. package/dist/src/__tests__/data/types/component-props-type.raw.d.ts +6 -0
  123. package/dist/src/__tests__/data/types/component-props-type.raw.jsx +6 -0
  124. package/dist/src/__tests__/data/types/component-with-default-values-types.raw.d.ts +5 -0
  125. package/dist/src/__tests__/data/types/component-with-default-values-types.raw.jsx +9 -0
  126. package/dist/src/__tests__/data/types/foo-type.d.ts +1 -0
  127. package/dist/src/{jsx-types.js → __tests__/data/types/foo-type.js} +0 -0
  128. package/dist/src/__tests__/data/types/preserve-typing.raw.d.ts +8 -0
  129. package/dist/src/__tests__/data/types/preserve-typing.raw.jsx +6 -0
  130. package/dist/src/__tests__/data/types/type-dependency.raw.d.ts +7 -0
  131. package/dist/src/__tests__/data/types/type-dependency.raw.jsx +6 -0
  132. package/dist/src/__tests__/data/types/type-export.lite.d.ts +3 -0
  133. package/dist/src/__tests__/data/types/type-export.lite.jsx +6 -0
  134. package/dist/src/__tests__/hash-code.test.d.ts +1 -0
  135. package/dist/src/__tests__/hash-code.test.js +11 -0
  136. package/dist/src/__tests__/html.test.js +2 -13
  137. package/dist/src/__tests__/liquid.test.js +2 -103
  138. package/dist/src/__tests__/lit.test.d.ts +1 -0
  139. package/dist/src/__tests__/lit.test.js +7 -0
  140. package/dist/src/__tests__/marko.test.d.ts +1 -0
  141. package/dist/src/__tests__/marko.test.js +14 -0
  142. package/dist/src/__tests__/parse-jsx.test.js +28 -0
  143. package/dist/src/__tests__/qwik/convert-method-to-function.test.d.ts +1 -0
  144. package/dist/src/__tests__/qwik/convert-method-to-function.test.js +37 -0
  145. package/dist/src/__tests__/qwik/src-generator.test.d.ts +1 -0
  146. package/dist/src/__tests__/qwik/src-generator.test.js +65 -0
  147. package/dist/src/__tests__/qwik.directive.test.js +1 -0
  148. package/dist/src/__tests__/qwik.test.js +54 -23
  149. package/dist/src/__tests__/react-native.test.js +3 -136
  150. package/dist/src/__tests__/react.test.js +9 -136
  151. package/dist/src/__tests__/shared.d.ts +3 -0
  152. package/dist/src/__tests__/shared.js +308 -0
  153. package/dist/src/__tests__/solid.test.js +5 -97
  154. package/dist/src/__tests__/stencil.test.js +3 -98
  155. package/dist/src/__tests__/styles.test.d.ts +1 -0
  156. package/dist/src/__tests__/styles.test.js +23 -0
  157. package/dist/src/__tests__/svelte.test.js +2 -31
  158. package/dist/src/__tests__/vue.test.js +2 -134
  159. package/dist/src/__tests__/webcomponent.test.js +8 -5
  160. package/dist/src/constants/hooks.d.ts +7 -0
  161. package/dist/src/constants/hooks.js +10 -0
  162. package/dist/src/flow.d.ts +6 -0
  163. package/dist/src/flow.js +6 -2
  164. package/dist/src/generators/angular.d.ts +10 -2
  165. package/dist/src/generators/angular.js +245 -47
  166. package/dist/src/generators/builder.d.ts +2 -2
  167. package/dist/src/generators/builder.js +26 -29
  168. package/dist/src/generators/context/{react copy.d.ts → qwik.d.ts} +2 -2
  169. package/dist/src/generators/context/{react copy.js → qwik.js} +4 -5
  170. package/dist/src/generators/context/react.js +1 -1
  171. package/dist/src/generators/context/solid.js +1 -1
  172. package/dist/src/generators/context/svelte.d.ts +1 -1
  173. package/dist/src/generators/context/svelte.js +1 -1
  174. package/dist/src/generators/helpers/context.js +1 -2
  175. package/dist/src/generators/html.d.ts +1 -1
  176. package/dist/src/generators/html.js +365 -108
  177. package/dist/src/generators/liquid.d.ts +1 -1
  178. package/dist/src/generators/liquid.js +18 -25
  179. package/dist/src/generators/lit/collect-class-string.d.ts +2 -0
  180. package/dist/src/generators/lit/collect-class-string.js +43 -0
  181. package/dist/src/generators/lit/generate.d.ts +5 -0
  182. package/dist/src/generators/lit/generate.js +223 -0
  183. package/dist/src/generators/lit/index.d.ts +1 -0
  184. package/dist/src/generators/lit/index.js +17 -0
  185. package/dist/src/generators/marko/generate.d.ts +21 -0
  186. package/dist/src/generators/marko/generate.js +289 -0
  187. package/dist/src/generators/marko/index.d.ts +1 -0
  188. package/dist/src/generators/marko/index.js +17 -0
  189. package/dist/src/generators/mitosis.d.ts +1 -1
  190. package/dist/src/generators/mitosis.js +39 -34
  191. package/dist/src/generators/qwik/add-prevent-default.d.ts +7 -0
  192. package/dist/src/generators/qwik/add-prevent-default.js +32 -0
  193. package/dist/src/generators/qwik/component-generator.d.ts +4 -0
  194. package/dist/src/generators/qwik/component-generator.js +311 -0
  195. package/dist/src/generators/qwik/component.d.ts +1 -0
  196. package/dist/src/generators/qwik/component.js +68 -36
  197. package/dist/src/generators/qwik/convert-method-to-function.d.ts +1 -0
  198. package/dist/src/generators/qwik/convert-method-to-function.js +162 -0
  199. package/dist/src/generators/qwik/directives.js +43 -23
  200. package/dist/src/generators/qwik/handlers.js +6 -22
  201. package/dist/src/generators/qwik/index.d.ts +3 -1
  202. package/dist/src/generators/qwik/index.js +3 -1
  203. package/dist/src/generators/qwik/jsx.d.ts +12 -0
  204. package/dist/src/generators/qwik/jsx.js +81 -24
  205. package/dist/src/generators/qwik/src-generator.d.ts +21 -8
  206. package/dist/src/generators/qwik/src-generator.js +177 -43
  207. package/dist/src/generators/qwik/styles.js +3 -3
  208. package/dist/src/generators/react/generator.d.ts +6 -0
  209. package/dist/src/generators/react/generator.js +447 -0
  210. package/dist/src/generators/react/helpers.d.ts +2 -0
  211. package/dist/src/generators/react/helpers.js +14 -0
  212. package/dist/src/generators/react/index.d.ts +2 -0
  213. package/dist/src/generators/react/index.js +18 -0
  214. package/dist/src/generators/react/state.d.ts +9 -0
  215. package/dist/src/generators/react/state.js +109 -0
  216. package/dist/src/generators/react/types.d.ts +10 -0
  217. package/dist/src/generators/react/types.js +2 -0
  218. package/dist/src/generators/react-native.d.ts +2 -2
  219. package/dist/src/generators/react-native.js +8 -10
  220. package/dist/src/generators/react.d.ts +7 -3
  221. package/dist/src/generators/react.js +190 -92
  222. package/dist/src/generators/solid/index.d.ts +3 -0
  223. package/dist/src/generators/solid/index.js +345 -0
  224. package/dist/src/generators/solid/state.d.ts +19 -0
  225. package/dist/src/generators/solid/state.js +144 -0
  226. package/dist/src/generators/solid/types.d.ts +6 -0
  227. package/dist/src/generators/solid/types.js +2 -0
  228. package/dist/src/generators/solid.d.ts +3 -2
  229. package/dist/src/generators/solid.js +86 -50
  230. package/dist/src/generators/stencil/collect-class-string.d.ts +1 -1
  231. package/dist/src/generators/stencil/collect-class-string.js +10 -11
  232. package/dist/src/generators/stencil/generate.d.ts +1 -1
  233. package/dist/src/generators/stencil/generate.js +16 -31
  234. package/dist/src/generators/svelte.d.ts +2 -2
  235. package/dist/src/generators/svelte.js +160 -88
  236. package/dist/src/generators/swift-ui.d.ts +1 -1
  237. package/dist/src/generators/swift-ui.js +19 -20
  238. package/dist/src/generators/template.d.ts +1 -1
  239. package/dist/src/generators/template.js +11 -18
  240. package/dist/src/generators/vue.d.ts +17 -9
  241. package/dist/src/generators/vue.js +227 -106
  242. package/dist/src/helpers/babel-transform.js +8 -14
  243. package/dist/src/helpers/create-mitosis-component.d.ts +1 -1
  244. package/dist/src/helpers/create-mitosis-component.js +1 -1
  245. package/dist/src/helpers/create-mitosis-node.js +1 -1
  246. package/dist/src/helpers/fast-clone.js +1 -3
  247. package/dist/src/helpers/filter-empty-text-nodes.js +1 -2
  248. package/dist/src/helpers/get-bindings.d.ts +2 -0
  249. package/dist/src/helpers/get-bindings.js +18 -0
  250. package/dist/src/helpers/get-custom-imports.d.ts +15 -0
  251. package/dist/src/helpers/get-custom-imports.js +40 -0
  252. package/dist/src/helpers/get-prop-functions.d.ts +5 -0
  253. package/dist/src/helpers/get-prop-functions.js +29 -0
  254. package/dist/src/helpers/get-props-ref.d.ts +2 -0
  255. package/dist/src/helpers/get-props-ref.js +32 -0
  256. package/dist/src/helpers/get-refs.js +3 -2
  257. package/dist/src/helpers/get-state-object-string.d.ts +6 -4
  258. package/dist/src/helpers/get-state-object-string.js +37 -27
  259. package/dist/src/helpers/get-styles.js +4 -3
  260. package/dist/src/helpers/getters-to-functions.d.ts +1 -1
  261. package/dist/src/helpers/getters-to-functions.js +3 -2
  262. package/dist/src/helpers/handle-missing-state.js +1 -1
  263. package/dist/src/helpers/has-bindings-text.d.ts +2 -0
  264. package/dist/src/helpers/has-bindings-text.js +21 -0
  265. package/dist/src/helpers/has-stateful-dom.d.ts +2 -0
  266. package/dist/src/helpers/has-stateful-dom.js +21 -0
  267. package/dist/src/helpers/has.d.ts +9 -0
  268. package/dist/src/helpers/has.js +27 -0
  269. package/dist/src/helpers/is-children.js +3 -1
  270. package/dist/src/helpers/is-component.js +1 -3
  271. package/dist/src/helpers/is-html-attribute.d.ts +4 -0
  272. package/dist/src/helpers/is-html-attribute.js +380 -0
  273. package/dist/src/helpers/json.d.ts +3 -1
  274. package/dist/src/helpers/map-refs.js +39 -14
  275. package/dist/src/helpers/nullable.d.ts +3 -0
  276. package/dist/src/helpers/nullable.js +7 -0
  277. package/dist/src/helpers/parsers.js +1 -2
  278. package/dist/src/helpers/process-http-requests.js +1 -1
  279. package/dist/src/helpers/render-imports.d.ts +20 -2
  280. package/dist/src/helpers/render-imports.js +115 -54
  281. package/dist/src/helpers/render-imports.test.d.ts +1 -0
  282. package/dist/src/helpers/render-imports.test.js +33 -0
  283. package/dist/src/helpers/replace-idenifiers.js +5 -7
  284. package/dist/src/helpers/slots.d.ts +2 -0
  285. package/dist/src/helpers/slots.js +8 -0
  286. package/dist/src/helpers/state.d.ts +11 -0
  287. package/dist/src/helpers/state.js +43 -0
  288. package/dist/src/helpers/strip-state-and-props-refs.d.ts +6 -1
  289. package/dist/src/helpers/strip-state-and-props-refs.js +70 -15
  290. package/dist/src/helpers/styles/collect-css.d.ts +6 -0
  291. package/dist/src/helpers/styles/collect-css.js +87 -0
  292. package/dist/src/helpers/styles/collect-css.test.d.ts +1 -0
  293. package/dist/src/helpers/styles/collect-css.test.js +18 -0
  294. package/dist/src/helpers/styles/collect-styled-components.d.ts +2 -0
  295. package/dist/src/helpers/styles/collect-styled-components.js +61 -0
  296. package/dist/src/helpers/styles/helpers.d.ts +31 -0
  297. package/dist/src/helpers/styles/helpers.js +80 -0
  298. package/dist/src/helpers/typescript.d.ts +5 -0
  299. package/dist/src/helpers/typescript.js +2 -0
  300. package/dist/src/index.d.ts +12 -4
  301. package/dist/src/index.js +28 -8
  302. package/dist/src/modules/plugins.d.ts +1 -1
  303. package/dist/src/parsers/angular.js +22 -34
  304. package/dist/src/parsers/builder.d.ts +32 -29
  305. package/dist/src/parsers/builder.js +99 -85
  306. package/dist/src/parsers/jsx/ast.d.ts +3 -0
  307. package/dist/src/parsers/jsx/ast.js +74 -0
  308. package/dist/src/parsers/jsx/component-types.d.ts +6 -0
  309. package/dist/src/parsers/jsx/component-types.js +88 -0
  310. package/dist/src/parsers/jsx/context.d.ts +6 -0
  311. package/dist/src/parsers/jsx/context.js +68 -0
  312. package/dist/src/parsers/jsx/helpers.d.ts +3 -0
  313. package/dist/src/parsers/jsx/helpers.js +36 -0
  314. package/dist/src/parsers/jsx/index.d.ts +4 -0
  315. package/dist/src/parsers/jsx/index.js +25 -0
  316. package/dist/src/parsers/jsx/jsx.d.ts +10 -0
  317. package/dist/src/parsers/{jsx.js → jsx/jsx.js} +258 -330
  318. package/dist/src/parsers/jsx/metadata.d.ts +12 -0
  319. package/dist/src/parsers/jsx/metadata.js +70 -0
  320. package/dist/src/parsers/jsx/props.d.ts +2 -0
  321. package/dist/src/parsers/jsx/props.js +72 -0
  322. package/dist/src/parsers/jsx/state.d.ts +13 -0
  323. package/dist/src/parsers/jsx/state.js +161 -0
  324. package/dist/src/parsers/jsx/types.d.ts +11 -0
  325. package/dist/src/parsers/jsx/types.js +2 -0
  326. package/dist/src/parsers/liquid.js +51 -149
  327. package/dist/src/plugins/compile-away-builder-components.js +161 -116
  328. package/dist/src/symbols/symbol-processor.d.ts +2 -0
  329. package/dist/src/symbols/symbol-processor.js +58 -20
  330. package/dist/src/targets.d.ts +11 -6
  331. package/dist/src/targets.js +13 -1
  332. package/dist/src/types/config.d.ts +42 -13
  333. package/dist/src/types/json.d.ts +5 -2
  334. package/dist/src/types/mitosis-component.d.ts +40 -12
  335. package/dist/src/types/mitosis-node.d.ts +15 -9
  336. package/dist/src/types/transpiler.d.ts +14 -0
  337. package/dist/src/types/transpiler.js +2 -0
  338. package/dist/test/qwik/Accordion/low.jsx +45 -12
  339. package/dist/test/qwik/Accordion/med.jsx +2 -8
  340. package/dist/test/qwik/For/low.jsx +46 -27
  341. package/dist/test/qwik/For/med.jsx +2 -8
  342. package/dist/test/qwik/Image/high.js +1 -1
  343. package/dist/test/qwik/Image/med.js +24 -18
  344. package/dist/test/qwik/Image.slow/high.js +1 -1
  345. package/dist/test/qwik/Image.slow/med.js +24 -18
  346. package/dist/test/qwik/bindings/low.cjs +16 -4
  347. package/dist/test/qwik/bindings/med.cjs +1 -10
  348. package/dist/test/qwik/button/high.js +1 -1
  349. package/dist/test/qwik/button/low.js +18 -4
  350. package/dist/test/qwik/button/med.js +4 -10
  351. package/dist/test/qwik/component/bindings/low.jsx +72 -11
  352. package/dist/test/qwik/component/bindings/med.jsx +3 -49
  353. package/dist/test/qwik/component/component/inputs/high.cjsx +1 -1
  354. package/dist/test/qwik/component/component/inputs/med.cjsx +18 -15
  355. package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
  356. package/dist/test/qwik/for-loop.bindings/low.cjs +56 -0
  357. package/dist/test/qwik/for-loop.bindings/med.cjs +5 -0
  358. package/dist/test/qwik/hello_world/stylesheet/low.jsx +17 -3
  359. package/dist/test/qwik/hello_world/stylesheet/med.jsx +2 -8
  360. package/dist/test/qwik/mount/high.cjs +0 -0
  361. package/dist/test/qwik/mount/low.cjs +47 -0
  362. package/dist/test/qwik/mount/med.cjs +3 -0
  363. package/dist/test/qwik/page-with-symbol/low.js +17 -3
  364. package/dist/test/qwik/page-with-symbol/med.js +2 -8
  365. package/dist/test/qwik/show-hide/high.jsx +1 -1
  366. package/dist/test/qwik/show-hide/med.jsx +28 -21
  367. package/dist/test/qwik/svg/low.js +22 -5
  368. package/dist/test/qwik/svg/med.js +2 -8
  369. package/dist/test/qwik/todo/Todo.cjs/high.cjs +6 -10
  370. package/dist/test/qwik/todo/Todo.cjs/med.cjs +18 -15
  371. package/dist/test/qwik/todo/Todo.js/high.js +7 -10
  372. package/dist/test/qwik/todo/Todo.js/med.js +17 -15
  373. package/dist/test/qwik/todo/Todo.tsx/high.tsx +7 -10
  374. package/dist/test/qwik/todo/Todo.tsx/med.tsx +17 -15
  375. package/dist/test/qwik/todos/Todo.tsx/high.tsx +1 -1
  376. package/dist/test/qwik/todos/Todo.tsx/low.tsx +18 -13
  377. package/dist/test/qwik/todos/Todo.tsx/med.tsx +1 -6
  378. package/dist/tsconfig.build.tsbuildinfo +1 -1
  379. package/dist/tsconfig.tsbuildinfo +1 -1
  380. package/jsx-runtime.d.ts +2133 -0
  381. package/package.json +20 -8
  382. package/README.md +0 -239
  383. package/dist/src/__tests__/data/blocks/onUpdate.raw copy.d.ts +0 -1
  384. package/dist/src/__tests__/data/blocks/onUpdate.raw copy.jsx +0 -10
  385. package/dist/src/__tests__/data/blocks/slot.raw.d.ts +0 -5
  386. package/dist/src/__tests__/data/blocks/slot.raw.jsx +0 -6
  387. package/dist/src/__tests__/data/blocks/styles.raw.d.ts +0 -1
  388. package/dist/src/__tests__/data/blocks/styles.raw.jsx +0 -10
  389. package/dist/src/helpers/babel-transform copy.d.ts +0 -8
  390. package/dist/src/helpers/babel-transform copy.js +0 -138
  391. package/dist/src/helpers/collect-styles.d.ts +0 -35
  392. package/dist/src/helpers/collect-styles.js +0 -178
  393. package/dist/src/jsx-types.d.ts +0 -1171
  394. package/dist/src/parsers/jsx.d.ts +0 -20
@@ -44,10 +44,8 @@ var babelTransform = function (code, visitor) {
44
44
  configFile: false,
45
45
  babelrc: false,
46
46
  presets: [[tsPreset, { isTSX: true, allExtensions: true }]],
47
- plugins: __spreadArray([
48
- [decorators, { legacy: true }],
49
- jsxPlugin
50
- ], (visitor ? [function () { return ({ visitor: visitor }); }] : []), true),
47
+ parserOpts: { allowReturnOutsideFunction: true },
48
+ plugins: __spreadArray([[decorators, { legacy: true }], jsxPlugin], (visitor ? [function () { return ({ visitor: visitor }); }] : []), true),
51
49
  });
52
50
  };
53
51
  exports.babelTransform = babelTransform;
@@ -57,7 +55,6 @@ var babelTransformCode = function (code, visitor) {
57
55
  };
58
56
  exports.babelTransformCode = babelTransformCode;
59
57
  var babelTransformExpression = function (code, visitor, type) {
60
- var _a;
61
58
  if (type === void 0) { type = 'unknown'; }
62
59
  if (!code) {
63
60
  return '';
@@ -68,8 +65,7 @@ var babelTransformExpression = function (code, visitor, type) {
68
65
  }
69
66
  // For Builder content
70
67
  if (type === 'unknown' &&
71
- (code.includes('return _virtual_index') ||
72
- code.trim().startsWith('return ')) &&
68
+ (code.includes('return _virtual_index') || code.trim().startsWith('return ')) &&
73
69
  !code.trim().startsWith('function')) {
74
70
  type = 'functionBody';
75
71
  }
@@ -80,8 +76,7 @@ var babelTransformExpression = function (code, visitor, type) {
80
76
  var result = type === 'expression'
81
77
  ? null
82
78
  : (0, lodash_1.attempt)(function () {
83
- var _a;
84
- var result = ((_a = (0, exports.babelTransform)(useCode, visitor)) === null || _a === void 0 ? void 0 : _a.code) || '';
79
+ var result = (0, exports.babelTransformCode)(useCode, visitor);
85
80
  if (type === 'functionBody') {
86
81
  return result.replace(/^function\(\)\{/, '').replace(/\};$/, '');
87
82
  }
@@ -97,8 +92,7 @@ var babelTransformExpression = function (code, visitor, type) {
97
92
  // If it can't, e.g. this is an expression or code fragment, modify the code below and try again
98
93
  // Detect method fragments. These get passed sometimes and otherwise
99
94
  // generate compile errors. They are of the form `foo() { ... }`
100
- var isMethod = Boolean(!code.startsWith('function') &&
101
- code.match(/^[a-z0-9]+\s*\([^\)]*\)\s*[\{:]/i));
95
+ var isMethod = Boolean(!code.startsWith('function') && code.match(/^[a-z0-9_]+\s*\([^\)]*\)\s*[\{:]/i));
102
96
  if (isMethod) {
103
97
  useCode = "function ".concat(useCode);
104
98
  }
@@ -106,8 +100,8 @@ var babelTransformExpression = function (code, visitor, type) {
106
100
  // e.g. if the code parsed is { ... } babel will treat that as a block by deafult, unless processed as an expression
107
101
  // that is an object
108
102
  useCode = "let _ = ".concat(useCode);
109
- result = (((_a = (0, exports.babelTransform)(useCode, visitor)) === null || _a === void 0 ? void 0 : _a.code) || '')
110
- // Babel addes trailing semicolons, but for expressions we need those gone
103
+ result = (0, exports.babelTransformCode)(useCode, visitor)
104
+ // Babel adds trailing semicolons, but for expressions we need those gone
111
105
  .replace(/;$/, '')
112
106
  // Remove our fake variable assignment
113
107
  .replace(/let _ =\s/, '');
@@ -129,7 +123,7 @@ var babelTransformExpression = function (code, visitor, type) {
129
123
  return result.replace(/^function\s*\(\)\s*\{/, '').replace(/\};?$/, '');
130
124
  }
131
125
  else {
132
- // Babel addes trailing semicolons, but for expressions we need those gone
126
+ // Babel adds trailing semicolons, but for expressions we need those gone
133
127
  // TODO: maybe detect if the original code ended with one, and keep it if so, for the case
134
128
  // of appending several fragements
135
129
  return result.replace(/;$/, '');
@@ -1,2 +1,2 @@
1
1
  import { MitosisComponent } from '../types/mitosis-component';
2
- export declare const createMitosisComponent: (options?: Partial<MitosisComponent> | undefined) => MitosisComponent;
2
+ export declare const createMitosisComponent: (options?: Partial<MitosisComponent>) => MitosisComponent;
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createMitosisComponent = void 0;
15
- var createMitosisComponent = function (options) { return (__assign({ '@type': '@builder.io/mitosis/component', imports: [], inputs: [], meta: {}, state: {}, children: [], hooks: {}, context: { get: {}, set: {} }, name: (options === null || options === void 0 ? void 0 : options.name) || 'MyComponent', subComponents: [] }, options)); };
15
+ var createMitosisComponent = function (options) { return (__assign({ '@type': '@builder.io/mitosis/component', imports: [], exports: {}, inputs: [], meta: {}, refs: {}, state: {}, children: [], hooks: {}, context: { get: {}, set: {} }, name: (options === null || options === void 0 ? void 0 : options.name) || 'MyComponent', subComponents: [] }, options)); };
16
16
  exports.createMitosisComponent = createMitosisComponent;
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createMitosisNode = void 0;
15
- var createMitosisNode = function (options) { return (__assign({ '@type': '@builder.io/mitosis/node', name: 'div', meta: {}, properties: {}, bindings: {}, children: [] }, options)); };
15
+ var createMitosisNode = function (options) { return (__assign({ '@type': '@builder.io/mitosis/node', name: 'div', meta: {}, scope: {}, properties: {}, bindings: {}, children: [] }, options)); };
16
16
  exports.createMitosisNode = createMitosisNode;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fastClone = void 0;
4
- var fastClone = function (obj) {
5
- return JSON.parse(JSON.stringify(obj));
6
- };
4
+ var fastClone = function (obj) { return JSON.parse(JSON.stringify(obj)); };
7
5
  exports.fastClone = fastClone;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filterEmptyTextNodes = void 0;
4
4
  var filterEmptyTextNodes = function (node) {
5
- return !(typeof node.properties._text === 'string' &&
6
- !node.properties._text.trim().length);
5
+ return !(typeof node.properties._text === 'string' && !node.properties._text.trim().length);
7
6
  };
8
7
  exports.filterEmptyTextNodes = filterEmptyTextNodes;
@@ -0,0 +1,2 @@
1
+ import { MitosisNode } from '../types/mitosis-node';
2
+ export declare function getBindingsCode(children: MitosisNode[]): string[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBindingsCode = void 0;
4
+ function getBindingsCode(children) {
5
+ var bindings = [];
6
+ children.forEach(function (child) {
7
+ if (child.bindings) {
8
+ Object.keys(child.bindings).forEach(function (key) {
9
+ bindings.push(child.bindings[key].code);
10
+ });
11
+ }
12
+ if (child.children) {
13
+ bindings.push.apply(bindings, getBindingsCode(child.children));
14
+ }
15
+ });
16
+ return bindings;
17
+ }
18
+ exports.getBindingsCode = getBindingsCode;
@@ -0,0 +1,15 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ /**
3
+ * Return custom imports of basic values (aka things
4
+ * that are not ClassCase like components and types)
5
+ *
6
+ * For for code like:
7
+ * import { foo, bar } from './constants'
8
+ *
9
+ * Will return:
10
+ * ['foo', 'bar' ]
11
+ *
12
+ * This also filters for strings that appears to be actually used
13
+ * by the template
14
+ */
15
+ export declare function getCustomImports(json: MitosisComponent): string[];
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomImports = void 0;
4
+ var is_upper_case_1 = require("./is-upper-case");
5
+ /**
6
+ * Return custom imports of basic values (aka things
7
+ * that are not ClassCase like components and types)
8
+ *
9
+ * For for code like:
10
+ * import { foo, bar } from './constants'
11
+ *
12
+ * Will return:
13
+ * ['foo', 'bar' ]
14
+ *
15
+ * This also filters for strings that appears to be actually used
16
+ * by the template
17
+ */
18
+ function getCustomImports(json) {
19
+ var blocksString = JSON.stringify(json.children);
20
+ var customImports = json.imports
21
+ .map(function (item) {
22
+ return Object.keys(item.imports).filter(function (item) {
23
+ return item &&
24
+ // this ignores component imports, which are CamelCased.
25
+ (!(0, is_upper_case_1.isUpperCase)(item[0]) ||
26
+ // this includes constants which are typically CAPITALIZED.
27
+ item.toUpperCase() === item);
28
+ });
29
+ })
30
+ .flat()
31
+ // This is imperfect. Basically, if the string of this import name
32
+ // doesn't occur at all, it's definitely not used. If it does, it might.
33
+ // So this simple check helps us ~90% of the time not over-add imports
34
+ // to templates. Arguably "good enough" for now, as there is generally no
35
+ // consequence to over adding here, and it would be a lot more performance expensive
36
+ // during compilation to do a complete AST parse and look for real references
37
+ .filter(function (item) { return blocksString.includes(item); });
38
+ return customImports;
39
+ }
40
+ exports.getCustomImports = getCustomImports;
@@ -0,0 +1,5 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ /**
3
+ * Get props used in the components by reference
4
+ */
5
+ export declare const getPropFunctions: (json: MitosisComponent) => string[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPropFunctions = void 0;
7
+ var traverse_1 = __importDefault(require("traverse"));
8
+ var propsRegex = /props\s*\.\s*([a-zA-Z0-9_\4]+)\(/;
9
+ var allPropsMatchesRegex = new RegExp(propsRegex, 'g');
10
+ /**
11
+ * Get props used in the components by reference
12
+ */
13
+ var getPropFunctions = function (json) {
14
+ var props = [];
15
+ (0, traverse_1.default)(json).forEach(function (item) {
16
+ if (typeof item === 'string') {
17
+ // TODO: proper babel ref matching
18
+ var matches = item.match(allPropsMatchesRegex);
19
+ if (matches) {
20
+ for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) {
21
+ var match = matches_1[_i];
22
+ props.push(match.match(propsRegex)[1]);
23
+ }
24
+ }
25
+ }
26
+ });
27
+ return props;
28
+ };
29
+ exports.getPropFunctions = getPropFunctions;
@@ -0,0 +1,2 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ export declare function getPropsRef(json: MitosisComponent, shouldRemove?: boolean): [string, boolean];
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPropsRef = void 0;
7
+ var traverse_1 = __importDefault(require("traverse"));
8
+ var is_mitosis_node_1 = require("./is-mitosis-node");
9
+ function getPropsRef(json, shouldRemove) {
10
+ var has = false;
11
+ var prop = '';
12
+ (0, traverse_1.default)(json).forEach(function (item) {
13
+ if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
14
+ var binding = item.bindings.ref;
15
+ var regexp = /(.+)?props\.(.+)( |\)|;|\()?$/;
16
+ if (binding && regexp.test(binding.code)) {
17
+ var match = regexp.exec(binding.code);
18
+ var _prop = match === null || match === void 0 ? void 0 : match[2];
19
+ if (_prop) {
20
+ prop = _prop;
21
+ }
22
+ if (shouldRemove) {
23
+ delete item.bindings.ref;
24
+ }
25
+ has = true;
26
+ this.stop();
27
+ }
28
+ }
29
+ });
30
+ return [prop, has];
31
+ }
32
+ exports.getPropsRef = getPropsRef;
@@ -9,9 +9,10 @@ var is_mitosis_node_1 = require("./is-mitosis-node");
9
9
  var getRefs = function (json) {
10
10
  var refs = new Set();
11
11
  (0, traverse_1.default)(json).forEach(function (item) {
12
+ var _a;
12
13
  if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
13
- if (typeof item.bindings.ref === 'string') {
14
- refs.add(item.bindings.ref);
14
+ if (typeof ((_a = item.bindings.ref) === null || _a === void 0 ? void 0 : _a.code) === 'string') {
15
+ refs.add(item.bindings.ref.code);
15
16
  }
16
17
  }
17
18
  });
@@ -1,12 +1,14 @@
1
- import { JSONObject } from '../types/json';
1
+ import { MitosisContext } from '../types/mitosis-context';
2
2
  import { MitosisComponent } from '../types/mitosis-component';
3
- export declare type GetStateObjectStringOptions = {
3
+ interface GetStateObjectStringOptions {
4
4
  data?: boolean;
5
5
  functions?: boolean;
6
6
  getters?: boolean;
7
7
  valueMapper?: (code: string, type: 'data' | 'function' | 'getter') => string;
8
8
  format?: 'object' | 'class' | 'variables';
9
9
  keyPrefix?: string;
10
- };
11
- export declare const getMemberObjectString: (object: JSONObject, options?: GetStateObjectStringOptions) => string;
10
+ }
11
+ export declare const getMemberObjectString: (object: MitosisComponent['state'], userOptions?: GetStateObjectStringOptions) => string;
12
+ export declare const stringifyContextValue: (object: MitosisContext['value'], userOptions?: GetStateObjectStringOptions) => string;
12
13
  export declare const getStateObjectStringFromComponent: (component: MitosisComponent, options?: GetStateObjectStringOptions) => string;
14
+ export {};
@@ -14,53 +14,62 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getStateObjectStringFromComponent = exports.getMemberObjectString = void 0;
17
+ exports.getStateObjectStringFromComponent = exports.stringifyContextValue = exports.getMemberObjectString = void 0;
18
18
  var json5_1 = __importDefault(require("json5"));
19
19
  var function_literal_prefix_1 = require("../constants/function-literal-prefix");
20
20
  var method_literal_prefix_1 = require("../constants/method-literal-prefix");
21
21
  var patterns_1 = require("./patterns");
22
- var convertStateMemberToString = function (options) {
22
+ var state_1 = require("./state");
23
+ var DEFAULT_OPTIONS = {
24
+ format: 'object',
25
+ keyPrefix: '',
26
+ valueMapper: function (val) { return val; },
27
+ data: true,
28
+ functions: true,
29
+ getters: true,
30
+ };
31
+ var convertStateMemberToString = function (_a) {
32
+ var data = _a.data, format = _a.format, functions = _a.functions, getters = _a.getters, keyPrefix = _a.keyPrefix, valueMapper = _a.valueMapper;
23
33
  return function (_a) {
24
- var key = _a[0], value = _a[1];
25
- var valueMapper = options.valueMapper || (function (val) { return val; });
26
- var keyValueDelimiter = options.format === 'object' ? ':' : '=';
27
- var keyPrefix = options.keyPrefix || '';
28
- if (typeof value === 'string') {
29
- if (value.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
30
- if (options.functions === false) {
34
+ var key = _a[0], state = _a[1];
35
+ var keyValueDelimiter = format === 'object' ? ':' : '=';
36
+ var code = state === null || state === void 0 ? void 0 : state.code;
37
+ if (typeof code === 'string') {
38
+ if (code.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
39
+ if (functions === false) {
31
40
  return undefined;
32
41
  }
33
- var functionValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
42
+ var functionValue = code.replace(function_literal_prefix_1.functionLiteralPrefix, '');
34
43
  return "".concat(keyPrefix, " ").concat(key, " ").concat(keyValueDelimiter, " ").concat(valueMapper(functionValue, 'function'));
35
44
  }
36
- else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
37
- var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
45
+ else if (code.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
46
+ var methodValue = code.replace(method_literal_prefix_1.methodLiteralPrefix, '');
38
47
  var isGet = Boolean(methodValue.match(patterns_1.GETTER));
39
- if (isGet && options.getters === false) {
48
+ if (isGet && getters === false) {
40
49
  return undefined;
41
50
  }
42
- if (!isGet && options.functions === false) {
51
+ if (!isGet && functions === false) {
43
52
  return undefined;
44
53
  }
45
54
  return "".concat(keyPrefix, " ").concat(valueMapper(methodValue, isGet ? 'getter' : 'function'));
46
55
  }
47
56
  }
48
- if (options.data === false) {
57
+ if (data === false) {
49
58
  return undefined;
50
59
  }
51
- return "".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data'));
60
+ return "".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(code), 'data'));
52
61
  };
53
62
  };
54
- var getMemberObjectString = function (object, options) {
55
- if (options === void 0) { options = {}; }
56
- var format = options.format || 'object';
57
- var lineItemDelimiter = format === 'object' ? ',' : '\n';
63
+ var getMemberObjectString = function (object, userOptions) {
64
+ if (userOptions === void 0) { userOptions = {}; }
65
+ var options = __assign(__assign({}, DEFAULT_OPTIONS), userOptions);
66
+ var lineItemDelimiter = options.format === 'object' ? ',' : '\n';
58
67
  var stringifiedProperties = Object.entries(object)
59
- .map(convertStateMemberToString(__assign(__assign({}, options), { format: format })))
68
+ .map(convertStateMemberToString(options))
60
69
  .filter(function (x) { return x !== undefined; })
61
70
  .join(lineItemDelimiter);
62
- var prefix = format === 'object' ? '{' : '';
63
- var suffix = format === 'object' ? '}' : '';
71
+ var prefix = options.format === 'object' ? '{' : '';
72
+ var suffix = options.format === 'object' ? '}' : '';
64
73
  // NOTE: we add a `lineItemDelimiter` at the very end because other functions will sometimes append more properties.
65
74
  // If the delimiter is a comma and the format is `object`, then we need to make sure we have an extra comma at the end,
66
75
  // or the object will become invalid JS.
@@ -69,9 +78,10 @@ var getMemberObjectString = function (object, options) {
69
78
  return "".concat(prefix).concat(stringifiedProperties).concat(extraDelimiter).concat(suffix);
70
79
  };
71
80
  exports.getMemberObjectString = getMemberObjectString;
72
- var getStateObjectStringFromComponent = function (component, options) {
73
- if (options === void 0) { options = {}; }
74
- var stateObjectStr = (0, exports.getMemberObjectString)(component.state, options);
75
- return stateObjectStr;
81
+ var stringifyContextValue = function (object, userOptions) {
82
+ if (userOptions === void 0) { userOptions = {}; }
83
+ return (0, exports.getMemberObjectString)((0, state_1.mapJsonObjectToStateValue)(object), userOptions);
76
84
  };
85
+ exports.stringifyContextValue = stringifyContextValue;
86
+ var getStateObjectStringFromComponent = function (component, options) { return (0, exports.getMemberObjectString)(component.state, options); };
77
87
  exports.getStateObjectStringFromComponent = getStateObjectStringFromComponent;
@@ -7,15 +7,16 @@ exports.setStyles = exports.getStyles = void 0;
7
7
  var json5_1 = __importDefault(require("json5"));
8
8
  var lodash_1 = require("lodash");
9
9
  var getStyles = function (json) {
10
+ var _a;
10
11
  if (!json.bindings.css) {
11
12
  return null;
12
13
  }
13
14
  var css;
14
15
  try {
15
- css = json5_1.default.parse(json.bindings.css);
16
+ css = json5_1.default.parse((_a = json.bindings.css) === null || _a === void 0 ? void 0 : _a.code);
16
17
  }
17
18
  catch (err) {
18
- console.warn('Could not json 5 parse css', err, json.bindings.css);
19
+ console.warn('Could not json 5 parse css', err, json.bindings.css.code);
19
20
  return null;
20
21
  }
21
22
  return css;
@@ -26,7 +27,7 @@ var setStyles = function (json, styles) {
26
27
  delete json.bindings.css;
27
28
  }
28
29
  else {
29
- json.bindings.css = json5_1.default.stringify(styles);
30
+ json.bindings.css = { code: json5_1.default.stringify(styles) };
30
31
  }
31
32
  };
32
33
  exports.setStyles = setStyles;
@@ -1,5 +1,5 @@
1
1
  import { MitosisComponent } from '../types/mitosis-component';
2
2
  /**
3
- * Map getters like `useState({ get foo() { ... }})` from `state.foo` to `foo()`
3
+ * Map getters like `useStore({ get foo() { ... }})` from `state.foo` to `foo()`
4
4
  */
5
5
  export declare const gettersToFunctions: (json: MitosisComponent) => void;
@@ -7,11 +7,12 @@ exports.gettersToFunctions = void 0;
7
7
  var method_literal_prefix_1 = require("../constants/method-literal-prefix");
8
8
  var traverse_1 = __importDefault(require("traverse"));
9
9
  /**
10
- * Map getters like `useState({ get foo() { ... }})` from `state.foo` to `foo()`
10
+ * Map getters like `useStore({ get foo() { ... }})` from `state.foo` to `foo()`
11
11
  */
12
12
  var gettersToFunctions = function (json) {
13
13
  var getterKeys = Object.keys(json.state).filter(function (item) {
14
- var value = json.state[item];
14
+ var _a;
15
+ var value = (_a = json.state[item]) === null || _a === void 0 ? void 0 : _a.code;
15
16
  if (typeof value === 'string' &&
16
17
  value.startsWith(method_literal_prefix_1.methodLiteralPrefix) &&
17
18
  value.replace(method_literal_prefix_1.methodLiteralPrefix, '').startsWith('get ')) {
@@ -6,7 +6,7 @@ function handleMissingState(json) {
6
6
  var stateUsed = (0, get_state_used_1.getStateUsed)(json);
7
7
  Array.from(stateUsed).forEach(function (property) {
8
8
  if (!(property in json.state)) {
9
- json.state[property] = null;
9
+ json.state[property] = { code: null, type: 'property' };
10
10
  }
11
11
  });
12
12
  }
@@ -0,0 +1,2 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ export declare const hasBindingsText: (json: MitosisComponent) => boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hasBindingsText = void 0;
7
+ var traverse_1 = __importDefault(require("traverse"));
8
+ var is_mitosis_node_1 = require("./is-mitosis-node");
9
+ var is_children_1 = __importDefault(require("./is-children"));
10
+ var hasBindingsText = function (json) {
11
+ var has = false;
12
+ (0, traverse_1.default)(json).forEach(function (node) {
13
+ var _a;
14
+ if ((0, is_mitosis_node_1.isMitosisNode)(node) && !(0, is_children_1.default)(node) && ((_a = node.bindings._text) === null || _a === void 0 ? void 0 : _a.code)) {
15
+ has = true;
16
+ this.stop();
17
+ }
18
+ });
19
+ return has;
20
+ };
21
+ exports.hasBindingsText = hasBindingsText;
@@ -0,0 +1,2 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ export declare const hasStatefulDom: (json: MitosisComponent) => boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hasStatefulDom = void 0;
7
+ var traverse_1 = __importDefault(require("traverse"));
8
+ var is_mitosis_node_1 = require("./is-mitosis-node");
9
+ var hasStatefulDom = function (json) {
10
+ var has = false;
11
+ (0, traverse_1.default)(json).forEach(function (item) {
12
+ if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
13
+ if (/input|textarea|select/.test(item.name)) {
14
+ has = true;
15
+ this.stop();
16
+ }
17
+ }
18
+ });
19
+ return has;
20
+ };
21
+ exports.hasStatefulDom = hasStatefulDom;
@@ -0,0 +1,9 @@
1
+ import { MitosisComponent } from '../types/mitosis-component';
2
+ import { MitosisNode } from '../types/mitosis-node';
3
+ /**
4
+ * Test if the component has something
5
+ *
6
+ * e.g.
7
+ * const hasSpread = has(component, node => Boolean(node.bindings._spread));
8
+ */
9
+ export declare function has(json: MitosisComponent, test: (node: MitosisNode) => boolean): boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.has = void 0;
7
+ var traverse_1 = __importDefault(require("traverse"));
8
+ var is_mitosis_node_1 = require("./is-mitosis-node");
9
+ /**
10
+ * Test if the component has something
11
+ *
12
+ * e.g.
13
+ * const hasSpread = has(component, node => Boolean(node.bindings._spread));
14
+ */
15
+ function has(json, test) {
16
+ var found = false;
17
+ (0, traverse_1.default)(json).forEach(function (thing) {
18
+ if ((0, is_mitosis_node_1.isMitosisNode)(thing)) {
19
+ if (test(thing)) {
20
+ found = true;
21
+ this.stop();
22
+ }
23
+ }
24
+ });
25
+ return found;
26
+ }
27
+ exports.has = has;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function isChildren(node) {
4
- return ("".concat(node.bindings._text || '').replace(/\s+/g, '') === 'props.children');
4
+ var _a;
5
+ return ("".concat(((_a = node.bindings._text) === null || _a === void 0 ? void 0 : _a.code) || node.properties.__text || '').replace(/\s+/g, '') ===
6
+ 'props.children');
5
7
  }
6
8
  exports.default = isChildren;
@@ -4,7 +4,5 @@ exports.isComponent = void 0;
4
4
  /**
5
5
  * This node is a component, vs a plain html tag (<Foo> vs <div>)
6
6
  */
7
- var isComponent = function (json) {
8
- return json.name.toLowerCase() !== json.name;
9
- };
7
+ var isComponent = function (json) { return json.name.toLowerCase() !== json.name; };
10
8
  exports.isComponent = isComponent;
@@ -0,0 +1,4 @@
1
+ export declare const htmlElementAttributes: {
2
+ [key: string]: string[];
3
+ };
4
+ export declare const isHtmlAttribute: (attr: string, tagName: string) => boolean;