@builder.io/mitosis 0.0.48 → 0.0.49

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 (152) 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/onUpdate.raw.d.ts +1 -0
  5. package/dist/src/__tests__/data/blocks/onUpdate.raw.jsx +10 -0
  6. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +1 -0
  7. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +11 -0
  8. package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +11 -0
  9. package/dist/src/__tests__/data/blocks/tabs.raw.jsx +24 -0
  10. package/dist/src/__tests__/qoot.test.d.ts +1 -0
  11. package/dist/src/__tests__/qoot.test.js +115 -0
  12. package/dist/src/__tests__/qwik.test.js +38 -10
  13. package/dist/src/__tests__/react.test.js +12 -0
  14. package/dist/src/__tests__/svelte.test.d.ts +1 -0
  15. package/dist/src/__tests__/svelte.test.js +12 -0
  16. package/dist/src/__tests__/vue.test.js +6 -0
  17. package/dist/src/generators/angular.js +7 -3
  18. package/dist/src/generators/builder.js +7 -7
  19. package/dist/src/generators/html.js +16 -7
  20. package/dist/src/generators/jsx-lite.d.ts +10 -0
  21. package/dist/src/generators/jsx-lite.js +176 -0
  22. package/dist/src/generators/minify.d.ts +1 -0
  23. package/dist/src/generators/minify.js +24 -0
  24. package/dist/src/generators/mitosis.js +5 -2
  25. package/dist/src/generators/qoot.d.ts +21 -0
  26. package/dist/src/generators/qoot.js +442 -0
  27. package/dist/src/generators/qwik/component.js +48 -6
  28. package/dist/src/generators/qwik/directives.d.ts +21 -1
  29. package/dist/src/generators/qwik/directives.js +80 -3
  30. package/dist/src/generators/qwik/jsx.d.ts +1 -1
  31. package/dist/src/generators/qwik/jsx.js +28 -5
  32. package/dist/src/generators/qwik/src-generator.d.ts +3 -1
  33. package/dist/src/generators/qwik/src-generator.js +34 -10
  34. package/dist/src/generators/qwik.d.ts +21 -0
  35. package/dist/src/generators/qwik.js +458 -0
  36. package/dist/src/generators/react.js +13 -7
  37. package/dist/src/generators/solid.js +5 -2
  38. package/dist/src/generators/svelte.js +10 -5
  39. package/dist/src/generators/vue.js +7 -5
  40. package/dist/src/helpers/create-jsx-lite-component.d.ts +2 -0
  41. package/dist/src/helpers/create-jsx-lite-component.js +16 -0
  42. package/dist/src/helpers/create-jsx-lite-context.d.ts +4 -0
  43. package/dist/src/helpers/create-jsx-lite-context.js +18 -0
  44. package/dist/src/helpers/create-jsx-lite-node.d.ts +2 -0
  45. package/dist/src/helpers/create-jsx-lite-node.js +16 -0
  46. package/dist/src/helpers/is-jsx-lite-node.d.ts +2 -0
  47. package/dist/src/helpers/is-jsx-lite-node.js +7 -0
  48. package/dist/src/helpers/map-refs.js +7 -6
  49. package/dist/src/helpers/process-http-requests.js +3 -3
  50. package/dist/src/helpers/process-tag-references.js +4 -3
  51. package/dist/src/index.d.ts +2 -1
  52. package/dist/src/index.js +4 -3
  53. package/dist/src/parsers/builder.d.ts +50 -10
  54. package/dist/src/parsers/builder.js +37 -7
  55. package/dist/src/parsers/jsx.js +43 -3
  56. package/dist/src/parsers/liquid.js +4 -4
  57. package/dist/src/plugins/compile-away-builder-components.js +40 -20
  58. package/dist/src/symbols/symbol-processor.d.ts +18 -0
  59. package/dist/src/symbols/symbol-processor.js +177 -0
  60. package/dist/src/types/jsx-lite-component.d.ts +63 -0
  61. package/dist/src/types/jsx-lite-component.js +2 -0
  62. package/dist/src/types/jsx-lite-context.d.ts +6 -0
  63. package/dist/src/types/jsx-lite-context.js +2 -0
  64. package/dist/src/types/jsx-lite-node.d.ts +13 -0
  65. package/dist/src/types/jsx-lite-node.js +2 -0
  66. package/dist/src/types/jsx-lite-styles.d.ts +1 -0
  67. package/dist/src/types/jsx-lite-styles.js +2 -0
  68. package/dist/src/types/mitosis-component.d.ts +10 -5
  69. package/dist/test/qoot/Todo/bundle.js +88 -0
  70. package/dist/test/qoot/Todo/component.ts +17 -0
  71. package/dist/test/qoot/Todo/onButtonClick.ts +13 -0
  72. package/dist/test/qoot/Todo/onInput2Blur.ts +11 -0
  73. package/dist/test/qoot/Todo/onInput2KeyUp.ts +10 -0
  74. package/dist/test/qoot/Todo/onInputClick.ts +10 -0
  75. package/dist/test/qoot/Todo/onLabelDblClick.ts +11 -0
  76. package/dist/test/qoot/Todo/public.ts +4 -0
  77. package/dist/test/qoot/Todo/template.tsx +46 -0
  78. package/dist/test/qoot/Todos/component.ts +9 -0
  79. package/dist/test/qoot/Todos/onInputClick.ts +14 -0
  80. package/dist/test/qoot/Todos/public.ts +3 -0
  81. package/dist/test/qoot/Todos/template.tsx +30 -0
  82. package/dist/test/qwik/{todo → Todo}/Todo.cjs/high.cjs +0 -0
  83. package/dist/test/qwik/{todo → Todo}/Todo.cjs/low.cjs +0 -0
  84. package/dist/test/qwik/{todo → Todo}/Todo.cjs/med.cjs +0 -0
  85. package/dist/test/qwik/{todo → Todo}/Todo.js/high.js +0 -0
  86. package/dist/test/qwik/{todo → Todo}/Todo.js/low.js +0 -0
  87. package/dist/test/qwik/{todo → Todo}/Todo.js/med.js +0 -0
  88. package/dist/test/qwik/{todo → Todo}/Todo.tsx/high.tsx +0 -0
  89. package/dist/test/qwik/{todo → Todo}/Todo.tsx/low.tsx +0 -0
  90. package/dist/test/qwik/{todo → Todo}/Todo.tsx/med.tsx +0 -0
  91. package/dist/test/qwik/Todo/bundle.js +46 -0
  92. package/dist/test/qwik/Todo/component.ts +17 -0
  93. package/dist/test/qwik/Todo/onButtonClick.ts +10 -0
  94. package/dist/test/qwik/Todo/onInput2Blur.ts +14 -0
  95. package/dist/test/qwik/Todo/onInput2KeyUp.ts +10 -0
  96. package/dist/test/qwik/Todo/onInputClick.ts +13 -0
  97. package/dist/test/qwik/Todo/onLabelDblClick.ts +11 -0
  98. package/dist/test/qwik/Todo/public.ts +3 -0
  99. package/dist/test/qwik/Todo/template.tsx +46 -0
  100. package/dist/test/qwik/Todo.ts +4 -0
  101. package/dist/test/qwik/Todo_component.ts +17 -0
  102. package/dist/test/qwik/Todo_onButtonClick.ts +13 -0
  103. package/dist/test/qwik/Todo_onInput2Blur.ts +14 -0
  104. package/dist/test/qwik/Todo_onInput2KeyUp.ts +10 -0
  105. package/dist/test/qwik/Todo_onInputClick.ts +13 -0
  106. package/dist/test/qwik/Todo_onLabelDblClick.ts +14 -0
  107. package/dist/test/qwik/Todo_template.tsx +46 -0
  108. package/dist/test/qwik/{todos → Todos}/Todo.tsx/high.tsx +0 -0
  109. package/dist/test/qwik/{todos → Todos}/Todo.tsx/low.tsx +3 -4
  110. package/dist/test/qwik/{todos → Todos}/Todo.tsx/med.tsx +0 -0
  111. package/dist/test/qwik/Todos/component.ts +9 -0
  112. package/dist/test/qwik/Todos/onInputClick.ts +14 -0
  113. package/dist/test/qwik/Todos/public.ts +3 -0
  114. package/dist/test/qwik/Todos/template.tsx +30 -0
  115. package/dist/test/qwik/Todos.ts +3 -0
  116. package/dist/test/qwik/Todos_component.ts +9 -0
  117. package/dist/test/qwik/Todos_onInputClick.ts +14 -0
  118. package/dist/test/qwik/Todos_template.tsx +30 -0
  119. package/dist/test/qwik/qwik/Image/high.js +1 -0
  120. package/dist/test/qwik/qwik/Image/low.js +75 -0
  121. package/dist/test/qwik/qwik/Image/med.js +9 -0
  122. package/dist/test/qwik/{For/high.jsx → qwik/Image.slow/high.js} +0 -0
  123. package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
  124. package/dist/test/qwik/{For/med.jsx → qwik/Image.slow/med.js} +0 -0
  125. package/dist/test/qwik/qwik/button/high.js +8 -0
  126. package/dist/test/qwik/qwik/button/low.js +34 -0
  127. package/dist/test/qwik/qwik/button/med.js +9 -0
  128. package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +1 -0
  129. package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +24 -0
  130. package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +9 -0
  131. package/dist/test/qwik/qwik/page-with-symbol/high.js +1 -0
  132. package/dist/test/qwik/qwik/page-with-symbol/low.js +49 -0
  133. package/dist/test/qwik/qwik/page-with-symbol/med.js +9 -0
  134. package/dist/test/qwik/qwik/svg/high.js +1 -0
  135. package/dist/test/qwik/qwik/svg/low.js +30 -0
  136. package/dist/test/qwik/qwik/svg/med.js +9 -0
  137. package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +31 -0
  138. package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +1 -0
  139. package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +59 -0
  140. package/dist/test/qwik/qwik/todo/Todo.js/high.js +5 -0
  141. package/dist/{src/types/generators.d.ts → test/qwik/qwik/todo/Todo.js/low.js} +0 -0
  142. package/dist/test/qwik/qwik/todo/Todo.js/med.js +1 -0
  143. package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +30 -0
  144. package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +1 -0
  145. package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +34 -0
  146. package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +12 -0
  147. package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +24 -0
  148. package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +8 -0
  149. package/dist/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +1 -1
  151. package/dist/src/types/generators.js +0 -1
  152. package/dist/test/qwik/For/low.jsx +0 -55
@@ -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;
@@ -294,7 +294,8 @@ 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);
298
299
  };
299
300
  var DEFAULT_OPTIONS = {
300
301
  stateType: 'useState',
@@ -343,6 +344,7 @@ var componentToReact = function (reactOptions) {
343
344
  };
344
345
  exports.componentToReact = componentToReact;
345
346
  var _componentToReact = function (json, options, isSubComponent) {
347
+ var _a, _b, _c, _d, _e, _f;
346
348
  if (isSubComponent === void 0) { isSubComponent = false; }
347
349
  (0, process_http_requests_1.processHttpRequests)(json);
348
350
  (0, handle_missing_state_1.handleMissingState)(json);
@@ -383,14 +385,16 @@ var _componentToReact = function (json, options, isSubComponent) {
383
385
  if (refs.size) {
384
386
  reactLibImports.add('useRef');
385
387
  }
386
- 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)) {
387
391
  reactLibImports.add('useEffect');
388
392
  }
389
393
  var wrap = wrapInFragment(json) || (componentHasStyles && stylesType === 'styled-jsx');
390
394
  var nativeStyles = stylesType === 'react-native' &&
391
395
  componentHasStyles &&
392
396
  (0, react_native_1.collectReactNativeStyles)(json);
393
- 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'
394
398
  ? ''
395
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
396
400
  ? "import { ".concat(Array.from(reactLibImports).join(', '), " } from 'react'")
@@ -413,10 +417,12 @@ var _componentToReact = function (json, options, isSubComponent) {
413
417
  : stateType === 'builder'
414
418
  ? "var state = useBuilderState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
415
419
  : "const state = useLocalProxy(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
416
- : '', getContextString(json, options), getRefsString(json), getInitCode(json, options), json.hooks.onMount
417
- ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onMount, options), options), "\n }, [])")
418
- : '', json.hooks.onUnMount
419
- ? "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 }, [])")
420
426
  : '', wrap ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToReact)(item, options); }).join('\n'), componentHasStyles && stylesType === 'styled-jsx'
421
427
  ? "<style jsx>{`".concat(css, "`}</style>")
422
428
  : '', wrap ? '</>' : '', !nativeStyles
@@ -150,6 +150,7 @@ var getRefsString = function (json, refs) {
150
150
  var componentToSolid = function (options) {
151
151
  if (options === void 0) { options = {}; }
152
152
  return function (_a) {
153
+ var _b, _c;
153
154
  var component = _a.component;
154
155
  var json = (0, fast_clone_1.fastClone)(component);
155
156
  if (options.plugins) {
@@ -169,9 +170,11 @@ var componentToSolid = function (options) {
169
170
  var hasForComponent = componentsUsed.has('For');
170
171
  var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n export default function ", "(props) {\n ", "\n \n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "], ["\n ", "\n ", "\n ", "\n ", "\n ", "\n\n export default function ", "(props) {\n ", "\n \n ", "\n\n ", "\n\n return (", "\n ", "\n ", ")\n }\n\n "])), !(hasShowComponent || hasForComponent)
171
172
  ? ''
172
- : "import { \n ".concat(!hasShowComponent ? '' : 'Show, ', "\n ").concat(!hasForComponent ? '' : 'For, ', "\n ").concat(!json.hooks.onMount ? '' : 'onMount, ', "\n } from 'solid-js';"), !foundDynamicComponents ? '' : "import { Dynamic } from 'solid-js/web';", !hasState ? '' : "import { createMutable } from 'solid-js/store';", !componentHasStyles
173
+ : "import { \n ".concat(!hasShowComponent ? '' : 'Show, ', "\n ").concat(!hasForComponent ? '' : 'For, ', "\n ").concat(!((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? '' : 'onMount, ', "\n } from 'solid-js';"), !foundDynamicComponents ? '' : "import { Dynamic } from 'solid-js/web';", !hasState ? '' : "import { createMutable } from 'solid-js/store';", !componentHasStyles
173
174
  ? ''
174
- : "import { css } from \"solid-styled-components\";", (0, render_imports_1.renderPreComponent)(json), json.name, !hasState ? '' : "const state = createMutable(".concat(stateString, ");"), getRefsString(json), !json.hooks.onMount ? '' : "onMount(() => { ".concat(json.hooks.onMount, " })"), addWrapper ? '<>' : '', json.children.map(function (item) { return blockToSolid(item, options); }).join('\n'), addWrapper ? '</>' : '');
175
+ : "import { css } from \"solid-styled-components\";", (0, render_imports_1.renderPreComponent)(json), json.name, !hasState ? '' : "const state = createMutable(".concat(stateString, ");"), getRefsString(json), !((_c = json.hooks.onMount) === null || _c === void 0 ? void 0 : _c.code)
176
+ ? ''
177
+ : "onMount(() => { ".concat(json.hooks.onMount.code, " })"), addWrapper ? '<>' : '', json.children.map(function (item) { return blockToSolid(item, options); }).join('\n'), addWrapper ? '</>' : '');
175
178
  if (options.plugins) {
176
179
  str = (0, plugins_1.runPreCodePlugins)(str, options.plugins);
177
180
  }
@@ -143,6 +143,7 @@ var useBindValue = function (json, options) {
143
143
  var componentToSvelte = function (options) {
144
144
  if (options === void 0) { options = {}; }
145
145
  return function (_a) {
146
+ var _b, _c, _d, _e, _f, _g;
146
147
  var component = _a.component;
147
148
  var useOptions = __assign(__assign({}, options), { stateType: 'variables' });
148
149
  // Make a copy we can safely mutate, similar to babel's toolchain
@@ -195,7 +196,7 @@ var componentToSvelte = function (options) {
195
196
  });
196
197
  var hasData = dataString.length > 4;
197
198
  var props = Array.from((0, get_props_1.getProps)(json));
198
- var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script>\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script>\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !json.hooks.onMount ? '' : "import { onMount } from 'svelte'", !json.hooks.onUnMount ? '' : "import { onDestroy } from 'svelte'", (0, render_imports_1.renderPreComponent)(json), !hasData || useOptions.stateType === 'variables'
199
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <script>\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script>\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), !((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? '' : "import { onMount } from 'svelte'", !((_c = json.hooks.onUpdate) === null || _c === void 0 ? void 0 : _c.code) ? '' : "import { afterUpdate } from 'svelte'", !((_d = json.hooks.onUnMount) === null || _d === void 0 ? void 0 : _d.code) ? '' : "import { onDestroy } from 'svelte'", (0, render_imports_1.renderPreComponent)(json), !hasData || useOptions.stateType === 'variables'
199
200
  ? ''
200
201
  : "import onChange from 'on-change'", refs
201
202
  .concat(props)
@@ -204,13 +205,17 @@ var componentToSvelte = function (options) {
204
205
  ? dataString.length < 4
205
206
  ? ''
206
207
  : "let state = onChange(".concat(dataString, ", () => state = state)")
207
- : dataString, !json.hooks.onMount
208
+ : dataString, !((_e = json.hooks.onMount) === null || _e === void 0 ? void 0 : _e.code)
208
209
  ? ''
209
- : "onMount(() => { ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onMount, {
210
+ : "onMount(() => { ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onMount.code, {
210
211
  includeState: useOptions.stateType === 'variables',
211
- }), " });"), !json.hooks.onUnMount
212
+ }), " });"), !((_f = json.hooks.onUpdate) === null || _f === void 0 ? void 0 : _f.code)
212
213
  ? ''
213
- : "onDestroy(() => { ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onUnMount, {
214
+ : "afterUpdate(() => { ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onUpdate.code, {
215
+ includeState: useOptions.stateType === 'variables',
216
+ }), " });"), !((_g = json.hooks.onUnMount) === null || _g === void 0 ? void 0 : _g.code)
217
+ ? ''
218
+ : "onDestroy(() => { ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onUnMount.code, {
214
219
  includeState: useOptions.stateType === 'variables',
215
220
  }), " });"), json.children.map(function (item) { return (0, exports.blockToSvelte)(item, useOptions); }).join('\n'), !css.trim().length
216
221
  ? ''
@@ -216,7 +216,7 @@ var componentToVue = function (options) {
216
216
  // hack while we migrate all other transpilers to receive/handle path
217
217
  // TO-DO: use `Transpiler` once possible
218
218
  return function (_a) {
219
- var _b, _c, _d, _e, _f;
219
+ var _b, _c, _d, _e, _f, _g;
220
220
  var component = _a.component, path = _a.path;
221
221
  // Make a copy we can safely mutate, similar to babel's toolchain can be used
222
222
  component = (0, fast_clone_1.fastClone)(component);
@@ -280,7 +280,7 @@ var componentToVue = function (options) {
280
280
  functionsString = functionsString.replace(/}\s*$/, "_classStringToObject(str) {\n const obj = {};\n if (typeof str !== 'string') { return obj }\n const classNames = str.trim().split(/\\s+/); \n for (const name of classNames) {\n obj[name] = true;\n } \n return obj;\n } }");
281
281
  }
282
282
  var builderRegister = Boolean(options.builderRegister && component.meta.registerComponent);
283
- var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default ", "{\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n }", "\n </script>\n ", "\n "], ["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default ", "{\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n }", "\n </script>\n ", "\n "])), template, (0, render_imports_1.renderPreComponent)(component), component.meta.registerComponent
283
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default ", "{\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }", "\n </script>\n ", "\n "], ["\n <template>\n ", "\n </template>\n <script>\n ", "\n ", "\n\n export default ", "{\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n ", "\n ", "\n\n ", "\n ", "\n }", "\n </script>\n ", "\n "])), template, (0, render_imports_1.renderPreComponent)(component), component.meta.registerComponent
284
284
  ? (_d = options.registerComponentPrepend) !== null && _d !== void 0 ? _d : ''
285
285
  : '', !builderRegister ? '' : 'registerComponent(', !component.name
286
286
  ? ''
@@ -300,10 +300,12 @@ var componentToVue = function (options) {
300
300
  ? "provide() {\n const _this = this;\n return ".concat(getContextProvideString(component, options), "\n },")
301
301
  : '', (0, lodash_1.size)(component.context.get)
302
302
  ? "inject: ".concat(getContextInjectString(component, options), ",")
303
- : '', component.hooks.onMount
304
- ? "mounted() {\n ".concat(processBinding(component.hooks.onMount, options, component), "\n },")
303
+ : '', ((_g = component.hooks.onMount) === null || _g === void 0 ? void 0 : _g.code)
304
+ ? "mounted() {\n ".concat(processBinding(component.hooks.onMount.code, options, component), "\n },")
305
+ : '', component.hooks.onUpdate
306
+ ? "updated() {\n ".concat(processBinding(component.hooks.onUpdate.code, options, component), "\n },")
305
307
  : '', component.hooks.onUnMount
306
- ? "unmounted() {\n ".concat(processBinding(component.hooks.onUnMount, options, component), "\n },")
308
+ ? "unmounted() {\n ".concat(processBinding(component.hooks.onUnMount.code, options, component), "\n },")
307
309
  : '', getterString.length < 4
308
310
  ? ''
309
311
  : "\n computed: ".concat(getterString, ",\n "), functionsString.length < 4
@@ -0,0 +1,2 @@
1
+ import { JSXLiteComponent } from '../types/jsx-lite-component';
2
+ export declare const createJSXLiteComponent: (options?: Partial<JSXLiteComponent> | undefined) => JSXLiteComponent;