@builder.io/mitosis 0.0.47 → 0.0.50-0

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 (173) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/src/__tests__/angular.test.d.ts +1 -0
  3. package/dist/src/__tests__/angular.test.js +12 -0
  4. package/dist/src/__tests__/data/blocks/columns.raw.jsx +6 -0
  5. package/dist/src/__tests__/data/blocks/onUpdate.raw.d.ts +1 -0
  6. package/dist/src/__tests__/data/blocks/onUpdate.raw.jsx +10 -0
  7. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +1 -0
  8. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +11 -0
  9. package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +11 -0
  10. package/dist/src/__tests__/data/blocks/tabs.raw.jsx +24 -0
  11. package/dist/src/__tests__/qoot.test.d.ts +1 -0
  12. package/dist/src/__tests__/qoot.test.js +115 -0
  13. package/dist/src/__tests__/qwik.test.js +38 -10
  14. package/dist/src/__tests__/react.test.js +12 -0
  15. package/dist/src/__tests__/svelte.test.d.ts +1 -0
  16. package/dist/src/__tests__/svelte.test.js +12 -0
  17. package/dist/src/__tests__/vue.test.js +6 -0
  18. package/dist/src/generators/angular.js +7 -3
  19. package/dist/src/generators/builder.js +7 -7
  20. package/dist/src/generators/html.js +16 -7
  21. package/dist/src/generators/jsx-lite.d.ts +10 -0
  22. package/dist/src/generators/jsx-lite.js +176 -0
  23. package/dist/src/generators/minify.d.ts +1 -0
  24. package/dist/src/generators/minify.js +24 -0
  25. package/dist/src/generators/mitosis.js +5 -2
  26. package/dist/src/generators/qoot.d.ts +21 -0
  27. package/dist/src/generators/qoot.js +442 -0
  28. package/dist/src/generators/qwik/component.js +48 -6
  29. package/dist/src/generators/qwik/directives.d.ts +21 -1
  30. package/dist/src/generators/qwik/directives.js +80 -3
  31. package/dist/src/generators/qwik/jsx.d.ts +1 -1
  32. package/dist/src/generators/qwik/jsx.js +28 -5
  33. package/dist/src/generators/qwik/src-generator.d.ts +3 -1
  34. package/dist/src/generators/qwik/src-generator.js +34 -10
  35. package/dist/src/generators/qwik.d.ts +21 -0
  36. package/dist/src/generators/qwik.js +458 -0
  37. package/dist/src/generators/react-native.js +57 -41
  38. package/dist/src/generators/react.js +18 -8
  39. package/dist/src/generators/solid.js +5 -2
  40. package/dist/src/generators/svelte.js +10 -5
  41. package/dist/src/generators/vue.js +7 -5
  42. package/dist/src/helpers/create-jsx-lite-component.d.ts +2 -0
  43. package/dist/src/helpers/create-jsx-lite-component.js +16 -0
  44. package/dist/src/helpers/create-jsx-lite-context.d.ts +4 -0
  45. package/dist/src/helpers/create-jsx-lite-context.js +18 -0
  46. package/dist/src/helpers/create-jsx-lite-node.d.ts +2 -0
  47. package/dist/src/helpers/create-jsx-lite-node.js +16 -0
  48. package/dist/src/helpers/is-jsx-lite-node.d.ts +2 -0
  49. package/dist/src/helpers/is-jsx-lite-node.js +7 -0
  50. package/dist/src/helpers/map-refs.js +7 -6
  51. package/dist/src/helpers/process-http-requests.js +3 -3
  52. package/dist/src/helpers/process-tag-references.js +4 -3
  53. package/dist/src/index.d.ts +2 -1
  54. package/dist/src/index.js +4 -3
  55. package/dist/src/jsx-types.d.ts +1 -1
  56. package/dist/src/parsers/builder.d.ts +50 -10
  57. package/dist/src/parsers/builder.js +37 -7
  58. package/dist/src/parsers/jsx.js +43 -3
  59. package/dist/src/parsers/liquid.js +4 -4
  60. package/dist/src/plugins/compile-away-builder-components.js +40 -20
  61. package/dist/src/symbols/symbol-processor.d.ts +18 -0
  62. package/dist/src/symbols/symbol-processor.js +177 -0
  63. package/dist/src/types/jsx-lite-component.d.ts +63 -0
  64. package/dist/src/types/jsx-lite-component.js +2 -0
  65. package/dist/src/types/jsx-lite-context.d.ts +6 -0
  66. package/dist/src/types/jsx-lite-context.js +2 -0
  67. package/dist/src/types/jsx-lite-node.d.ts +13 -0
  68. package/dist/src/types/jsx-lite-node.js +2 -0
  69. package/dist/src/types/jsx-lite-styles.d.ts +1 -0
  70. package/dist/src/types/jsx-lite-styles.js +2 -0
  71. package/dist/src/types/mitosis-component.d.ts +10 -5
  72. package/dist/test/qoot/Todo/bundle.js +88 -0
  73. package/dist/test/qoot/Todo/component.ts +17 -0
  74. package/dist/test/qoot/Todo/onButtonClick.ts +13 -0
  75. package/dist/test/qoot/Todo/onInput2Blur.ts +11 -0
  76. package/dist/test/qoot/Todo/onInput2KeyUp.ts +10 -0
  77. package/dist/test/qoot/Todo/onInputClick.ts +10 -0
  78. package/dist/test/qoot/Todo/onLabelDblClick.ts +11 -0
  79. package/dist/test/qoot/Todo/public.ts +4 -0
  80. package/dist/test/qoot/Todo/template.tsx +46 -0
  81. package/dist/test/qoot/Todos/component.ts +9 -0
  82. package/dist/test/qoot/Todos/onInputClick.ts +14 -0
  83. package/dist/test/qoot/Todos/public.ts +3 -0
  84. package/dist/test/qoot/Todos/template.tsx +30 -0
  85. package/dist/test/qwik/Accordion/low.jsx +39 -33
  86. package/dist/test/qwik/Accordion/med.jsx +1 -0
  87. package/dist/test/qwik/For/low.jsx +22 -14
  88. package/dist/test/qwik/For/med.jsx +1 -0
  89. package/dist/test/qwik/Image/low.js +20 -47
  90. package/dist/test/qwik/Image/med.js +3 -1
  91. package/dist/test/qwik/Image.slow/low.js +20 -47
  92. package/dist/test/qwik/Image.slow/med.js +3 -1
  93. package/dist/test/qwik/{todo → Todo}/Todo.cjs/high.cjs +0 -0
  94. package/dist/test/qwik/{todo → Todo}/Todo.cjs/low.cjs +0 -0
  95. package/dist/test/qwik/Todo/Todo.cjs/med.cjs +64 -0
  96. package/dist/test/qwik/{todo → Todo}/Todo.js/high.js +0 -0
  97. package/dist/test/qwik/{todo → Todo}/Todo.js/low.js +0 -0
  98. package/dist/test/qwik/Todo/Todo.js/med.js +1 -0
  99. package/dist/test/qwik/{todo → Todo}/Todo.tsx/high.tsx +0 -0
  100. package/dist/test/qwik/{todo → Todo}/Todo.tsx/low.tsx +0 -0
  101. package/dist/test/qwik/Todo/Todo.tsx/med.tsx +39 -0
  102. package/dist/test/qwik/Todo/bundle.js +46 -0
  103. package/dist/test/qwik/Todo/component.ts +17 -0
  104. package/dist/test/qwik/Todo/onButtonClick.ts +10 -0
  105. package/dist/test/qwik/Todo/onInput2Blur.ts +14 -0
  106. package/dist/test/qwik/Todo/onInput2KeyUp.ts +10 -0
  107. package/dist/test/qwik/Todo/onInputClick.ts +13 -0
  108. package/dist/test/qwik/Todo/onLabelDblClick.ts +11 -0
  109. package/dist/test/qwik/Todo/public.ts +3 -0
  110. package/dist/test/qwik/Todo/template.tsx +46 -0
  111. package/dist/test/qwik/Todo.ts +4 -0
  112. package/dist/test/qwik/Todo_component.ts +17 -0
  113. package/dist/test/qwik/Todo_onButtonClick.ts +13 -0
  114. package/dist/test/qwik/Todo_onInput2Blur.ts +14 -0
  115. package/dist/test/qwik/Todo_onInput2KeyUp.ts +10 -0
  116. package/dist/test/qwik/Todo_onInputClick.ts +13 -0
  117. package/dist/test/qwik/Todo_onLabelDblClick.ts +14 -0
  118. package/dist/test/qwik/Todo_template.tsx +46 -0
  119. package/dist/test/qwik/{todos → Todos}/Todo.tsx/high.tsx +0 -0
  120. package/dist/test/qwik/Todos/Todo.tsx/low.tsx +33 -0
  121. package/dist/test/qwik/Todos/Todo.tsx/med.tsx +9 -0
  122. package/dist/test/qwik/Todos/component.ts +9 -0
  123. package/dist/test/qwik/Todos/onInputClick.ts +14 -0
  124. package/dist/test/qwik/Todos/public.ts +3 -0
  125. package/dist/test/qwik/Todos/template.tsx +30 -0
  126. package/dist/test/qwik/Todos.ts +3 -0
  127. package/dist/test/qwik/Todos_component.ts +9 -0
  128. package/dist/test/qwik/Todos_onInputClick.ts +14 -0
  129. package/dist/test/qwik/Todos_template.tsx +30 -0
  130. package/dist/test/qwik/button/low.js +18 -10
  131. package/dist/test/qwik/button/med.js +3 -1
  132. package/dist/test/qwik/component/bindings/high.jsx +1 -0
  133. package/dist/test/qwik/component/bindings/low.jsx +84 -0
  134. package/dist/test/qwik/component/bindings/med.jsx +47 -0
  135. package/dist/test/qwik/hello_world/stylesheet/low.jsx +10 -4
  136. package/dist/test/qwik/hello_world/stylesheet/med.jsx +1 -0
  137. package/dist/test/qwik/page-with-symbol/low.js +23 -17
  138. package/dist/test/qwik/page-with-symbol/med.js +1 -0
  139. package/dist/test/qwik/qwik/Image/high.js +1 -0
  140. package/dist/test/qwik/qwik/Image/low.js +75 -0
  141. package/dist/test/qwik/qwik/Image/med.js +9 -0
  142. package/dist/test/qwik/qwik/Image.slow/high.js +1 -0
  143. package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
  144. package/dist/test/qwik/qwik/Image.slow/med.js +9 -0
  145. package/dist/test/qwik/qwik/button/high.js +8 -0
  146. package/dist/test/qwik/qwik/button/low.js +34 -0
  147. package/dist/test/qwik/qwik/button/med.js +9 -0
  148. package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +1 -0
  149. package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +24 -0
  150. package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +9 -0
  151. package/dist/test/qwik/qwik/page-with-symbol/high.js +1 -0
  152. package/dist/test/qwik/qwik/page-with-symbol/low.js +49 -0
  153. package/dist/test/qwik/qwik/page-with-symbol/med.js +9 -0
  154. package/dist/test/qwik/qwik/svg/high.js +1 -0
  155. package/dist/test/qwik/qwik/svg/low.js +30 -0
  156. package/dist/test/qwik/qwik/svg/med.js +9 -0
  157. package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +31 -0
  158. package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +1 -0
  159. package/dist/test/qwik/{todo → qwik/todo}/Todo.cjs/med.cjs +0 -0
  160. package/dist/test/qwik/qwik/todo/Todo.js/high.js +5 -0
  161. package/dist/{src/types/generators.d.ts → test/qwik/qwik/todo/Todo.js/low.js} +0 -0
  162. package/dist/test/qwik/{todo → qwik/todo}/Todo.js/med.js +0 -0
  163. package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +30 -0
  164. package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +1 -0
  165. package/dist/test/qwik/{todo → qwik/todo}/Todo.tsx/med.tsx +0 -0
  166. package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +12 -0
  167. package/dist/test/qwik/{todos → qwik/todos}/Todo.tsx/low.tsx +3 -4
  168. package/dist/test/qwik/{todos → qwik/todos}/Todo.tsx/med.tsx +0 -0
  169. package/dist/test/qwik/svg/low.js +16 -10
  170. package/dist/test/qwik/svg/med.js +1 -0
  171. package/dist/tsconfig.tsbuildinfo +1 -1
  172. package/package.json +1 -1
  173. package/dist/src/types/generators.js +0 -1
@@ -0,0 +1,458 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
54
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
55
+ to[j] = from[i];
56
+ return to;
57
+ };
58
+ var __importDefault = (this && this.__importDefault) || function (mod) {
59
+ return (mod && mod.__esModule) ? mod : { "default": mod };
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.componentToQwik = void 0;
63
+ var core_1 = require("@babel/core");
64
+ var plugin_virtual_1 = __importDefault(require("@rollup/plugin-virtual"));
65
+ var dedent_1 = __importDefault(require("dedent"));
66
+ var lodash_1 = require("lodash");
67
+ var standalone_1 = require("prettier/standalone");
68
+ var rollup_1 = require("rollup");
69
+ var traverse_1 = __importDefault(require("traverse"));
70
+ var babel_transform_1 = require("../helpers/babel-transform");
71
+ var capitalize_1 = require("../helpers/capitalize");
72
+ var collect_styles_1 = require("../helpers/collect-styles");
73
+ var fast_clone_1 = require("../helpers/fast-clone");
74
+ var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
75
+ var get_state_object_string_1 = require("../helpers/get-state-object-string");
76
+ var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
77
+ var is_valid_attribute_name_1 = require("../helpers/is-valid-attribute-name");
78
+ var remove_surrounding_block_1 = require("../helpers/remove-surrounding-block");
79
+ var render_imports_1 = require("../helpers/render-imports");
80
+ var strip_meta_properties_1 = require("../helpers/strip-meta-properties");
81
+ var strip_state_and_props_refs_1 = require("../helpers/strip-state-and-props-refs");
82
+ var plugins_1 = require("../modules/plugins");
83
+ var jsx_1 = require("../parsers/jsx");
84
+ var html_escape_1 = require("../helpers/html-escape");
85
+ var qwikImport = function (options) {
86
+ return options.qwikLib || '@builder.io/qwik';
87
+ };
88
+ function addMarkDirtyAfterSetInCode(code, options, useString) {
89
+ if (useString === void 0) { useString = 'markDirty(this)'; }
90
+ return babel_transform_1.babelTransformExpression(code, {
91
+ UpdateExpression: function (path) {
92
+ var node = path.node;
93
+ if (core_1.types.isMemberExpression(node.argument)) {
94
+ if (core_1.types.isIdentifier(node.argument.object)) {
95
+ // TODO: utility to properly trace this reference to the beginning
96
+ if (node.argument.object.name === 'state') {
97
+ // TODO: ultimately do updates by property, e.g. updateName()
98
+ // that updates any attributes dependent on name, etc
99
+ var parent_1 = path;
100
+ // `_temp = ` assignments are created sometimes when we insertAfter
101
+ // for simple expressions. this causes us to re-process the same expression
102
+ // in an infinite loop
103
+ while ((parent_1 = parent_1.parentPath)) {
104
+ if (core_1.types.isAssignmentExpression(parent_1.node) &&
105
+ core_1.types.isIdentifier(parent_1.node.left) &&
106
+ parent_1.node.left.name.startsWith('_temp')) {
107
+ return;
108
+ }
109
+ }
110
+ path.insertAfter(core_1.types.identifier(useString));
111
+ }
112
+ }
113
+ }
114
+ },
115
+ AssignmentExpression: function (path) {
116
+ var node = path.node;
117
+ if (core_1.types.isMemberExpression(node.left)) {
118
+ if (core_1.types.isIdentifier(node.left.object)) {
119
+ // TODO: utility to properly trace this reference to the beginning
120
+ if (node.left.object.name === 'state') {
121
+ // TODO: ultimately do updates by property, e.g. updateName()
122
+ // that updates any attributes dependent on name, etc
123
+ var parent_2 = path;
124
+ // `_temp = ` assignments are created sometimes when we insertAfter
125
+ // for simple expressions. this causes us to re-process the same expression
126
+ // in an infinite loop
127
+ while ((parent_2 = parent_2.parentPath)) {
128
+ if (core_1.types.isAssignmentExpression(parent_2.node) &&
129
+ core_1.types.isIdentifier(parent_2.node.left) &&
130
+ parent_2.node.left.name.startsWith('_temp')) {
131
+ return;
132
+ }
133
+ }
134
+ path.insertAfter(core_1.types.identifier(useString));
135
+ }
136
+ }
137
+ }
138
+ },
139
+ });
140
+ }
141
+ var processBinding = function (binding, options) {
142
+ return strip_state_and_props_refs_1.stripStateAndPropsRefs(addMarkDirtyAfterSetInCode(binding, options), {
143
+ replaceWith: 'this.',
144
+ })
145
+ // Remove trailing semicolon
146
+ .trim()
147
+ .replace(/;$/, '');
148
+ };
149
+ var NODE_MAPPERS = {
150
+ Fragment: function (json, options) {
151
+ return "<>" + json.children
152
+ .map(function (item) { return blockToQwik(item, options); })
153
+ .join('\n') + "</>";
154
+ },
155
+ For: function (json, options) {
156
+ return "{" + processBinding(json.bindings.each, options) + "?.map(" + json.properties._forName + " => (\n <>" + json.children
157
+ .filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
158
+ .map(function (item) { return blockToQwik(item, options); })
159
+ .join('\n') + "</>\n ))}";
160
+ },
161
+ Show: function (json, options) {
162
+ return "{" + processBinding(json.bindings.when, options) + " ? (\n <>" + json.children
163
+ .filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
164
+ .map(function (item) { return blockToQwik(item, options); })
165
+ .join('\n') + "</>\n ) : undefined}";
166
+ },
167
+ };
168
+ var getId = function (json, options) {
169
+ var name = json.properties.$name
170
+ ? camelCase(json.properties.$name)
171
+ : /^h\d$/.test(json.name || '') // don't dashcase h1 into h-1
172
+ ? json.name
173
+ : camelCase(json.name || 'div');
174
+ var newNameNum = (options.namesMap[name] || 0) + 1;
175
+ options.namesMap[name] = newNameNum;
176
+ return capitalize_1.capitalize("" + name + (newNameNum === 1 ? '' : "" + newNameNum));
177
+ };
178
+ var elId = function (node, options) {
179
+ if (node.meta.id) {
180
+ return node.meta.id;
181
+ }
182
+ var id = getId(node, options);
183
+ node.meta.id = id;
184
+ return id;
185
+ };
186
+ var blockToQwik = function (json, options) {
187
+ if (NODE_MAPPERS[json.name]) {
188
+ return NODE_MAPPERS[json.name](json, options);
189
+ }
190
+ if (json.bindings._text) {
191
+ return "{" + processBinding(json.bindings._text, options) + "}";
192
+ }
193
+ if (json.properties._text) {
194
+ return json.properties._text;
195
+ }
196
+ var str = '';
197
+ str += "<" + json.name + " ";
198
+ if (json.bindings._spread) {
199
+ str += " {...(" + json.bindings._spread + ")} ";
200
+ }
201
+ for (var key in json.properties) {
202
+ if (!key || key.startsWith('_') || key.startsWith('$')) {
203
+ continue;
204
+ }
205
+ var value = html_escape_1.htmlAttributeEscape(json.properties[key] || '');
206
+ if (is_valid_attribute_name_1.isValidAttributeName(key)) {
207
+ str += " " + key + "=\"" + value + "\" ";
208
+ }
209
+ }
210
+ var eventBindings = {};
211
+ for (var key in json.bindings) {
212
+ var value = json.bindings[key];
213
+ if (key.startsWith('_') || key.startsWith('$')) {
214
+ continue;
215
+ }
216
+ if (key.startsWith('on')) {
217
+ var useKey = key.replace('on', 'on:').toLowerCase();
218
+ var componentName = getComponentName(options.componentJson, options);
219
+ if (options.bundle) {
220
+ eventBindings[useKey] = "QRL`" + options.qrlPrefix + "/" + componentName + "/bundle" + (options.qrlSuffix || '') + ".on" + elId(json, options) + key.slice(2) + "`";
221
+ }
222
+ else {
223
+ eventBindings[useKey] = "QRL`" + options.qrlPrefix + "/" + componentName + "_on" + elId(json, options) + key.slice(2) + (options.qrlSuffix || '') + "`";
224
+ }
225
+ }
226
+ else {
227
+ if (!is_valid_attribute_name_1.isValidAttributeName(key)) {
228
+ console.warn('Skipping invalid attribute name:', key);
229
+ }
230
+ else {
231
+ str += " " + key + "={" + processBinding(value, options) + "} ";
232
+ }
233
+ }
234
+ }
235
+ if (lodash_1.size(eventBindings)) {
236
+ for (var event_1 in eventBindings) {
237
+ str += event_1 + "={" + eventBindings[event_1] + "}";
238
+ }
239
+ }
240
+ if (jsx_1.selfClosingTags.has(json.name)) {
241
+ return str + ' />';
242
+ }
243
+ str += '>';
244
+ if (json.children) {
245
+ str += json.children.map(function (item) { return blockToQwik(item, options); }).join('\n');
246
+ }
247
+ str += "</" + json.name + ">";
248
+ return str;
249
+ };
250
+ var getComponentName = function (json, options) {
251
+ return capitalize_1.capitalize(camelCase(json.name || 'my-component'));
252
+ };
253
+ // TODO
254
+ var getProvidersString = function (componentJson, options) {
255
+ return 'null';
256
+ };
257
+ var formatCode = function (str, options, type) {
258
+ if (type === void 0) { type = 'typescript'; }
259
+ if (options.prettier !== false) {
260
+ try {
261
+ str = standalone_1.format(str, {
262
+ parser: type === 'typescript' ? 'babel-ts' : type,
263
+ plugins: [
264
+ require('prettier/parser-typescript'),
265
+ require('prettier/parser-babel'),
266
+ require('prettier/parser-postcss'),
267
+ ],
268
+ });
269
+ }
270
+ catch (err) {
271
+ console.warn('Error formatting code', err);
272
+ }
273
+ }
274
+ return str;
275
+ };
276
+ var getEventHandlerFiles = function (componentJson, options) {
277
+ var files = [];
278
+ traverse_1.default(componentJson).forEach(function (item) {
279
+ if (is_mitosis_node_1.isMitosisNode(item)) {
280
+ for (var binding in item.bindings) {
281
+ if (binding.startsWith('on')) {
282
+ var eventHandlerName = elId(item, options) + binding.slice(2);
283
+ var componentName = getComponentName(componentJson, options);
284
+ var str = formatCode("import {\n injectEventHandler,\n provideEvent,\n markDirty\n } from '" + qwikImport(options) + "';\n import { " + componentName + "Component } from './" + componentName + "_component.js'\n \n export " + (options.bundle ? "const on" + eventHandlerName + " =" : 'default') + " injectEventHandler(\n " + componentName + "Component,\n provideEvent(),\n async function (this: " + componentName + "Component, event: Event) {\n " + remove_surrounding_block_1.removeSurroundingBlock(processBinding(item.bindings[binding], options)) + "\n }\n )\n ", options);
285
+ str = formatCode(str, options);
286
+ files.push({
287
+ path: componentName + "_on" + eventHandlerName + ".ts",
288
+ contents: str,
289
+ });
290
+ }
291
+ }
292
+ }
293
+ });
294
+ return files;
295
+ };
296
+ var componentToQwik = function (componentJson, toQwikOptions) {
297
+ if (toQwikOptions === void 0) { toQwikOptions = {}; }
298
+ return __awaiter(void 0, void 0, void 0, function () {
299
+ var json, options, css, hasCss, addWrapper, componentName, str, dataString, output, moduleMap, bundle, bundleOutput;
300
+ return __generator(this, function (_a) {
301
+ switch (_a.label) {
302
+ case 0:
303
+ json = fast_clone_1.fastClone(componentJson);
304
+ options = __assign(__assign({ qrlPrefix: 'ui:' }, toQwikOptions), { namesMap: {}, componentJson: json });
305
+ if (options.plugins) {
306
+ json = plugins_1.runPreJsonPlugins(json, options.plugins);
307
+ }
308
+ css = collect_styles_1.collectCss(json, {
309
+ classProperty: 'class',
310
+ prefix: options.cssNamespace,
311
+ });
312
+ if (options.minifyStyles) {
313
+ css = css.trim().replace(/\s+/g, ' ');
314
+ }
315
+ else {
316
+ css = formatCode(css, options, 'css');
317
+ }
318
+ hasCss = Boolean(css.trim().length);
319
+ addWrapper = json.children.length > 1 || hasCss;
320
+ if (options.plugins) {
321
+ json = plugins_1.runPostJsonPlugins(json, options.plugins);
322
+ }
323
+ componentName = capitalize_1.capitalize(camelCase(componentJson.name || 'my-component'));
324
+ strip_meta_properties_1.stripMetaProperties(json);
325
+ str = dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { injectMethod, QRL, h } from '", "';\n import { ", "Component } from './", "_component.js'\n ", "\n\n export ", " injectMethod(", "Component, function (this: ", "Component) {\n return (", "\n ", "\n ", "\n ", ")\n })\n "], ["\n import { injectMethod, QRL, h } from '", "';\n import { ", "Component } from './", "_component.js'\n ",
326
+ "\n\n export ",
327
+ " injectMethod(", "Component, function (this: ", "Component) {\n return (", "\n ",
328
+ "\n ", "\n ", ")\n })\n "])), qwikImport(options), componentName, componentName, render_imports_1.renderPreComponent(__assign(__assign({}, json), { imports: json.imports.map(function (item) {
329
+ if (item.path.endsWith('.lite')) {
330
+ var clone = fast_clone_1.fastClone(item);
331
+ var name_1 = clone.path
332
+ .split(/[\.\/]/)
333
+ // Get the -1 index of array
334
+ .slice(-2, -1)
335
+ .pop();
336
+ var pascalName = capitalize_1.capitalize(camelCase(name_1));
337
+ clone.path = "../" + pascalName + "/public.js";
338
+ for (var key in clone.imports) {
339
+ var value = clone.imports[key];
340
+ if (value === 'default') {
341
+ clone.imports[key] = pascalName;
342
+ }
343
+ }
344
+ return clone;
345
+ }
346
+ return item;
347
+ }) })), options.bundle ? "const template = " : 'default', componentName, componentName, addWrapper ? '<>' : '', !hasCss
348
+ ? ''
349
+ : "<style>{`" + css
350
+ .trim()
351
+ .replace(/^|\n/g, '\n' + ' '.repeat(12)) + "`}</style>", json.children.map(function (item) { return blockToQwik(item, options); }).join('\n'), addWrapper ? '</>' : '');
352
+ if (options.plugins) {
353
+ str = plugins_1.runPreCodePlugins(str, options.plugins);
354
+ }
355
+ str = formatCode(str, options);
356
+ if (options.plugins) {
357
+ str = plugins_1.runPostCodePlugins(str, options.plugins);
358
+ }
359
+ dataString = get_state_object_string_1.getStateObjectStringFromComponent(json, {
360
+ format: 'class',
361
+ valueMapper: function (code) { return processBinding(code, options); },
362
+ });
363
+ output = {
364
+ files: __spreadArray([
365
+ {
366
+ path: componentName + "_template.tsx",
367
+ contents: str,
368
+ },
369
+ {
370
+ path: componentName + ".ts",
371
+ contents: formatCode("\n import { jsxDeclareComponent, QRL } from '" + qwikImport(options) + "';\n \n export const " + componentName + " = jsxDeclareComponent(QRL`" + options.qrlPrefix + "/" + componentName + (options.bundle ? '/bundle' : '_template') + (options.qrlSuffix || '') + (options.bundle ? '.template' : '') + "`, '" + lodash_1.kebabCase(componentName) + "');\n ", options),
372
+ },
373
+ {
374
+ path: componentName + "_component.ts",
375
+ contents: formatCode((function () {
376
+ var str = "\n " + (options.format === 'builder' ? '' : 'export ') + "class " + (options.format === 'builder' ? '_' : '') + componentName + "Component extends Component<any, any> {\n " + (options.format === 'builder'
377
+ ? ''
378
+ : "static $templateQRL = '" + options.qrlPrefix + "/" + componentName + (options.bundle ? '/bundle' : '_template') + (options.qrlSuffix || '') + (options.bundle ? '.template' : '') + "'") + "\n\n " + dataString + "\n\n " + (!json.hooks.onMount
379
+ ? ''
380
+ : "\n constructor(...args) {\n super(...args);\n\n " + processBinding(json.hooks.onMount, options) + "\n }\n ") + "\n\n $newState() {\n return {} // TODO\n }\n }\n " + (options.format !== 'builder'
381
+ ? ''
382
+ : "\n export const " + componentName + "Component = new Proxy(_" + componentName + "Component, {\n get(target, prop) {\n if (prop === '$templateQRL') {\n return '" + options.qrlPrefix + "/" + componentName + (options.bundle ? '/bundle' : '_template') + (options.qrlSuffix || '') + (options.bundle ? '.template' : '') + "'\n }\n return Reflect.get(...arguments)\n }\n })\n ") + "\n ";
383
+ str = "\n import { Component, QRL " + (str.includes('markDirty(') ? ', markDirty' : '') + " } from '" + qwikImport(options) + "';\n " + str + "\n ";
384
+ return str;
385
+ })(), options),
386
+ }
387
+ ], getEventHandlerFiles(json, options)),
388
+ };
389
+ if (!options.bundle) return [3 /*break*/, 3];
390
+ moduleMap = __assign({ entry: output.files
391
+ .filter(function (file) { return !file.path.endsWith('.ts'); })
392
+ .map(function (file) { return "export * from './" + file.path.replace(/\.tsx?$/, '.js') + "';"; })
393
+ .join('\n') }, output.files.reduce(function (memo, arg) {
394
+ var transformed = core_1.transform(arg.contents, {
395
+ sourceFileName: arg.path,
396
+ plugins: [
397
+ [
398
+ require('@babel/plugin-transform-typescript'),
399
+ {
400
+ jsx: 'react',
401
+ isTSX: true,
402
+ allExtensions: true,
403
+ jsxFactory: 'h',
404
+ jsxPragma: 'h',
405
+ },
406
+ ],
407
+ [
408
+ require('@babel/plugin-transform-react-jsx'),
409
+ {
410
+ pragma: 'h',
411
+ pragmaFrag: 'null',
412
+ throwIfNamespace: false,
413
+ },
414
+ ],
415
+ require('@babel/plugin-proposal-class-properties'),
416
+ ],
417
+ });
418
+ memo['./' + arg.path.replace(/\.tsx?$/, '.js')] = transformed.code;
419
+ return memo;
420
+ }, {}));
421
+ return [4 /*yield*/, rollup_1.rollup({
422
+ input: 'entry',
423
+ external: [options.qwikLib || '@builder.io/qwik'],
424
+ plugins: [plugin_virtual_1.default(moduleMap)],
425
+ })];
426
+ case 1:
427
+ bundle = _a.sent();
428
+ return [4 /*yield*/, bundle.generate({
429
+ file: 'bundle.js',
430
+ format: 'esm',
431
+ })];
432
+ case 2:
433
+ bundleOutput = (_a.sent()).output;
434
+ output.files.push({
435
+ path: componentName + "/bundle.js",
436
+ contents: bundleOutput[0].code,
437
+ });
438
+ _a.label = 3;
439
+ case 3: return [2 /*return*/, output];
440
+ }
441
+ });
442
+ });
443
+ };
444
+ exports.componentToQwik = componentToQwik;
445
+ /**
446
+ * This is a function similar to loadash `camelCase`, but it does not mess with capitalization.
447
+ *
448
+ * loadash: `camelCase('A-BC')` => "ABc"
449
+ * this fn: `camelCase('A-BC')` => "ABC"
450
+ *
451
+ */
452
+ function camelCase(text) {
453
+ if (text === void 0) { text = ''; }
454
+ var parts = text.split('-');
455
+ var first = parts.shift();
456
+ return first + parts.map(capitalize_1.capitalize).join('');
457
+ }
458
+ var templateObject_1;
@@ -22,63 +22,79 @@ var traverse_1 = __importDefault(require("traverse"));
22
22
  var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
23
23
  var react_1 = require("./react");
24
24
  var stylePropertiesThatMustBeNumber = new Set(['lineHeight']);
25
+ var MEDIA_QUERY_KEY_REGEX = /^@media.*/;
25
26
  var collectReactNativeStyles = function (json) {
26
27
  var styleMap = {};
27
28
  var componentIndexes = {};
28
29
  (0, traverse_1.default)(json).forEach(function (item) {
29
- if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
30
- if (typeof item.bindings.css === 'string') {
31
- var value = json5_1.default.parse(item.bindings.css);
32
- delete item.bindings.css;
33
- if (!(0, lodash_1.size)(value)) {
34
- return;
35
- }
36
- // Style properties like `"20px"` need to be numbers like `20` for react native
37
- for (var key in value) {
38
- var propertyValue = value[key];
39
- if (typeof propertyValue === 'string' && propertyValue.match(/^\d/)) {
40
- var newValue = parseFloat(propertyValue);
41
- if (!isNaN(newValue)) {
42
- value[key] = newValue;
43
- }
44
- }
45
- if (stylePropertiesThatMustBeNumber.has(key) &&
46
- typeof value[key] !== 'number') {
47
- console.warn("Style key ".concat(key, " must be a number, but had value `").concat(value[key], "`"));
48
- delete value[key];
49
- }
30
+ if (!(0, is_mitosis_node_1.isMitosisNode)(item) || typeof item.bindings.css !== 'string') {
31
+ return;
32
+ }
33
+ var value = json5_1.default.parse(item.bindings.css);
34
+ delete item.bindings.css;
35
+ if (!(0, lodash_1.size)(value)) {
36
+ return;
37
+ }
38
+ // Style properties like `"20px"` need to be numbers like `20` for react native
39
+ for (var key in value) {
40
+ var propertyValue = value[key];
41
+ if (key.match(MEDIA_QUERY_KEY_REGEX)) {
42
+ console.warn('Unsupported: skipping media queries for react-native: ', key, propertyValue);
43
+ delete value[key];
44
+ continue;
45
+ }
46
+ if (stylePropertiesThatMustBeNumber.has(key) &&
47
+ typeof propertyValue !== 'number') {
48
+ console.warn("Style key ".concat(key, " must be a number, but had value `").concat(propertyValue, "`"));
49
+ delete value[key];
50
+ continue;
51
+ }
52
+ // convert strings to number if applicable
53
+ if (typeof propertyValue === 'string' && propertyValue.match(/^\d/)) {
54
+ var newValue = parseFloat(propertyValue);
55
+ if (!isNaN(newValue)) {
56
+ value[key] = newValue;
50
57
  }
51
- var componentName = (0, lodash_1.camelCase)(item.name || 'view');
52
- var index = (componentIndexes[componentName] =
53
- (componentIndexes[componentName] || 0) + 1);
54
- var className = "".concat(componentName).concat(index);
55
- item.bindings.style = "styles.".concat(className);
56
- styleMap[className] = value;
57
58
  }
58
59
  }
60
+ var componentName = (0, lodash_1.camelCase)(item.name || 'view');
61
+ var index = (componentIndexes[componentName] =
62
+ (componentIndexes[componentName] || 0) + 1);
63
+ var className = "".concat(componentName).concat(index);
64
+ item.bindings.style = "styles.".concat(className);
65
+ styleMap[className] = value;
59
66
  });
60
67
  return styleMap;
61
68
  };
62
69
  exports.collectReactNativeStyles = collectReactNativeStyles;
70
+ // Plugin to convert DOM tags to <View /> and <Text />
71
+ function processReactNative() {
72
+ return function () { return ({
73
+ json: {
74
+ pre: function (json) {
75
+ (0, traverse_1.default)(json).forEach(function (node) {
76
+ var _a, _b, _c;
77
+ if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
78
+ // TODO: handle TextInput, Image, etc
79
+ if (node.name.toLowerCase() === node.name) {
80
+ node.name = 'View';
81
+ }
82
+ if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) ||
83
+ ((_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.length)) {
84
+ node.name = 'Text';
85
+ }
86
+ }
87
+ });
88
+ },
89
+ },
90
+ }); };
91
+ }
63
92
  var componentToReactNative = function (options) {
64
93
  if (options === void 0) { options = {}; }
65
94
  return function (_a) {
66
95
  var component = _a.component, path = _a.path;
67
96
  var json = (0, fast_clone_1.fastClone)(component);
68
- (0, traverse_1.default)(json).forEach(function (node) {
69
- var _a, _b, _c;
70
- if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
71
- // TODO: handle TextInput, Image, etc
72
- if (node.name.toLowerCase() === node.name) {
73
- node.name = 'View';
74
- }
75
- if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) ||
76
- ((_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.length)) {
77
- node.name = 'Text';
78
- }
79
- }
80
- });
81
- return (0, react_1.componentToReact)(__assign(__assign({}, options), { stylesType: options.stylesType || 'react-native', type: 'native' }))({ component: json, path: path });
97
+ return (0, react_1.componentToReact)(__assign(__assign({}, options), { plugins: (options.plugins || []).concat([processReactNative()]), stylesType: options.stylesType || 'react-native', type: 'native' }))({ component: json, path: path });
82
98
  };
83
99
  };
84
100
  exports.componentToReactNative = componentToReactNative;
@@ -294,14 +294,19 @@ function hasContext(component) {
294
294
  Object.keys(component.context.set).length);
295
295
  }
296
296
  var getInitCode = function (json, options) {
297
- return processBinding(json.hooks.init || '', options);
297
+ var _a;
298
+ return processBinding(((_a = json.hooks.init) === null || _a === void 0 ? void 0 : _a.code) || '', options);
299
+ };
300
+ var DEFAULT_OPTIONS = {
301
+ stateType: 'useState',
302
+ stylesType: 'styled-jsx',
298
303
  };
299
304
  var componentToReact = function (reactOptions) {
300
305
  if (reactOptions === void 0) { reactOptions = {}; }
301
306
  return function (_a) {
302
307
  var component = _a.component;
303
308
  var json = (0, fast_clone_1.fastClone)(component);
304
- var options = __assign({ stateType: 'useState', stylesType: 'styled-jsx' }, reactOptions);
309
+ var options = __assign(__assign({}, DEFAULT_OPTIONS), reactOptions);
305
310
  if (options.plugins) {
306
311
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
307
312
  }
@@ -339,6 +344,7 @@ var componentToReact = function (reactOptions) {
339
344
  };
340
345
  exports.componentToReact = componentToReact;
341
346
  var _componentToReact = function (json, options, isSubComponent) {
347
+ var _a, _b, _c, _d, _e, _f;
342
348
  if (isSubComponent === void 0) { isSubComponent = false; }
343
349
  (0, process_http_requests_1.processHttpRequests)(json);
344
350
  (0, handle_missing_state_1.handleMissingState)(json);
@@ -379,14 +385,16 @@ var _componentToReact = function (json, options, isSubComponent) {
379
385
  if (refs.size) {
380
386
  reactLibImports.add('useRef');
381
387
  }
382
- if (json.hooks.onMount || json.hooks.onUnMount) {
388
+ if (((_a = json.hooks.onMount) === null || _a === void 0 ? void 0 : _a.code) ||
389
+ ((_b = json.hooks.onUnMount) === null || _b === void 0 ? void 0 : _b.code) ||
390
+ ((_c = json.hooks.onUpdate) === null || _c === void 0 ? void 0 : _c.code)) {
383
391
  reactLibImports.add('useEffect');
384
392
  }
385
393
  var wrap = wrapInFragment(json) || (componentHasStyles && stylesType === 'styled-jsx');
386
394
  var nativeStyles = stylesType === 'react-native' &&
387
395
  componentHasStyles &&
388
396
  (0, react_native_1.collectReactNativeStyles)(json);
389
- var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "function ", "(props) {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (\n ", "\n ", "\n ", "\n ", "\n );\n }\n\n ", "\n\n ", "\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "function ", "(props) {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n return (\n ", "\n ", "\n ", "\n ", "\n );\n }\n\n ", "\n\n ", "\n "])), options.type !== 'native'
397
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "function ", "(props) {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n return (\n ", "\n ", "\n ", "\n ", "\n );\n }\n\n ", "\n\n ", "\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n ", "function ", "(props) {\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n return (\n ", "\n ", "\n ", "\n ", "\n );\n }\n\n ", "\n\n ", "\n "])), options.type !== 'native'
390
398
  ? ''
391
399
  : "\n import * as React from 'react';\n import { View, StyleSheet, Image, Text } from 'react-native';\n ", styledComponentsCode ? "import styled from 'styled-components';\n" : '', reactLibImports.size
392
400
  ? "import { ".concat(Array.from(reactLibImports).join(', '), " } from 'react'")
@@ -409,10 +417,12 @@ var _componentToReact = function (json, options, isSubComponent) {
409
417
  : stateType === 'builder'
410
418
  ? "var state = useBuilderState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
411
419
  : "const state = useLocalProxy(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
412
- : '', getContextString(json, options), getRefsString(json), getInitCode(json, options), json.hooks.onMount
413
- ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onMount, options), options), "\n }, [])")
414
- : '', json.hooks.onUnMount
415
- ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onUnMount, options), options), "\n }, [])")
420
+ : '', getContextString(json, options), getRefsString(json), getInitCode(json, options), ((_d = json.hooks.onMount) === null || _d === void 0 ? void 0 : _d.code)
421
+ ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onMount.code, options), options), "\n }, [])")
422
+ : '', ((_e = json.hooks.onUpdate) === null || _e === void 0 ? void 0 : _e.code)
423
+ ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onUpdate.code, options), options), "\n }, ").concat(json.hooks.onUpdate.deps, ")")
424
+ : '', ((_f = json.hooks.onUnMount) === null || _f === void 0 ? void 0 : _f.code)
425
+ ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onUnMount.code, options), options), "\n }, [])")
416
426
  : '', wrap ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToReact)(item, options); }).join('\n'), componentHasStyles && stylesType === 'styled-jsx'
417
427
  ? "<style jsx>{`".concat(css, "`}</style>")
418
428
  : '', wrap ? '</>' : '', !nativeStyles