@builder.io/mitosis 0.0.56-10 → 0.0.56-11

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.
@@ -8,6 +8,8 @@ var onMount = require('./data/blocks/onMount.raw');
8
8
  var onInitonMount = require('./data/blocks/onInit-onMount.raw');
9
9
  var onInit = require('./data/blocks/onInit.raw');
10
10
  var basicFor = require('./data/basic-for.raw');
11
+ var basicChildComponent = require('./data/basic-child-component.raw');
12
+ var basicOutputsMeta = require('./data/basic-outputs-meta.raw');
11
13
  var basicOutputs = require('./data/basic-outputs.raw');
12
14
  var contentSlotHtml = require('./data/blocks/content-slot-html.raw');
13
15
  var contentSlotJsx = require('./data/blocks/content-slot-jsx.raw');
@@ -15,11 +17,28 @@ var slotJsx = require('./data/blocks/slot-jsx.raw');
15
17
  var classNameJsx = require('./data/blocks/classname-jsx.raw');
16
18
  // const slotHtml = require('./data/blocks/slot-html.raw');
17
19
  describe('Angular', function () {
20
+ test('Basic Child Component', function () {
21
+ var component = (0, jsx_1.parseJsx)(basicChildComponent);
22
+ var output = (0, angular_1.componentToAngular)()({ component: component });
23
+ expect(output).toMatchSnapshot();
24
+ });
25
+ test('basic outputs meta', function () {
26
+ var component = (0, jsx_1.parseJsx)(basicOutputsMeta);
27
+ var output = (0, angular_1.componentToAngular)()({ component: component });
28
+ expect(output).toMatchSnapshot();
29
+ });
18
30
  test('basic outputs', function () {
19
31
  var component = (0, jsx_1.parseJsx)(basicOutputs);
20
32
  var output = (0, angular_1.componentToAngular)()({ component: component });
21
33
  expect(output).toMatchSnapshot();
22
34
  });
35
+ test('basic outputs same as meta', function () {
36
+ var component = (0, jsx_1.parseJsx)(basicOutputs);
37
+ var componentMeta = (0, jsx_1.parseJsx)(basicOutputsMeta);
38
+ var output = (0, angular_1.componentToAngular)()({ component: component });
39
+ var outputMeta = (0, angular_1.componentToAngular)()({ component: componentMeta });
40
+ expect(output).toMatch(outputMeta);
41
+ });
23
42
  test('multiple onUpdate', function () {
24
43
  var component = (0, jsx_1.parseJsx)(multipleOnUpdate);
25
44
  var output = (0, angular_1.componentToAngular)()({ component: component });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var react_1 = require("../generators/react");
4
4
  var jsx_1 = require("../parsers/jsx");
5
5
  var basic = require('./data/basic.raw');
6
+ var basicChildComponent = require('./data/basic-child-component.raw');
6
7
  var basicFor = require('./data/basic-for.raw');
7
8
  var submitButtonBlock = require('./data/blocks/submit-button.raw');
8
9
  var inputBlock = require('./data/blocks/input.raw');
@@ -57,6 +58,11 @@ describe('React', function () {
57
58
  var output = (0, react_1.componentToReact)()({ component: component });
58
59
  expect(output).toMatchSnapshot();
59
60
  });
61
+ test('Basic Child Component', function () {
62
+ var component = (0, jsx_1.parseJsx)(basicChildComponent);
63
+ var output = (0, react_1.componentToReact)()({ component: component });
64
+ expect(output).toMatchSnapshot();
65
+ });
60
66
  test('BasicFor', function () {
61
67
  var component = (0, jsx_1.parseJsx)(basicFor);
62
68
  var output = (0, react_1.componentToReact)()({ component: component });
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var html_1 = require("../generators/html");
4
4
  var jsx_1 = require("../parsers/jsx");
5
5
  var basic = require('./data/basic.raw');
6
+ var basicChildComponent = require('./data/basic-child-component.raw');
6
7
  var basicFor = require('./data/basic-for.raw');
7
8
  var basicForShow = require('./data/basic-for-show.raw');
8
9
  var basicOnMountUpdate = require('./data/basic-onMount-update.raw');
@@ -35,6 +36,11 @@ describe('webcomponent', function () {
35
36
  var output = (0, html_1.componentToCustomElement)()({ component: component });
36
37
  expect(output).toMatchSnapshot();
37
38
  });
39
+ test('Basic Child Component', function () {
40
+ var component = (0, jsx_1.parseJsx)(basicChildComponent);
41
+ var output = (0, html_1.componentToCustomElement)()({ component: component });
42
+ expect(output).toMatchSnapshot();
43
+ });
38
44
  test('BasicFor', function () {
39
45
  var component = (0, jsx_1.parseJsx)(basicFor);
40
46
  var output = (0, html_1.componentToCustomElement)()({ component: component });
@@ -4,8 +4,6 @@ export interface ToVueOptions extends BaseTranspilerOptions {
4
4
  vueVersion?: 2 | 3;
5
5
  cssNamespace?: () => string;
6
6
  namePrefix?: (path: string) => string;
7
- builderRegister?: boolean;
8
- registerComponentPrepend?: string;
9
7
  }
10
8
  export declare const blockToVue: (node: MitosisNode, options: ToVueOptions) => string;
11
9
  export declare const componentToVue: (userOptions?: ToVueOptions) => ({ component, path }: TranspilerArgs & {
@@ -59,7 +59,6 @@ var get_components_used_1 = require("../helpers/get-components-used");
59
59
  var lodash_1 = require("lodash");
60
60
  var replace_idenifiers_1 = require("../helpers/replace-idenifiers");
61
61
  var filter_empty_text_nodes_1 = require("../helpers/filter-empty-text-nodes");
62
- var json5_1 = __importDefault(require("json5"));
63
62
  var process_http_requests_1 = require("../helpers/process-http-requests");
64
63
  var patterns_1 = require("../helpers/patterns");
65
64
  var method_literal_prefix_1 = require("../constants/method-literal-prefix");
@@ -288,7 +287,7 @@ var componentToVue = function (userOptions) {
288
287
  // hack while we migrate all other transpilers to receive/handle path
289
288
  // TO-DO: use `Transpiler` once possible
290
289
  return function (_a) {
291
- var _b, _c, _d, _e, _f, _g, _h, _j;
290
+ var _b, _c, _d, _e, _f, _g, _h;
292
291
  var component = _a.component, path = _a.path;
293
292
  var options = mergeOptions(BASE_OPTIONS, userOptions);
294
293
  // Make a copy we can safely mutate, similar to babel's toolchain can be used
@@ -352,15 +351,12 @@ var componentToVue = function (userOptions) {
352
351
  if (includeClassMapHelper) {
353
352
  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 } }");
354
353
  }
355
- var builderRegister = Boolean(options.builderRegister && component.meta.registerComponent);
356
354
  var onUpdateWithDeps = ((_d = component.hooks.onUpdate) === null || _d === void 0 ? void 0 : _d.filter(function (hook) { var _a; return (_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length; })) || [];
357
355
  var onUpdateWithoutDeps = ((_e = component.hooks.onUpdate) === null || _e === void 0 ? void 0 : _e.filter(function (hook) { var _a; return !((_a = hook.deps) === null || _a === void 0 ? void 0 : _a.length); })) || [];
358
- 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 }", "\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 }", "\n </script>\n ", "\n "])), template, (0, render_imports_1.renderPreComponent)(component), component.meta.registerComponent
359
- ? (_f = options.registerComponentPrepend) !== null && _f !== void 0 ? _f : ''
360
- : '', !builderRegister ? '' : 'registerComponent(', !component.name
356
+ var str = (0, dedent_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n <template>\n ", "\n </template>\n <script>\n ", "\n\n export default {\n ", "\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 export default {\n ", "\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.name
361
357
  ? ''
362
- : "name: '".concat(((_g = options.namePrefix) === null || _g === void 0 ? void 0 : _g.call(options, path))
363
- ? ((_h = options.namePrefix) === null || _h === void 0 ? void 0 : _h.call(options, path)) + '-'
358
+ : "name: '".concat(((_f = options.namePrefix) === null || _f === void 0 ? void 0 : _f.call(options, path))
359
+ ? ((_g = options.namePrefix) === null || _g === void 0 ? void 0 : _g.call(options, path)) + '-'
364
360
  : '').concat((0, lodash_1.kebabCase)(component.name), "',"), !componentsUsed.length
365
361
  ? ''
366
362
  : "components: { ".concat(componentsUsed
@@ -375,7 +371,7 @@ var componentToVue = function (userOptions) {
375
371
  ? "provide() {\n const _this = this;\n return ".concat(getContextProvideString(component, options), "\n },")
376
372
  : '', (0, lodash_1.size)(component.context.get)
377
373
  ? "inject: ".concat(getContextInjectString(component, options), ",")
378
- : '', ((_j = component.hooks.onMount) === null || _j === void 0 ? void 0 : _j.code)
374
+ : '', ((_h = component.hooks.onMount) === null || _h === void 0 ? void 0 : _h.code)
379
375
  ? "mounted() {\n ".concat(processBinding(component.hooks.onMount.code, options, component), "\n },")
380
376
  : '', onUpdateWithoutDeps.length
381
377
  ? "updated() {\n ".concat(onUpdateWithoutDeps
@@ -393,9 +389,7 @@ var componentToVue = function (userOptions) {
393
389
  ? ''
394
390
  : "\n computed: ".concat(getterString, ",\n "), functionsString.length < 4
395
391
  ? ''
396
- : "\n methods: ".concat(functionsString, ",\n "), !builderRegister
397
- ? ''
398
- : ", ".concat(json5_1.default.stringify(component.meta.registerComponent || {}), ")"), !css.trim().length
392
+ : "\n methods: ".concat(functionsString, ",\n "), !css.trim().length
399
393
  ? ''
400
394
  : "<style scoped>\n ".concat(css, "\n </style>"));
401
395
  if (options.plugins) {
@@ -76,7 +76,7 @@ function convertBuilderContentToSymbolHierarchy(content, _a) {
76
76
  if (cssCode) {
77
77
  collectComponentStyles && collectComponentStyles.push((0, minify_1.minify)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), cssCode));
78
78
  }
79
- while (path[0 /* Path.DEPTH */] >= this.path.length) {
79
+ while (path[0 /* DEPTH */] >= this.path.length) {
80
80
  path.shift();
81
81
  path.shift();
82
82
  }
@@ -92,10 +92,10 @@ function convertBuilderContentToSymbolHierarchy(content, _a) {
92
92
  collectComponentState[id] = state;
93
93
  }
94
94
  }
95
- if (path[0 /* Path.DEPTH */] < this.path.length) {
95
+ if (path[0 /* DEPTH */] < this.path.length) {
96
96
  var id = getIdFromSymbol(el);
97
97
  hierarchy[id] = [];
98
- addIfMissing(hierarchy[path[1 /* Path.ID */]], id);
98
+ addIfMissing(hierarchy[path[1 /* ID */]], id);
99
99
  path.unshift(this.path.length, id);
100
100
  }
101
101
  // TODO(misko): This should be `el.content` not `el`