@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
@@ -8,7 +8,7 @@ var File = /** @class */ (function () {
8
8
  this.exports = new Map();
9
9
  this.filename = filename;
10
10
  this.options = options;
11
- this.src = new SrcBuilder(this.options);
11
+ this.src = new SrcBuilder(this, this.options);
12
12
  this.qwikModule = qwikModule;
13
13
  this.qrlPrefix = qrlPrefix;
14
14
  }
@@ -33,8 +33,8 @@ var File = /** @class */ (function () {
33
33
  enumerable: false,
34
34
  configurable: true
35
35
  });
36
- File.prototype.import = function (module, symbol) {
37
- return this.imports.get(module, symbol);
36
+ File.prototype.import = function (module, symbol, as) {
37
+ return this.imports.get(module, symbol, as);
38
38
  };
39
39
  File.prototype.toQrlChunk = function () {
40
40
  return quote(this.qrlPrefix + this.module + '.js');
@@ -46,58 +46,110 @@ var File = /** @class */ (function () {
46
46
  this.exports.set(name, this.src.isModule ? name : 'exports.' + name);
47
47
  this.src.const(name, value, true, locallyVisible);
48
48
  };
49
+ File.prototype.exportDefault = function (symbolName) {
50
+ if (this.options.isModule) {
51
+ this.src.emit('export default ', symbolName, ';');
52
+ }
53
+ else {
54
+ this.src.emit('module.exports=', symbolName, ';');
55
+ }
56
+ };
49
57
  File.prototype.toString = function () {
50
58
  var _this = this;
51
- var srcImports = new SrcBuilder(this.options);
59
+ var srcImports = new SrcBuilder(this, this.options);
52
60
  var imports = this.imports.imports;
53
61
  var modules = Array.from(imports.keys()).sort();
54
62
  modules.forEach(function (module) {
63
+ if (module == '<SELF>')
64
+ return;
55
65
  var symbolMap = imports.get(module);
56
- var symbols = Array.from(symbolMap.keys()).sort();
66
+ var symbols = Array.from(symbolMap.values());
67
+ symbols.sort(symbolSort);
57
68
  if (removeExt(module) !== removeExt(_this.qrlPrefix + _this.filename)) {
58
69
  srcImports.import(module, symbols);
59
70
  }
60
71
  });
61
72
  var source = srcImports.toString() + this.src.toString();
62
73
  if (this.options.isPretty) {
63
- source = (0, standalone_1.format)(source, {
64
- parser: 'typescript',
65
- plugins: [
66
- // To support running in browsers
67
- require('prettier/parser-typescript'),
68
- require('prettier/parser-postcss'),
69
- require('prettier/parser-html'),
70
- require('prettier/parser-babel'),
71
- ],
72
- htmlWhitespaceSensitivity: 'ignore',
73
- });
74
+ try {
75
+ source = (0, standalone_1.format)(source, {
76
+ parser: 'typescript',
77
+ plugins: [
78
+ // To support running in browsers
79
+ require('prettier/parser-typescript'),
80
+ require('prettier/parser-postcss'),
81
+ require('prettier/parser-html'),
82
+ require('prettier/parser-babel'),
83
+ ],
84
+ htmlWhitespaceSensitivity: 'ignore',
85
+ });
86
+ }
87
+ catch (e) {
88
+ throw new Error(e +
89
+ '\n' +
90
+ '========================================================================\n' +
91
+ source +
92
+ '\n\n========================================================================');
93
+ }
74
94
  }
75
95
  return source;
76
96
  };
77
97
  return File;
78
98
  }());
79
99
  exports.File = File;
100
+ function symbolSort(a, b) {
101
+ return a.importName < b.importName ? -1 : a.importName === b.importName ? 0 : 1;
102
+ }
80
103
  function removeExt(filename) {
81
104
  var indx = filename.lastIndexOf('.');
82
105
  return indx == -1 ? filename : filename.substr(0, indx);
83
106
  }
84
107
  var spaces = [''];
85
108
  var SrcBuilder = /** @class */ (function () {
86
- function SrcBuilder(options) {
109
+ function SrcBuilder(file, options) {
87
110
  this.buf = [];
111
+ this.jsxDepth = 0;
112
+ /**
113
+ * Used to signal that we are generating code for Builder.
114
+ *
115
+ * In builder the `<For/>` iteration places the value on the state.
116
+ */
117
+ this.isBuilder = false;
118
+ this.file = file;
88
119
  this.isTypeScript = options.isTypeScript;
89
120
  this.isModule = options.isModule;
90
121
  this.isJSX = options.isJSX;
122
+ this.isBuilder = options.isBuilder;
91
123
  }
92
124
  SrcBuilder.prototype.import = function (module, symbols) {
93
125
  var _this = this;
94
126
  if (this.isModule) {
95
- this.emit('import{', symbols, '}from', quote(module), ';');
127
+ this.emit('import');
128
+ if (symbols.length === 1 && symbols[0].importName === 'default') {
129
+ this.emit(' ', symbols[0].localName, ' ');
130
+ }
131
+ else {
132
+ this.emit('{');
133
+ symbols.forEach(function (symbol) {
134
+ if (symbol.importName === symbol.localName) {
135
+ _this.emit(symbol.importName);
136
+ }
137
+ else {
138
+ _this.emit(symbol.importName, ' as ', symbol.localName);
139
+ }
140
+ _this.emit(',');
141
+ });
142
+ this.emit('}');
143
+ }
144
+ this.emit('from', quote(module), ';');
96
145
  }
97
146
  else {
98
147
  symbols.forEach(function (symbol) {
99
- _this.const(symbol, function () {
100
- this.emit(invoke('require', [quote(module)]), '.', symbol);
148
+ _this.const(symbol.localName, function () {
149
+ this.emit(invoke('require', [quote(module)]));
150
+ if (symbol.importName !== 'default') {
151
+ this.emit('.', symbol.importName);
152
+ }
101
153
  });
102
154
  });
103
155
  }
@@ -156,6 +208,7 @@ var SrcBuilder = /** @class */ (function () {
156
208
  value.startsWith(':') ||
157
209
  value.startsWith(']') ||
158
210
  value.startsWith('}') ||
211
+ value.startsWith(',') ||
159
212
  value.startsWith('?')) {
160
213
  // clear last ',' or ';';
161
214
  var index = this.buf.length - 1;
@@ -209,7 +262,24 @@ var SrcBuilder = /** @class */ (function () {
209
262
  this.emit('<', typeParameters, '>');
210
263
  }
211
264
  };
265
+ SrcBuilder.prototype.jsxExpression = function (expression) {
266
+ var previousJsxDepth = this.jsxDepth;
267
+ try {
268
+ if (previousJsxDepth) {
269
+ this.jsxDepth = 0;
270
+ this.isJSX && this.emit('{');
271
+ }
272
+ expression.apply(this);
273
+ }
274
+ finally {
275
+ if (previousJsxDepth) {
276
+ this.isJSX && this.emit('}');
277
+ }
278
+ this.jsxDepth = previousJsxDepth;
279
+ }
280
+ };
212
281
  SrcBuilder.prototype.jsxBegin = function (symbol, props, bindings) {
282
+ this.jsxDepth++;
213
283
  var self = this;
214
284
  if (symbol == 'div' && ('href' in props || 'href' in bindings)) {
215
285
  // HACK: if we contain href then we are `a` not `div`
@@ -225,15 +295,35 @@ var SrcBuilder = /** @class */ (function () {
225
295
  if (Object.prototype.hasOwnProperty.call(props, key) &&
226
296
  !ignoreKey(key) &&
227
297
  !Object.prototype.hasOwnProperty.call(bindings, key)) {
228
- emitJsxProp(possiblyQuotePropertyName(key), quote(props[key]));
298
+ emitJsxProp(key, quote(props[key]));
229
299
  }
230
300
  }
231
301
  var _loop_1 = function (rawKey) {
232
- if (Object.prototype.hasOwnProperty.call(bindings, rawKey) &&
233
- !ignoreKey(rawKey)) {
302
+ if (rawKey === '_spread') {
303
+ if (this_1.isJSX) {
304
+ this_1.emit('{...', bindings[rawKey].code, '}');
305
+ }
306
+ else {
307
+ this_1.emit('...', bindings[rawKey].code);
308
+ }
309
+ }
310
+ else if (Object.prototype.hasOwnProperty.call(bindings, rawKey) && !ignoreKey(rawKey)) {
234
311
  var binding_1 = bindings[rawKey];
312
+ binding_1 =
313
+ binding_1 && typeof binding_1 == 'object' && 'code' in binding_1 ? binding_1.code : binding_1;
314
+ if (rawKey === 'class' && props.class) {
315
+ // special case for classes as they can have both static and dynamic binding
316
+ binding_1 = quote(props.class + ' ') + '+' + binding_1;
317
+ }
235
318
  var key = lastProperty(rawKey);
236
- if (binding_1 === props[key]) {
319
+ if (isEvent(key)) {
320
+ key = key + '$';
321
+ binding_1 = "(event)=>".concat(binding_1);
322
+ }
323
+ if (!binding_1 && rawKey in props) {
324
+ binding_1 = quote(props[rawKey]);
325
+ }
326
+ else if (binding_1 != null && binding_1 === props[key]) {
237
327
  // HACK: workaround for the fact that sometimes the `bindings` have string literals
238
328
  // We assume that when the binding content equals prop content.
239
329
  binding_1 = quote(binding_1);
@@ -248,10 +338,11 @@ var SrcBuilder = /** @class */ (function () {
248
338
  });
249
339
  }
250
340
  else {
251
- emitJsxProp(possiblyQuotePropertyName(key), binding_1);
341
+ emitJsxProp(key, binding_1);
252
342
  }
253
343
  }
254
344
  };
345
+ var this_1 = this;
255
346
  for (var rawKey in bindings) {
256
347
  _loop_1(rawKey);
257
348
  }
@@ -262,18 +353,22 @@ var SrcBuilder = /** @class */ (function () {
262
353
  this.emit('},');
263
354
  }
264
355
  function emitJsxProp(key, value) {
265
- if (self.isJSX) {
266
- self.emit(' ', key, '=');
267
- if (typeof value == 'string' && value.startsWith('"')) {
268
- self.emit(value);
356
+ if (value) {
357
+ if (key === 'innerHTML')
358
+ key = 'dangerouslySetInnerHTML';
359
+ if (self.isJSX) {
360
+ self.emit(' ', key, '=');
361
+ if (typeof value == 'string' && value.startsWith('"') && value.endsWith('"')) {
362
+ self.emit(value);
363
+ }
364
+ else {
365
+ self.emit('{', value, '}');
366
+ }
269
367
  }
270
368
  else {
271
- self.emit('{', value, '}');
369
+ self.emit(possiblyQuotePropertyName(key), ':', value, ',');
272
370
  }
273
371
  }
274
- else {
275
- self.emit(key, ':', value, ',');
276
- }
277
372
  }
278
373
  };
279
374
  SrcBuilder.prototype.jsxEnd = function (symbol) {
@@ -283,16 +378,19 @@ var SrcBuilder = /** @class */ (function () {
283
378
  else {
284
379
  this.emit('),');
285
380
  }
381
+ this.jsxDepth--;
286
382
  };
287
383
  SrcBuilder.prototype.jsxBeginFragment = function (symbol) {
384
+ this.jsxDepth++;
288
385
  if (this.isJSX) {
289
386
  this.emit('<>');
290
387
  }
291
388
  else {
292
- this.emit('h(', symbol.name, ',null,');
389
+ this.emit('h(', symbol.localName, ',null,');
293
390
  }
294
391
  };
295
392
  SrcBuilder.prototype.jsxEndFragment = function () {
393
+ this.jsxDepth--;
296
394
  if (this.isJSX) {
297
395
  this.emit('</>');
298
396
  }
@@ -314,9 +412,16 @@ var SrcBuilder = /** @class */ (function () {
314
412
  return SrcBuilder;
315
413
  }());
316
414
  exports.SrcBuilder = SrcBuilder;
415
+ function isEvent(name) {
416
+ return name.startsWith('on') && isUppercase(name.charAt(2)) && !name.endsWith('$');
417
+ }
418
+ function isUppercase(ch) {
419
+ return ch == ch.toUpperCase();
420
+ }
317
421
  var Symbol = /** @class */ (function () {
318
- function Symbol(name) {
319
- this.name = name;
422
+ function Symbol(importName, localName) {
423
+ this.importName = importName;
424
+ this.localName = localName;
320
425
  }
321
426
  return Symbol;
322
427
  }());
@@ -325,7 +430,7 @@ var Imports = /** @class */ (function () {
325
430
  function Imports() {
326
431
  this.imports = new Map();
327
432
  }
328
- Imports.prototype.get = function (moduleName, symbolName) {
433
+ Imports.prototype.get = function (moduleName, symbolName, as) {
329
434
  var importSymbols = this.imports.get(moduleName);
330
435
  if (!importSymbols) {
331
436
  importSymbols = new Map();
@@ -333,11 +438,23 @@ var Imports = /** @class */ (function () {
333
438
  }
334
439
  var symbol = importSymbols.get(symbolName);
335
440
  if (!symbol) {
336
- symbol = new Symbol(symbolName);
441
+ symbol = new Symbol(symbolName, as || symbolName);
337
442
  importSymbols.set(symbolName, symbol);
338
443
  }
339
444
  return symbol;
340
445
  };
446
+ Imports.prototype.hasImport = function (localName) {
447
+ for (var _i = 0, _a = Array.from(this.imports.values()); _i < _a.length; _i++) {
448
+ var symbolMap = _a[_i];
449
+ for (var _b = 0, _c = Array.from(symbolMap.values()); _b < _c.length; _b++) {
450
+ var symbol = _c[_b];
451
+ if (symbol.localName === localName) {
452
+ return true;
453
+ }
454
+ }
455
+ }
456
+ return false;
457
+ };
341
458
  return Imports;
342
459
  }());
343
460
  exports.Imports = Imports;
@@ -346,7 +463,6 @@ function ignoreKey(key) {
346
463
  key.startsWith('_') ||
347
464
  key == 'code' ||
348
465
  key == '' ||
349
- key == 'builder-id' ||
350
466
  key.indexOf('.') !== -1);
351
467
  }
352
468
  var Block = /** @class */ (function () {
@@ -371,15 +487,25 @@ function quote(text) {
371
487
  exports.quote = quote;
372
488
  function invoke(symbol, args, typeParameters) {
373
489
  return function () {
374
- this.emit(typeof symbol == 'string' ? symbol : symbol.name);
490
+ this.emit(typeof symbol == 'string' ? symbol : symbol.localName);
375
491
  this.typeParameters(typeParameters);
376
492
  this.emit('(', args, ')');
377
493
  };
378
494
  }
379
495
  exports.invoke = invoke;
380
- function arrowFnBlock(args, statements) {
496
+ function arrowFnBlock(args, statements, argTypes) {
381
497
  return function () {
382
- this.emit('(', args, ')=>{').emitList(statements, ';').emit('}');
498
+ this.emit('(');
499
+ for (var i = 0; i < args.length; i++) {
500
+ var arg = args[i];
501
+ var type = argTypes && argTypes[i];
502
+ this.emit(arg);
503
+ if (type && this.file.options.isTypeScript) {
504
+ this.emit(':', type);
505
+ }
506
+ this.emit(',');
507
+ }
508
+ this.emit(')=>{').emitList(statements, ';').emit('}');
383
509
  };
384
510
  }
385
511
  exports.arrowFnBlock = arrowFnBlock;
@@ -389,7 +515,15 @@ function arrowFnValue(args, expression) {
389
515
  };
390
516
  }
391
517
  exports.arrowFnValue = arrowFnValue;
518
+ var _virtual_index = '_virtual_index;';
519
+ var return_virtual_index = 'return _virtual_index;';
392
520
  function iif(code) {
521
+ if (!code)
522
+ return;
523
+ code = code.trim();
524
+ if (code.endsWith(_virtual_index) && !code.endsWith(return_virtual_index)) {
525
+ code = code.substr(0, code.length - _virtual_index.length) + return_virtual_index;
526
+ }
393
527
  return function () {
394
528
  code && this.emit('(()=>{', code, '})()');
395
529
  };
@@ -431,7 +565,7 @@ exports.isStatement = isStatement;
431
565
  // https://regexr.com/6cppf
432
566
  var STRING_LITERAL = /(["'`])((\\{2})*|((\n|.)*?[^\\](\\{2})*))\1/g;
433
567
  // https://regexr.com/6cpk4
434
- var EXPRESSION_SEPARATORS = /[()\[\]{}.\?:\-+/*,]+/;
568
+ var EXPRESSION_SEPARATORS = /[()\[\]{}.\?:\-+/*,|&]+/;
435
569
  // https://regexr.com/6cpka
436
570
  var EXPRESSION_IDENTIFIER = /^\s*[a-zA-Z0-9_$]+\s*$/;
437
571
  function lastProperty(expr) {
@@ -27,11 +27,12 @@ exports.renderStyles = exports.collectStyles = void 0;
27
27
  var json5_1 = __importDefault(require("json5"));
28
28
  var dash_case_1 = require("../../helpers/dash-case");
29
29
  function collectStyles(children, styleMap) {
30
+ var _a;
30
31
  var nodes = __spreadArray([], children, true);
31
32
  while (nodes.length) {
32
33
  var child = nodes.shift();
33
34
  nodes.push.apply(nodes, child.children);
34
- var css = child.bindings.css;
35
+ var css = (_a = child.bindings.css) === null || _a === void 0 ? void 0 : _a.code;
35
36
  if (css && typeof css == 'string') {
36
37
  var value = __assign({ CLASS_NAME: 'c' + hashCode(css) }, json5_1.default.parse(css));
37
38
  styleMap.set(css, value);
@@ -59,8 +60,7 @@ function renderStyles(styles) {
59
60
  styles.forEach(function (styles) {
60
61
  _this.emit('.', styles.CLASS_NAME, /*'.🏷️�', WS,*/ '{');
61
62
  for (var key in styles) {
62
- if (key !== 'CLASS_NAME' &&
63
- Object.prototype.hasOwnProperty.call(styles, key)) {
63
+ if (key !== 'CLASS_NAME' && Object.prototype.hasOwnProperty.call(styles, key)) {
64
64
  var value = styles[key];
65
65
  if (value && typeof value == 'object') {
66
66
  mediaStyles.push(styles.CLASS_NAME, key, value);
@@ -0,0 +1,6 @@
1
+ import { Transpiler } from '../../types/transpiler';
2
+ import { MitosisNode } from '../../types/mitosis-node';
3
+ import { ToReactOptions } from './types';
4
+ export declare const blockToReact: (json: MitosisNode, options: ToReactOptions, parentSlots?: any[]) => string;
5
+ export declare const componentToPreact: (reactOptions?: ToReactOptions) => Transpiler;
6
+ export declare const componentToReact: (reactOptions?: ToReactOptions) => Transpiler;