@builder.io/mitosis 0.0.45-4 → 0.0.47

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 (218) hide show
  1. package/dist/src/__tests__/builder.test.js +73 -65
  2. package/dist/src/__tests__/context.test.js +13 -10
  3. package/dist/src/__tests__/data/basic.raw.jsx +1 -1
  4. package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +1 -1
  5. package/dist/src/__tests__/data/blocks/columns.raw.jsx +2 -2
  6. package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -3
  7. package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -3
  8. package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
  9. package/dist/src/__tests__/data/blocks/image.raw.jsx +4 -4
  10. package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -4
  11. package/dist/src/__tests__/data/context/component-with-context.lite.jsx +2 -2
  12. package/dist/src/__tests__/data/context/simple.context.lite.js +1 -1
  13. package/dist/src/__tests__/html.test.js +2 -2
  14. package/dist/src/__tests__/liquid.test.js +34 -34
  15. package/dist/src/__tests__/parse-jsx.test.js +1 -1
  16. package/dist/src/__tests__/qwik.test.js +197 -50
  17. package/dist/src/__tests__/react-native.test.js +35 -35
  18. package/dist/src/__tests__/react.test.js +35 -35
  19. package/dist/src/__tests__/solid.test.js +32 -32
  20. package/dist/src/__tests__/vue.test.js +35 -34
  21. package/dist/src/generators/angular.d.ts +4 -7
  22. package/dist/src/generators/angular.js +77 -81
  23. package/dist/src/generators/builder.d.ts +4 -4
  24. package/dist/src/generators/builder.js +57 -57
  25. package/dist/src/generators/context/react.d.ts +3 -1
  26. package/dist/src/generators/context/react.js +20 -17
  27. package/dist/src/generators/html.d.ts +5 -9
  28. package/dist/src/generators/html.js +205 -199
  29. package/dist/src/generators/liquid.d.ts +5 -9
  30. package/dist/src/generators/liquid.js +62 -59
  31. package/dist/src/generators/mitosis.d.ts +6 -7
  32. package/dist/src/generators/mitosis.js +61 -63
  33. package/dist/src/generators/qwik/component.d.ts +20 -0
  34. package/dist/src/generators/qwik/component.js +117 -0
  35. package/dist/src/generators/qwik/directives.d.ts +2 -0
  36. package/dist/src/generators/qwik/directives.js +27 -0
  37. package/dist/src/generators/qwik/handlers.d.ts +4 -0
  38. package/dist/src/generators/qwik/handlers.js +80 -0
  39. package/dist/src/generators/qwik/index.d.ts +2 -0
  40. package/dist/src/generators/qwik/index.js +9 -0
  41. package/dist/src/generators/qwik/jsx.d.ts +4 -0
  42. package/dist/src/generators/qwik/jsx.js +124 -0
  43. package/dist/src/generators/qwik/src-generator.d.ts +79 -0
  44. package/dist/src/generators/qwik/src-generator.js +427 -0
  45. package/dist/src/generators/qwik/styles.d.ts +7 -0
  46. package/dist/src/generators/qwik/styles.js +94 -0
  47. package/dist/src/generators/react-native.d.ts +4 -7
  48. package/dist/src/generators/react-native.js +25 -22
  49. package/dist/src/generators/react.d.ts +4 -8
  50. package/dist/src/generators/react.js +118 -114
  51. package/dist/src/generators/solid.d.ts +4 -8
  52. package/dist/src/generators/solid.js +55 -54
  53. package/dist/src/generators/svelte.d.ts +4 -7
  54. package/dist/src/generators/svelte.js +120 -123
  55. package/dist/src/generators/swift-ui.d.ts +2 -2
  56. package/dist/src/generators/swift-ui.js +62 -62
  57. package/dist/src/generators/template.d.ts +4 -8
  58. package/dist/src/generators/template.js +48 -45
  59. package/dist/src/generators/vue.d.ts +9 -9
  60. package/dist/src/generators/vue.js +170 -169
  61. package/dist/src/helpers/babel-transform.js +9 -9
  62. package/dist/src/helpers/camel-case.d.ts +8 -0
  63. package/dist/src/helpers/camel-case.js +18 -0
  64. package/dist/src/helpers/collect-styles.js +39 -37
  65. package/dist/src/helpers/dash-case.js +1 -1
  66. package/dist/src/helpers/generic-format.test.js +2 -2
  67. package/dist/src/helpers/get-components-used.js +2 -2
  68. package/dist/src/helpers/get-components.js +3 -3
  69. package/dist/src/helpers/get-props.js +1 -1
  70. package/dist/src/helpers/get-refs.js +2 -2
  71. package/dist/src/helpers/get-state-object-string.js +52 -39
  72. package/dist/src/helpers/get-state-used.js +1 -1
  73. package/dist/src/helpers/get-styles.js +1 -1
  74. package/dist/src/helpers/getters-to-functions.js +4 -4
  75. package/dist/src/helpers/handle-missing-state.js +1 -1
  76. package/dist/src/helpers/has-component.js +2 -2
  77. package/dist/src/helpers/has-props.js +1 -1
  78. package/dist/src/helpers/is-children.js +1 -1
  79. package/dist/src/helpers/json.d.ts +1 -0
  80. package/dist/src/helpers/json.js +17 -0
  81. package/dist/src/helpers/map-refs.js +7 -6
  82. package/dist/src/helpers/map-to-attributes.js +4 -4
  83. package/dist/src/helpers/map-to-css.js +2 -2
  84. package/dist/src/helpers/parse-node.js +2 -2
  85. package/dist/src/helpers/parse-reactive-script.js +4 -4
  86. package/dist/src/helpers/patterns.d.ts +2 -0
  87. package/dist/src/helpers/patterns.js +5 -0
  88. package/dist/src/helpers/process-http-requests.js +1 -1
  89. package/dist/src/helpers/process-tag-references.js +4 -4
  90. package/dist/src/helpers/remove-surrounding-block.test.js +1 -1
  91. package/dist/src/helpers/render-imports.js +7 -7
  92. package/dist/src/helpers/replace-idenifiers.js +1 -1
  93. package/dist/src/helpers/strip-meta-properties.js +2 -2
  94. package/dist/src/helpers/trace-reference-to-module-path.js +1 -1
  95. package/dist/src/helpers/traverse-nodes.js +2 -2
  96. package/dist/src/helpers/try-prettier-format.js +1 -1
  97. package/dist/src/index.d.ts +3 -1
  98. package/dist/src/index.js +3 -1
  99. package/dist/src/modules/plugins.d.ts +2 -10
  100. package/dist/src/parsers/angular.js +13 -13
  101. package/dist/src/parsers/builder.d.ts +1 -1
  102. package/dist/src/parsers/builder.js +56 -59
  103. package/dist/src/parsers/context.js +2 -2
  104. package/dist/src/parsers/jsx.js +59 -87
  105. package/dist/src/parsers/liquid.js +193 -195
  106. package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
  107. package/dist/src/plugins/compile-away-builder-components.js +337 -92
  108. package/dist/src/plugins/compile-away-components.js +3 -3
  109. package/dist/src/plugins/map-styles.js +3 -3
  110. package/dist/src/targets.d.ts +24 -0
  111. package/dist/src/targets.js +30 -0
  112. package/dist/src/types/config.d.ts +31 -0
  113. package/dist/src/types/{jsx-lite-component.js → config.js} +0 -0
  114. package/dist/src/types/generators.d.ts +0 -0
  115. package/dist/src/types/generators.js +1 -0
  116. package/dist/src/types/plugins.d.ts +11 -0
  117. package/dist/src/types/{jsx-lite-context.js → plugins.js} +0 -0
  118. package/dist/test/qwik/Accordion/high.jsx +1 -0
  119. package/dist/test/qwik/Accordion/low.jsx +92 -0
  120. package/dist/test/qwik/Accordion/med.jsx +9 -0
  121. package/dist/test/qwik/For/high.jsx +1 -0
  122. package/dist/test/qwik/For/low.jsx +55 -0
  123. package/dist/test/qwik/For/med.jsx +9 -0
  124. package/dist/test/qwik/Image/high.js +1 -0
  125. package/dist/test/qwik/Image/low.js +68 -0
  126. package/dist/test/qwik/Image/med.js +9 -0
  127. package/dist/test/qwik/Image.slow/high.js +1 -0
  128. package/dist/test/qwik/Image.slow/low.js +68 -0
  129. package/dist/test/qwik/Image.slow/med.js +9 -0
  130. package/dist/test/qwik/button/high.js +8 -0
  131. package/dist/test/qwik/button/low.js +34 -0
  132. package/dist/test/qwik/button/med.js +9 -0
  133. package/dist/test/qwik/hello_world/stylesheet/high.jsx +1 -0
  134. package/dist/test/qwik/hello_world/stylesheet/low.jsx +24 -0
  135. package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -0
  136. package/dist/test/qwik/page-with-symbol/high.js +1 -0
  137. package/dist/test/qwik/page-with-symbol/low.js +49 -0
  138. package/dist/test/qwik/page-with-symbol/med.js +9 -0
  139. package/dist/test/qwik/svg/high.js +1 -0
  140. package/dist/test/qwik/svg/low.js +30 -0
  141. package/dist/test/qwik/svg/med.js +9 -0
  142. package/dist/test/qwik/todo/Todo.cjs/high.cjs +31 -0
  143. package/dist/test/qwik/todo/Todo.cjs/low.cjs +1 -0
  144. package/dist/test/qwik/todo/Todo.cjs/med.cjs +59 -0
  145. package/dist/test/qwik/todo/Todo.js/high.js +5 -0
  146. package/dist/test/qwik/todo/Todo.js/low.js +0 -0
  147. package/dist/test/qwik/todo/Todo.js/med.js +1 -0
  148. package/dist/test/qwik/todo/Todo.tsx/high.tsx +30 -0
  149. package/dist/test/qwik/todo/Todo.tsx/low.tsx +1 -0
  150. package/dist/test/qwik/todo/Todo.tsx/med.tsx +34 -0
  151. package/dist/test/qwik/todos/Todo.tsx/high.tsx +12 -0
  152. package/dist/test/qwik/todos/Todo.tsx/low.tsx +25 -0
  153. package/dist/test/qwik/todos/Todo.tsx/med.tsx +8 -0
  154. package/dist/tsconfig.tsbuildinfo +1 -1
  155. package/package.json +5 -4
  156. package/CHANGELOG.md +0 -4
  157. package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
  158. package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
  159. package/dist/src/__tests__/qoot.test.d.ts +0 -1
  160. package/dist/src/__tests__/qoot.test.js +0 -115
  161. package/dist/src/generators/jsx-lite.d.ts +0 -10
  162. package/dist/src/generators/jsx-lite.js +0 -176
  163. package/dist/src/generators/qoot.d.ts +0 -21
  164. package/dist/src/generators/qoot.js +0 -442
  165. package/dist/src/generators/qwik.d.ts +0 -21
  166. package/dist/src/generators/qwik.js +0 -458
  167. package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
  168. package/dist/src/helpers/create-jsx-lite-component.js +0 -16
  169. package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
  170. package/dist/src/helpers/create-jsx-lite-context.js +0 -18
  171. package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
  172. package/dist/src/helpers/create-jsx-lite-node.js +0 -16
  173. package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
  174. package/dist/src/helpers/is-jsx-lite-node.js +0 -7
  175. package/dist/src/types/jsx-lite-component.d.ts +0 -63
  176. package/dist/src/types/jsx-lite-context.d.ts +0 -6
  177. package/dist/src/types/jsx-lite-node.d.ts +0 -13
  178. package/dist/src/types/jsx-lite-node.js +0 -2
  179. package/dist/src/types/jsx-lite-styles.d.ts +0 -1
  180. package/dist/src/types/jsx-lite-styles.js +0 -2
  181. package/dist/test/qoot/Todo/bundle.js +0 -88
  182. package/dist/test/qoot/Todo/component.ts +0 -17
  183. package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
  184. package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
  185. package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
  186. package/dist/test/qoot/Todo/onInputClick.ts +0 -10
  187. package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
  188. package/dist/test/qoot/Todo/public.ts +0 -4
  189. package/dist/test/qoot/Todo/template.tsx +0 -46
  190. package/dist/test/qoot/Todos/component.ts +0 -9
  191. package/dist/test/qoot/Todos/onInputClick.ts +0 -14
  192. package/dist/test/qoot/Todos/public.ts +0 -3
  193. package/dist/test/qoot/Todos/template.tsx +0 -30
  194. package/dist/test/qwik/Todo/bundle.js +0 -46
  195. package/dist/test/qwik/Todo/component.ts +0 -17
  196. package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
  197. package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
  198. package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
  199. package/dist/test/qwik/Todo/onInputClick.ts +0 -13
  200. package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
  201. package/dist/test/qwik/Todo/public.ts +0 -3
  202. package/dist/test/qwik/Todo/template.tsx +0 -46
  203. package/dist/test/qwik/Todo.ts +0 -4
  204. package/dist/test/qwik/Todo_component.ts +0 -14
  205. package/dist/test/qwik/Todo_onButtonClick.ts +0 -10
  206. package/dist/test/qwik/Todo_onInput2Blur.ts +0 -11
  207. package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
  208. package/dist/test/qwik/Todo_onInputClick.ts +0 -10
  209. package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -11
  210. package/dist/test/qwik/Todo_template.tsx +0 -46
  211. package/dist/test/qwik/Todos/component.ts +0 -9
  212. package/dist/test/qwik/Todos/onInputClick.ts +0 -14
  213. package/dist/test/qwik/Todos/public.ts +0 -3
  214. package/dist/test/qwik/Todos/template.tsx +0 -30
  215. package/dist/test/qwik/Todos.ts +0 -3
  216. package/dist/test/qwik/Todos_component.ts +0 -9
  217. package/dist/test/qwik/Todos_onInputClick.ts +0 -14
  218. package/dist/test/qwik/Todos_template.tsx +0 -30
@@ -20,83 +20,83 @@ var image = require('./data/blocks/image.raw');
20
20
  var columns = require('./data/blocks/columns.raw');
21
21
  describe('Solid', function () {
22
22
  test('Basic', function () {
23
- var json = jsx_1.parseJsx(basic);
24
- var output = solid_1.componentToSolid(json);
23
+ var component = (0, jsx_1.parseJsx)(basic);
24
+ var output = (0, solid_1.componentToSolid)()({ component: component });
25
25
  expect(output).toMatchSnapshot();
26
26
  });
27
27
  test('Input block', function () {
28
- var json = jsx_1.parseJsx(inputBlock);
29
- var output = solid_1.componentToSolid(json);
28
+ var component = (0, jsx_1.parseJsx)(inputBlock);
29
+ var output = (0, solid_1.componentToSolid)()({ component: component });
30
30
  expect(output).toMatchSnapshot();
31
31
  });
32
32
  test('Submit button block', function () {
33
- var json = jsx_1.parseJsx(submitButtonBlock);
34
- var output = solid_1.componentToSolid(json);
33
+ var component = (0, jsx_1.parseJsx)(submitButtonBlock);
34
+ var output = (0, solid_1.componentToSolid)()({ component: component });
35
35
  expect(output).toMatchSnapshot();
36
36
  });
37
37
  test('Select block', function () {
38
- var json = jsx_1.parseJsx(selectBlock);
39
- var output = solid_1.componentToSolid(json);
38
+ var component = (0, jsx_1.parseJsx)(selectBlock);
39
+ var output = (0, solid_1.componentToSolid)()({ component: component });
40
40
  expect(output).toMatchSnapshot();
41
41
  });
42
42
  test('Form block', function () {
43
- var json = jsx_1.parseJsx(formBlock);
44
- var output = solid_1.componentToSolid(json);
43
+ var component = (0, jsx_1.parseJsx)(formBlock);
44
+ var output = (0, solid_1.componentToSolid)()({ component: component });
45
45
  expect(output).toMatchSnapshot();
46
46
  });
47
47
  test('Button', function () {
48
- var json = jsx_1.parseJsx(button);
49
- var output = solid_1.componentToSolid(json);
48
+ var component = (0, jsx_1.parseJsx)(button);
49
+ var output = (0, solid_1.componentToSolid)()({ component: component });
50
50
  expect(output).toMatchSnapshot();
51
51
  });
52
52
  test('Textarea', function () {
53
- var json = jsx_1.parseJsx(textarea);
54
- var output = solid_1.componentToSolid(json);
53
+ var component = (0, jsx_1.parseJsx)(textarea);
54
+ var output = (0, solid_1.componentToSolid)()({ component: component });
55
55
  expect(output).toMatchSnapshot();
56
56
  });
57
57
  test('Img', function () {
58
- var json = jsx_1.parseJsx(img);
59
- var output = solid_1.componentToSolid(json);
58
+ var component = (0, jsx_1.parseJsx)(img);
59
+ var output = (0, solid_1.componentToSolid)()({ component: component });
60
60
  expect(output).toMatchSnapshot();
61
61
  });
62
62
  test('Video', function () {
63
- var json = jsx_1.parseJsx(video);
64
- var output = solid_1.componentToSolid(json);
63
+ var component = (0, jsx_1.parseJsx)(video);
64
+ var output = (0, solid_1.componentToSolid)()({ component: component });
65
65
  expect(output).toMatchSnapshot();
66
66
  });
67
67
  test('Section', function () {
68
- var json = jsx_1.parseJsx(section);
69
- var output = solid_1.componentToSolid(json);
68
+ var component = (0, jsx_1.parseJsx)(section);
69
+ var output = (0, solid_1.componentToSolid)()({ component: component });
70
70
  expect(output).toMatchSnapshot();
71
71
  });
72
72
  test('Text', function () {
73
- var json = jsx_1.parseJsx(text);
74
- var output = solid_1.componentToSolid(json);
73
+ var component = (0, jsx_1.parseJsx)(text);
74
+ var output = (0, solid_1.componentToSolid)()({ component: component });
75
75
  expect(output).toMatchSnapshot();
76
76
  });
77
77
  test('RawText', function () {
78
- var json = jsx_1.parseJsx(rawText);
79
- var output = solid_1.componentToSolid(json);
78
+ var component = (0, jsx_1.parseJsx)(rawText);
79
+ var output = (0, solid_1.componentToSolid)()({ component: component });
80
80
  expect(output).toMatchSnapshot();
81
81
  });
82
82
  test('CustomCode', function () {
83
- var json = jsx_1.parseJsx(customCode);
84
- var output = solid_1.componentToSolid(json);
83
+ var component = (0, jsx_1.parseJsx)(customCode);
84
+ var output = (0, solid_1.componentToSolid)()({ component: component });
85
85
  expect(output).toMatchSnapshot();
86
86
  });
87
87
  test('Embed', function () {
88
- var json = jsx_1.parseJsx(customCode);
89
- var output = solid_1.componentToSolid(json);
88
+ var component = (0, jsx_1.parseJsx)(customCode);
89
+ var output = (0, solid_1.componentToSolid)()({ component: component });
90
90
  expect(output).toMatchSnapshot();
91
91
  });
92
92
  test('Image', function () {
93
- var json = jsx_1.parseJsx(image);
94
- var output = solid_1.componentToSolid(json);
93
+ var component = (0, jsx_1.parseJsx)(image);
94
+ var output = (0, solid_1.componentToSolid)()({ component: component });
95
95
  expect(output).toMatchSnapshot();
96
96
  });
97
97
  test('Columns', function () {
98
- var json = jsx_1.parseJsx(columns);
99
- var output = solid_1.componentToSolid(json);
98
+ var component = (0, jsx_1.parseJsx)(columns);
99
+ var output = (0, solid_1.componentToSolid)()({ component: component });
100
100
  expect(output).toMatchSnapshot();
101
101
  });
102
102
  });
@@ -19,90 +19,91 @@ var customCode = require('./data/blocks/custom-code.raw');
19
19
  var embed = require('./data/blocks/embed.raw');
20
20
  var image = require('./data/blocks/image.raw');
21
21
  var columns = require('./data/blocks/columns.raw');
22
+ var path = 'test-path';
22
23
  describe('Vue', function () {
23
24
  test('Basic', function () {
24
- var json = jsx_1.parseJsx(basic);
25
- var output = vue_1.componentToVue(json);
25
+ var component = (0, jsx_1.parseJsx)(basic);
26
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
26
27
  expect(output).toMatchSnapshot();
27
28
  });
28
29
  test('Input block', function () {
29
- var json = jsx_1.parseJsx(inputBlock);
30
- var output = vue_1.componentToVue(json);
30
+ var component = (0, jsx_1.parseJsx)(inputBlock);
31
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
31
32
  expect(output).toMatchSnapshot();
32
33
  });
33
34
  test('Submit button block', function () {
34
- var json = jsx_1.parseJsx(submitButtonBlock);
35
- var output = vue_1.componentToVue(json);
35
+ var component = (0, jsx_1.parseJsx)(submitButtonBlock);
36
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
36
37
  expect(output).toMatchSnapshot();
37
38
  });
38
39
  test('Select block', function () {
39
- var json = jsx_1.parseJsx(selectBlock);
40
- var output = vue_1.componentToVue(json);
40
+ var component = (0, jsx_1.parseJsx)(selectBlock);
41
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
41
42
  expect(output).toMatchSnapshot();
42
43
  });
43
44
  test('Form block', function () {
44
- var json = jsx_1.parseJsx(formBlock);
45
- var output = vue_1.componentToVue(json);
45
+ var component = (0, jsx_1.parseJsx)(formBlock);
46
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
46
47
  expect(output).toMatchSnapshot();
47
48
  });
48
49
  test('Button', function () {
49
- var json = jsx_1.parseJsx(button);
50
- var output = vue_1.componentToVue(json);
50
+ var component = (0, jsx_1.parseJsx)(button);
51
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
51
52
  expect(output).toMatchSnapshot();
52
53
  });
53
54
  test('Textarea', function () {
54
- var json = jsx_1.parseJsx(textarea);
55
- var output = vue_1.componentToVue(json);
55
+ var component = (0, jsx_1.parseJsx)(textarea);
56
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
56
57
  expect(output).toMatchSnapshot();
57
58
  });
58
59
  test('Img', function () {
59
- var json = jsx_1.parseJsx(img);
60
- var output = vue_1.componentToVue(json);
60
+ var component = (0, jsx_1.parseJsx)(img);
61
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
61
62
  expect(output).toMatchSnapshot();
62
63
  });
63
64
  test('Video', function () {
64
- var json = jsx_1.parseJsx(video);
65
- var output = vue_1.componentToVue(json);
65
+ var component = (0, jsx_1.parseJsx)(video);
66
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
66
67
  expect(output).toMatchSnapshot();
67
68
  });
68
69
  test('Section', function () {
69
- var json = jsx_1.parseJsx(section);
70
- var output = vue_1.componentToVue(json);
70
+ var component = (0, jsx_1.parseJsx)(section);
71
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
71
72
  expect(output).toMatchSnapshot();
72
73
  });
73
74
  test('Text', function () {
74
- var json = jsx_1.parseJsx(text);
75
- var output = vue_1.componentToVue(json);
75
+ var component = (0, jsx_1.parseJsx)(text);
76
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
76
77
  expect(output).toMatchSnapshot();
77
78
  });
78
79
  test('RawText', function () {
79
- var json = jsx_1.parseJsx(rawText);
80
- var output = vue_1.componentToVue(json);
80
+ var component = (0, jsx_1.parseJsx)(rawText);
81
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
81
82
  expect(output).toMatchSnapshot();
82
83
  });
83
84
  test('Stamped.io', function () {
84
- var json = jsx_1.parseJsx(stamped);
85
- var output = vue_1.componentToVue(json);
85
+ var component = (0, jsx_1.parseJsx)(stamped);
86
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
86
87
  expect(output).toMatchSnapshot();
87
88
  });
88
89
  test('CustomCode', function () {
89
- var json = jsx_1.parseJsx(customCode);
90
- var output = vue_1.componentToVue(json);
90
+ var component = (0, jsx_1.parseJsx)(customCode);
91
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
91
92
  expect(output).toMatchSnapshot();
92
93
  });
93
94
  test('Embed', function () {
94
- var json = jsx_1.parseJsx(customCode);
95
- var output = vue_1.componentToVue(json);
95
+ var component = (0, jsx_1.parseJsx)(customCode);
96
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
96
97
  expect(output).toMatchSnapshot();
97
98
  });
98
99
  test('Image', function () {
99
- var json = jsx_1.parseJsx(image);
100
- var output = vue_1.componentToVue(json);
100
+ var component = (0, jsx_1.parseJsx)(image);
101
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
101
102
  expect(output).toMatchSnapshot();
102
103
  });
103
104
  test('Columns', function () {
104
- var json = jsx_1.parseJsx(columns);
105
- var output = vue_1.componentToVue(json);
105
+ var component = (0, jsx_1.parseJsx)(columns);
106
+ var output = (0, vue_1.componentToVue)()({ component: component, path: path });
106
107
  expect(output).toMatchSnapshot();
107
108
  });
108
109
  });
@@ -1,9 +1,6 @@
1
- import { MitosisComponent } from '../types/mitosis-component';
2
1
  import { MitosisNode } from '../types/mitosis-node';
3
- import { Plugin } from '../modules/plugins';
4
- export declare type ToAngularOptions = {
5
- prettier?: boolean;
6
- plugins?: Plugin[];
7
- };
2
+ import { BaseTranspilerOptions, Transpiler } from '../types/config';
3
+ export interface ToAngularOptions extends BaseTranspilerOptions {
4
+ }
8
5
  export declare const blockToAngular: (json: MitosisNode, options?: ToAngularOptions) => string;
9
- export declare const componentToAngular: (componentJson: MitosisComponent, options?: ToAngularOptions) => string;
6
+ export declare const componentToAngular: (options?: ToAngularOptions) => Transpiler;
@@ -26,9 +26,9 @@ var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
26
26
  var remove_surrounding_block_1 = require("../helpers/remove-surrounding-block");
27
27
  var mappers = {
28
28
  Fragment: function (json, options) {
29
- return "<div>" + json.children
30
- .map(function (item) { return exports.blockToAngular(item, options); })
31
- .join('\n') + "</div>";
29
+ return "<div>".concat(json.children
30
+ .map(function (item) { return (0, exports.blockToAngular)(item, options); })
31
+ .join('\n'), "</div>");
32
32
  },
33
33
  };
34
34
  var blockToAngular = function (json, options) {
@@ -36,32 +36,32 @@ var blockToAngular = function (json, options) {
36
36
  if (mappers[json.name]) {
37
37
  return mappers[json.name](json, options);
38
38
  }
39
- if (is_children_1.default(json)) {
39
+ if ((0, is_children_1.default)(json)) {
40
40
  return "<ng-slot></ng-slot>";
41
41
  }
42
42
  if (json.properties._text) {
43
43
  return json.properties._text;
44
44
  }
45
45
  if (json.bindings._text) {
46
- return "{{" + strip_state_and_props_refs_1.stripStateAndPropsRefs(json.bindings._text) + "}}";
46
+ return "{{".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings._text), "}}");
47
47
  }
48
48
  var str = '';
49
49
  if (json.name === 'For') {
50
- str += "<ng-container *ngFor=\"let " + json.properties._forName + " of " + strip_state_and_props_refs_1.stripStateAndPropsRefs(json.bindings.each) + "\">";
50
+ str += "<ng-container *ngFor=\"let ".concat(json.properties._forName, " of ").concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.each), "\">");
51
51
  str += json.children
52
- .map(function (item) { return exports.blockToAngular(item, options); })
52
+ .map(function (item) { return (0, exports.blockToAngular)(item, options); })
53
53
  .join('\n');
54
54
  str += "</ng-container>";
55
55
  }
56
56
  else if (json.name === 'Show') {
57
- str += "<ng-container *ngIf=\"" + strip_state_and_props_refs_1.stripStateAndPropsRefs(json.bindings.when) + "\">";
57
+ str += "<ng-container *ngIf=\"".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.bindings.when), "\">");
58
58
  str += json.children
59
- .map(function (item) { return exports.blockToAngular(item, options); })
59
+ .map(function (item) { return (0, exports.blockToAngular)(item, options); })
60
60
  .join('\n');
61
61
  str += "</ng-container>";
62
62
  }
63
63
  else {
64
- str += "<" + json.name + " ";
64
+ str += "<".concat(json.name, " ");
65
65
  // TODO: spread support for angular
66
66
  // if (json.bindings._spread) {
67
67
  // str += `v-bind="${stripStateAndPropsRefs(
@@ -73,7 +73,7 @@ var blockToAngular = function (json, options) {
73
73
  continue;
74
74
  }
75
75
  var value = json.properties[key];
76
- str += " " + key + "=\"" + value + "\" ";
76
+ str += " ".concat(key, "=\"").concat(value, "\" ");
77
77
  }
78
78
  for (var key in json.bindings) {
79
79
  if (key === '_spread') {
@@ -84,7 +84,7 @@ var blockToAngular = function (json, options) {
84
84
  }
85
85
  var value = json.bindings[key];
86
86
  // TODO: proper babel transform to replace. Util for this
87
- var useValue = strip_state_and_props_refs_1.stripStateAndPropsRefs(value);
87
+ var useValue = (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(value);
88
88
  if (key.startsWith('on')) {
89
89
  var event_1 = key.replace('on', '').toLowerCase();
90
90
  if (event_1 === 'change' &&
@@ -92,14 +92,14 @@ var blockToAngular = function (json, options) {
92
92
  event_1 = 'input';
93
93
  }
94
94
  // TODO: proper babel transform to replace. Util for this
95
- var finalValue = remove_surrounding_block_1.removeSurroundingBlock(useValue.replace(/event\./g, '$event.'));
96
- str += " (" + event_1 + ")=\"" + finalValue + "\" ";
95
+ var finalValue = (0, remove_surrounding_block_1.removeSurroundingBlock)(useValue.replace(/event\./g, '$event.'));
96
+ str += " (".concat(event_1, ")=\"").concat(finalValue, "\" ");
97
97
  }
98
98
  else if (key === 'ref') {
99
- str += " #" + useValue + " ";
99
+ str += " #".concat(useValue, " ");
100
100
  }
101
101
  else {
102
- str += " [" + key + "]=\"" + useValue + "\" ";
102
+ str += " [".concat(key, "]=\"").concat(useValue, "\" ");
103
103
  }
104
104
  }
105
105
  if (jsx_1.selfClosingTags.has(json.name)) {
@@ -108,85 +108,81 @@ var blockToAngular = function (json, options) {
108
108
  str += '>';
109
109
  if (json.children) {
110
110
  str += json.children
111
- .map(function (item) { return exports.blockToAngular(item, options); })
111
+ .map(function (item) { return (0, exports.blockToAngular)(item, options); })
112
112
  .join('\n');
113
113
  }
114
- str += "</" + json.name + ">";
114
+ str += "</".concat(json.name, ">");
115
115
  }
116
116
  return str;
117
117
  };
118
118
  exports.blockToAngular = blockToAngular;
119
119
  var indent = function (str, spaces) {
120
120
  if (spaces === void 0) { spaces = 4; }
121
- return str.replace(/\n([^\n])/g, "\n" + ' '.repeat(spaces) + "$1");
121
+ return str.replace(/\n([^\n])/g, "\n".concat(' '.repeat(spaces), "$1"));
122
122
  };
123
- var componentToAngular = function (componentJson, options) {
123
+ var componentToAngular = function (options) {
124
124
  if (options === void 0) { options = {}; }
125
- // Make a copy we can safely mutate, similar to babel's toolchain
126
- var json = fast_clone_1.fastClone(componentJson);
127
- if (options.plugins) {
128
- json = plugins_1.runPreJsonPlugins(json, options.plugins);
129
- }
130
- var props = get_props_1.getProps(componentJson);
131
- var refs = Array.from(get_refs_1.getRefs(json));
132
- map_refs_1.mapRefs(json, function (refName) { return "this." + refName + ".nativeElement"; });
133
- if (options.plugins) {
134
- json = plugins_1.runPostJsonPlugins(json, options.plugins);
135
- }
136
- var css = collect_styles_1.collectCss(json);
137
- if (options.prettier !== false) {
138
- css = tryFormat(css, 'css');
139
- }
140
- var template = json.children.map(function (item) { return exports.blockToAngular(item); }).join('\n');
141
- if (options.prettier !== false) {
142
- template = tryFormat(template, 'html');
143
- }
144
- strip_meta_properties_1.stripMetaProperties(json);
145
- var dataString = get_state_object_string_1.getStateObjectStringFromComponent(json, {
146
- format: 'class',
147
- valueMapper: function (code) {
148
- return strip_state_and_props_refs_1.stripStateAndPropsRefs(code, { replaceWith: 'this.' });
149
- },
150
- });
151
- var str = dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n }\n "], ["\n import { Component ", "",
152
- " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: \\`\n ",
153
- "\n \\`,\n ",
154
- "\n })\n export default class ", " {\n ",
155
- "\n\n ",
156
- "\n\n ",
157
- "\n\n ",
158
- "\n\n ", "\n }\n "])), refs.length ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', render_imports_1.renderPreComponent(json), lodash_1.kebabCase(json.name || 'my-component'), indent(template, 8)
159
- .replace(/`/g, '\\`')
160
- .replace(/\$\{/g, '\\${'), css.length
161
- ? "styles: [\n `" + indent(css, 8) + "`\n ],"
162
- : '', componentJson.name, Array.from(props)
163
- .map(function (item) { return "@Input() " + item + ": any"; })
164
- .join('\n'), refs
165
- .map(function (refName) { return "@ViewChild('" + refName + "') " + refName + ": ElementRef"; })
166
- .join('\n'), !componentJson.hooks.onMount
167
- ? ''
168
- : "ngOnInit() {\n " + strip_state_and_props_refs_1.stripStateAndPropsRefs(componentJson.hooks.onMount, {
169
- replaceWith: 'this.',
170
- }) + "\n }", !componentJson.hooks.onUnMount
171
- ? ''
172
- : "ngOnDestroy() {\n " + strip_state_and_props_refs_1.stripStateAndPropsRefs(componentJson.hooks.onUnMount, {
173
- replaceWith: 'this.',
174
- }) + "\n }", dataString);
175
- if (options.plugins) {
176
- str = plugins_1.runPreCodePlugins(str, options.plugins);
177
- }
178
- if (options.prettier !== false) {
179
- str = tryFormat(str, 'typescript');
180
- }
181
- if (options.plugins) {
182
- str = plugins_1.runPostCodePlugins(str, options.plugins);
183
- }
184
- return str;
125
+ return function (_a) {
126
+ var component = _a.component;
127
+ // Make a copy we can safely mutate, similar to babel's toolchain
128
+ var json = (0, fast_clone_1.fastClone)(component);
129
+ if (options.plugins) {
130
+ json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
131
+ }
132
+ var props = (0, get_props_1.getProps)(component);
133
+ var refs = Array.from((0, get_refs_1.getRefs)(json));
134
+ (0, map_refs_1.mapRefs)(json, function (refName) { return "this.".concat(refName, ".nativeElement"); });
135
+ if (options.plugins) {
136
+ json = (0, plugins_1.runPostJsonPlugins)(json, options.plugins);
137
+ }
138
+ var css = (0, collect_styles_1.collectCss)(json);
139
+ if (options.prettier !== false) {
140
+ css = tryFormat(css, 'css');
141
+ }
142
+ var template = json.children.map(function (item) { return (0, exports.blockToAngular)(item); }).join('\n');
143
+ if (options.prettier !== false) {
144
+ template = tryFormat(template, 'html');
145
+ }
146
+ (0, strip_meta_properties_1.stripMetaProperties)(json);
147
+ var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
148
+ format: 'class',
149
+ valueMapper: function (code) {
150
+ return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, { replaceWith: 'this.' });
151
+ },
152
+ });
153
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: `\n ", "\n `,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n }\n "], ["\n import { Component ", "", " } from '@angular/core';\n ", "\n\n @Component({\n selector: '", "',\n template: \\`\n ", "\n \\`,\n ", "\n })\n export default class ", " {\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n }\n "])), refs.length ? ', ViewChild, ElementRef' : '', props.size ? ', Input' : '', (0, render_imports_1.renderPreComponent)(json), (0, lodash_1.kebabCase)(json.name || 'my-component'), indent(template, 8)
154
+ .replace(/`/g, '\\`')
155
+ .replace(/\$\{/g, '\\${'), css.length
156
+ ? "styles: [\n `".concat(indent(css, 8), "`\n ],")
157
+ : '', component.name, Array.from(props)
158
+ .map(function (item) { return "@Input() ".concat(item, ": any"); })
159
+ .join('\n'), refs
160
+ .map(function (refName) { return "@ViewChild('".concat(refName, "') ").concat(refName, ": ElementRef"); })
161
+ .join('\n'), !component.hooks.onMount
162
+ ? ''
163
+ : "ngOnInit() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onMount, {
164
+ replaceWith: 'this.',
165
+ }), "\n }"), !component.hooks.onUnMount
166
+ ? ''
167
+ : "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onUnMount, {
168
+ replaceWith: 'this.',
169
+ }), "\n }"), dataString);
170
+ if (options.plugins) {
171
+ str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
172
+ }
173
+ if (options.prettier !== false) {
174
+ str = tryFormat(str, 'typescript');
175
+ }
176
+ if (options.plugins) {
177
+ str = (0, plugins_1.runPostCodePlugins)(str, options.plugins);
178
+ }
179
+ return str;
180
+ };
185
181
  };
186
182
  exports.componentToAngular = componentToAngular;
187
183
  var tryFormat = function (str, parser) {
188
184
  try {
189
- return standalone_1.format(str, {
185
+ return (0, standalone_1.format)(str, {
190
186
  parser: parser,
191
187
  plugins: [
192
188
  // To support running in browsers
@@ -1,14 +1,14 @@
1
- import { MitosisComponent } from '../types/mitosis-component';
2
1
  import { MitosisNode } from '../types/mitosis-node';
3
2
  import { BuilderElement } from '@builder.io/sdk';
4
- export declare type ToBuilderOptions = {
3
+ import { TranspilerArgs } from '../types/config';
4
+ export interface ToBuilderOptions {
5
5
  includeIds?: boolean;
6
- };
6
+ }
7
7
  declare type InternalOptions = {
8
8
  skipMapper?: boolean;
9
9
  };
10
10
  export declare const blockToBuilder: (json: MitosisNode, options?: ToBuilderOptions, _internalOptions?: InternalOptions) => BuilderElement;
11
- export declare const componentToBuilder: (componentJson: MitosisComponent, options?: ToBuilderOptions) => {
11
+ export declare const componentToBuilder: (options?: ToBuilderOptions) => ({ component, }: TranspilerArgs) => {
12
12
  data: {
13
13
  httpRequests: any;
14
14
  jsCode: string;