@builder.io/mitosis 0.4.0 → 0.4.2

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 (196) hide show
  1. package/dist/src/constants/media-sizes.js +4 -5
  2. package/dist/src/generators/alpine/generate.js +114 -132
  3. package/dist/src/generators/alpine/render-mount-hook.js +8 -5
  4. package/dist/src/generators/alpine/render-update-hooks.js +13 -13
  5. package/dist/src/generators/angular/helpers.js +19 -9
  6. package/dist/src/generators/angular/index.js +599 -584
  7. package/dist/src/generators/builder.js +200 -165
  8. package/dist/src/generators/context/angular.js +32 -26
  9. package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
  10. package/dist/src/generators/context/qwik.js +21 -21
  11. package/dist/src/generators/context/react.js +22 -22
  12. package/dist/src/generators/context/rsc.js +20 -22
  13. package/dist/src/generators/context/solid.js +22 -22
  14. package/dist/src/generators/context/svelte.js +33 -28
  15. package/dist/src/generators/context/vue.js +1 -1
  16. package/dist/src/generators/helpers/context.js +6 -13
  17. package/dist/src/generators/helpers/functions.js +8 -8
  18. package/dist/src/generators/helpers/on-mount.js +9 -5
  19. package/dist/src/generators/helpers/rsc.js +7 -9
  20. package/dist/src/generators/html.js +995 -534
  21. package/dist/src/generators/liquid.js +81 -79
  22. package/dist/src/generators/lit/collect-class-string.js +10 -12
  23. package/dist/src/generators/lit/generate.js +204 -159
  24. package/dist/src/generators/marko/generate.js +193 -183
  25. package/dist/src/generators/minify.js +5 -9
  26. package/dist/src/generators/mitosis.js +135 -134
  27. package/dist/src/generators/qwik/component-generator.js +159 -154
  28. package/dist/src/generators/qwik/component.js +51 -81
  29. package/dist/src/generators/qwik/directives.js +68 -84
  30. package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
  31. package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
  32. package/dist/src/generators/qwik/helpers/handlers.js +16 -25
  33. package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
  34. package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
  35. package/dist/src/generators/qwik/helpers/state.js +36 -43
  36. package/dist/src/generators/qwik/helpers/styles.js +19 -40
  37. package/dist/src/generators/qwik/jsx.js +63 -75
  38. package/dist/src/generators/qwik/src-generator.js +134 -167
  39. package/dist/src/generators/react/blocks.js +122 -127
  40. package/dist/src/generators/react/generator.js +314 -259
  41. package/dist/src/generators/react/helpers.js +23 -28
  42. package/dist/src/generators/react/state.js +34 -51
  43. package/dist/src/generators/react-native/index.js +72 -84
  44. package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
  45. package/dist/src/generators/rsc.js +30 -36
  46. package/dist/src/generators/solid/blocks.js +46 -43
  47. package/dist/src/generators/solid/helpers/styles.js +11 -11
  48. package/dist/src/generators/solid/index.js +199 -190
  49. package/dist/src/generators/solid/state/helpers.js +76 -90
  50. package/dist/src/generators/solid/state/signals.js +30 -37
  51. package/dist/src/generators/solid/state/state.js +35 -48
  52. package/dist/src/generators/solid/state/store.js +40 -46
  53. package/dist/src/generators/stencil/collect-class-string.js +10 -12
  54. package/dist/src/generators/stencil/generate.js +158 -145
  55. package/dist/src/generators/svelte/blocks.js +146 -144
  56. package/dist/src/generators/svelte/helpers.js +10 -17
  57. package/dist/src/generators/svelte/svelte.js +321 -287
  58. package/dist/src/generators/swift-ui.js +162 -101
  59. package/dist/src/generators/taro.js +32 -36
  60. package/dist/src/generators/template.js +71 -74
  61. package/dist/src/generators/vue/blocks.js +116 -107
  62. package/dist/src/generators/vue/compositionApi.js +67 -50
  63. package/dist/src/generators/vue/helpers.js +71 -96
  64. package/dist/src/generators/vue/optionsApi.js +134 -105
  65. package/dist/src/generators/vue/vue.js +210 -207
  66. package/dist/src/helpers/babel-transform.js +40 -63
  67. package/dist/src/helpers/bindings.js +4 -12
  68. package/dist/src/helpers/camel-case.js +4 -5
  69. package/dist/src/helpers/capitalize.js +1 -1
  70. package/dist/src/helpers/component-file-extensions.js +23 -35
  71. package/dist/src/helpers/create-mitosis-component.js +22 -26
  72. package/dist/src/helpers/create-mitosis-context.js +5 -12
  73. package/dist/src/helpers/create-mitosis-node.js +10 -12
  74. package/dist/src/helpers/dash-case.js +2 -2
  75. package/dist/src/helpers/dedent.js +18 -22
  76. package/dist/src/helpers/event-handlers.js +1 -1
  77. package/dist/src/helpers/fast-clone.js +1 -1
  78. package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
  79. package/dist/src/helpers/generic-format.js +7 -8
  80. package/dist/src/helpers/get-bindings.js +4 -4
  81. package/dist/src/helpers/get-components-used.js +3 -3
  82. package/dist/src/helpers/get-components.js +4 -4
  83. package/dist/src/helpers/get-custom-imports.js +10 -12
  84. package/dist/src/helpers/get-prop-functions.js +7 -8
  85. package/dist/src/helpers/get-props-ref.js +8 -8
  86. package/dist/src/helpers/get-props.js +12 -13
  87. package/dist/src/helpers/get-refs.js +4 -4
  88. package/dist/src/helpers/get-state-object-string.js +42 -61
  89. package/dist/src/helpers/get-state-used.js +7 -8
  90. package/dist/src/helpers/get-styles.js +6 -6
  91. package/dist/src/helpers/getters-to-functions.js +8 -12
  92. package/dist/src/helpers/handle-missing-state.js +3 -3
  93. package/dist/src/helpers/has-bindings-text.js +6 -6
  94. package/dist/src/helpers/has-component.js +4 -4
  95. package/dist/src/helpers/has-props.js +3 -3
  96. package/dist/src/helpers/has-stateful-dom.js +4 -4
  97. package/dist/src/helpers/has.js +3 -3
  98. package/dist/src/helpers/indent.js +2 -3
  99. package/dist/src/helpers/is-children.js +4 -5
  100. package/dist/src/helpers/is-component.js +1 -1
  101. package/dist/src/helpers/is-html-attribute.js +2 -11
  102. package/dist/src/helpers/is-mitosis-node.js +1 -1
  103. package/dist/src/helpers/is-root-text-node.js +1 -1
  104. package/dist/src/helpers/is-upper-case.js +1 -1
  105. package/dist/src/helpers/is-valid-attribute-name.js +1 -1
  106. package/dist/src/helpers/json.js +2 -2
  107. package/dist/src/helpers/map-refs.js +29 -40
  108. package/dist/src/helpers/merge-options.js +20 -31
  109. package/dist/src/helpers/mitosis-imports.js +5 -6
  110. package/dist/src/helpers/nodes/for.js +2 -3
  111. package/dist/src/helpers/nullable.js +1 -3
  112. package/dist/src/helpers/on-event.js +32 -36
  113. package/dist/src/helpers/output.js +4 -5
  114. package/dist/src/helpers/parse-node.js +13 -5
  115. package/dist/src/helpers/parsers.js +10 -14
  116. package/dist/src/helpers/patterns.js +6 -8
  117. package/dist/src/helpers/plugins/process-code/index.js +114 -120
  118. package/dist/src/helpers/plugins/process-signals.js +114 -125
  119. package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
  120. package/dist/src/helpers/process-http-requests.js +8 -4
  121. package/dist/src/helpers/remove-surrounding-block.js +2 -2
  122. package/dist/src/helpers/render-imports.js +99 -111
  123. package/dist/src/helpers/replace-identifiers.js +40 -49
  124. package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
  125. package/dist/src/helpers/signals/signals.js +27 -35
  126. package/dist/src/helpers/slots.js +11 -20
  127. package/dist/src/helpers/state.js +1 -3
  128. package/dist/src/helpers/strip-meta-properties.js +6 -6
  129. package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
  130. package/dist/src/helpers/styles/collect-css.js +39 -44
  131. package/dist/src/helpers/styles/collect-styled-components.js +30 -28
  132. package/dist/src/helpers/styles/helpers.js +23 -29
  133. package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
  134. package/dist/src/helpers/transform-state-setters.js +16 -19
  135. package/dist/src/helpers/traverse-nodes.js +2 -2
  136. package/dist/src/helpers/try-prettier-format.js +3 -3
  137. package/dist/src/helpers/typescript-project.js +25 -25
  138. package/dist/src/helpers/typescript.js +1 -3
  139. package/dist/src/modules/plugins.js +20 -28
  140. package/dist/src/parsers/angular.js +49 -57
  141. package/dist/src/parsers/builder/builder.js +448 -343
  142. package/dist/src/parsers/builder/helpers.js +10 -10
  143. package/dist/src/parsers/context.js +15 -17
  144. package/dist/src/parsers/jsx/ast.js +11 -11
  145. package/dist/src/parsers/jsx/component-types.js +22 -32
  146. package/dist/src/parsers/jsx/context.js +12 -12
  147. package/dist/src/parsers/jsx/element-parser.js +43 -54
  148. package/dist/src/parsers/jsx/exports.js +12 -14
  149. package/dist/src/parsers/jsx/function-parser.js +108 -119
  150. package/dist/src/parsers/jsx/helpers.js +11 -13
  151. package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
  152. package/dist/src/parsers/jsx/hooks/index.js +34 -44
  153. package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
  154. package/dist/src/parsers/jsx/imports.js +7 -17
  155. package/dist/src/parsers/jsx/jsx.js +92 -91
  156. package/dist/src/parsers/jsx/props-types.js +8 -10
  157. package/dist/src/parsers/jsx/props.js +15 -23
  158. package/dist/src/parsers/jsx/signals.js +28 -29
  159. package/dist/src/parsers/jsx/state.d.ts +2 -4
  160. package/dist/src/parsers/jsx/state.js +59 -93
  161. package/dist/src/parsers/svelte/css/index.js +1 -1
  162. package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
  163. package/dist/src/parsers/svelte/helpers/children.js +5 -6
  164. package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
  165. package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
  166. package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
  167. package/dist/src/parsers/svelte/helpers/string.js +5 -5
  168. package/dist/src/parsers/svelte/html/actions.js +17 -10
  169. package/dist/src/parsers/svelte/html/each.js +11 -16
  170. package/dist/src/parsers/svelte/html/element.js +68 -78
  171. package/dist/src/parsers/svelte/html/fragment.js +3 -3
  172. package/dist/src/parsers/svelte/html/if-else.js +11 -18
  173. package/dist/src/parsers/svelte/html/index.js +14 -14
  174. package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
  175. package/dist/src/parsers/svelte/html/slot.js +5 -5
  176. package/dist/src/parsers/svelte/html/text.js +7 -14
  177. package/dist/src/parsers/svelte/index.js +23 -72
  178. package/dist/src/parsers/svelte/instance/context.js +17 -17
  179. package/dist/src/parsers/svelte/instance/expressions.js +2 -2
  180. package/dist/src/parsers/svelte/instance/functions.js +35 -30
  181. package/dist/src/parsers/svelte/instance/hooks.js +4 -5
  182. package/dist/src/parsers/svelte/instance/imports.js +11 -21
  183. package/dist/src/parsers/svelte/instance/index.js +22 -22
  184. package/dist/src/parsers/svelte/instance/properties.js +11 -23
  185. package/dist/src/parsers/svelte/instance/reactive.js +11 -11
  186. package/dist/src/parsers/svelte/instance/references.js +13 -13
  187. package/dist/src/parsers/svelte/instance/statements.js +3 -3
  188. package/dist/src/parsers/svelte/module/index.js +14 -26
  189. package/dist/src/parsers/svelte/typescript/index.js +27 -36
  190. package/dist/src/plugins/compile-away-builder-components.js +223 -156
  191. package/dist/src/plugins/compile-away-components.js +13 -21
  192. package/dist/src/plugins/map-styles.js +7 -7
  193. package/dist/src/symbols/symbol-processor.js +44 -62
  194. package/dist/src/targets.js +19 -19
  195. package/dist/src/types/mitosis-node.js +1 -1
  196. package/package.json +1 -1
@@ -1,38 +1,27 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.blockToReact = void 0;
18
- var filter_empty_text_nodes_1 = require("../../helpers/filter-empty-text-nodes");
19
- var is_children_1 = __importDefault(require("../../helpers/is-children"));
20
- var is_root_text_node_1 = require("../../helpers/is-root-text-node");
21
- var is_valid_attribute_name_1 = require("../../helpers/is-valid-attribute-name");
22
- var for_1 = require("../../helpers/nodes/for");
23
- var slots_1 = require("../../helpers/slots");
24
- var mitosis_node_1 = require("../../types/mitosis-node");
25
- var html_tags_1 = require("../../constants/html_tags");
26
- var helpers_1 = require("./helpers");
27
- var state_1 = require("./state");
28
- var NODE_MAPPERS = {
29
- Slot: function (json, options, component, _insideJsx, parentSlots) {
7
+ const filter_empty_text_nodes_1 = require("../../helpers/filter-empty-text-nodes");
8
+ const is_children_1 = __importDefault(require("../../helpers/is-children"));
9
+ const is_root_text_node_1 = require("../../helpers/is-root-text-node");
10
+ const is_valid_attribute_name_1 = require("../../helpers/is-valid-attribute-name");
11
+ const for_1 = require("../../helpers/nodes/for");
12
+ const slots_1 = require("../../helpers/slots");
13
+ const mitosis_node_1 = require("../../types/mitosis-node");
14
+ const html_tags_1 = require("../../constants/html_tags");
15
+ const helpers_1 = require("./helpers");
16
+ const state_1 = require("./state");
17
+ const NODE_MAPPERS = {
18
+ Slot(json, options, component, _insideJsx, parentSlots) {
30
19
  var _a, _b;
31
- var slotName = ((_a = json.bindings.name) === null || _a === void 0 ? void 0 : _a.code) || json.properties.name;
32
- var hasChildren = json.children.length;
33
- var renderChildren = function () {
20
+ const slotName = ((_a = json.bindings.name) === null || _a === void 0 ? void 0 : _a.code) || json.properties.name;
21
+ const hasChildren = json.children.length;
22
+ const renderChildren = () => {
34
23
  var _a;
35
- var childrenStr = (_a = json.children) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (0, exports.blockToReact)(item, options, component, true); }).join('\n').trim();
24
+ const childrenStr = (_a = json.children) === null || _a === void 0 ? void 0 : _a.map((item) => (0, exports.blockToReact)(item, options, component, true)).join('\n').trim();
36
25
  /**
37
26
  * Ad-hoc way of figuring out if the children defaultProp is:
38
27
  * - a JSX element, e.g. `<div>foo</div>`
@@ -41,151 +30,158 @@ var NODE_MAPPERS = {
41
30
  *
42
31
  * and correctly wrapping it in quotes when appropriate.
43
32
  */
44
- if (childrenStr.startsWith("<") && childrenStr.endsWith(">")) {
33
+ if (childrenStr.startsWith(`<`) && childrenStr.endsWith(`>`)) {
45
34
  return childrenStr;
46
35
  }
47
36
  else if (['false', 'true', 'null', 'undefined'].includes(childrenStr)) {
48
37
  return childrenStr;
49
38
  }
50
39
  else {
51
- return "\"".concat(childrenStr, "\"");
40
+ return `"${childrenStr}"`;
52
41
  }
53
42
  };
54
43
  if (!slotName) {
55
44
  // TODO: update MitosisNode for simple code
56
- var key = Object.keys(json.bindings).find(Boolean);
45
+ const key = Object.keys(json.bindings).find(Boolean);
57
46
  if (key && parentSlots) {
58
- parentSlots.push({ key: key, value: (_b = json.bindings[key]) === null || _b === void 0 ? void 0 : _b.code });
47
+ parentSlots.push({ key, value: (_b = json.bindings[key]) === null || _b === void 0 ? void 0 : _b.code });
59
48
  return '';
60
49
  }
61
- var children = (0, helpers_1.processBinding)('props.children', options);
62
- return "<>{".concat(children, " ").concat(hasChildren ? "|| (".concat(renderChildren(), ")") : '', "}</>");
50
+ const children = (0, helpers_1.processBinding)('props.children', options);
51
+ return `<>{${children} ${hasChildren ? `|| (${renderChildren()})` : ''}}</>`;
63
52
  }
64
- var slotProp = (0, helpers_1.processBinding)(slotName, options).replace('name=', '');
53
+ let slotProp = (0, helpers_1.processBinding)(slotName, options).replace('name=', '');
65
54
  if (!slotProp.startsWith('props.')) {
66
- slotProp = "props.".concat(slotProp);
55
+ slotProp = `props.${slotProp}`;
67
56
  }
68
- return "<>{".concat(slotProp, " ").concat(hasChildren ? "|| (".concat(renderChildren(), ")") : '', "}</>");
57
+ return `<>{${slotProp} ${hasChildren ? `|| (${renderChildren()})` : ''}}</>`;
69
58
  },
70
- Fragment: function (json, options, component) {
71
- var wrap = (0, helpers_1.wrapInFragment)(json) || (0, is_root_text_node_1.isRootTextNode)(json);
72
- return "".concat(wrap ? (0, helpers_1.getFragment)('open', options) : '').concat(json.children
73
- .map(function (item) { return (0, exports.blockToReact)(item, options, component, wrap); })
74
- .join('\n')).concat(wrap ? (0, helpers_1.getFragment)('close', options) : '');
59
+ Fragment(json, options, component) {
60
+ const wrap = (0, helpers_1.wrapInFragment)(json) || (0, is_root_text_node_1.isRootTextNode)(json);
61
+ return `${wrap ? (0, helpers_1.getFragment)('open', options) : ''}${json.children
62
+ .map((item) => (0, exports.blockToReact)(item, options, component, wrap))
63
+ .join('\n')}${wrap ? (0, helpers_1.getFragment)('close', options) : ''}`;
75
64
  },
76
- For: function (_json, options, component, insideJsx) {
65
+ For(_json, options, component, insideJsx) {
77
66
  var _a;
78
- var json = _json;
79
- var wrap = (0, helpers_1.wrapInFragment)(json);
80
- var forArguments = (0, for_1.getForArguments)(json).join(', ');
81
- var expression = "".concat((0, helpers_1.processBinding)((_a = json.bindings.each) === null || _a === void 0 ? void 0 : _a.code, options), "?.map((").concat(forArguments, ") => (\n ").concat(wrap ? (0, helpers_1.openFrag)(options) : '').concat(json.children
67
+ const json = _json;
68
+ const wrap = (0, helpers_1.wrapInFragment)(json);
69
+ const forArguments = (0, for_1.getForArguments)(json).join(', ');
70
+ const expression = `${(0, helpers_1.processBinding)((_a = json.bindings.each) === null || _a === void 0 ? void 0 : _a.code, options)}?.map((${forArguments}) => (
71
+ ${wrap ? (0, helpers_1.openFrag)(options) : ''}${json.children
82
72
  .filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
83
- .map(function (item) { return (0, exports.blockToReact)(item, options, component, wrap); })
84
- .join('\n')).concat(wrap ? (0, helpers_1.closeFrag)(options) : '', "\n ))");
73
+ .map((item) => (0, exports.blockToReact)(item, options, component, wrap))
74
+ .join('\n')}${wrap ? (0, helpers_1.closeFrag)(options) : ''}
75
+ ))`;
85
76
  if (insideJsx) {
86
- return "{".concat(expression, "}");
77
+ return `{${expression}}`;
87
78
  }
88
79
  else {
89
80
  return expression;
90
81
  }
91
82
  },
92
- Show: function (json, options, component, insideJsx) {
83
+ Show(json, options, component, insideJsx) {
93
84
  var _a;
94
- var wrap = (0, helpers_1.wrapInFragment)(json) ||
85
+ const wrap = (0, helpers_1.wrapInFragment)(json) ||
95
86
  (0, is_root_text_node_1.isRootTextNode)(json) ||
96
87
  component.children[0] === json ||
97
88
  // when `<Show><For>...</For></Show>`, we need to wrap the For generated code in a fragment
98
89
  // since it's a `.map()` call
99
90
  (json.children.length === 1 && ['For', 'Show'].includes(json.children[0].name));
100
- var wrapElse = !!(json.meta.else &&
91
+ const wrapElse = !!(json.meta.else &&
101
92
  ((0, helpers_1.wrapInFragment)(json.meta.else) || (0, mitosis_node_1.checkIsForNode)(json.meta.else)));
102
- var expression = "".concat((0, helpers_1.processBinding)((_a = json.bindings.when) === null || _a === void 0 ? void 0 : _a.code, options), " ? (\n ").concat(wrap ? (0, helpers_1.openFrag)(options) : '').concat(json.children
93
+ const expression = `${(0, helpers_1.processBinding)((_a = json.bindings.when) === null || _a === void 0 ? void 0 : _a.code, options)} ? (
94
+ ${wrap ? (0, helpers_1.openFrag)(options) : ''}${json.children
103
95
  .filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
104
- .map(function (item) { return (0, exports.blockToReact)(item, options, component, wrap); })
105
- .join('\n')).concat(wrap ? (0, helpers_1.closeFrag)(options) : '', "\n ) : ").concat(!json.meta.else
96
+ .map((item) => (0, exports.blockToReact)(item, options, component, wrap))
97
+ .join('\n')}${wrap ? (0, helpers_1.closeFrag)(options) : ''}
98
+ ) : ${!json.meta.else
106
99
  ? 'null'
107
100
  : (wrapElse ? (0, helpers_1.openFrag)(options) : '') +
108
101
  (0, exports.blockToReact)(json.meta.else, options, component, wrapElse) +
109
- (wrapElse ? (0, helpers_1.closeFrag)(options) : ''));
102
+ (wrapElse ? (0, helpers_1.closeFrag)(options) : '')}`;
110
103
  if (insideJsx) {
111
- return "{".concat(expression, "}");
104
+ return `{${expression}}`;
112
105
  }
113
106
  else {
114
107
  return expression;
115
108
  }
116
109
  },
117
110
  };
118
- var ATTTRIBUTE_MAPPERS = {
111
+ const ATTTRIBUTE_MAPPERS = {
119
112
  spellcheck: 'spellCheck',
120
113
  autocapitalize: 'autoCapitalize',
121
114
  autocomplete: 'autoComplete',
122
115
  for: 'htmlFor',
123
116
  };
124
117
  // TODO: Maybe in the future allow defining `string | function` as values
125
- var BINDING_MAPPERS = __assign({ ref: function (ref, value, options) {
118
+ const BINDING_MAPPERS = {
119
+ ref(ref, value, options) {
126
120
  if (options === null || options === void 0 ? void 0 : options.preact) {
127
121
  return [ref, value];
128
122
  }
129
- var regexp = /(.+)?props\.(.+)( |\)|;|\()?$/m;
123
+ const regexp = /(.+)?props\.(.+)( |\)|;|\()?$/m;
130
124
  if (regexp.test(value)) {
131
- var match = regexp.exec(value);
132
- var prop = match === null || match === void 0 ? void 0 : match[2];
125
+ const match = regexp.exec(value);
126
+ const prop = match === null || match === void 0 ? void 0 : match[2];
133
127
  if (prop) {
134
128
  return [ref, prop];
135
129
  }
136
130
  }
137
131
  return [ref, value];
138
- }, innerHTML: function (_key, value) {
139
- return ['dangerouslySetInnerHTML', "{__html: ".concat(value.replace(/\s+/g, ' '), "}")];
140
- } }, ATTTRIBUTE_MAPPERS);
141
- var NATIVE_EVENT_MAPPER = {
132
+ },
133
+ innerHTML(_key, value) {
134
+ return ['dangerouslySetInnerHTML', `{__html: ${value.replace(/\s+/g, ' ')}}`];
135
+ },
136
+ ...ATTTRIBUTE_MAPPERS,
137
+ };
138
+ const NATIVE_EVENT_MAPPER = {
142
139
  onClick: 'onPress',
143
140
  };
144
- var blockToReact = function (json, options, component, insideJsx, parentSlots) {
141
+ const blockToReact = (json, options, component, insideJsx, parentSlots = []) => {
145
142
  var _a, _b, _c, _d;
146
- if (parentSlots === void 0) { parentSlots = []; }
147
- var needsToRenderSlots = [];
143
+ const needsToRenderSlots = [];
148
144
  if (NODE_MAPPERS[json.name]) {
149
145
  return NODE_MAPPERS[json.name](json, options, component, insideJsx, parentSlots);
150
146
  }
151
147
  if (json.properties._text) {
152
- var text = json.properties._text;
148
+ const text = json.properties._text;
153
149
  if (options.type === 'native' && text.trim().length) {
154
- return "<Text>".concat(text, "</Text>");
150
+ return `<Text>${text}</Text>`;
155
151
  }
156
152
  return text;
157
153
  }
158
154
  if ((_a = json.bindings._text) === null || _a === void 0 ? void 0 : _a.code) {
159
- var processed = (0, helpers_1.processBinding)(json.bindings._text.code, options);
155
+ const processed = (0, helpers_1.processBinding)(json.bindings._text.code, options);
160
156
  if (options.type === 'native' &&
161
157
  !(0, is_children_1.default)({ node: json }) &&
162
158
  !(0, slots_1.isSlotProperty)(json.bindings._text.code.split('.')[1] || '')) {
163
- return "<Text>{".concat(processed, "}</Text>");
159
+ return `<Text>{${processed}}</Text>`;
164
160
  }
165
- return "{".concat(processed, "}");
161
+ return `{${processed}}`;
166
162
  }
167
- var str = '';
168
- str += "<".concat(json.name, " ");
169
- for (var key in json.properties) {
170
- var value = (json.properties[key] || '').replace(/"/g, '&quot;').replace(/\n/g, '\\n');
163
+ let str = '';
164
+ str += `<${json.name} `;
165
+ for (const key in json.properties) {
166
+ const value = (json.properties[key] || '').replace(/"/g, '&quot;').replace(/\n/g, '\\n');
171
167
  // Handle src for Image
172
168
  // Handle src for Image
173
169
  if (json.name === 'Image' && key === 'src') {
174
- var src = void 0;
175
- var imageSource = json.properties.src;
170
+ let src;
171
+ const imageSource = json.properties.src;
176
172
  if (imageSource) {
177
- var isUrl = /^(http|https):\/\/[^ "]+$/.test(imageSource);
178
- src = isUrl ? "{ uri: '".concat(imageSource, "' }") : "require('".concat(imageSource, "')");
179
- str += "source={".concat(src, "} ");
173
+ const isUrl = /^(http|https):\/\/[^ "]+$/.test(imageSource);
174
+ src = isUrl ? `{ uri: '${imageSource}' }` : `require('${imageSource}')`;
175
+ str += `source={${src}} `;
180
176
  continue; // Skip further processing for 'src' in Image
181
177
  }
182
178
  }
183
179
  // Handle href for TouchableOpacity
184
180
  if (json.name === 'TouchableOpacity' && key === 'href') {
185
- var hrefValue = (0, helpers_1.processBinding)(value, options);
181
+ const hrefValue = (0, helpers_1.processBinding)(value, options);
186
182
  if (hrefValue) {
187
- var onPress = "() => Linking.openURL(".concat(JSON.stringify(hrefValue), ")");
188
- str += " onPress={".concat(onPress, "} ");
183
+ const onPress = `() => Linking.openURL(${JSON.stringify(hrefValue)})`;
184
+ str += ` onPress={${onPress}} `;
189
185
  }
190
186
  continue; // Skip further processing for 'href' in TouchableOpacity
191
187
  }
@@ -194,49 +190,49 @@ var blockToReact = function (json, options, component, insideJsx, parentSlots) {
194
190
  continue; // Skip further processing for 'target' in TouchableOpacity
195
191
  }
196
192
  if (key === 'class') {
197
- str = "".concat(str.trim(), " className=\"").concat(value, "\" ");
193
+ str = `${str.trim()} className="${value}" `;
198
194
  }
199
195
  else if (BINDING_MAPPERS[key]) {
200
- var mapper = BINDING_MAPPERS[key];
196
+ const mapper = BINDING_MAPPERS[key];
201
197
  if (typeof mapper === 'function') {
202
- var _e = mapper(key, value, options), newKey = _e[0], newValue = _e[1];
203
- str += " ".concat(newKey, "={").concat(newValue, "} ");
198
+ const [newKey, newValue] = mapper(key, value, options);
199
+ str += ` ${newKey}={${newValue}} `;
204
200
  }
205
201
  else {
206
- str += " ".concat(BINDING_MAPPERS[key], "=\"").concat(value, "\" ");
202
+ str += ` ${BINDING_MAPPERS[key]}="${value}" `;
207
203
  }
208
204
  }
209
205
  else {
210
206
  if ((0, is_valid_attribute_name_1.isValidAttributeName)(key)) {
211
- str += " ".concat(key, "=\"").concat(value.replace(/"/g, '&quot;'), "\" ");
207
+ str += ` ${key}="${value.replace(/"/g, '&quot;')}" `;
212
208
  }
213
209
  }
214
210
  }
215
- for (var key in json.bindings) {
211
+ for (const key in json.bindings) {
216
212
  // ignore duplicate slot attribute
217
213
  if ((_b = json.slots) === null || _b === void 0 ? void 0 : _b[key]) {
218
214
  continue;
219
215
  }
220
- var value = String((_c = json.bindings[key]) === null || _c === void 0 ? void 0 : _c.code);
216
+ const value = String((_c = json.bindings[key]) === null || _c === void 0 ? void 0 : _c.code);
221
217
  if (key === 'css' && value.trim() === '{}') {
222
218
  continue;
223
219
  }
224
- var useBindingValue = (0, helpers_1.processBinding)(value, options);
220
+ const useBindingValue = (0, helpers_1.processBinding)(value, options);
225
221
  if (json.name === 'Image' && key === 'src') {
226
- var src = void 0;
227
- var imageSource = (0, helpers_1.processBinding)(value, options);
222
+ let src;
223
+ const imageSource = (0, helpers_1.processBinding)(value, options);
228
224
  if (imageSource) {
229
- src = "{ uri: ".concat(imageSource, " }");
230
- str += "source={".concat(src, "} ");
225
+ src = `{ uri: ${imageSource} }`;
226
+ str += `source={${src}} `;
231
227
  continue; // Skip further processing for 'src' in Image
232
228
  }
233
229
  }
234
230
  // Handle href for TouchableOpacity
235
231
  if (json.name === 'TouchableOpacity' && key === 'href') {
236
- var hrefValue = (0, helpers_1.processBinding)(value, options);
232
+ const hrefValue = (0, helpers_1.processBinding)(value, options);
237
233
  if (hrefValue) {
238
- var onPress = "() => Linking.openURL(".concat(hrefValue, ")");
239
- str += " onPress={".concat(onPress, "} ");
234
+ const onPress = `() => Linking.openURL(${hrefValue})`;
235
+ str += ` onPress={${onPress}} `;
240
236
  continue; // Skip further processing for 'href' in TouchableOpacity
241
237
  }
242
238
  }
@@ -245,59 +241,59 @@ var blockToReact = function (json, options, component, insideJsx, parentSlots) {
245
241
  continue; // Skip further processing for 'target' in TouchableOpacity
246
242
  }
247
243
  if (((_d = json.bindings[key]) === null || _d === void 0 ? void 0 : _d.type) === 'spread') {
248
- str += " {...(".concat(value, ")} ");
244
+ str += ` {...(${value})} `;
249
245
  }
250
246
  else if (key.startsWith('on')) {
251
- var _f = json.bindings[key].arguments, cusArgs = _f === void 0 ? ['event'] : _f;
252
- var eventName = options.type === 'native' ? NATIVE_EVENT_MAPPER[key] || key : key;
253
- str += " ".concat(eventName, "={(").concat(cusArgs.join(','), ") => ").concat((0, state_1.updateStateSettersInCode)(useBindingValue, options), " } ");
247
+ const { arguments: cusArgs = ['event'] } = json.bindings[key];
248
+ const eventName = options.type === 'native' ? NATIVE_EVENT_MAPPER[key] || key : key;
249
+ str += ` ${eventName}={(${cusArgs.join(',')}) => ${(0, state_1.updateStateSettersInCode)(useBindingValue, options)} } `;
254
250
  }
255
251
  else if (key.startsWith('slot')) {
256
252
  // <Component slotProjected={<AnotherComponent />} />
257
- str += " ".concat(key, "={").concat(value, "} ");
253
+ str += ` ${key}={${value}} `;
258
254
  }
259
255
  else if (key === 'class') {
260
- str += " className={".concat(useBindingValue, "} ");
256
+ str += ` className={${useBindingValue}} `;
261
257
  }
262
258
  else if (BINDING_MAPPERS[key]) {
263
- var mapper = BINDING_MAPPERS[key];
259
+ const mapper = BINDING_MAPPERS[key];
264
260
  if (typeof mapper === 'function') {
265
- var _g = mapper(key, useBindingValue, options), newKey = _g[0], newValue = _g[1];
266
- str += " ".concat(newKey, "={").concat(newValue, "} ");
261
+ const [newKey, newValue] = mapper(key, useBindingValue, options);
262
+ str += ` ${newKey}={${newValue}} `;
267
263
  }
268
264
  else {
269
265
  if (useBindingValue === 'true') {
270
- str += " ".concat(BINDING_MAPPERS[key], " ");
266
+ str += ` ${BINDING_MAPPERS[key]} `;
271
267
  }
272
268
  else {
273
- str += " ".concat(BINDING_MAPPERS[key], "={").concat(useBindingValue, "} ");
269
+ str += ` ${BINDING_MAPPERS[key]}={${useBindingValue}} `;
274
270
  }
275
271
  }
276
272
  }
277
273
  else if (key === 'style' && options.type === 'native' && json.name === 'ScrollView') {
278
274
  // React Native's ScrollView has a different prop for styles: `contentContainerStyle`
279
- str += " contentContainerStyle={".concat(useBindingValue, "} ");
275
+ str += ` contentContainerStyle={${useBindingValue}} `;
280
276
  }
281
277
  else {
282
278
  if ((0, is_valid_attribute_name_1.isValidAttributeName)(key)) {
283
279
  if (useBindingValue === 'true') {
284
- str += " ".concat(key, " ");
280
+ str += ` ${key} `;
285
281
  }
286
282
  else {
287
- str += " ".concat(key, "={").concat(useBindingValue, "} ");
283
+ str += ` ${key}={${useBindingValue}} `;
288
284
  }
289
285
  }
290
286
  }
291
287
  }
292
288
  if (json.slots) {
293
- for (var key in json.slots) {
294
- var value = json.slots[key];
289
+ for (const key in json.slots) {
290
+ const value = json.slots[key];
295
291
  if (!(value === null || value === void 0 ? void 0 : value.length)) {
296
292
  continue;
297
293
  }
298
- var reactComponents = value.map(function (node) { return (0, exports.blockToReact)(node, options, component, true); });
299
- var slotStringValue = reactComponents.length === 1 ? reactComponents[0] : "<>".concat(reactComponents.join('\n'), "</>");
300
- str += " ".concat(key, "={").concat(slotStringValue, "} ");
294
+ const reactComponents = value.map((node) => (0, exports.blockToReact)(node, options, component, true));
295
+ const slotStringValue = reactComponents.length === 1 ? reactComponents[0] : `<>${reactComponents.join('\n')}</>`;
296
+ str += ` ${key}={${slotStringValue}} `;
301
297
  }
302
298
  }
303
299
  if (html_tags_1.SELF_CLOSING_HTML_TAGS.has(json.name)) {
@@ -309,22 +305,21 @@ var blockToReact = function (json, options, component, insideJsx, parentSlots) {
309
305
  return str;
310
306
  }
311
307
  // TODO: update MitosisNode for simple code
312
- var childrenNodes = '';
308
+ let childrenNodes = '';
313
309
  if (json.children) {
314
310
  childrenNodes = json.children
315
- .map(function (item) { return (0, exports.blockToReact)(item, options, component, true, needsToRenderSlots); })
311
+ .map((item) => (0, exports.blockToReact)(item, options, component, true, needsToRenderSlots))
316
312
  .join('');
317
313
  }
318
314
  if (needsToRenderSlots.length) {
319
- needsToRenderSlots.forEach(function (_a) {
320
- var key = _a.key, value = _a.value;
321
- str += " ".concat(key, "={").concat(value, "} ");
315
+ needsToRenderSlots.forEach(({ key, value }) => {
316
+ str += ` ${key}={${value}} `;
322
317
  });
323
318
  }
324
319
  str = str.trim() + '>';
325
320
  if (json.children) {
326
321
  str += childrenNodes;
327
322
  }
328
- return str + "</".concat(json.name, ">");
323
+ return str + `</${json.name}>`;
329
324
  };
330
325
  exports.blockToReact = blockToReact;