@builder.io/mitosis 0.0.56-13 → 0.0.56-16

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 (217) hide show
  1. package/dist/src/__tests__/angular.test.js +2 -104
  2. package/dist/src/__tests__/builder.test.js +3 -3
  3. package/dist/src/__tests__/data/basic-child-component.raw.jsx +1 -2
  4. package/dist/src/__tests__/data/basic-context.raw.d.ts +1 -0
  5. package/dist/src/__tests__/data/basic-context.raw.jsx +29 -0
  6. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.d.ts +1 -0
  7. package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.jsx +10 -0
  8. package/dist/src/__tests__/data/basic-for-show.raw.jsx +2 -3
  9. package/dist/src/__tests__/data/basic-for.raw.jsx +2 -3
  10. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.d.ts +5 -0
  11. package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.jsx +17 -0
  12. package/dist/src/__tests__/data/basic-forwardRef.raw.d.ts +5 -0
  13. package/dist/src/__tests__/data/basic-forwardRef.raw.jsx +14 -0
  14. package/dist/src/__tests__/data/basic-onChange.raw.d.ts +1 -0
  15. package/dist/src/__tests__/data/basic-onChange.raw.jsx +17 -0
  16. package/dist/src/__tests__/data/basic-onMount-update.raw.jsx +1 -1
  17. package/dist/src/__tests__/data/basic-onUpdate-return.raw.d.ts +1 -0
  18. package/dist/src/__tests__/data/basic-onUpdate-return.raw.jsx +24 -0
  19. package/dist/src/__tests__/data/basic-outputs-meta.raw.jsx +1 -1
  20. package/dist/src/__tests__/data/basic-outputs.raw.jsx +1 -1
  21. package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.d.ts +6 -0
  22. package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.jsx +14 -0
  23. package/dist/src/__tests__/data/basic-props-destructure.raw.d.ts +6 -0
  24. package/dist/src/__tests__/data/basic-props-destructure.raw.jsx +14 -0
  25. package/dist/src/__tests__/data/basic-props.raw.d.ts +6 -0
  26. package/dist/src/__tests__/data/basic-props.raw.jsx +13 -0
  27. package/dist/src/__tests__/data/basic-ref-assignment.raw.d.ts +4 -0
  28. package/dist/src/__tests__/data/basic-ref-assignment.raw.jsx +15 -0
  29. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.d.ts +5 -0
  30. package/dist/src/__tests__/data/basic-ref-usePrevious.raw.jsx +35 -0
  31. package/dist/src/__tests__/data/basic-ref.raw.d.ts +4 -0
  32. package/dist/src/__tests__/data/basic-ref.raw.jsx +36 -0
  33. package/dist/src/__tests__/data/basic.raw.d.ts +6 -1
  34. package/dist/src/__tests__/data/basic.raw.jsx +10 -3
  35. package/dist/src/__tests__/data/blocks/classname-jsx.raw.jsx +1 -1
  36. package/dist/src/__tests__/data/blocks/columns.raw.jsx +1 -1
  37. package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -7
  38. package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -7
  39. package/dist/src/__tests__/data/blocks/form.raw.jsx +3 -3
  40. package/dist/src/__tests__/data/blocks/image.raw.jsx +8 -9
  41. package/dist/src/__tests__/data/blocks/img-state.raw.jsx +1 -1
  42. package/dist/src/__tests__/data/blocks/input.raw.jsx +1 -3
  43. package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.jsx +7 -1
  44. package/dist/src/__tests__/data/blocks/onInit.raw.d.ts +8 -1
  45. package/dist/src/__tests__/data/blocks/onInit.raw.jsx +13 -3
  46. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +1 -1
  47. package/dist/src/__tests__/data/blocks/section-state.raw.jsx +1 -1
  48. package/dist/src/__tests__/data/blocks/select.raw.jsx +1 -3
  49. package/dist/src/__tests__/data/blocks/shadow-dom.raw.jsx +2 -4
  50. package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +2 -4
  51. package/dist/src/__tests__/data/blocks/text.raw.jsx +2 -5
  52. package/dist/src/__tests__/data/styles/class-and-className.raw.jsx +1 -3
  53. package/dist/src/__tests__/data/styles/className.raw.jsx +1 -3
  54. package/dist/src/__tests__/data/styles/classState.raw.d.ts +1 -0
  55. package/dist/src/__tests__/data/styles/classState.raw.jsx +12 -0
  56. package/dist/src/__tests__/data/types/component-props-interface.raw.d.ts +6 -0
  57. package/dist/src/__tests__/data/types/component-props-interface.raw.jsx +6 -0
  58. package/dist/src/__tests__/data/types/component-props-type.raw.d.ts +6 -0
  59. package/dist/src/__tests__/data/types/component-props-type.raw.jsx +6 -0
  60. package/dist/src/__tests__/data/types/preserve-typing.raw.d.ts +8 -0
  61. package/dist/src/__tests__/data/types/preserve-typing.raw.jsx +6 -0
  62. package/dist/src/__tests__/html.test.js +2 -145
  63. package/dist/src/__tests__/liquid.test.js +2 -109
  64. package/dist/src/__tests__/parse-jsx.test.js +22 -0
  65. package/dist/src/__tests__/qwik/convertMethodToFunction.test.d.ts +1 -0
  66. package/dist/src/__tests__/qwik/convertMethodToFunction.test.js +34 -0
  67. package/dist/src/__tests__/qwik/src-generator.test.d.ts +1 -0
  68. package/dist/src/__tests__/qwik/src-generator.test.js +65 -0
  69. package/dist/src/__tests__/qwik.test.js +44 -21
  70. package/dist/src/__tests__/react-native.test.js +2 -135
  71. package/dist/src/__tests__/react.test.js +5 -177
  72. package/dist/src/__tests__/shared.d.ts +3 -0
  73. package/dist/src/__tests__/shared.js +224 -0
  74. package/dist/src/__tests__/solid.test.js +2 -103
  75. package/dist/src/__tests__/stencil.test.js +3 -98
  76. package/dist/src/__tests__/styles.test.js +9 -1
  77. package/dist/src/__tests__/svelte.test.js +6 -0
  78. package/dist/src/__tests__/vue.test.js +2 -134
  79. package/dist/src/__tests__/webcomponent.test.js +6 -165
  80. package/dist/src/constants/hooks.d.ts +6 -0
  81. package/dist/src/constants/hooks.js +9 -0
  82. package/dist/src/generators/angular.d.ts +1 -1
  83. package/dist/src/generators/angular.js +66 -34
  84. package/dist/src/generators/builder.d.ts +1 -1
  85. package/dist/src/generators/builder.js +6 -12
  86. package/dist/src/generators/context/{react copy.d.ts → qwik.d.ts} +2 -2
  87. package/dist/src/generators/context/{react copy.js → qwik.js} +4 -5
  88. package/dist/src/generators/context/svelte.d.ts +1 -1
  89. package/dist/src/generators/helpers/context.js +1 -2
  90. package/dist/src/generators/html.d.ts +1 -1
  91. package/dist/src/generators/html.js +206 -120
  92. package/dist/src/generators/liquid.d.ts +1 -1
  93. package/dist/src/generators/liquid.js +6 -14
  94. package/dist/src/generators/mitosis.d.ts +1 -1
  95. package/dist/src/generators/mitosis.js +30 -29
  96. package/dist/src/generators/qwik/component-generator.d.ts +4 -0
  97. package/dist/src/generators/qwik/component-generator.js +271 -0
  98. package/dist/src/generators/qwik/component.js +4 -5
  99. package/dist/src/generators/qwik/convertMethodToFunction.d.ts +1 -0
  100. package/dist/src/generators/qwik/convertMethodToFunction.js +161 -0
  101. package/dist/src/generators/qwik/directives.js +20 -18
  102. package/dist/src/generators/qwik/index.d.ts +3 -1
  103. package/dist/src/generators/qwik/index.js +3 -1
  104. package/dist/src/generators/qwik/jsx.js +10 -6
  105. package/dist/src/generators/qwik/src-generator.d.ts +19 -7
  106. package/dist/src/generators/qwik/src-generator.js +149 -31
  107. package/dist/src/generators/qwik/styles.js +1 -2
  108. package/dist/src/generators/react-native.d.ts +2 -2
  109. package/dist/src/generators/react-native.js +3 -6
  110. package/dist/src/generators/react.d.ts +4 -2
  111. package/dist/src/generators/react.js +88 -68
  112. package/dist/src/generators/solid.d.ts +1 -1
  113. package/dist/src/generators/solid.js +9 -12
  114. package/dist/src/generators/stencil/generate.d.ts +1 -1
  115. package/dist/src/generators/stencil/generate.js +5 -11
  116. package/dist/src/generators/svelte.d.ts +1 -1
  117. package/dist/src/generators/svelte.js +19 -26
  118. package/dist/src/generators/swift-ui.d.ts +1 -1
  119. package/dist/src/generators/swift-ui.js +6 -12
  120. package/dist/src/generators/template.d.ts +1 -1
  121. package/dist/src/generators/template.js +6 -14
  122. package/dist/src/generators/vue.d.ts +12 -6
  123. package/dist/src/generators/vue.js +62 -31
  124. package/dist/src/helpers/babel-transform.js +3 -8
  125. package/dist/src/helpers/create-mitosis-component.d.ts +1 -1
  126. package/dist/src/helpers/create-mitosis-component.js +1 -1
  127. package/dist/src/helpers/fast-clone.js +1 -3
  128. package/dist/src/helpers/filter-empty-text-nodes.js +1 -2
  129. package/dist/src/helpers/get-bindings.d.ts +2 -0
  130. package/dist/src/helpers/get-bindings.js +18 -0
  131. package/dist/src/helpers/get-props-ref.d.ts +2 -0
  132. package/dist/src/helpers/get-props-ref.js +32 -0
  133. package/dist/src/helpers/getters-to-functions.d.ts +1 -1
  134. package/dist/src/helpers/getters-to-functions.js +1 -1
  135. package/dist/src/helpers/has-bindings-text.d.ts +2 -0
  136. package/dist/src/helpers/has-bindings-text.js +21 -0
  137. package/dist/src/helpers/has-stateful-dom.d.ts +2 -0
  138. package/dist/src/helpers/has-stateful-dom.js +21 -0
  139. package/dist/src/helpers/is-children.js +1 -2
  140. package/dist/src/helpers/is-component.js +1 -3
  141. package/dist/src/helpers/is-html-attribute.d.ts +1 -1
  142. package/dist/src/helpers/is-html-attribute.js +4 -19
  143. package/dist/src/helpers/map-refs.js +4 -1
  144. package/dist/src/helpers/parsers.js +1 -2
  145. package/dist/src/helpers/render-imports.d.ts +18 -2
  146. package/dist/src/helpers/render-imports.js +86 -45
  147. package/dist/src/helpers/render-imports.test.d.ts +1 -0
  148. package/dist/src/helpers/render-imports.test.js +19 -0
  149. package/dist/src/helpers/replace-idenifiers.js +2 -5
  150. package/dist/src/helpers/strip-state-and-props-refs.d.ts +2 -1
  151. package/dist/src/helpers/strip-state-and-props-refs.js +5 -8
  152. package/dist/src/helpers/styles/collect-css.d.ts +6 -0
  153. package/dist/src/helpers/styles/collect-css.js +87 -0
  154. package/dist/src/helpers/styles/collect-css.test.d.ts +1 -0
  155. package/dist/src/helpers/styles/collect-css.test.js +18 -0
  156. package/dist/src/helpers/styles/collect-styled-components.d.ts +2 -0
  157. package/dist/src/helpers/styles/collect-styled-components.js +61 -0
  158. package/dist/src/helpers/styles/helpers.d.ts +30 -0
  159. package/dist/src/helpers/styles/helpers.js +61 -0
  160. package/dist/src/helpers/typescript.d.ts +2 -0
  161. package/dist/src/helpers/typescript.js +2 -0
  162. package/dist/src/index.d.ts +7 -4
  163. package/dist/src/index.js +24 -8
  164. package/dist/src/jsx-types.d.ts +1 -0
  165. package/dist/src/modules/plugins.d.ts +1 -1
  166. package/dist/src/parsers/angular.js +10 -28
  167. package/dist/src/parsers/builder.d.ts +23 -23
  168. package/dist/src/parsers/builder.js +15 -33
  169. package/dist/src/parsers/jsx.d.ts +2 -1
  170. package/dist/src/parsers/jsx.js +214 -64
  171. package/dist/src/parsers/liquid.js +51 -149
  172. package/dist/src/plugins/compile-away-builder-components.js +4 -10
  173. package/dist/src/symbols/symbol-processor.js +4 -6
  174. package/dist/src/targets.d.ts +5 -3
  175. package/dist/src/targets.js +7 -1
  176. package/dist/src/types/config.d.ts +37 -17
  177. package/dist/src/types/mitosis-component.d.ts +30 -10
  178. package/dist/src/types/transpiler.d.ts +14 -0
  179. package/dist/src/types/transpiler.js +2 -0
  180. package/dist/test/qwik/Accordion/low.jsx +1 -0
  181. package/dist/test/qwik/For/low.jsx +1 -0
  182. package/dist/test/qwik/Image/med.js +2 -1
  183. package/dist/test/qwik/Image.slow/med.js +2 -1
  184. package/dist/test/qwik/bindings/low.cjs +3 -2
  185. package/dist/test/qwik/button/low.js +1 -0
  186. package/dist/test/qwik/component/bindings/low.jsx +2 -1
  187. package/dist/test/qwik/component/component/inputs/med.cjsx +2 -1
  188. package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
  189. package/dist/test/qwik/for-loop.bindings/low.cjs +47 -0
  190. package/dist/test/qwik/for-loop.bindings/med.cjs +5 -0
  191. package/dist/test/qwik/hello_world/stylesheet/low.jsx +1 -0
  192. package/dist/test/qwik/mount/high.cjs +0 -0
  193. package/dist/test/qwik/mount/low.cjs +44 -0
  194. package/dist/test/qwik/mount/med.cjs +3 -0
  195. package/dist/test/qwik/page-with-symbol/low.js +1 -0
  196. package/dist/test/qwik/show-hide/med.jsx +2 -1
  197. package/dist/test/qwik/svg/low.js +1 -0
  198. package/dist/test/qwik/todo/Todo.cjs/med.cjs +1 -0
  199. package/dist/test/qwik/todo/Todo.js/med.js +1 -0
  200. package/dist/test/qwik/todo/Todo.tsx/med.tsx +1 -0
  201. package/dist/test/qwik/todos/Todo.tsx/low.tsx +1 -0
  202. package/dist/tsconfig.build.tsbuildinfo +1 -1
  203. package/dist/tsconfig.tsbuildinfo +1 -1
  204. package/package.json +6 -3
  205. package/README.md +0 -239
  206. package/dist/src/__tests__/data/blocks/content-slot.raw.d.ts +0 -6
  207. package/dist/src/__tests__/data/blocks/content-slot.raw.jsx +0 -13
  208. package/dist/src/__tests__/data/blocks/onUpdate.raw copy.d.ts +0 -1
  209. package/dist/src/__tests__/data/blocks/onUpdate.raw copy.jsx +0 -10
  210. package/dist/src/__tests__/data/blocks/slot.raw.d.ts +0 -5
  211. package/dist/src/__tests__/data/blocks/slot.raw.jsx +0 -6
  212. package/dist/src/__tests__/data/blocks/styles.raw.d.ts +0 -1
  213. package/dist/src/__tests__/data/blocks/styles.raw.jsx +0 -10
  214. package/dist/src/helpers/babel-transform copy.d.ts +0 -8
  215. package/dist/src/helpers/babel-transform copy.js +0 -138
  216. package/dist/src/helpers/collect-styles.d.ts +0 -29
  217. package/dist/src/helpers/collect-styles.js +0 -176
@@ -1,109 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var angular_1 = require("../generators/angular");
4
- var jsx_1 = require("../parsers/jsx");
5
- var multipleOnUpdate = require('./data/blocks/multiple-onUpdate.raw');
6
- var onUpdate = require('./data/blocks/onUpdate.raw');
7
- var onMount = require('./data/blocks/onMount.raw');
8
- var onInitonMount = require('./data/blocks/onInit-onMount.raw');
9
- var onInit = require('./data/blocks/onInit.raw');
10
- var basicFor = require('./data/basic-for.raw');
11
- var basic = require('./data/basic.raw');
12
- var basicChildComponent = require('./data/basic-child-component.raw');
13
- var basicOutputsMeta = require('./data/basic-outputs-meta.raw');
14
- var basicOutputs = require('./data/basic-outputs.raw');
15
- var contentSlotHtml = require('./data/blocks/content-slot-html.raw');
16
- var contentSlotJsx = require('./data/blocks/content-slot-jsx.raw');
17
- var slotJsx = require('./data/blocks/slot-jsx.raw');
18
- var classNameJsx = require('./data/blocks/classname-jsx.raw');
19
- var text = require('./data/blocks/text.raw');
20
- // const slotHtml = require('./data/blocks/slot-html.raw');
4
+ var shared_1 = require("./shared");
21
5
  describe('Angular', function () {
22
- test('Basic', function () {
23
- var component = (0, jsx_1.parseJsx)(basic);
24
- var output = (0, angular_1.componentToAngular)()({ component: component });
25
- expect(output).toMatchSnapshot();
26
- });
27
- test('Basic Child Component', function () {
28
- var component = (0, jsx_1.parseJsx)(basicChildComponent);
29
- var output = (0, angular_1.componentToAngular)()({ component: component });
30
- expect(output).toMatchSnapshot();
31
- });
32
- test('basic outputs meta', function () {
33
- var component = (0, jsx_1.parseJsx)(basicOutputsMeta);
34
- var output = (0, angular_1.componentToAngular)()({ component: component });
35
- expect(output).toMatchSnapshot();
36
- });
37
- test('basic outputs', function () {
38
- var component = (0, jsx_1.parseJsx)(basicOutputs);
39
- var output = (0, angular_1.componentToAngular)()({ component: component });
40
- expect(output).toMatchSnapshot();
41
- });
42
- test('basic outputs same as meta', function () {
43
- var component = (0, jsx_1.parseJsx)(basicOutputs);
44
- var componentMeta = (0, jsx_1.parseJsx)(basicOutputsMeta);
45
- var output = (0, angular_1.componentToAngular)()({ component: component });
46
- var outputMeta = (0, angular_1.componentToAngular)()({ component: componentMeta });
47
- expect(output).toMatch(outputMeta);
48
- });
49
- test('multiple onUpdate', function () {
50
- var component = (0, jsx_1.parseJsx)(multipleOnUpdate);
51
- var output = (0, angular_1.componentToAngular)()({ component: component });
52
- expect(output).toMatchSnapshot();
53
- });
54
- test('onUpdate', function () {
55
- var component = (0, jsx_1.parseJsx)(onUpdate);
56
- var output = (0, angular_1.componentToAngular)()({ component: component });
57
- expect(output).toMatchSnapshot();
58
- });
59
- test('onMount', function () {
60
- var component = (0, jsx_1.parseJsx)(onMount);
61
- var output = (0, angular_1.componentToAngular)()({ component: component });
62
- expect(output).toMatchSnapshot();
63
- });
64
- test('onInit and onMount', function () {
65
- var component = (0, jsx_1.parseJsx)(onInitonMount);
66
- var output = (0, angular_1.componentToAngular)()({ component: component });
67
- expect(output).toMatchSnapshot();
68
- });
69
- test('onInit', function () {
70
- var component = (0, jsx_1.parseJsx)(onInit);
71
- var output = (0, angular_1.componentToAngular)()({ component: component });
72
- expect(output).toMatchSnapshot();
73
- });
74
- test('BasicFor', function () {
75
- var component = (0, jsx_1.parseJsx)(basicFor);
76
- var output = (0, angular_1.componentToAngular)()({ component: component });
77
- expect(output).toMatchSnapshot();
78
- });
79
- test('ng-content and Slot', function () {
80
- var component = (0, jsx_1.parseJsx)(contentSlotHtml);
81
- var output = (0, angular_1.componentToAngular)()({ component: component });
82
- expect(output).toMatchSnapshot();
83
- });
84
- test('ng-content and Slot jsx-props', function () {
85
- var component = (0, jsx_1.parseJsx)(contentSlotJsx);
86
- var output = (0, angular_1.componentToAngular)()({ component: component });
87
- expect(output).toMatchSnapshot();
88
- });
89
- test('Slot Jsx', function () {
90
- var component = (0, jsx_1.parseJsx)(slotJsx);
91
- var output = (0, angular_1.componentToAngular)()({ component: component });
92
- expect(output).toMatchSnapshot();
93
- });
94
- // test('Slot Html', () => {
95
- // const component = parseJsx(slotHtml);
96
- // const output = componentToAngular()({ component });
97
- // expect(output).toMatchSnapshot();
98
- // });
99
- test('className to class', function () {
100
- var component = (0, jsx_1.parseJsx)(classNameJsx);
101
- var output = (0, angular_1.componentToAngular)()({ component: component });
102
- expect(output).toMatchSnapshot();
103
- });
104
- test('Text', function () {
105
- var component = (0, jsx_1.parseJsx)(text);
106
- var output = (0, angular_1.componentToAngular)()({ component: component });
107
- expect(output).toMatchSnapshot();
108
- });
6
+ (0, shared_1.runTestsForTarget)('angular', (0, angular_1.componentToAngular)());
109
7
  });
@@ -160,7 +160,7 @@ describe('Builder', function () {
160
160
  });
161
161
  }); });
162
162
  test('Regenerate Image', function () {
163
- var code = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { useState } from \"@builder.io/mitosis\";\n import { Image } from \"@components\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <Image\n image=\"https://cdn.builder.io/api/v1/image/foobar\"\n sizes=\"100vw\"\n backgroundSize=\"contain\"\n css={{\n marignTop: \"50px\",\n display: \"block\",\n }}\n />\n </div>\n );\n }\n "], ["\n import { useState } from \"@builder.io/mitosis\";\n import { Image } from \"@components\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <Image\n image=\"https://cdn.builder.io/api/v1/image/foobar\"\n sizes=\"100vw\"\n backgroundSize=\"contain\"\n css={{\n marignTop: \"50px\",\n display: \"block\",\n }}\n />\n </div>\n );\n }\n "])));
163
+ var code = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { useStore } from \"@builder.io/mitosis\";\n import { Image } from \"@components\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <Image\n image=\"https://cdn.builder.io/api/v1/image/foobar\"\n sizes=\"100vw\"\n backgroundSize=\"contain\"\n css={{\n marignTop: \"50px\",\n display: \"block\",\n }}\n />\n </div>\n );\n }\n "], ["\n import { useStore } from \"@builder.io/mitosis\";\n import { Image } from \"@components\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <Image\n image=\"https://cdn.builder.io/api/v1/image/foobar\"\n sizes=\"100vw\"\n backgroundSize=\"contain\"\n css={{\n marignTop: \"50px\",\n display: \"block\",\n }}\n />\n </div>\n );\n }\n "])));
164
164
  var component = (0, jsx_1.parseJsx)(code);
165
165
  var builderJson = (0, builder_1.componentToBuilder)()({ component: component });
166
166
  var backToMitosis = (0, builder_2.builderContentToMitosisComponent)(builderJson);
@@ -174,7 +174,7 @@ describe('Builder', function () {
174
174
  expect(react).toMatchSnapshot();
175
175
  });
176
176
  test('Regenerate Text', function () {
177
- var code = (0, dedent_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n import { useState } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <h2\n css={{\n marginBottom: \"20px\",\n }}\n >\n Hello!\n </h2>\n </div>\n );\n }\n "], ["\n import { useState } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <h2\n css={{\n marginBottom: \"20px\",\n }}\n >\n Hello!\n </h2>\n </div>\n );\n }\n "])));
177
+ var code = (0, dedent_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n import { useStore } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <h2\n css={{\n marginBottom: \"20px\",\n }}\n >\n Hello!\n </h2>\n </div>\n );\n }\n "], ["\n import { useStore } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <div\n css={{\n padding: \"20px\",\n }}\n >\n <h2\n css={{\n marginBottom: \"20px\",\n }}\n >\n Hello!\n </h2>\n </div>\n );\n }\n "])));
178
178
  var component = (0, jsx_1.parseJsx)(code);
179
179
  var builderJson = (0, builder_1.componentToBuilder)()({ component: component });
180
180
  var backToMitosis = (0, builder_2.builderContentToMitosisComponent)(builderJson);
@@ -184,7 +184,7 @@ describe('Builder', function () {
184
184
  expect(mitosis.trim()).toEqual(code.trim());
185
185
  });
186
186
  test('Regenerate loop', function () {
187
- var code = (0, dedent_1.default)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n import { useState, For } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <For each={state.people}>\n {(person, index) => (\n <div\n key={person}\n css={{\n padding: \"10px 0\",\n }}\n >\n <span>{person}</span>\n <span>{index}</span>\n </div>\n )}\n </For>\n );\n }\n "], ["\n import { useState, For } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useState({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <For each={state.people}>\n {(person, index) => (\n <div\n key={person}\n css={{\n padding: \"10px 0\",\n }}\n >\n <span>{person}</span>\n <span>{index}</span>\n </div>\n )}\n </For>\n );\n }\n "])));
187
+ var code = (0, dedent_1.default)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n import { useStore, For } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <For each={state.people}>\n {(person, index) => (\n <div\n key={person}\n css={{\n padding: \"10px 0\",\n }}\n >\n <span>{person}</span>\n <span>{index}</span>\n </div>\n )}\n </For>\n );\n }\n "], ["\n import { useStore, For } from \"@builder.io/mitosis\";\n\n export default function MyComponent(props) {\n const state = useStore({ people: [\"Steve\", \"Sewell\"] });\n\n return (\n <For each={state.people}>\n {(person, index) => (\n <div\n key={person}\n css={{\n padding: \"10px 0\",\n }}\n >\n <span>{person}</span>\n <span>{index}</span>\n </div>\n )}\n </For>\n );\n }\n "])));
188
188
  var component = (0, jsx_1.parseJsx)(code);
189
189
  var builderJson = (0, builder_1.componentToBuilder)()({ component: component });
190
190
  var backToMitosis = (0, builder_2.builderContentToMitosisComponent)(builderJson);
@@ -7,12 +7,11 @@ var mitosis_1 = require("@builder.io/mitosis");
7
7
  var basic_raw_1 = __importDefault(require("./basic.raw"));
8
8
  var basic_onMount_update_raw_1 = __importDefault(require("./basic-onMount-update.raw"));
9
9
  function MyBasicChildComponent() {
10
- var state = (0, mitosis_1.useState)({
10
+ var state = (0, mitosis_1.useStore)({
11
11
  name: 'Steve',
12
12
  dev: 'PatrickJS',
13
13
  });
14
14
  return (<div>
15
- {/*// @ts-ignore */}
16
15
  <basic_raw_1.default id={state.dev}/>
17
16
  <div>
18
17
  <basic_onMount_update_raw_1.default hi={state.name} bye={state.dev}/>
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ var injection_js_1 = require("@dummy/injection-js");
5
+ function MyBasicComponent() {
6
+ (0, mitosis_1.setContext)(injection_js_1.Injector, (0, injection_js_1.createInjector)());
7
+ var myService = (0, mitosis_1.useContext)(injection_js_1.MyService);
8
+ var state = (0, mitosis_1.useStore)({
9
+ name: 'PatrickJS',
10
+ });
11
+ (0, mitosis_1.onInit)(function () {
12
+ var hi = myService.method('hi');
13
+ console.log(hi);
14
+ });
15
+ (0, mitosis_1.onMount)(function () {
16
+ var bye = myService.method('hi');
17
+ console.log(bye);
18
+ });
19
+ function onChange() {
20
+ var change = myService.method('change');
21
+ console.log(change);
22
+ }
23
+ return (<div>
24
+ {myService.method('hello') + state.name}
25
+ Hello! I can run in React, Vue, Solid, or Liquid!
26
+ <input onChange={onChange}></input>
27
+ </div>);
28
+ }
29
+ exports.default = MyBasicComponent;
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var custom_mitosis_1 = require("@dummy/custom-mitosis");
4
+ function MyBasicComponent() {
5
+ var state = (0, custom_mitosis_1.useStore)({
6
+ name: 'PatrickJS',
7
+ });
8
+ return <div>Hello {state.name}! I can run in React, Qwik, Vue, Solid, or Liquid!</div>;
9
+ }
10
+ exports.default = MyBasicComponent;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function MyBasicForShowComponent() {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  name: 'PatrickJS',
7
7
  names: ['Steve', 'PatrickJS'],
8
8
  });
@@ -12,8 +12,7 @@ function MyBasicForShowComponent() {
12
12
  <input value={state.name} onChange={function (event) {
13
13
  state.name = event.target.value + ' and ' + person;
14
14
  }}/>
15
- Hello {person}! I can run in Qwik, Web Component, React, Vue, Solid,
16
- or Liquid!
15
+ Hello {person}! I can run in Qwik, Web Component, React, Vue, Solid, or Liquid!
17
16
  </mitosis_1.Show>); }}
18
17
  </mitosis_1.For>
19
18
  </div>);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function MyBasicForComponent() {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  name: 'PatrickJS',
7
7
  names: ['Steve', 'PatrickJS'],
8
8
  });
@@ -15,8 +15,7 @@ function MyBasicForComponent() {
15
15
  <input value={state.name} onChange={function (event) {
16
16
  state.name = event.target.value + ' and ' + person;
17
17
  }}/>
18
- Hello {person}! I can run in Qwik, Web Component, React, Vue, Solid,
19
- or Liquid!
18
+ Hello {person}! I can run in Qwik, Web Component, React, Vue, Solid, or Liquid!
20
19
  </>); }}
21
20
  </mitosis_1.For>
22
21
  </div>);
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ inputRef: HTMLInputElement;
4
+ }
5
+ export default function MyBasicForwardRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ (0, mitosis_1.useMetadata)({
5
+ forwardRef: 'inputRef',
6
+ });
7
+ function MyBasicForwardRefComponent(props) {
8
+ var state = (0, mitosis_1.useStore)({
9
+ name: 'PatrickJS',
10
+ });
11
+ return (<div>
12
+ <input ref={props.inputRef} css={{
13
+ color: 'red',
14
+ }} value={state.name} onChange={function (event) { return (state.name = event.target.value); }}/>
15
+ </div>);
16
+ }
17
+ exports.default = MyBasicForwardRefComponent;
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ inputRef: HTMLInputElement;
4
+ }
5
+ export default function MyBasicForwardRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicForwardRefComponent(props) {
5
+ var state = (0, mitosis_1.useStore)({
6
+ name: 'PatrickJS',
7
+ });
8
+ return (<div>
9
+ <input ref={props.inputRef} css={{
10
+ color: 'red',
11
+ }} value={state.name} onChange={function (event) { return (state.name = event.target.value); }}/>
12
+ </div>);
13
+ }
14
+ exports.default = MyBasicForwardRefComponent;
@@ -0,0 +1 @@
1
+ export default function MyBasicComponent(): JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicComponent() {
5
+ var state = (0, mitosis_1.useStore)({
6
+ name: 'Steve',
7
+ });
8
+ return (<div class="test" css={{
9
+ padding: '10px',
10
+ }}>
11
+ <input value={state.name} onChange={function (myEvent) {
12
+ state.name = myEvent.target.value;
13
+ }}/>
14
+ Hello! I can run in React, Vue, Solid, or Liquid!
15
+ </div>);
16
+ }
17
+ exports.default = MyBasicComponent;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function MyBasicOnMountUpdateComponent(props) {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  name: 'PatrickJS',
7
7
  names: ['Steve', 'PatrickJS'],
8
8
  });
@@ -0,0 +1 @@
1
+ export default function MyBasicOnUpdateReturnComponent(): JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicOnUpdateReturnComponent() {
5
+ var state = (0, mitosis_1.useStore)({
6
+ name: 'PatrickJS',
7
+ });
8
+ (0, mitosis_1.onUpdate)(function () {
9
+ var controller = new AbortController();
10
+ var signal = controller.signal;
11
+ fetch('https://patrickjs.com/api/resource.json', { signal: signal })
12
+ .then(function (response) { return response.json(); })
13
+ .then(function (data) {
14
+ state.name = data.name;
15
+ });
16
+ return function () {
17
+ if (!signal.aborted) {
18
+ controller.abort();
19
+ }
20
+ };
21
+ }, [state.name]);
22
+ return <div>Hello! {state.name}</div>;
23
+ }
24
+ exports.default = MyBasicOnUpdateReturnComponent;
@@ -5,7 +5,7 @@ var mitosis_1 = require("@builder.io/mitosis");
5
5
  outputs: ['onMessage', 'onEvent'],
6
6
  });
7
7
  function MyBasicOutputsComponent(props) {
8
- var state = (0, mitosis_1.useState)({
8
+ var state = (0, mitosis_1.useStore)({
9
9
  name: 'PatrickJS',
10
10
  });
11
11
  (0, mitosis_1.onMount)(function () {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function MyBasicOutputsComponent(props) {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  name: 'PatrickJS',
7
7
  });
8
8
  (0, mitosis_1.onMount)(function () {
@@ -0,0 +1,6 @@
1
+ export declare const a = 3;
2
+ export declare const bar: () => void;
3
+ export declare function run<T>(value: T): void;
4
+ export default function MyBasicComponent(props: {
5
+ id: string;
6
+ }): JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = exports.bar = exports.a = void 0;
4
+ var b = 3;
5
+ var foo = function () { };
6
+ exports.a = 3;
7
+ var bar = function () { };
8
+ exports.bar = bar;
9
+ function run(value) { }
10
+ exports.run = run;
11
+ function MyBasicComponent(props) {
12
+ return <div></div>;
13
+ }
14
+ exports.default = MyBasicComponent;
@@ -0,0 +1,6 @@
1
+ declare type Props = {
2
+ children: any;
3
+ type: string;
4
+ };
5
+ export default function MyBasicComponent({ children: c, type }: Props): JSX.Element;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicComponent(_a) {
5
+ var c = _a.children, type = _a.type;
6
+ var state = (0, mitosis_1.useStore)({
7
+ name: 'Decadef20',
8
+ });
9
+ return (<div>
10
+ {c} {type}
11
+ Hello! I can run in React, Vue, Solid, or Liquid!
12
+ </div>);
13
+ }
14
+ exports.default = MyBasicComponent;
@@ -0,0 +1,6 @@
1
+ declare type Props = {
2
+ children: any;
3
+ type: string;
4
+ };
5
+ export default function MyBasicComponent(props: Props): JSX.Element;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicComponent(props) {
5
+ var state = (0, mitosis_1.useStore)({
6
+ name: 'Decadef20',
7
+ });
8
+ return (<div>
9
+ {props.children} {props.type}
10
+ Hello! I can run in React, Vue, Solid, or Liquid!
11
+ </div>);
12
+ }
13
+ exports.default = MyBasicComponent;
@@ -0,0 +1,4 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export default function MyBasicRefAssignmentComponent(props: Props): JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicRefAssignmentComponent(props) {
5
+ var holdValueRef = (0, mitosis_1.useRef)('Patrick');
6
+ function handlerClick(event) {
7
+ event.preventDefault();
8
+ console.log('current value', holdValueRef);
9
+ holdValueRef = holdValueRef + 'JS';
10
+ }
11
+ return (<div>
12
+ <button onClick={function (evt) { return handlerClick(evt); }}>Click</button>
13
+ </div>);
14
+ }
15
+ exports.default = MyBasicRefAssignmentComponent;
@@ -0,0 +1,5 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export declare function usePrevious<T>(value: T): T;
5
+ export default function MyPreviousComponent(props: Props): JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePrevious = void 0;
4
+ var mitosis_1 = require("@builder.io/mitosis");
5
+ function usePrevious(value) {
6
+ // The ref object is a generic container whose current property is mutable ...
7
+ // ... and can hold any value, similar to an instance property on a class
8
+ var ref = (0, mitosis_1.useRef)(null);
9
+ // Store current value in ref
10
+ (0, mitosis_1.onUpdate)(function () {
11
+ ref = value;
12
+ }, [value]); // Only re-run if value changes
13
+ // Return previous value (happens before update in useEffect above)
14
+ return ref;
15
+ }
16
+ exports.usePrevious = usePrevious;
17
+ function MyPreviousComponent(props) {
18
+ var state = (0, mitosis_1.useStore)({
19
+ count: 0,
20
+ });
21
+ var prevCount = (0, mitosis_1.useRef)(state.count);
22
+ (0, mitosis_1.onUpdate)(function () {
23
+ prevCount = state.count;
24
+ }, [state.count]); //
25
+ // Get the previous value (was passed into hook on last render)
26
+ // const prevCount = usePrevious(state.count);
27
+ // Display both current and previous count value
28
+ return (<div>
29
+ <h1>
30
+ Now: {state.count}, before: {prevCount}
31
+ </h1>
32
+ <button onClick={function () { return (state.count += 1); }}>Increment</button>
33
+ </div>);
34
+ }
35
+ exports.default = MyPreviousComponent;
@@ -0,0 +1,4 @@
1
+ export interface Props {
2
+ showInput: boolean;
3
+ }
4
+ export default function MyBasicRefComponent(props: Props): JSX.Element;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var mitosis_1 = require("@builder.io/mitosis");
4
+ function MyBasicRefComponent(props) {
5
+ var inputRef = (0, mitosis_1.useRef)(null);
6
+ var inputNoArgRef = (0, mitosis_1.useRef)(null);
7
+ var state = (0, mitosis_1.useStore)({
8
+ name: 'PatrickJS',
9
+ });
10
+ function onBlur() {
11
+ // Maintain focus
12
+ inputRef.focus();
13
+ }
14
+ function lowerCaseName() {
15
+ return state.name.toLowerCase();
16
+ }
17
+ return (<div>
18
+ {props.showInput && (<>
19
+ <input ref={inputRef} css={{
20
+ color: 'red',
21
+ }} value={state.name} onBlur={function (event) { return onBlur(); }} onChange={function (event) { return (state.name = event.target.value); }}/>
22
+
23
+ <label ref={inputNoArgRef} for="cars">
24
+ Choose a car:
25
+ </label>
26
+
27
+ <select name="cars" id="cars">
28
+ <option value="supra">GR Supra</option>
29
+ <option value="86">GR 86</option>
30
+ </select>
31
+ </>)}
32
+ Hello
33
+ {lowerCaseName()}! I can run in React, Qwik, Vue, Solid, or Web Component!
34
+ </div>);
35
+ }
36
+ exports.default = MyBasicRefComponent;
@@ -1 +1,6 @@
1
- export default function MyBasicComponent(): JSX.Element;
1
+ export declare const DEFAULT_VALUES: {
2
+ name: string;
3
+ };
4
+ export default function MyBasicComponent(props: {
5
+ id: string;
6
+ }): JSX.Element;
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_VALUES = void 0;
3
4
  var mitosis_1 = require("@builder.io/mitosis");
4
- function MyBasicComponent() {
5
- var state = (0, mitosis_1.useState)({
5
+ exports.DEFAULT_VALUES = {
6
+ name: 'Steve',
7
+ };
8
+ function MyBasicComponent(props) {
9
+ var state = (0, mitosis_1.useStore)({
6
10
  name: 'Steve',
11
+ underscore_fn_name: function () {
12
+ return 'bar';
13
+ },
7
14
  });
8
15
  return (<div class="test" css={{
9
16
  padding: '10px',
10
17
  }}>
11
- <input value={state.name} onChange={function (myEvent) { return (state.name = myEvent.target.value); }}/>
18
+ <input value={exports.DEFAULT_VALUES.name || state.name} onChange={function (myEvent) { return (state.name = myEvent.target.value); }}/>
12
19
  Hello! I can run in React, Vue, Solid, or Liquid!
13
20
  </div>);
14
21
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function ClassNameCode(props) {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  bindings: 'a binding',
7
7
  });
8
8
  return (<div>
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var mitosis_1 = require("@builder.io/mitosis");
4
4
  function Column(props) {
5
- var state = (0, mitosis_1.useState)({
5
+ var state = (0, mitosis_1.useStore)({
6
6
  getColumns: function () {
7
7
  return props.columns || [];
8
8
  },