@builder.io/mitosis 0.3.16 → 0.3.17

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.
@@ -573,6 +573,24 @@ var classPropertiesPlugin = function () { return ({
573
573
  },
574
574
  },
575
575
  }); };
576
+ // if any state "property" is trying to access state.* or props.*
577
+ // then we need to move them to onInit where they can be accessed
578
+ var transformState = function (json) {
579
+ Object.entries(json.state).forEach(function (_a) {
580
+ var _b;
581
+ var key = _a[0], value = _a[1];
582
+ if ((value === null || value === void 0 ? void 0 : value.type) === 'property') {
583
+ if (value.code && (value.code.includes('state.') || value.code.includes('props.'))) {
584
+ var code = (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(value.code, { replaceWith: 'this' });
585
+ json.state[key].code = 'null';
586
+ if (!((_b = json.hooks.onInit) === null || _b === void 0 ? void 0 : _b.code)) {
587
+ json.hooks.onInit = { code: '' };
588
+ }
589
+ json.hooks.onInit.code += "\nthis.".concat(key, " = ").concat(code, ";\n");
590
+ }
591
+ }
592
+ });
593
+ };
576
594
  var componentToAngular = function (userOptions) {
577
595
  if (userOptions === void 0) { userOptions = {}; }
578
596
  return function (_a) {
@@ -734,6 +752,7 @@ var componentToAngular = function (userOptions) {
734
752
  childComponents: childComponents,
735
753
  nativeAttributes: (_e = (_d = useMetadata === null || useMetadata === void 0 ? void 0 : useMetadata.angular) === null || _d === void 0 ? void 0 : _d.nativeAttributes) !== null && _e !== void 0 ? _e : [],
736
754
  }), dynamicComponents = _p.components, dynamicTemplate = _p.dynamicTemplate;
755
+ transformState(json);
737
756
  var dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(json, {
738
757
  format: 'class',
739
758
  valueMapper: processAngularCode({
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.3.16",
25
+ "version": "0.3.17",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {