@builder.io/mitosis 0.0.56-85 → 0.0.56-88

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.
@@ -194,9 +194,9 @@ var componentToAngular = function (options) {
194
194
  if (options === void 0) { options = {}; }
195
195
  return function (_a) {
196
196
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
197
- var component = _a.component;
197
+ var _component = _a.component;
198
198
  // Make a copy we can safely mutate, similar to babel's toolchain
199
- var json = (0, fast_clone_1.fastClone)(component);
199
+ var json = (0, fast_clone_1.fastClone)(_component);
200
200
  if (options.plugins) {
201
201
  json = (0, plugins_1.runPreJsonPlugins)(json, options.plugins);
202
202
  }
@@ -212,7 +212,7 @@ var componentToAngular = function (options) {
212
212
  });
213
213
  });
214
214
  var customImports = (0, get_custom_imports_1.getCustomImports)(json);
215
- var _p = component.exports, localExports = _p === void 0 ? {} : _p;
215
+ var _p = json.exports, localExports = _p === void 0 ? {} : _p;
216
216
  var localExportVars = Object.keys(localExports)
217
217
  .filter(function (key) { return localExports[key].usedInLocal; })
218
218
  .map(function (key) { return "".concat(key, " = ").concat(key, ";"); });
@@ -229,14 +229,14 @@ var componentToAngular = function (options) {
229
229
  }
230
230
  return "public ".concat(variableName, " : ").concat(variableType);
231
231
  });
232
- var hasConstructor = Boolean(injectables.length || ((_e = component.hooks) === null || _e === void 0 ? void 0 : _e.onInit));
233
- var props = (0, get_props_1.getProps)(component);
232
+ var hasConstructor = Boolean(injectables.length || ((_e = json.hooks) === null || _e === void 0 ? void 0 : _e.onInit));
233
+ var props = (0, get_props_1.getProps)(json);
234
234
  // prevent jsx props from showing up as @Input
235
235
  if (hasPropRef) {
236
236
  props.delete(forwardProp);
237
237
  }
238
238
  props.delete('children');
239
- var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(component), true));
239
+ var outputVars = (0, lodash_1.uniq)(__spreadArray(__spreadArray([], metaOutputVars, true), (0, get_prop_functions_1.getPropFunctions)(json), true));
240
240
  // remove props for outputs
241
241
  outputVars.forEach(function (variableName) {
242
242
  props.delete(variableName);
@@ -248,7 +248,7 @@ var componentToAngular = function (options) {
248
248
  }
249
249
  return "@Output() ".concat(variableName, " = new EventEmitter()");
250
250
  });
251
- var hasOnMount = Boolean((_f = component.hooks) === null || _f === void 0 ? void 0 : _f.onMount);
251
+ var hasOnMount = Boolean((_f = json.hooks) === null || _f === void 0 ? void 0 : _f.onMount);
252
252
  var domRefs = (0, get_refs_1.getRefs)(json);
253
253
  var jsRefs = Object.keys(json.refs).filter(function (ref) { return !domRefs.has(ref); });
254
254
  var stateVars = Object.keys((json === null || json === void 0 ? void 0 : json.state) || {});
@@ -298,7 +298,7 @@ var componentToAngular = function (options) {
298
298
  "\n standalone: true,\n imports: [CommonModule".concat(componentsUsed.length ? ", ".concat(componentsUsed.join(', ')) : '', "],\n ")
299
299
  : '', (0, lodash_1.kebabCase)(json.name || 'my-component'), (0, indent_1.indent)(template, 8).replace(/`/g, '\\`').replace(/\$\{/g, '\\${'), css.length
300
300
  ? "styles: [\n `".concat((0, indent_1.indent)(css, 8), "`\n ],")
301
- : '', component.name, localExportVars.join('\n'), customImports.map(function (name) { return "".concat(name, " = ").concat(name); }).join('\n'), Array.from(props)
301
+ : '', json.name, localExportVars.join('\n'), customImports.map(function (name) { return "".concat(name, " = ").concat(name); }).join('\n'), Array.from(props)
302
302
  .filter(function (item) { return !(0, slots_1.isSlotProperty)(item) && item !== 'children'; })
303
303
  .map(function (item) {
304
304
  var propType = propsTypeRef ? "".concat(propsTypeRef, "[\"").concat(item, "\"]") : 'any';
@@ -308,8 +308,8 @@ var componentToAngular = function (options) {
308
308
  .map(function (refName) { return "@ViewChild('".concat(refName, "') ").concat(refName, ": ElementRef"); })
309
309
  .join('\n'), dataString, jsRefs
310
310
  .map(function (ref) {
311
- var argument = component.refs[ref].argument;
312
- var typeParameter = component.refs[ref].typeParameter;
311
+ var argument = json.refs[ref].argument;
312
+ var typeParameter = json.refs[ref].typeParameter;
313
313
  return "private _".concat(ref).concat(typeParameter ? ": ".concat(typeParameter) : '').concat(argument
314
314
  ? " = ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(argument, {
315
315
  replaceWith: 'this.',
@@ -322,25 +322,25 @@ var componentToAngular = function (options) {
322
322
  })
323
323
  .join('\n'), !hasConstructor
324
324
  ? ''
325
- : "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = component.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
325
+ : "constructor(\n".concat(injectables.join(',\n'), ") {\n ").concat(!((_h = json.hooks) === null || _h === void 0 ? void 0 : _h.onInit)
326
326
  ? ''
327
- : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = component.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
327
+ : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_j = json.hooks.onInit) === null || _j === void 0 ? void 0 : _j.code, {
328
328
  replaceWith: 'this.',
329
329
  contextVars: contextVars,
330
330
  outputVars: outputVars,
331
331
  }), "\n "), "\n }\n "), !hasOnMount
332
332
  ? ''
333
- : "ngOnInit() {\n \n ".concat(!((_k = component.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
333
+ : "ngOnInit() {\n \n ".concat(!((_k = json.hooks) === null || _k === void 0 ? void 0 : _k.onMount)
334
334
  ? ''
335
- : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = component.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
335
+ : "\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)((_l = json.hooks.onMount) === null || _l === void 0 ? void 0 : _l.code, {
336
336
  replaceWith: 'this.',
337
337
  contextVars: contextVars,
338
338
  outputVars: outputVars,
339
339
  domRefs: Array.from(domRefs),
340
340
  stateVars: stateVars,
341
- }), "\n "), "\n }"), !((_m = component.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.length)
341
+ }), "\n "), "\n }"), !((_m = json.hooks.onUpdate) === null || _m === void 0 ? void 0 : _m.length)
342
342
  ? ''
343
- : "ngAfterContentChecked() {\n ".concat(component.hooks.onUpdate.reduce(function (code, hook) {
343
+ : "ngAfterContentChecked() {\n ".concat(json.hooks.onUpdate.reduce(function (code, hook) {
344
344
  code += (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(hook.code, {
345
345
  replaceWith: 'this.',
346
346
  contextVars: contextVars,
@@ -349,9 +349,9 @@ var componentToAngular = function (options) {
349
349
  stateVars: stateVars,
350
350
  });
351
351
  return code + '\n';
352
- }, ''), "\n }"), !component.hooks.onUnMount
352
+ }, ''), "\n }"), !json.hooks.onUnMount
353
353
  ? ''
354
- : "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(component.hooks.onUnMount.code, {
354
+ : "ngOnDestroy() {\n ".concat((0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(json.hooks.onUnMount.code, {
355
355
  replaceWith: 'this.',
356
356
  contextVars: contextVars,
357
357
  outputVars: outputVars,
@@ -221,7 +221,7 @@ var componentToMarko = function (userOptions) {
221
221
  // Convert on-click=(...) -> on-click(...)
222
222
  .replace(/(on-[a-z]+)=\(/g, function (_match, group) { return group + '('; })
223
223
  // Fix a weird edge case where </if> becomes </if \n > which is invalid in marko
224
- .replace(/<\/([a-z]+)\s+>/g, '</$1>');
224
+ .replace(/<\/([a-z]+)\s+>/gi, '</$1>');
225
225
  var finalStr = "\n".concat(jsString, "\n").concat(cssString, "\n").concat(htmlString, "\n ")
226
226
  .replace(/\n{3,}/g, '\n\n')
227
227
  .trim();
@@ -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
  });