@builder.io/mitosis 0.0.56-91 → 0.0.56-94

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.
@@ -197,9 +197,9 @@ var componentToAngular = function (options) {
197
197
  if (options === void 0) { options = {}; }
198
198
  return function (_a) {
199
199
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
200
- var component = _a.component;
200
+ var _component = _a.component;
201
201
  // Make a copy we can safely mutate, similar to babel's toolchain
202
- var json = (0, fast_clone_1.fastClone)(component);
202
+ var json = (0, fast_clone_1.fastClone)(_component);
203
203
  if (options.plugins) {
204
204
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
205
205
  }
@@ -215,7 +215,7 @@ var componentToAngular = function (options) {
215
215
  });
216
216
  });
217
217
  var customImports = (0, get_custom_imports_1.getCustomImports)(json);
218
- var _p = component.exports, localExports = _p === void 0 ? {} : _p;
218
+ var _p = json.exports, localExports = _p === void 0 ? {} : _p;
219
219
  var localExportVars = Object.keys(localExports)
220
220
  .filter(function (key) { return localExports[key].usedInLocal; })
221
221
  .map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
@@ -232,14 +232,14 @@ var componentToAngular = function (options) {
232
232
  }
233
233
  return "public ".concat(variableName, " : ").concat(variableType);
234
234
  });
235
- var hasConstructor = Boolean(injectables.length || ((_e = component.hooks) === null || _e === void 0 ? void 0 : _e.onInit));
236
- var props = (0, get_props_1.getProps)(component);
235
+ var hasConstructor = Boolean(injectables.length || ((_e = json.hooks) === null || _e === void 0 ? void 0 : _e.onInit));
236
+ var props = (0, get_props_1.getProps)(json);
237
237
  // prevent jsx props from showing up as @Input
238
238
  if (hasPropRef) {
239
239
  props.delete(forwardProp);
240
240
  }
241
241
  props.delete('children');
242
- var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(component), true));
242
+ var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(json), true));
243
243
  // remove props for outputs
244
244
  outputVars.forEach(function (variableName) {
245
245
  props.delete(variableName);
@@ -251,7 +251,7 @@ var componentToAngular = function (options) {
251
251
  }
252
252
  return "@Output() ".concat(variableName, " = new EventEmitter()");
253
253
  });
254
- var hasOnMount = Boolean((_f = component.hooks) === null || _f === void 0 ? void 0 : _f.onMount);
254
+ var hasOnMount = Boolean((_f = json.hooks) === null || _f === void 0 ? void 0 : _f.onMount);
255
255
  var domRefs = (0, get_refs_1.getRefs)(json);
256
256
  var jsRefs = Object.keys(json.refs).filter(function (ref) { return !domRefs.has(ref); });
257
257
  var stateVars = Object.keys((json === null || json === void 0 ? void 0 : json.state) || {});
@@ -301,7 +301,7 @@ var componentToAngular = function (options) {
301
301
  "\n standalone: true,\n imports: [CommonModule".concat(componentsUsed.length ? ", ".concat(componentsUsed.join(', ')) : '', "],\n ")
302
302
  : '', (0, lodash_1.kebabCase)(json.name || 'my-component'), (0, indent_1.indent)(template, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${'), css.length
303
303
  ? "styles: [\n `".concat((0, indent_1.indent)(css, 8), "`\n ],")
304
- : '', component.name, localExportVars.join('\n'), customImports.map(function (name) { return "".concat(name, " = ").concat(name); }).join('\n'), Array.from(props)
304
+ : '', json.name, localExportVars.join('\n'), customImports.map(function (name) { return "".concat(name, " = ").concat(name); }).join('\n'), Array.from(props)
305
305
  .filter(function (item) { return !(0, slots_1.isSlotProperty)(item) && item !== 'children'; })
306
306
  .map(function (item) {
307
307
  var propType = propsTypeRef ? "".concat(propsTypeRef, "[\"").concat(item, "\"]") : 'any';
@@ -311,8 +311,8 @@ var componentToAngular = function (options) {
311
311
  .map(function (refName) { return "@ViewChild('".concat(refName, "') ").concat(refName, ": ElementRef"); })
312
312
  .join('\n'), dataString, jsRefs
313
313
  .map(function (ref) {
314
- var argument = component.refs[ref].argument;
315
- var typeParameter = component.refs[ref].typeParameter;
314
+ var argument = json.refs[ref].argument;
315
+ var typeParameter = json.refs[ref].typeParameter;
316
316
  return "private _".concat(ref).concat(typeParameter ? ": ".concat(typeParameter) : '').concat(argument
317
317
  ? " = ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(argument, {
318
318
  replaceWith: 'this.',
@@ -325,25 +325,25 @@ var componentToAngular = function (options) {
325
325
  })
326
326
  .join('\n'), !hasConstructor
327
327
  ? ''
328
- : "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = component.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
328
+ : "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = json.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
329
329
  ? ''
330
- : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = component.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
330
+ : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = json.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
331
331
  replaceWith: 'this.',
332
332
  contextVars: contextVars,
333
333
  outputVars: outputVars,
334
334
  }), "\n "), "\n }\n "), !hasOnMount
335
335
  ? ''
336
- : "ngOnInit() {\n \n ".concat(!((_k = component.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
336
+ : "ngOnInit() {\n \n ".concat(!((_k = json.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
337
337
  ? ''
338
- : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = component.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
338
+ : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = json.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
339
339
  replaceWith: 'this.',
340
340
  contextVars: contextVars,
341
341
  outputVars: outputVars,
342
342
  domRefs: Array.from(domRefs),
343
343
  stateVars: stateVars,
344
- }), "\n "), "\n }"), !((_m = component.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.length)
344
+ }), "\n "), "\n }"), !((_m = json.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.length)
345
345
  ? ''
346
- : "ngAfterContentChecked() {\n ".concat(component.hooks.onUpdate.reduce(function (code, hook) {
346
+ : "ngAfterContentChecked() {\n ".concat(json.hooks.onUpdate.reduce(function (code, hook) {
347
347
  code += (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(hook.code, {
348
348
  replaceWith: 'this.',
349
349
  contextVars: contextVars,
@@ -352,9 +352,9 @@ var componentToAngular = function (options) {
352
352
  stateVars: stateVars,
353
353
  });
354
354
  return code + '\n';
355
- }, ''), "\n }"), !component.hooks.onUnMount
355
+ }, ''), "\n }"), !json.hooks.onUnMount
356
356
  ? ''
357
- : "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onUnMount.code, {
357
+ : "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onUnMount.code, {
358
358
  replaceWith: 'this.',
359
359
  contextVars: contextVars,
360
360
  outputVars: outputVars,
@@ -39,22 +39,6 @@ var lodash_1 = require("lodash");
39
39
  var hash_sum_1 = __importDefault(require("hash-sum"));
40
40
  // Having issues with this, so off for now
41
41
  var USE_MARKO_PRETTIER = false;
42
- /**
43
- * Return the names of methods and functions on state
44
- */
45
- function getStateMethodNames(json) {
46
- return Object.keys(json.state).filter(function (key) {
47
- var _a;
48
- var type = (_a = json.state[key]) === null || _a === void 0 ? void 0 : _a.type;
49
- return type === 'function' || type === 'method';
50
- });
51
- }
52
- /**
53
- * Return the names of getter and functions on state
54
- */
55
- function getStateGetterNames(json) {
56
- return Object.keys(json.state).filter(function (key) { var _a; return ((_a = json.state[key]) === null || _a === void 0 ? void 0 : _a.type) === 'getter'; });
57
- }
58
42
  /**
59
43
  * Return the names of properties (basic literal values) on state
60
44
  */
@@ -62,7 +46,7 @@ function getStatePropertyNames(json) {
62
46
  return Object.keys(json.state).filter(function (key) { var _a; return ((_a = json.state[key]) === null || _a === void 0 ? void 0 : _a.type) === 'property'; });
63
47
  }
64
48
  var blockToMarko = function (json, options) {
65
- var _a, _b, _c, _d, _e, _f;
49
+ var _a, _b, _c, _d, _e, _f, _g;
66
50
  if (json.properties._text) {
67
51
  return json.properties._text;
68
52
  }
@@ -95,7 +79,7 @@ var blockToMarko = function (json, options) {
95
79
  str += " ".concat(key, "=\"").concat(value, "\" ");
96
80
  }
97
81
  for (var key in json.bindings) {
98
- var _g = json.bindings[key], code = _g.code, _h = _g.arguments, cusArgs = _h === void 0 ? ['event'] : _h;
82
+ var _h = json.bindings[key], code = _h.code, _j = _h.arguments, cusArgs = _j === void 0 ? ['event'] : _j;
99
83
  if (key === '_spread' || key === '_forName') {
100
84
  continue;
101
85
  }
@@ -106,7 +90,7 @@ var blockToMarko = function (json, options) {
106
90
  var useKey = key === 'onChange' && json.name === 'input' ? 'onInput' : key;
107
91
  str += " ".concat((0, dash_case_1.dashCase)(useKey), "=(").concat(cusArgs.join(','), " => ").concat(processBinding(options.component, code), ") ");
108
92
  }
109
- else {
93
+ else if (key !== 'innerHTML') {
110
94
  str += " ".concat(key, "=(").concat(processBinding(options.component, code), ") ");
111
95
  }
112
96
  }
@@ -114,6 +98,9 @@ var blockToMarko = function (json, options) {
114
98
  return str + ' />';
115
99
  }
116
100
  str += '>';
101
+ if ((_g = json.bindings.innerHTML) === null || _g === void 0 ? void 0 : _g.code) {
102
+ str += "$!{".concat(processBinding(options.component, json.bindings.innerHTML.code), "}");
103
+ }
117
104
  if (json.children) {
118
105
  str += json.children.map(function (item) { return blockToMarko(item, options); }).join('\n');
119
106
  }
@@ -28,7 +28,7 @@ var stripStateAndPropsRefs = function (code, options) {
28
28
  if (outputVars.length) {
29
29
  outputVars.forEach(function (_var) {
30
30
  // determine expression edge cases onMessage( to this.onMessage.emit(
31
- var regexp = '( |;|\\()(props\\.?)' + _var + '\\(';
31
+ var regexp = '(^|\\s|;|\\()(props\\.?)' + _var + '\\(';
32
32
  var replacer = '$1' + context + _var + '.emit(';
33
33
  newCode = newCode.replace(new RegExp(regexp, 'g'), replacer);
34
34
  });