@builder.io/mitosis 0.0.45-5 → 0.0.48

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 (219) hide show
  1. package/dist/src/__tests__/builder.test.js +71 -68
  2. package/dist/src/__tests__/context.test.js +13 -10
  3. package/dist/src/__tests__/data/basic.raw.jsx +1 -1
  4. package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +1 -1
  5. package/dist/src/__tests__/data/blocks/columns.raw.jsx +8 -2
  6. package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +3 -3
  7. package/dist/src/__tests__/data/blocks/embed.raw.jsx +3 -3
  8. package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
  9. package/dist/src/__tests__/data/blocks/image.raw.jsx +4 -4
  10. package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +4 -4
  11. package/dist/src/__tests__/data/context/component-with-context.lite.jsx +2 -2
  12. package/dist/src/__tests__/data/context/simple.context.lite.js +1 -1
  13. package/dist/src/__tests__/html.test.js +2 -2
  14. package/dist/src/__tests__/liquid.test.js +34 -34
  15. package/dist/src/__tests__/parse-jsx.test.js +1 -1
  16. package/dist/src/__tests__/qwik.test.js +197 -50
  17. package/dist/src/__tests__/react-native.test.js +35 -35
  18. package/dist/src/__tests__/react.test.js +35 -35
  19. package/dist/src/__tests__/solid.test.js +32 -32
  20. package/dist/src/__tests__/vue.test.js +35 -34
  21. package/dist/src/generators/angular.d.ts +4 -7
  22. package/dist/src/generators/angular.js +77 -81
  23. package/dist/src/generators/builder.d.ts +4 -4
  24. package/dist/src/generators/builder.js +57 -57
  25. package/dist/src/generators/context/react.d.ts +3 -1
  26. package/dist/src/generators/context/react.js +20 -17
  27. package/dist/src/generators/html.d.ts +5 -9
  28. package/dist/src/generators/html.js +205 -199
  29. package/dist/src/generators/liquid.d.ts +5 -9
  30. package/dist/src/generators/liquid.js +62 -59
  31. package/dist/src/generators/mitosis.d.ts +6 -7
  32. package/dist/src/generators/mitosis.js +61 -63
  33. package/dist/src/generators/qwik/component.d.ts +20 -0
  34. package/dist/src/generators/qwik/component.js +117 -0
  35. package/dist/src/generators/qwik/directives.d.ts +2 -0
  36. package/dist/src/generators/qwik/directives.js +27 -0
  37. package/dist/src/generators/qwik/handlers.d.ts +4 -0
  38. package/dist/src/generators/qwik/handlers.js +80 -0
  39. package/dist/src/generators/qwik/index.d.ts +2 -0
  40. package/dist/src/generators/qwik/index.js +9 -0
  41. package/dist/src/generators/qwik/jsx.d.ts +4 -0
  42. package/dist/src/generators/qwik/jsx.js +124 -0
  43. package/dist/src/generators/qwik/src-generator.d.ts +79 -0
  44. package/dist/src/generators/qwik/src-generator.js +427 -0
  45. package/dist/src/generators/qwik/styles.d.ts +7 -0
  46. package/dist/src/generators/qwik/styles.js +94 -0
  47. package/dist/src/generators/react-native.d.ts +4 -7
  48. package/dist/src/generators/react-native.js +53 -43
  49. package/dist/src/generators/react.d.ts +4 -8
  50. package/dist/src/generators/react.js +122 -114
  51. package/dist/src/generators/solid.d.ts +4 -8
  52. package/dist/src/generators/solid.js +55 -54
  53. package/dist/src/generators/svelte.d.ts +4 -7
  54. package/dist/src/generators/svelte.js +120 -123
  55. package/dist/src/generators/swift-ui.d.ts +2 -2
  56. package/dist/src/generators/swift-ui.js +62 -62
  57. package/dist/src/generators/template.d.ts +4 -8
  58. package/dist/src/generators/template.js +48 -45
  59. package/dist/src/generators/vue.d.ts +9 -9
  60. package/dist/src/generators/vue.js +170 -169
  61. package/dist/src/helpers/babel-transform.js +9 -9
  62. package/dist/src/helpers/camel-case.d.ts +8 -0
  63. package/dist/src/helpers/camel-case.js +18 -0
  64. package/dist/src/helpers/collect-styles.js +39 -37
  65. package/dist/src/helpers/dash-case.js +1 -1
  66. package/dist/src/helpers/generic-format.test.js +2 -2
  67. package/dist/src/helpers/get-components-used.js +2 -2
  68. package/dist/src/helpers/get-components.js +3 -3
  69. package/dist/src/helpers/get-props.js +1 -1
  70. package/dist/src/helpers/get-refs.js +2 -2
  71. package/dist/src/helpers/get-state-object-string.js +52 -39
  72. package/dist/src/helpers/get-state-used.js +1 -1
  73. package/dist/src/helpers/get-styles.js +1 -1
  74. package/dist/src/helpers/getters-to-functions.js +4 -4
  75. package/dist/src/helpers/handle-missing-state.js +1 -1
  76. package/dist/src/helpers/has-component.js +2 -2
  77. package/dist/src/helpers/has-props.js +1 -1
  78. package/dist/src/helpers/is-children.js +1 -1
  79. package/dist/src/helpers/json.d.ts +1 -0
  80. package/dist/src/helpers/json.js +17 -0
  81. package/dist/src/helpers/map-refs.js +7 -6
  82. package/dist/src/helpers/map-to-attributes.js +4 -4
  83. package/dist/src/helpers/map-to-css.js +2 -2
  84. package/dist/src/helpers/parse-node.js +2 -2
  85. package/dist/src/helpers/parse-reactive-script.js +4 -4
  86. package/dist/src/helpers/patterns.d.ts +2 -0
  87. package/dist/src/helpers/patterns.js +5 -0
  88. package/dist/src/helpers/process-http-requests.js +1 -1
  89. package/dist/src/helpers/process-tag-references.js +4 -4
  90. package/dist/src/helpers/remove-surrounding-block.test.js +1 -1
  91. package/dist/src/helpers/render-imports.js +7 -7
  92. package/dist/src/helpers/replace-idenifiers.js +1 -1
  93. package/dist/src/helpers/strip-meta-properties.js +2 -2
  94. package/dist/src/helpers/trace-reference-to-module-path.js +1 -1
  95. package/dist/src/helpers/traverse-nodes.js +2 -2
  96. package/dist/src/helpers/try-prettier-format.js +1 -1
  97. package/dist/src/index.d.ts +3 -1
  98. package/dist/src/index.js +3 -1
  99. package/dist/src/jsx-types.d.ts +1 -1
  100. package/dist/src/modules/plugins.d.ts +2 -10
  101. package/dist/src/parsers/angular.js +13 -13
  102. package/dist/src/parsers/builder.d.ts +1 -1
  103. package/dist/src/parsers/builder.js +56 -59
  104. package/dist/src/parsers/context.js +2 -2
  105. package/dist/src/parsers/jsx.js +59 -87
  106. package/dist/src/parsers/liquid.js +193 -195
  107. package/dist/src/plugins/compile-away-builder-components.d.ts +1 -1
  108. package/dist/src/plugins/compile-away-builder-components.js +330 -91
  109. package/dist/src/plugins/compile-away-components.js +3 -3
  110. package/dist/src/plugins/map-styles.js +3 -3
  111. package/dist/src/targets.d.ts +24 -0
  112. package/dist/src/targets.js +30 -0
  113. package/dist/src/types/config.d.ts +31 -0
  114. package/dist/src/types/{jsx-lite-component.js → config.js} +0 -0
  115. package/dist/src/types/generators.d.ts +0 -0
  116. package/dist/src/types/generators.js +1 -0
  117. package/dist/src/types/plugins.d.ts +11 -0
  118. package/dist/src/types/{jsx-lite-context.js → plugins.js} +0 -0
  119. package/dist/test/qwik/Accordion/high.jsx +1 -0
  120. package/dist/test/qwik/Accordion/low.jsx +92 -0
  121. package/dist/test/qwik/Accordion/med.jsx +9 -0
  122. package/dist/test/qwik/For/high.jsx +1 -0
  123. package/dist/test/qwik/For/low.jsx +55 -0
  124. package/dist/test/qwik/For/med.jsx +9 -0
  125. package/dist/test/qwik/Image/high.js +1 -0
  126. package/dist/test/qwik/Image/low.js +68 -0
  127. package/dist/test/qwik/Image/med.js +9 -0
  128. package/dist/test/qwik/Image.slow/high.js +1 -0
  129. package/dist/test/qwik/Image.slow/low.js +68 -0
  130. package/dist/test/qwik/Image.slow/med.js +9 -0
  131. package/dist/test/qwik/button/high.js +8 -0
  132. package/dist/test/qwik/button/low.js +34 -0
  133. package/dist/test/qwik/button/med.js +9 -0
  134. package/dist/test/qwik/hello_world/stylesheet/high.jsx +1 -0
  135. package/dist/test/qwik/hello_world/stylesheet/low.jsx +24 -0
  136. package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -0
  137. package/dist/test/qwik/page-with-symbol/high.js +1 -0
  138. package/dist/test/qwik/page-with-symbol/low.js +49 -0
  139. package/dist/test/qwik/page-with-symbol/med.js +9 -0
  140. package/dist/test/qwik/svg/high.js +1 -0
  141. package/dist/test/qwik/svg/low.js +30 -0
  142. package/dist/test/qwik/svg/med.js +9 -0
  143. package/dist/test/qwik/todo/Todo.cjs/high.cjs +31 -0
  144. package/dist/test/qwik/todo/Todo.cjs/low.cjs +1 -0
  145. package/dist/test/qwik/todo/Todo.cjs/med.cjs +59 -0
  146. package/dist/test/qwik/todo/Todo.js/high.js +5 -0
  147. package/dist/test/qwik/todo/Todo.js/low.js +0 -0
  148. package/dist/test/qwik/todo/Todo.js/med.js +1 -0
  149. package/dist/test/qwik/todo/Todo.tsx/high.tsx +30 -0
  150. package/dist/test/qwik/todo/Todo.tsx/low.tsx +1 -0
  151. package/dist/test/qwik/todo/Todo.tsx/med.tsx +34 -0
  152. package/dist/test/qwik/todos/Todo.tsx/high.tsx +12 -0
  153. package/dist/test/qwik/todos/Todo.tsx/low.tsx +25 -0
  154. package/dist/test/qwik/todos/Todo.tsx/med.tsx +8 -0
  155. package/dist/tsconfig.tsbuildinfo +1 -1
  156. package/package.json +2 -2
  157. package/CHANGELOG.md +0 -4
  158. package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
  159. package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
  160. package/dist/src/__tests__/qoot.test.d.ts +0 -1
  161. package/dist/src/__tests__/qoot.test.js +0 -115
  162. package/dist/src/generators/jsx-lite.d.ts +0 -10
  163. package/dist/src/generators/jsx-lite.js +0 -176
  164. package/dist/src/generators/qoot.d.ts +0 -21
  165. package/dist/src/generators/qoot.js +0 -442
  166. package/dist/src/generators/qwik.d.ts +0 -21
  167. package/dist/src/generators/qwik.js +0 -458
  168. package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
  169. package/dist/src/helpers/create-jsx-lite-component.js +0 -16
  170. package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
  171. package/dist/src/helpers/create-jsx-lite-context.js +0 -18
  172. package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
  173. package/dist/src/helpers/create-jsx-lite-node.js +0 -16
  174. package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
  175. package/dist/src/helpers/is-jsx-lite-node.js +0 -7
  176. package/dist/src/types/jsx-lite-component.d.ts +0 -63
  177. package/dist/src/types/jsx-lite-context.d.ts +0 -6
  178. package/dist/src/types/jsx-lite-node.d.ts +0 -13
  179. package/dist/src/types/jsx-lite-node.js +0 -2
  180. package/dist/src/types/jsx-lite-styles.d.ts +0 -1
  181. package/dist/src/types/jsx-lite-styles.js +0 -2
  182. package/dist/test/qoot/Todo/bundle.js +0 -88
  183. package/dist/test/qoot/Todo/component.ts +0 -17
  184. package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
  185. package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
  186. package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
  187. package/dist/test/qoot/Todo/onInputClick.ts +0 -10
  188. package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
  189. package/dist/test/qoot/Todo/public.ts +0 -4
  190. package/dist/test/qoot/Todo/template.tsx +0 -46
  191. package/dist/test/qoot/Todos/component.ts +0 -9
  192. package/dist/test/qoot/Todos/onInputClick.ts +0 -14
  193. package/dist/test/qoot/Todos/public.ts +0 -3
  194. package/dist/test/qoot/Todos/template.tsx +0 -30
  195. package/dist/test/qwik/Todo/bundle.js +0 -46
  196. package/dist/test/qwik/Todo/component.ts +0 -17
  197. package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
  198. package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
  199. package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
  200. package/dist/test/qwik/Todo/onInputClick.ts +0 -13
  201. package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
  202. package/dist/test/qwik/Todo/public.ts +0 -3
  203. package/dist/test/qwik/Todo/template.tsx +0 -46
  204. package/dist/test/qwik/Todo.ts +0 -4
  205. package/dist/test/qwik/Todo_component.ts +0 -17
  206. package/dist/test/qwik/Todo_onButtonClick.ts +0 -13
  207. package/dist/test/qwik/Todo_onInput2Blur.ts +0 -14
  208. package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
  209. package/dist/test/qwik/Todo_onInputClick.ts +0 -13
  210. package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -14
  211. package/dist/test/qwik/Todo_template.tsx +0 -46
  212. package/dist/test/qwik/Todos/component.ts +0 -9
  213. package/dist/test/qwik/Todos/onInputClick.ts +0 -14
  214. package/dist/test/qwik/Todos/public.ts +0 -3
  215. package/dist/test/qwik/Todos/template.tsx +0 -30
  216. package/dist/test/qwik/Todos.ts +0 -3
  217. package/dist/test/qwik/Todos_component.ts +0 -9
  218. package/dist/test/qwik/Todos_onInputClick.ts +0 -14
  219. package/dist/test/qwik/Todos_template.tsx +0 -30
@@ -1,6 +1,6 @@
1
1
  import { TraverseContext } from 'traverse';
2
- import { MitosisNode } from '../types/mitosis-node';
3
2
  import { MitosisComponent } from '../types/mitosis-component';
3
+ import { MitosisNode } from '../types/mitosis-node';
4
4
  declare type CompileAwayComponentsMap = {
5
5
  [key: string]: (node: MitosisNode, context: TraverseContext, components: CompileAwayComponentsMap) => MitosisNode | void;
6
6
  };
@@ -10,32 +10,52 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
14
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
15
- to[j] = from[i];
16
- return to;
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
33
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
34
+ if (ar || !(i in from)) {
35
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
36
+ ar[i] = from[i];
37
+ }
38
+ }
39
+ return to.concat(ar || Array.prototype.slice.call(from));
17
40
  };
18
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
19
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
43
  };
21
44
  Object.defineProperty(exports, "__esModule", { value: true });
22
45
  exports.compileAwayBuilderComponents = exports.compileAwayBuilderComponentsFromTree = exports.components = void 0;
46
+ var react_1 = require("@builder.io/react");
23
47
  var lodash_1 = require("lodash");
24
- var parse_node_1 = require("../helpers/parse-node");
25
48
  var traverse_1 = __importDefault(require("traverse"));
26
- var mitosis_1 = require("../generators/mitosis");
27
- var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
28
49
  var create_mitosis_node_1 = require("../helpers/create-mitosis-node");
50
+ var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
29
51
  var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
30
- var react_1 = require("@builder.io/react");
52
+ var JSON5 = __importStar(require("json5"));
53
+ var builder_1 = require("../parsers/builder");
31
54
  function getComponentInputNames(componentName) {
32
55
  var _a;
33
56
  var componentInfo = react_1.Builder.components.find(function (item) { return item.name === componentName; });
34
57
  return ((_a = componentInfo === null || componentInfo === void 0 ? void 0 : componentInfo.inputs) === null || _a === void 0 ? void 0 : _a.map(function (item) { return item.name; })) || [];
35
58
  }
36
- var getRenderOptions = function (node) {
37
- return __assign(__assign({}, lodash_1.mapValues(node.properties, function (value) { return "\"" + value + "\""; })), lodash_1.mapValues(node.bindings, function (value) { return "{" + value + "}"; }));
38
- };
39
59
  function updateQueryParam(uri, key, value) {
40
60
  if (uri === void 0) { uri = ''; }
41
61
  var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
@@ -47,8 +67,8 @@ function updateQueryParam(uri, key, value) {
47
67
  }
48
68
  var wrapOutput = function (node, child, components) {
49
69
  var inputNames = getComponentInputNames(node.name);
50
- exports.compileAwayBuilderComponentsFromTree(child, components);
51
- return create_mitosis_node_1.createMitosisNode(__assign(__assign({}, node), { properties: __assign({}, lodash_1.omit.apply(void 0, __spreadArray([node.properties], inputNames))), bindings: __assign({}, lodash_1.omit.apply(void 0, __spreadArray([node.bindings], inputNames))),
70
+ (0, exports.compileAwayBuilderComponentsFromTree)(child, components);
71
+ return (0, create_mitosis_node_1.createMitosisNode)(__assign(__assign({}, node), { properties: __assign({}, lodash_1.omit.apply(void 0, __spreadArray([node.properties], inputNames, false))), bindings: __assign({}, lodash_1.omit.apply(void 0, __spreadArray([node.bindings], inputNames, false))),
52
72
  // TODO: forward tagName as a $tagName="..."
53
73
  name: node.properties._tagName || node.properties.$tagName || 'div', children: Array.isArray(child) ? child : [child] }));
54
74
  };
@@ -69,67 +89,117 @@ exports.components = {
69
89
  bindings.innerHTML = node.properties.text;
70
90
  }
71
91
  if ('openInNewTab' in node.bindings) {
72
- bindings.target = node.bindings.openInNewTab + " ? '_blank' : '_self'";
92
+ bindings.target = "".concat(node.bindings.openInNewTab, " ? '_blank' : '_self'");
73
93
  }
74
94
  var omitFields = ['link', 'openInNewTab', 'text'];
75
95
  var hasLink = node.properties.link || node.bindings.link;
76
- return create_mitosis_node_1.createMitosisNode(__assign(__assign({}, node), { name: hasLink ? 'a' : node.properties.$tagName || 'span', properties: __assign(__assign({}, lodash_1.omit(node.properties, omitFields)), properties), bindings: __assign(__assign({}, lodash_1.omit(node.bindings, omitFields)), bindings) }));
96
+ return (0, create_mitosis_node_1.createMitosisNode)(__assign(__assign({}, node), { name: hasLink ? 'a' : node.properties.$tagName || 'span', properties: __assign(__assign({}, (0, lodash_1.omit)(node.properties, omitFields)), properties), bindings: __assign(__assign({}, (0, lodash_1.omit)(node.bindings, omitFields)), bindings) }));
77
97
  },
78
98
  Embed: function (node, context, components) {
79
- return wrapOutput(node, create_mitosis_node_1.createMitosisNode({
99
+ return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
80
100
  name: node.properties.builderTag || 'div',
81
101
  properties: {
82
- innerHTML: (node.properties.content || '').replace(/"/g, '&quot;'),
102
+ innerHTML: node.properties.content || '',
83
103
  },
84
104
  }), components);
85
105
  },
86
- BuilderAccordion: function () {
87
- // TODO
88
- return create_mitosis_node_1.createMitosisNode({
89
- name: 'div',
90
- properties: { 'data-missing-component': 'BuilderAccordion' },
106
+ BuilderAccordion: function (node, context, components) {
107
+ var itemsJSON = node.bindings.items || '[]';
108
+ var accordionItems = JSON5.parse(itemsJSON);
109
+ var children = accordionItems.map(function (accordionItem) {
110
+ var titleChildren = accordionItem.title.map(function (element) {
111
+ return (0, builder_1.builderElementToMitosisNode)(element, {
112
+ includeBuilderExtras: true,
113
+ preserveTextBlocks: true,
114
+ });
115
+ });
116
+ var detailChildren = accordionItem.detail.map(function (element) {
117
+ return (0, builder_1.builderElementToMitosisNode)(element, {
118
+ includeBuilderExtras: true,
119
+ preserveTextBlocks: true,
120
+ });
121
+ });
122
+ return (0, create_mitosis_node_1.createMitosisNode)({
123
+ name: 'div',
124
+ properties: { builder: 'accordion' },
125
+ children: [
126
+ (0, create_mitosis_node_1.createMitosisNode)({
127
+ name: 'div',
128
+ properties: { builder: 'accordion-title' },
129
+ children: titleChildren,
130
+ }),
131
+ (0, create_mitosis_node_1.createMitosisNode)({
132
+ name: 'div',
133
+ properties: { builder: 'accordion-detail' },
134
+ children: detailChildren,
135
+ }),
136
+ ],
137
+ });
91
138
  });
139
+ return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
140
+ name: node.properties.builderTag || 'div',
141
+ properties: {
142
+ $name: 'accordion',
143
+ },
144
+ children: children,
145
+ }), components);
92
146
  },
93
147
  BuilderMasonry: function () {
94
148
  // TODO
95
- return create_mitosis_node_1.createMitosisNode({
149
+ return (0, create_mitosis_node_1.createMitosisNode)({
96
150
  name: 'div',
97
151
  properties: { 'data-missing-component': 'BuilderMasonry' },
98
152
  });
99
153
  },
100
154
  BuilderTabs: function () {
101
155
  // TODO
102
- return create_mitosis_node_1.createMitosisNode({
156
+ return (0, create_mitosis_node_1.createMitosisNode)({
103
157
  name: 'div',
104
158
  properties: { 'data-missing-component': 'BuilderTabs' },
105
159
  });
106
160
  },
107
161
  BuilderCarousel: function () {
108
162
  // TODO
109
- return create_mitosis_node_1.createMitosisNode({
163
+ return (0, create_mitosis_node_1.createMitosisNode)({
110
164
  name: 'div',
111
165
  properties: { 'data-missing-component': 'BuilderCarousel' },
112
166
  });
113
167
  },
114
168
  CustomCode: function (node, context, components) {
115
- var options = getRenderOptions(node);
116
- return wrapOutput(node, create_mitosis_node_1.createMitosisNode({
169
+ return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
117
170
  name: node.properties.builderTag || 'div',
118
171
  properties: {
119
- innerHTML: (node.properties.code || '').replace(/"/g, '&quot;'),
172
+ innerHTML: node.properties.code || '',
120
173
  },
121
174
  }), components);
122
175
  },
123
176
  CoreSection: function (node, context, components) {
124
- return wrapOutput(node, parse_node_1.parseNode("<section\n $name=\"section\"\n " + (node.bindings.lazyLoad === 'true' ? 'lazyload="true"' : '') + "\n css={{\n width: '100%',\n alignSelf: 'stretch',\n flexGrow: '1',\n boxSizing: 'border-box',\n maxWidth: '" + ((node.bindings.maxWidth && Number(node.bindings.maxWidth)) || 1200) + "px',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'stretch',\n marginLeft: 'auto',\n marginRight: 'auto',\n }}\n >\n " + node.children
125
- .map(function (block) {
126
- return mitosis_1.blockToMitosis(block, {
127
- prettier: false,
128
- });
129
- })
130
- .join('\n') + "\n </section>"), components);
177
+ return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
178
+ name: 'section',
179
+ properties: __assign(__assign(__assign({}, node.properties), { $name: 'section' }), (node.bindings.lazyLoad === 'true' && {
180
+ lazyLoad: 'true',
181
+ })),
182
+ bindings: {
183
+ css: JSON.stringify({
184
+ width: '100%',
185
+ alignSelf: 'stretch',
186
+ flexGrow: '1',
187
+ boxSizing: 'border-box',
188
+ maxWidth: "".concat((node.bindings.maxWidth &&
189
+ Number(node.bindings.maxWidth)) ||
190
+ 1200, "px"),
191
+ display: 'flex',
192
+ flexDirection: 'column',
193
+ alignItems: 'stretch',
194
+ marginLeft: 'auto',
195
+ marginRight: 'auto',
196
+ }),
197
+ },
198
+ children: node.children,
199
+ }), components);
131
200
  },
132
201
  Columns: function (node, context, components) {
202
+ var _a;
133
203
  var columns = node.children.filter(filter_empty_text_nodes_1.filterEmptyTextNodes).map(function (item) { return ({
134
204
  width: parseFloat(item.properties.width || item.bindings.width || '0') || 0,
135
205
  children: item.children,
@@ -141,31 +211,51 @@ exports.components = {
141
211
  }
142
212
  function getColumnWidth(index) {
143
213
  var subtractWidth = (gutterSize * (columns.length - 1)) / columns.length;
144
- return "calc(" + getWidth(index) + "% - " + subtractWidth + "px)";
214
+ return "calc(".concat(getWidth(index), "% - ").concat(subtractWidth, "px)");
145
215
  }
146
216
  var properties = node.properties;
147
- return wrapOutput(node, parse_node_1.parseNode("\n <div\n class=\"builder-columns\"\n $name=\"columns\"\n css={{\n display: 'flex',\n " + (properties.stackColumnsAt === 'never'
148
- ? ''
149
- : "\n \"@media (max-width: " + (properties.stackColumnsAt !== 'tablet' ? 639 : 999) + "px)\": {\n flexDirection: \"" + (properties.reverseColumnsWhenStacked === 'true'
150
- ? 'column-reverse'
151
- : 'column') + "\",\n alignItems: 'stretch',\n },\n ") + "\n }}\n >\n " + columns
152
- .map(function (col, index) {
153
- // TODO: pass size down in context
154
- return "<div\n $name=\"column\"\n class=\"builder-column\"\n css={{\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'stretch',\n lineHeight: 'normal',\n width: \"" + getColumnWidth(index) + "\",\n marginLeft: \"" + (index === 0 ? 0 : gutterSize) + "px\",\n " + (properties.stackColumnsAt === 'never'
155
- ? ''
156
- : "\n \n \"@media (max-width: " + (properties.stackColumnsAt !== 'tablet' ? 639 : 999) + "px)\": {\n width: '100%',\n marginLeft: 0,\n },\n ") + "\n }}\n >\n " + col.children
157
- .map(function (block) {
158
- return mitosis_1.blockToMitosis(block, {
159
- prettier: false,
217
+ return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
218
+ name: 'div',
219
+ properties: {
220
+ class: 'builder-columns',
221
+ },
222
+ bindings: {
223
+ css: JSON.stringify(__assign({ display: 'flex' }, (properties.stackColumnsAt === 'never'
224
+ ? {}
225
+ : (_a = {},
226
+ _a["@media (max-width: ".concat(properties.stackColumnsAt !== 'tablet' ? 639 : 999, "px)")] = {
227
+ flexDirection: properties.reverseColumnsWhenStacked === 'true'
228
+ ? 'column-reverse'
229
+ : 'column',
230
+ alignItems: 'stretch',
231
+ },
232
+ _a)))),
233
+ },
234
+ children: columns.map(function (col, index) {
235
+ var _a;
236
+ return (0, create_mitosis_node_1.createMitosisNode)({
237
+ name: 'div',
238
+ properties: {
239
+ $name: 'column',
240
+ class: 'builder-column',
241
+ },
242
+ bindings: {
243
+ css: JSON.stringify(__assign({ display: 'flex', flexDirection: 'column', alignItems: 'stretch', lineHeight: 'normal', width: "".concat(getColumnWidth(index)), marginLeft: "".concat(index === 0 ? 0 : gutterSize, "px") }, (properties.stackColumnsAt === 'never'
244
+ ? {}
245
+ : (_a = {},
246
+ _a["@media (max-width: ".concat(properties.stackColumnsAt !== 'tablet' ? 639 : 999, "px)")] = {
247
+ width: '100%',
248
+ marginLeft: 0,
249
+ },
250
+ _a)))),
251
+ },
252
+ children: col.children,
160
253
  });
161
- })
162
- .join('\n') + "\n </div>\n ";
163
- })
164
- .join('\n') + "\n </div>\n "), components);
254
+ }),
255
+ }), components);
165
256
  },
166
257
  Image: function (node, context, components) {
167
- var options = getRenderOptions(node);
168
- var backgroundSize = options.backgroundSize, backgroundPosition = options.backgroundPosition, sizes = options.sizes, lazy = options.lazy, image = options.image;
258
+ var _a = node.properties, backgroundSize = _a.backgroundSize, backgroundPosition = _a.backgroundPosition;
169
259
  var srcset = node.properties.srcset;
170
260
  var widths = [100, 200, 400, 800, 1200, 1600, 2000];
171
261
  var aspectRatio = node.bindings.aspectRatio
@@ -175,56 +265,193 @@ exports.components = {
175
265
  aspectRatio = null;
176
266
  }
177
267
  var srcSet = srcset ||
178
- "" + ((node.properties.image || '').match(/builder\.io/)
268
+ "".concat((node.properties.image || '').match(/builder\.io/)
179
269
  ? widths
180
270
  .map(function (size) {
181
- return updateQueryParam(node.properties.image, 'width', String(size)) + " " + size + "w";
271
+ return "".concat(updateQueryParam(node.properties.image, 'width', String(size)), " ").concat(size, "w");
182
272
  })
183
273
  .concat([node.properties.image])
184
274
  .join(', ')
185
275
  : '');
186
- return wrapOutput(node, parse_node_1.parseNodes("\n <picture>\n " + (srcSet && srcSet.match(/builder\.io/)
187
- ? "<source srcSet=\"" + srcSet.replace(/\?/g, '?format=webp&') + "\" type=\"image/webp\" />"
188
- : '') + "\n <img\n $name=\"image\"\n " + (lazy ? " loading=\"lazy\" " : '') + "\n " + (image ? " src=" + image + " " : '') + " \n " + (!sizes ? '' : "sizes=" + sizes) + " \n " + (!srcSet ? '' : "srcSet=\"" + srcSet + "\"") + "\n css={{\n objectFit: " + (backgroundSize || '"cover"') + ",\n objectPosition: " + (backgroundPosition || '"cover"') + ",\n " + (!aspectRatio
189
- ? ''
190
- : "\n position: 'absolute',\n height: '100%',\n width: '100%',\n top: '0',\n left: '0',\n ") + "\n }} />\n </picture>\n " + (aspectRatio
191
- ? "<div\n class=\"builder-image-sizer\"\n $name=\"image-sizer\"\n css={{\n width: '100%',\n paddingTop: \"" + (aspectRatio * 100 + '%') + "\",\n pointerEvents: 'none',\n fontSize: '0',\n }} />"
192
- : '') + "\n " + (node.children && node.children.length
193
- ? "\n <div\n $name=\"image-contents\"\n css={{\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'stretch',\n position: 'absolute',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%',\n }}\n >\n " + node.children
194
- .map(function (block) {
195
- return mitosis_1.blockToMitosis(block, {
196
- prettier: false,
197
- });
198
- })
199
- .join('\n') + "\n </div>"
200
- : '') + "\n "), components);
276
+ var source = node.bindings.noWebp !== 'true' &&
277
+ (0, create_mitosis_node_1.createMitosisNode)({
278
+ name: 'source',
279
+ properties: {
280
+ srcset: srcSet.replace(/\?/g, '?format=webp&'),
281
+ type: 'image/webp',
282
+ },
283
+ });
284
+ var img = (0, create_mitosis_node_1.createMitosisNode)({
285
+ name: 'img',
286
+ properties: noUndefined({
287
+ $name: 'image',
288
+ loading: node.properties.lazy ? 'lazy' : undefined,
289
+ src: node.properties.image,
290
+ sizes: node.properties.sizes,
291
+ srcset: srcSet || null,
292
+ }),
293
+ bindings: noUndefined({
294
+ loading: node.bindings.lazy ? '"lazy"' : undefined,
295
+ src: node.bindings.image,
296
+ sizes: node.bindings.sizes,
297
+ css: JSON.stringify(__assign({ objectFit: backgroundSize || 'cover', objectPosition: backgroundPosition || 'cover' }, (aspectRatio
298
+ ? {
299
+ position: 'absolute',
300
+ height: '100%',
301
+ width: '100%',
302
+ top: '0',
303
+ left: '0',
304
+ }
305
+ : {}))),
306
+ }),
307
+ });
308
+ var picture = (0, create_mitosis_node_1.createMitosisNode)({
309
+ name: 'picture',
310
+ children: source ? [source, img] : [img],
311
+ });
312
+ var imgSizer = aspectRatio &&
313
+ (0, create_mitosis_node_1.createMitosisNode)({
314
+ name: 'div',
315
+ properties: {
316
+ $name: 'image-sizer',
317
+ class: 'builder-image-sizer',
318
+ },
319
+ bindings: {
320
+ css: JSON.stringify({
321
+ width: '100%',
322
+ paddingTop: aspectRatio * 100 + '%',
323
+ pointerEvents: 'none',
324
+ fontSize: '0',
325
+ }),
326
+ },
327
+ });
328
+ var children = node.children &&
329
+ node.children.length &&
330
+ (0, create_mitosis_node_1.createMitosisNode)({
331
+ name: 'div',
332
+ properties: {
333
+ $name: 'image-contents',
334
+ },
335
+ bindings: {
336
+ css: JSON.stringify({
337
+ display: 'flex',
338
+ flexDirection: 'column',
339
+ alignItems: 'stretch',
340
+ position: 'absolute',
341
+ top: '0',
342
+ left: '0',
343
+ width: '100%',
344
+ height: '100%',
345
+ }),
346
+ },
347
+ children: node.children,
348
+ });
349
+ var imageNodes = [picture];
350
+ imgSizer && imageNodes.push(imgSizer);
351
+ children && imageNodes.push(children);
352
+ return wrapOutput(node, imageNodes, components);
201
353
  },
202
354
  Video: function (node, context, components) {
203
- var options = getRenderOptions(node);
204
355
  var aspectRatio = node.bindings.aspectRatio
205
356
  ? parseFloat(node.bindings.aspectRatio)
206
357
  : null;
207
358
  if (typeof aspectRatio === 'number' && isNaN(aspectRatio)) {
208
359
  aspectRatio = null;
209
360
  }
210
- var str = "\n <div $name=\"video-container\" css={{ position: 'relative' }}>\n <video\n " + (options.posterImage ? "poster=" + options.posterImage : '') + "\n " + (options.autoPlay ? "autoPlay=" + options.autoPlay : '') + "\n " + (options.muted ? "muted=" + options.muted : '') + "\n " + (options.controls ? "controls=" + options.controls : '') + "\n " + (options.loop ? "loop=" + options.loop : '') + "\n " + (options.lazy ? 'preload="none"' : '') + "\n $name=\"builder-video\"\n css={{\n width: '100%',\n height: '100%',\n " + (options.fit ? "objectFit: " + options.fit + "," : '') + "\n " + (options.position ? "objectPosition: " + options.position + "," : '') + "\n borderRadius: '1',\n " + (aspectRatio ? "position: \"absolute\"," : '') + "\n }}\n >\n <source type=\"video/mp4\" src=" + options.video + " />\n </video>\n " + (!aspectRatio
211
- ? ''
212
- : "\n <div\n $name=\"builder-video-sizer\"\n css={{\n width: '100%',\n paddingTop: '" + (aspectRatio * 100 + '%') + "',\n pointerEvents: 'none',\n fontSize: '0'\n }}\n />\n ") + "\n " + (node.children && node.children.length
213
- ? "\n <div\n $name=\"video-contents\"\n css={{\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'stretch',\n position: 'absolute',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%'\n }}\n >\n " + node.children
214
- .map(function (block) {
215
- return mitosis_1.blockToMitosis(block, {
216
- prettier: false,
217
- });
218
- })
219
- .join('\n') + "\n </div>"
220
- : '') + "\n </div>\n ";
221
- var output = wrapOutput(node, parse_node_1.parseNodes(str), components);
222
- return output;
361
+ var videoContainerNodes = [];
362
+ videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
363
+ name: 'video',
364
+ properties: noUndefined({
365
+ $name: 'builder-video',
366
+ poster: node.properties.posterImage,
367
+ autoplay: node.properties.autoPlay,
368
+ muted: node.properties.muted,
369
+ controls: node.properties.controls,
370
+ loop: node.properties.loop,
371
+ playsinline: node.properties.playsInline,
372
+ preload: node.properties.lazy ? 'none' : undefined,
373
+ }),
374
+ bindings: noUndefined({
375
+ poster: node.bindings.posterImage,
376
+ autoplay: node.bindings.autoPlay,
377
+ muted: node.bindings.muted,
378
+ controls: node.bindings.controls,
379
+ playsinline: node.bindings.playsInline,
380
+ loop: node.bindings.loop,
381
+ css: JSON.stringify({
382
+ width: '100%',
383
+ height: '100%',
384
+ objectFit: node.properties.fit,
385
+ objectPosition: node.properties.position,
386
+ borderRadius: '1',
387
+ position: aspectRatio ? 'absolute' : '',
388
+ }),
389
+ }),
390
+ children: [
391
+ (0, create_mitosis_node_1.createMitosisNode)({
392
+ name: 'source',
393
+ properties: {
394
+ type: 'video/mp4',
395
+ src: node.properties.video,
396
+ },
397
+ bindings: {
398
+ src: node.bindings.video,
399
+ },
400
+ }),
401
+ ],
402
+ }));
403
+ aspectRatio &&
404
+ videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
405
+ name: 'div',
406
+ properties: {
407
+ $name: 'builder-video-sizer',
408
+ },
409
+ bindings: {
410
+ css: JSON.stringify({
411
+ width: '100%',
412
+ paddingTop: aspectRatio * 100 + '%',
413
+ pointerEvents: 'none',
414
+ fontSize: '0',
415
+ }),
416
+ },
417
+ }));
418
+ node.children &&
419
+ node.children.length &&
420
+ videoContainerNodes.push((0, create_mitosis_node_1.createMitosisNode)({
421
+ name: 'div',
422
+ properties: {
423
+ $name: 'image-contents',
424
+ },
425
+ bindings: {
426
+ css: JSON.stringify({
427
+ display: 'flex',
428
+ flexDirection: 'column',
429
+ alignItems: 'stretch',
430
+ position: 'absolute',
431
+ top: '0',
432
+ left: '0',
433
+ width: '100%',
434
+ height: '100%',
435
+ }),
436
+ },
437
+ children: node.children,
438
+ }));
439
+ var videoContainer = (0, create_mitosis_node_1.createMitosisNode)({
440
+ name: 'div',
441
+ properties: {
442
+ $name: 'video-container',
443
+ },
444
+ bindings: {
445
+ css: JSON.stringify({ position: 'relative' }),
446
+ },
447
+ children: videoContainerNodes,
448
+ });
449
+ return wrapOutput(node, videoContainer, components);
223
450
  },
224
451
  };
225
452
  var compileAwayBuilderComponentsFromTree = function (tree, components) {
226
- traverse_1.default(tree).forEach(function (item) {
227
- if (is_mitosis_node_1.isMitosisNode(item)) {
453
+ (0, traverse_1.default)(tree).forEach(function (item) {
454
+ if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
228
455
  var mapper = components[item.name];
229
456
  if (mapper) {
230
457
  var result = mapper(item, this, components);
@@ -240,17 +467,29 @@ var compileAwayBuilderComponents = function (pluginOptions) {
240
467
  if (pluginOptions === void 0) { pluginOptions = {}; }
241
468
  var obj = exports.components;
242
469
  if (pluginOptions.omit) {
243
- obj = lodash_1.omit(obj, pluginOptions.omit);
470
+ obj = (0, lodash_1.omit)(obj, pluginOptions.omit);
244
471
  }
245
472
  if (pluginOptions.only) {
246
- obj = lodash_1.pick(obj, pluginOptions.only);
473
+ obj = (0, lodash_1.pick)(obj, pluginOptions.only);
247
474
  }
248
475
  return function (options) { return ({
249
476
  json: {
250
477
  pre: function (json) {
251
- exports.compileAwayBuilderComponentsFromTree(json, exports.components);
478
+ (0, exports.compileAwayBuilderComponentsFromTree)(json, exports.components);
252
479
  },
253
480
  },
254
481
  }); };
255
482
  };
256
483
  exports.compileAwayBuilderComponents = compileAwayBuilderComponents;
484
+ function noUndefined(obj) {
485
+ var cleanObj = {};
486
+ for (var key in obj) {
487
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
488
+ var value = obj[key];
489
+ if (value != null) {
490
+ cleanObj[key] = value;
491
+ }
492
+ }
493
+ }
494
+ return cleanObj;
495
+ }
@@ -19,7 +19,7 @@ var lodash_1 = require("lodash");
19
19
  var traverse_1 = __importDefault(require("traverse"));
20
20
  var is_mitosis_node_1 = require("../helpers/is-mitosis-node");
21
21
  var getRenderOptions = function (node) {
22
- return __assign(__assign({}, lodash_1.mapValues(node.properties, function (value) { return "\"" + value + "\""; })), lodash_1.mapValues(node.bindings, function (value) { return "{" + value + "}"; }));
22
+ return __assign(__assign({}, (0, lodash_1.mapValues)(node.properties, function (value) { return "\"".concat(value, "\""); })), (0, lodash_1.mapValues)(node.bindings, function (value) { return "{".concat(value, "}"); }));
23
23
  };
24
24
  exports.getRenderOptions = getRenderOptions;
25
25
  /**
@@ -41,8 +41,8 @@ exports.getRenderOptions = getRenderOptions;
41
41
  var compileAwayComponents = function (pluginOptions) { return function (options) { return ({
42
42
  json: {
43
43
  pre: function (json) {
44
- traverse_1.default(json).forEach(function (item) {
45
- if (is_mitosis_node_1.isMitosisNode(item)) {
44
+ (0, traverse_1.default)(json).forEach(function (item) {
45
+ if ((0, is_mitosis_node_1.isMitosisNode)(item)) {
46
46
  var mapper = pluginOptions.components[item.name];
47
47
  if (mapper) {
48
48
  var result = mapper(item, this);
@@ -6,9 +6,9 @@ var traverse_nodes_1 = require("../helpers/traverse-nodes");
6
6
  var mapStyles = function (pluginOptions) { return function (options) { return ({
7
7
  json: {
8
8
  pre: function (json) {
9
- traverse_nodes_1.tarverseNodes(json, function (node, context) {
10
- var styles = get_styles_1.getStyles(node);
11
- get_styles_1.setStyles(node, pluginOptions.map(styles || {}, context));
9
+ (0, traverse_nodes_1.tarverseNodes)(json, function (node, context) {
10
+ var styles = (0, get_styles_1.getStyles)(node);
11
+ (0, get_styles_1.setStyles)(node, pluginOptions.map(styles || {}, context));
12
12
  });
13
13
  },
14
14
  },
@@ -0,0 +1,24 @@
1
+ export declare const targets: {
2
+ angular: (options?: import("./generators/angular").ToAngularOptions) => import(".").Transpiler;
3
+ builder: (options?: import("./generators/builder").ToBuilderOptions) => ({ component, }: import(".").TranspilerArgs) => {
4
+ data: {
5
+ httpRequests: any;
6
+ jsCode: string;
7
+ tsCode: string;
8
+ blocks: import("@builder.io/sdk").BuilderElement[];
9
+ };
10
+ };
11
+ customElement: (options?: import("./generators/html").ToHtmlOptions) => import(".").Transpiler;
12
+ html: (options?: import("./generators/html").ToHtmlOptions) => import(".").Transpiler;
13
+ mitosis: (toMitosisOptions?: Partial<import("./generators/mitosis").ToMitosisOptions>) => import(".").Transpiler;
14
+ liquid: (options?: import("./generators/liquid").ToLiquidOptions) => import(".").Transpiler;
15
+ react: (reactOptions?: import("./generators/react").ToReactOptions) => import(".").Transpiler;
16
+ reactNative: (options?: import("./generators/react-native").ToReactNativeOptions) => import(".").Transpiler;
17
+ solid: (options?: import("./generators/solid").ToSolidOptions) => import(".").Transpiler;
18
+ svelte: (options?: import("./generators/svelte").ToSvelteOptions) => import(".").Transpiler;
19
+ swift: (options?: import("./generators/swift-ui").ToSwiftOptions) => import(".").Transpiler;
20
+ template: (options?: import("./generators/template").ToTemplateOptions) => import(".").Transpiler;
21
+ vue: (options?: import("./generators/vue").ToVueOptions) => ({ component, path }: import(".").TranspilerArgs & {
22
+ path: string;
23
+ }) => string;
24
+ };