@builder.io/mitosis 0.0.46 → 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 (156) hide show
  1. package/dist/src/__tests__/angular.test.d.ts +1 -0
  2. package/dist/src/__tests__/angular.test.js +12 -0
  3. package/dist/src/__tests__/data/blocks/columns.raw.jsx +6 -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 +68 -9
  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 +93 -13
  30. package/dist/src/generators/qwik/jsx.d.ts +1 -1
  31. package/dist/src/generators/qwik/jsx.js +30 -7
  32. package/dist/src/generators/qwik/src-generator.d.ts +15 -2
  33. package/dist/src/generators/qwik/src-generator.js +82 -16
  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-native.js +34 -27
  37. package/dist/src/generators/react.js +36 -14
  38. package/dist/src/generators/solid.js +5 -2
  39. package/dist/src/generators/svelte.js +10 -5
  40. package/dist/src/generators/vue.js +9 -6
  41. package/dist/src/helpers/create-jsx-lite-component.d.ts +2 -0
  42. package/dist/src/helpers/create-jsx-lite-component.js +16 -0
  43. package/dist/src/helpers/create-jsx-lite-context.d.ts +4 -0
  44. package/dist/src/helpers/create-jsx-lite-context.js +18 -0
  45. package/dist/src/helpers/create-jsx-lite-node.d.ts +2 -0
  46. package/dist/src/helpers/create-jsx-lite-node.js +16 -0
  47. package/dist/src/helpers/get-state-object-string.js +51 -38
  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 +10 -8
  51. package/dist/src/helpers/patterns.d.ts +2 -0
  52. package/dist/src/helpers/patterns.js +5 -0
  53. package/dist/src/helpers/process-http-requests.js +3 -3
  54. package/dist/src/helpers/process-tag-references.js +4 -3
  55. package/dist/src/index.d.ts +2 -1
  56. package/dist/src/index.js +4 -3
  57. package/dist/src/jsx-types.d.ts +1 -1
  58. package/dist/src/parsers/builder.d.ts +50 -10
  59. package/dist/src/parsers/builder.js +37 -7
  60. package/dist/src/parsers/jsx.js +43 -3
  61. package/dist/src/parsers/liquid.js +4 -4
  62. package/dist/src/plugins/compile-away-builder-components.js +40 -20
  63. package/dist/src/symbols/symbol-processor.d.ts +18 -0
  64. package/dist/src/symbols/symbol-processor.js +177 -0
  65. package/dist/src/types/jsx-lite-component.d.ts +63 -0
  66. package/dist/src/types/jsx-lite-component.js +2 -0
  67. package/dist/src/types/jsx-lite-context.d.ts +6 -0
  68. package/dist/src/types/jsx-lite-context.js +2 -0
  69. package/dist/src/types/jsx-lite-node.d.ts +13 -0
  70. package/dist/src/types/jsx-lite-node.js +2 -0
  71. package/dist/src/types/jsx-lite-styles.d.ts +1 -0
  72. package/dist/src/types/jsx-lite-styles.js +2 -0
  73. package/dist/src/types/mitosis-component.d.ts +10 -5
  74. package/dist/test/qoot/Todo/bundle.js +88 -0
  75. package/dist/test/qoot/Todo/component.ts +17 -0
  76. package/dist/test/qoot/Todo/onButtonClick.ts +13 -0
  77. package/dist/test/qoot/Todo/onInput2Blur.ts +11 -0
  78. package/dist/test/qoot/Todo/onInput2KeyUp.ts +10 -0
  79. package/dist/test/qoot/Todo/onInputClick.ts +10 -0
  80. package/dist/test/qoot/Todo/onLabelDblClick.ts +11 -0
  81. package/dist/test/qoot/Todo/public.ts +4 -0
  82. package/dist/test/qoot/Todo/template.tsx +46 -0
  83. package/dist/test/qoot/Todos/component.ts +9 -0
  84. package/dist/test/qoot/Todos/onInputClick.ts +14 -0
  85. package/dist/test/qoot/Todos/public.ts +3 -0
  86. package/dist/test/qoot/Todos/template.tsx +30 -0
  87. package/dist/test/qwik/{todo → Todo}/Todo.cjs/high.cjs +0 -0
  88. package/dist/test/qwik/{todo → Todo}/Todo.cjs/low.cjs +0 -0
  89. package/dist/test/qwik/{todo → Todo}/Todo.cjs/med.cjs +0 -0
  90. package/dist/test/qwik/{todo → Todo}/Todo.js/high.js +0 -0
  91. package/dist/test/qwik/{todo → Todo}/Todo.js/low.js +0 -0
  92. package/dist/test/qwik/{todo → Todo}/Todo.js/med.js +0 -0
  93. package/dist/test/qwik/{todo → Todo}/Todo.tsx/high.tsx +0 -0
  94. package/dist/test/qwik/{todo → Todo}/Todo.tsx/low.tsx +0 -0
  95. package/dist/test/qwik/{todo → Todo}/Todo.tsx/med.tsx +0 -0
  96. package/dist/test/qwik/Todo/bundle.js +46 -0
  97. package/dist/test/qwik/Todo/component.ts +17 -0
  98. package/dist/test/qwik/Todo/onButtonClick.ts +10 -0
  99. package/dist/test/qwik/Todo/onInput2Blur.ts +14 -0
  100. package/dist/test/qwik/Todo/onInput2KeyUp.ts +10 -0
  101. package/dist/test/qwik/Todo/onInputClick.ts +13 -0
  102. package/dist/test/qwik/Todo/onLabelDblClick.ts +11 -0
  103. package/dist/test/qwik/Todo/public.ts +3 -0
  104. package/dist/test/qwik/Todo/template.tsx +46 -0
  105. package/dist/test/qwik/Todo.ts +4 -0
  106. package/dist/test/qwik/Todo_component.ts +17 -0
  107. package/dist/test/qwik/Todo_onButtonClick.ts +13 -0
  108. package/dist/test/qwik/Todo_onInput2Blur.ts +14 -0
  109. package/dist/test/qwik/Todo_onInput2KeyUp.ts +10 -0
  110. package/dist/test/qwik/Todo_onInputClick.ts +13 -0
  111. package/dist/test/qwik/Todo_onLabelDblClick.ts +14 -0
  112. package/dist/test/qwik/Todo_template.tsx +46 -0
  113. package/dist/test/qwik/{todos → Todos}/Todo.tsx/high.tsx +0 -0
  114. package/dist/test/qwik/{todos → Todos}/Todo.tsx/low.tsx +0 -0
  115. package/dist/test/qwik/{todos → Todos}/Todo.tsx/med.tsx +0 -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/public.ts +3 -0
  119. package/dist/test/qwik/Todos/template.tsx +30 -0
  120. package/dist/test/qwik/Todos.ts +3 -0
  121. package/dist/test/qwik/Todos_component.ts +9 -0
  122. package/dist/test/qwik/Todos_onInputClick.ts +14 -0
  123. package/dist/test/qwik/Todos_template.tsx +30 -0
  124. package/dist/test/qwik/qwik/Image/high.js +1 -0
  125. package/dist/test/qwik/qwik/Image/low.js +75 -0
  126. package/dist/test/qwik/qwik/Image/med.js +9 -0
  127. package/dist/test/qwik/qwik/Image.slow/high.js +1 -0
  128. package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
  129. package/dist/test/qwik/qwik/Image.slow/med.js +9 -0
  130. package/dist/test/qwik/qwik/button/high.js +8 -0
  131. package/dist/test/qwik/qwik/button/low.js +34 -0
  132. package/dist/test/qwik/qwik/button/med.js +9 -0
  133. package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +1 -0
  134. package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +24 -0
  135. package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +9 -0
  136. package/dist/test/qwik/qwik/page-with-symbol/high.js +1 -0
  137. package/dist/test/qwik/qwik/page-with-symbol/low.js +49 -0
  138. package/dist/test/qwik/qwik/page-with-symbol/med.js +9 -0
  139. package/dist/test/qwik/qwik/svg/high.js +1 -0
  140. package/dist/test/qwik/qwik/svg/low.js +30 -0
  141. package/dist/test/qwik/qwik/svg/med.js +9 -0
  142. package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +31 -0
  143. package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +1 -0
  144. package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +59 -0
  145. package/dist/test/qwik/qwik/todo/Todo.js/high.js +5 -0
  146. package/dist/{src/types/generators.d.ts → test/qwik/qwik/todo/Todo.js/low.js} +0 -0
  147. package/dist/test/qwik/qwik/todo/Todo.js/med.js +1 -0
  148. package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +30 -0
  149. package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +1 -0
  150. package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +34 -0
  151. package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +12 -0
  152. package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +24 -0
  153. package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +8 -0
  154. package/dist/tsconfig.tsbuildinfo +1 -1
  155. package/package.json +1 -1
  156. package/dist/src/types/generators.js +0 -1
@@ -183,6 +183,15 @@ var getRefsString = function (json, refs) {
183
183
  }
184
184
  return str;
185
185
  };
186
+ /**
187
+ * Removes all `this.` references.
188
+ */
189
+ var stripThisRefs = function (str, options) {
190
+ if (options.stateType !== 'useState') {
191
+ return str;
192
+ }
193
+ return str.replace(/this\.([a-zA-Z_\$0-9]+)/g, '$1');
194
+ };
186
195
  var processBinding = function (str, options) {
187
196
  if (options.stateType !== 'useState') {
188
197
  return str;
@@ -196,29 +205,32 @@ var getUseStateCode = function (json, options) {
196
205
  var str = '';
197
206
  var state = json.state;
198
207
  var valueMapper = function (val) {
199
- return processBinding(updateStateSettersInCode(val, options), options);
208
+ var x = processBinding(updateStateSettersInCode(val, options), options);
209
+ return stripThisRefs(x, options);
200
210
  };
201
- var keyValueDelimiter = '=';
202
211
  var lineItemDelimiter = '\n\n\n';
203
212
  for (var key in state) {
204
213
  var value = state[key];
214
+ var defaultCase = "const [".concat(key, ", set").concat((0, capitalize_1.capitalize)(key), "] = useState(() => (").concat(valueMapper(json5_1.default.stringify(value)), "))");
205
215
  if (typeof value === 'string') {
206
216
  if (value.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
207
217
  var useValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
208
- str += "".concat(valueMapper(useValue), " ").concat(lineItemDelimiter);
218
+ var mappedVal = valueMapper(useValue);
219
+ str += mappedVal;
209
220
  }
210
221
  else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
211
222
  var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
212
223
  var useValue = methodValue.replace(/^(get )?/, 'function ');
213
- str += "".concat(valueMapper(useValue), " ").concat(lineItemDelimiter);
224
+ str += valueMapper(useValue);
214
225
  }
215
226
  else {
216
- str += "const [".concat(key, ", set").concat((0, capitalize_1.capitalize)(key), "] ").concat(keyValueDelimiter, " useState(() => (").concat(valueMapper(json5_1.default.stringify(value)), "))").concat(lineItemDelimiter, " ");
227
+ str += defaultCase;
217
228
  }
218
229
  }
219
230
  else {
220
- str += "const [".concat(key, ", set").concat((0, capitalize_1.capitalize)(key), "] ").concat(keyValueDelimiter, " useState(() => (").concat(valueMapper(json5_1.default.stringify(value)), "))").concat(lineItemDelimiter, " ");
231
+ str += defaultCase;
221
232
  }
233
+ str += lineItemDelimiter;
222
234
  }
223
235
  return str;
224
236
  };
@@ -282,14 +294,19 @@ function hasContext(component) {
282
294
  Object.keys(component.context.set).length);
283
295
  }
284
296
  var getInitCode = function (json, options) {
285
- 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',
286
303
  };
287
304
  var componentToReact = function (reactOptions) {
288
305
  if (reactOptions === void 0) { reactOptions = {}; }
289
306
  return function (_a) {
290
307
  var component = _a.component;
291
308
  var json = (0, fast_clone_1.fastClone)(component);
292
- var options = __assign({ stateType: 'useState', stylesType: 'styled-jsx' }, reactOptions);
309
+ var options = __assign(__assign({}, DEFAULT_OPTIONS), reactOptions);
293
310
  if (options.plugins) {
294
311
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
295
312
  }
@@ -327,6 +344,7 @@ var componentToReact = function (reactOptions) {
327
344
  };
328
345
  exports.componentToReact = componentToReact;
329
346
  var _componentToReact = function (json, options, isSubComponent) {
347
+ var _a, _b, _c, _d, _e, _f;
330
348
  if (isSubComponent === void 0) { isSubComponent = false; }
331
349
  (0, process_http_requests_1.processHttpRequests)(json);
332
350
  (0, handle_missing_state_1.handleMissingState)(json);
@@ -367,14 +385,16 @@ var _componentToReact = function (json, options, isSubComponent) {
367
385
  if (refs.size) {
368
386
  reactLibImports.add('useRef');
369
387
  }
370
- 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)) {
371
391
  reactLibImports.add('useEffect');
372
392
  }
373
393
  var wrap = wrapInFragment(json) || (componentHasStyles && stylesType === 'styled-jsx');
374
394
  var nativeStyles = stylesType === 'react-native' &&
375
395
  componentHasStyles &&
376
396
  (0, react_native_1.collectReactNativeStyles)(json);
377
- 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'
378
398
  ? ''
379
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
380
400
  ? "import { ".concat(Array.from(reactLibImports).join(', '), " } from 'react'")
@@ -397,10 +417,12 @@ var _componentToReact = function (json, options, isSubComponent) {
397
417
  : stateType === 'builder'
398
418
  ? "var state = useBuilderState(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
399
419
  : "const state = useLocalProxy(".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), ");")
400
- : '', getContextString(json, options), getRefsString(json), getInitCode(json, options), json.hooks.onMount
401
- ? "useEffect(() => {\n ".concat(processBinding(updateStateSettersInCode(json.hooks.onMount, options), options), "\n }, [])")
402
- : '', json.hooks.onUnMount
403
- ? "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 }, [])")
404
426
  : '', wrap ? '<>' : '', json.children.map(function (item) { return (0, exports.blockToReact)(item, options); }).join('\n'), componentHasStyles && stylesType === 'styled-jsx'
405
427
  ? "<style jsx>{`".concat(css, "`}</style>")
406
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
  ? ''
@@ -30,6 +30,7 @@ var replace_idenifiers_1 = require("../helpers/replace-idenifiers");
30
30
  var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
31
31
  var json5_1 = __importDefault(require("json5"));
32
32
  var process_http_requests_1 = require("../helpers/process-http-requests");
33
+ var patterns_1 = require("../helpers/patterns");
33
34
  function getContextNames(json) {
34
35
  return Object.keys(json.context.get);
35
36
  }
@@ -215,7 +216,7 @@ var componentToVue = function (options) {
215
216
  // hack while we migrate all other transpilers to receive/handle path
216
217
  // TO-DO: use `Transpiler` once possible
217
218
  return function (_a) {
218
- var _b, _c, _d, _e, _f;
219
+ var _b, _c, _d, _e, _f, _g;
219
220
  var component = _a.component, path = _a.path;
220
221
  // Make a copy we can safely mutate, similar to babel's toolchain can be used
221
222
  component = (0, fast_clone_1.fastClone)(component);
@@ -242,7 +243,7 @@ var componentToVue = function (options) {
242
243
  getters: true,
243
244
  functions: false,
244
245
  valueMapper: function (code) {
245
- return processBinding(code.replace(/^get /, ''), options, component);
246
+ return processBinding(code.replace(patterns_1.GETTER, ''), options, component);
246
247
  },
247
248
  });
248
249
  var functionsString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
@@ -279,7 +280,7 @@ var componentToVue = function (options) {
279
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 } }");
280
281
  }
281
282
  var builderRegister = Boolean(options.builderRegister && component.meta.registerComponent);
282
- 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
283
284
  ? (_d = options.registerComponentPrepend) !== null && _d !== void 0 ? _d : ''
284
285
  : '', !builderRegister ? '' : 'registerComponent(', !component.name
285
286
  ? ''
@@ -299,10 +300,12 @@ var componentToVue = function (options) {
299
300
  ? "provide() {\n const _this = this;\n return ".concat(getContextProvideString(component, options), "\n },")
300
301
  : '', (0, lodash_1.size)(component.context.get)
301
302
  ? "inject: ".concat(getContextInjectString(component, options), ",")
302
- : '', component.hooks.onMount
303
- ? "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 },")
304
307
  : '', component.hooks.onUnMount
305
- ? "unmounted() {\n ".concat(processBinding(component.hooks.onUnMount, options, component), "\n },")
308
+ ? "unmounted() {\n ".concat(processBinding(component.hooks.onUnMount.code, options, component), "\n },")
306
309
  : '', getterString.length < 4
307
310
  ? ''
308
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;
@@ -0,0 +1,16 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createJSXLiteComponent = void 0;
15
+ var createJSXLiteComponent = function (options) { return (__assign({ '@type': '@jsx-lite/component', imports: [], meta: {}, state: {}, children: [], hooks: {}, context: { get: {}, set: {} }, name: (options === null || options === void 0 ? void 0 : options.name) || 'MyComponent', subComponents: [] }, options)); };
16
+ exports.createJSXLiteComponent = createJSXLiteComponent;
@@ -0,0 +1,4 @@
1
+ import { JSXLiteContext } from '../types/jsx-lite-context';
2
+ export declare function createJsxLiteContext(options: Partial<JSXLiteContext> & {
3
+ name: string;
4
+ }): JSXLiteContext;
@@ -0,0 +1,18 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createJsxLiteContext = void 0;
15
+ function createJsxLiteContext(options) {
16
+ return __assign({ '@type': '@jsx-lite/context', value: {} }, options);
17
+ }
18
+ exports.createJsxLiteContext = createJsxLiteContext;
@@ -0,0 +1,2 @@
1
+ import { JSXLiteNode } from '../types/jsx-lite-node';
2
+ export declare const createJSXLiteNode: (options: Partial<JSXLiteNode>) => JSXLiteNode;
@@ -0,0 +1,16 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createJSXLiteNode = void 0;
15
+ var createJSXLiteNode = function (options) { return (__assign({ '@type': '@jsx-lite/node', name: 'div', meta: {}, properties: {}, bindings: {}, children: [] }, options)); };
16
+ exports.createJSXLiteNode = createJSXLiteNode;
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -7,51 +18,53 @@ exports.getStateObjectStringFromComponent = exports.getMemberObjectString = void
7
18
  var json5_1 = __importDefault(require("json5"));
8
19
  var function_literal_prefix_1 = require("../constants/function-literal-prefix");
9
20
  var method_literal_prefix_1 = require("../constants/method-literal-prefix");
10
- var getMemberObjectString = function (object, options) {
11
- if (options === void 0) { options = {}; }
12
- var format = options.format || 'object';
13
- var str = format === 'object' ? '{' : '';
21
+ var patterns_1 = require("./patterns");
22
+ var convertStateMemberToString = function (options) { return function (_a) {
23
+ var key = _a[0], value = _a[1];
14
24
  var valueMapper = options.valueMapper || (function (val) { return val; });
15
- var keyValueDelimiter = format === 'object' ? ':' : '=';
16
- var lineItemDelimiter = format === 'object' ? ',' : '\n';
25
+ var keyValueDelimiter = options.format === 'object' ? ':' : '=';
17
26
  var keyPrefix = options.keyPrefix || '';
18
- for (var key in object) {
19
- var value = object[key];
20
- if (typeof value === 'string') {
21
- if (value.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
22
- if (options.functions === false) {
23
- continue;
24
- }
25
- var functionValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
26
- str += " ".concat(keyPrefix, " ").concat(key, " ").concat(keyValueDelimiter, " ").concat(valueMapper(functionValue, 'function')).concat(lineItemDelimiter, " ");
27
- }
28
- else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
29
- var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
30
- var isGet = Boolean(methodValue.match(/^get /));
31
- if (isGet && options.getters === false) {
32
- continue;
33
- }
34
- if (!isGet && options.functions === false) {
35
- continue;
36
- }
37
- str += "".concat(keyPrefix, " ").concat(valueMapper(methodValue, isGet ? 'getter' : 'function'), " ").concat(lineItemDelimiter);
38
- }
39
- else {
40
- if (options.data === false) {
41
- continue;
42
- }
43
- str += " ".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data')).concat(lineItemDelimiter, " ");
27
+ if (typeof value === 'string') {
28
+ if (value.startsWith(function_literal_prefix_1.functionLiteralPrefix)) {
29
+ if (options.functions === false) {
30
+ return undefined;
44
31
  }
32
+ var functionValue = value.replace(function_literal_prefix_1.functionLiteralPrefix, '');
33
+ return "".concat(keyPrefix, " ").concat(key, " ").concat(keyValueDelimiter, " ").concat(valueMapper(functionValue, 'function'));
45
34
  }
46
- else {
47
- if (options.data === false) {
48
- continue;
35
+ else if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
36
+ var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
37
+ var isGet = Boolean(methodValue.match(patterns_1.GETTER));
38
+ if (isGet && options.getters === false) {
39
+ return undefined;
40
+ }
41
+ if (!isGet && options.functions === false) {
42
+ return undefined;
49
43
  }
50
- str += " ".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data')).concat(lineItemDelimiter, " ");
44
+ return "".concat(keyPrefix, " ").concat(valueMapper(methodValue, isGet ? 'getter' : 'function'));
51
45
  }
52
46
  }
53
- str += format === 'object' ? '}' : '';
54
- return str;
47
+ if (options.data === false) {
48
+ return undefined;
49
+ }
50
+ return "".concat(keyPrefix, " ").concat(key).concat(keyValueDelimiter, " ").concat(valueMapper(json5_1.default.stringify(value), 'data'));
51
+ }; };
52
+ var getMemberObjectString = function (object, options) {
53
+ if (options === void 0) { options = {}; }
54
+ var format = options.format || 'object';
55
+ var lineItemDelimiter = format === 'object' ? ',' : '\n';
56
+ var stringifiedProperties = Object.entries(object)
57
+ .map(convertStateMemberToString(__assign(__assign({}, options), { format: format })))
58
+ .filter(function (x) { return x !== undefined; })
59
+ .join(lineItemDelimiter);
60
+ var prefix = format === 'object' ? '{' : '';
61
+ var suffix = format === 'object' ? '}' : '';
62
+ // NOTE: we add a `lineItemDelimiter` at the very end because other functions will sometimes append more properties.
63
+ // If the delimiter is a comma and the format is `object`, then we need to make sure we have an extra comma at the end,
64
+ // or the object will become invalid JS.
65
+ // We also have to make sure that `stringifiedProperties` isn't empty, or we will get `{,}` which is invalid
66
+ var extraDelimiter = stringifiedProperties.length > 0 ? lineItemDelimiter : '';
67
+ return "".concat(prefix).concat(stringifiedProperties).concat(extraDelimiter).concat(suffix);
55
68
  };
56
69
  exports.getMemberObjectString = getMemberObjectString;
57
70
  var getStateObjectStringFromComponent = function (component, options) {
@@ -0,0 +1,2 @@
1
+ import { JSXLiteNode } from '../types/jsx-lite-node';
2
+ export declare const isJsxLiteNode: (thing: unknown) => thing is JSXLiteNode;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isJsxLiteNode = void 0;
4
+ var isJsxLiteNode = function (thing) {
5
+ return Boolean(thing && thing['@type'] === '@jsx-lite/node');
6
+ };
7
+ exports.isJsxLiteNode = isJsxLiteNode;
@@ -30,6 +30,7 @@ var is_mitosis_node_1 = require("./is-mitosis-node");
30
30
  var method_literal_prefix_1 = require("../constants/method-literal-prefix");
31
31
  var function_literal_prefix_1 = require("../constants/function-literal-prefix");
32
32
  var babel_transform_1 = require("./babel-transform");
33
+ var patterns_1 = require("./patterns");
33
34
  var tsPreset = require('@babel/preset-typescript');
34
35
  var replaceRefsInString = function (code, refs, mapper) {
35
36
  return (0, babel_transform_1.babelTransformExpression)(code, {
@@ -43,15 +44,16 @@ var replaceRefsInString = function (code, refs, mapper) {
43
44
  });
44
45
  };
45
46
  var mapRefs = function (component, mapper) {
47
+ var _a;
46
48
  var refs = Array.from((0, get_refs_1.getRefs)(component));
47
- for (var _i = 0, _a = Object.keys(component.state); _i < _a.length; _i++) {
48
- var key = _a[_i];
49
+ for (var _i = 0, _b = Object.keys(component.state); _i < _b.length; _i++) {
50
+ var key = _b[_i];
49
51
  var value = component.state[key];
50
52
  if (typeof value === 'string') {
51
53
  if (value.startsWith(method_literal_prefix_1.methodLiteralPrefix)) {
52
54
  var methodValue = value.replace(method_literal_prefix_1.methodLiteralPrefix, '');
53
- var isGet = Boolean(methodValue.match(/^get /));
54
- var isSet = Boolean(methodValue.match(/^set /));
55
+ var isGet = Boolean(methodValue.match(patterns_1.GETTER));
56
+ var isSet = Boolean(methodValue.match(patterns_1.SETTER));
55
57
  component.state[key] =
56
58
  method_literal_prefix_1.methodLiteralPrefix +
57
59
  replaceRefsInString(methodValue.replace(/^(get |set )?/, 'function '), refs, mapper).replace(/^function /, isGet ? 'get ' : isSet ? 'set ' : '');
@@ -74,11 +76,11 @@ var mapRefs = function (component, mapper) {
74
76
  }
75
77
  }
76
78
  });
77
- for (var _b = 0, _c = Object.keys(component.hooks); _b < _c.length; _b++) {
78
- var key = _c[_b];
79
- var hookCode = component.hooks[key];
79
+ for (var _c = 0, _d = Object.keys(component.hooks); _c < _d.length; _c++) {
80
+ var key = _d[_c];
81
+ var hookCode = (_a = component.hooks[key]) === null || _a === void 0 ? void 0 : _a.code;
80
82
  if (hookCode) {
81
- component.hooks[key] = replaceRefsInString(hookCode, refs, mapper);
83
+ component.hooks[key].code = replaceRefsInString(hookCode, refs, mapper);
82
84
  }
83
85
  }
84
86
  };
@@ -0,0 +1,2 @@
1
+ export declare const GETTER: RegExp;
2
+ export declare const SETTER: RegExp;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SETTER = exports.GETTER = void 0;
4
+ exports.GETTER = /^get /;
5
+ exports.SETTER = /^set /;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processHttpRequests = void 0;
4
4
  function processHttpRequests(json) {
5
- var _a;
5
+ var _a, _b;
6
6
  var httpRequests = (_a = json.meta
7
7
  .useMetadata) === null || _a === void 0 ? void 0 : _a.httpRequests;
8
- var onMount = json.hooks.onMount || '';
8
+ var onMount = ((_b = json.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code) ? json.hooks.onMount : { code: '' };
9
9
  if (httpRequests) {
10
10
  for (var key in httpRequests) {
11
11
  if (!json.state[key]) {
@@ -14,7 +14,7 @@ function processHttpRequests(json) {
14
14
  var value = httpRequests[key];
15
15
  // TODO: unravel our proxy. aka parse out methods, header, etc
16
16
  // and remove our proxy from being used anymore
17
- onMount += "\n fetch(\"".concat(value, "\").then(res => res.json()).then(result => {\n state.").concat(key, " = result;\n })\n ");
17
+ onMount.code += "\n fetch(\"".concat(value, "\").then(res => res.json()).then(result => {\n state.").concat(key, " = result;\n })\n ");
18
18
  }
19
19
  }
20
20
  json.hooks.onMount = onMount;
@@ -13,14 +13,15 @@ function getRefName(path) {
13
13
  function processTagReferences(json) {
14
14
  var namesFound = new Set();
15
15
  (0, traverse_1.default)(json).forEach(function (el) {
16
+ var _a;
16
17
  if ((0, is_mitosis_node_1.isMitosisNode)(el)) {
17
18
  if (el.name.includes('.')) {
18
19
  if (!namesFound.has(el.name)) {
19
20
  namesFound.add(el.name);
20
- if (typeof json.hooks.init !== 'string') {
21
- json.hooks.init = '';
21
+ if (typeof ((_a = json.hooks.init) === null || _a === void 0 ? void 0 : _a.code) !== 'string') {
22
+ json.hooks.init = { code: '' };
22
23
  }
23
- json.hooks.init += "\n const ".concat(getRefName(el.name), " = ").concat(el.name, ";\n ");
24
+ json.hooks.init.code += "\n const ".concat(getRefName(el.name), " = ").concat(el.name, ";\n ");
24
25
  }
25
26
  el.name = getRefName(el.name);
26
27
  }
@@ -9,10 +9,10 @@ export declare const setContext: (key: any, value: {
9
9
  [key: string]: any;
10
10
  }) => any;
11
11
  export declare const onMount: (fn: () => any) => any;
12
+ export declare const onUpdate: (fn: () => any, deps?: any[] | undefined) => any;
12
13
  export declare const onCreate: (fn: () => any) => any;
13
14
  export declare const onInit: (fn: () => any) => any;
14
15
  export declare const onUnMount: (fn: () => any) => any;
15
- export declare const afterUnmount: (fn: () => any) => any;
16
16
  export declare const useDynamicTag: (fn: () => any) => any;
17
17
  export declare const onError: (fn: () => any) => any;
18
18
  export declare const useMetadata: (obj: object) => null;
@@ -30,6 +30,7 @@ export * from './generators/solid';
30
30
  export * from './generators/liquid';
31
31
  export * from './generators/builder';
32
32
  export * from './generators/qwik/index';
33
+ export * from './symbols/symbol-processor';
33
34
  export * from './generators/html';
34
35
  export * from './generators/svelte';
35
36
  export * from './generators/mitosis';
package/dist/src/index.js CHANGED
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.useMetadata = exports.onError = exports.useDynamicTag = exports.afterUnmount = exports.onUnMount = exports.onInit = exports.onCreate = exports.onMount = exports.setContext = exports.createContext = exports.useContext = exports.useRef = exports.useState = void 0;
13
+ exports.useMetadata = exports.onError = exports.useDynamicTag = exports.onUnMount = exports.onInit = exports.onCreate = exports.onUpdate = exports.onMount = exports.setContext = exports.createContext = exports.useContext = exports.useRef = exports.useState = void 0;
14
14
  __exportStar(require("./flow"), exports);
15
15
  // These compile away
16
16
  var useState = function (obj) { return obj; };
@@ -27,14 +27,14 @@ var setContext = function (key, value) {
27
27
  exports.setContext = setContext;
28
28
  var onMount = function (fn) { return null; };
29
29
  exports.onMount = onMount;
30
+ var onUpdate = function (fn, deps) { return null; };
31
+ exports.onUpdate = onUpdate;
30
32
  var onCreate = function (fn) { return null; };
31
33
  exports.onCreate = onCreate;
32
34
  var onInit = function (fn) { return null; };
33
35
  exports.onInit = onInit;
34
36
  var onUnMount = function (fn) { return null; };
35
37
  exports.onUnMount = onUnMount;
36
- var afterUnmount = function (fn) { return null; };
37
- exports.afterUnmount = afterUnmount;
38
38
  var useDynamicTag = function (fn) { return null; };
39
39
  exports.useDynamicTag = useDynamicTag;
40
40
  var onError = function (fn) { return null; };
@@ -55,6 +55,7 @@ __exportStar(require("./generators/solid"), exports);
55
55
  __exportStar(require("./generators/liquid"), exports);
56
56
  __exportStar(require("./generators/builder"), exports);
57
57
  __exportStar(require("./generators/qwik/index"), exports);
58
+ __exportStar(require("./symbols/symbol-processor"), exports);
58
59
  __exportStar(require("./generators/html"), exports);
59
60
  __exportStar(require("./generators/svelte"), exports);
60
61
  __exportStar(require("./generators/mitosis"), exports);
@@ -1,5 +1,5 @@
1
1
  declare type CSS = Partial<CSSStyleDeclaration> & {
2
- [key: string]: string;
2
+ [key: string]: Partial<CSSStyleDeclaration> | string;
3
3
  };
4
4
  declare global {
5
5
  /**