@builder.io/mitosis 0.7.6 → 0.8.0

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.
@@ -13,6 +13,12 @@ type BuilderToMitosisOptions = {
13
13
  preserveTextBlocks?: boolean;
14
14
  includeSpecialBindings?: boolean;
15
15
  includeMeta?: boolean;
16
+ /**
17
+ * When `true`, invalid bindings will be escaped as strings with special comments.
18
+ * This can then be used to have LLMs such as Claude attempt to repair the broken code.
19
+ * Defaults to `false`.
20
+ */
21
+ escapeInvalidCode?: boolean;
16
22
  };
17
23
  export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode;
18
24
  export declare const getMetaFromBlock: (block: BuilderElement, options: BuilderToMitosisOptions) => {};
@@ -127,9 +127,20 @@ const getStyleStringFromBlock = (block, options) => {
127
127
  if (!key.includes('.')) {
128
128
  continue;
129
129
  }
130
+ let code = ((_b = (_a = block.code) === null || _a === void 0 ? void 0 : _a.bindings) === null || _b === void 0 ? void 0 : _b[key]) || block.bindings[key];
131
+ const verifyCode = verifyIsValid(code);
132
+ if (!verifyCode.valid) {
133
+ if (options.escapeInvalidCode) {
134
+ code = '`' + code + ' [INVALID CODE]`';
135
+ }
136
+ else {
137
+ console.warn(`Dropping binding "${key}" due to invalid code: ${code}`);
138
+ continue;
139
+ }
140
+ }
130
141
  if (key.includes('style')) {
131
142
  const styleProperty = key.split('.')[1];
132
- styleBindings[styleProperty] = convertExportDefaultToReturn(((_b = (_a = block.code) === null || _a === void 0 ? void 0 : _a.bindings) === null || _b === void 0 ? void 0 : _b[key]) || block.bindings[key]);
143
+ styleBindings[styleProperty] = convertExportDefaultToReturn(code);
133
144
  /**
134
145
  * responsiveStyles that are bound need to be merged into media queries.
135
146
  * Example:
@@ -152,7 +163,7 @@ const getStyleStringFromBlock = (block, options) => {
152
163
  const objKey = `"${mediaKey}"`;
153
164
  responsiveStyles[objKey] = {
154
165
  ...responsiveStyles[objKey],
155
- [prop]: block.bindings[key],
166
+ [prop]: code,
156
167
  };
157
168
  }
158
169
  }
@@ -672,8 +683,19 @@ const builderElementToMitosisNode = (block, options, _internalOptions = {}) => {
672
683
  }
673
684
  const useKey = key.replace(/^(component\.)?options\./, '');
674
685
  if (!useKey.includes('.')) {
686
+ let code = blockBindings[key].code || blockBindings[key];
687
+ const verifyCode = verifyIsValid(code);
688
+ if (!verifyCode.valid) {
689
+ if (options.escapeInvalidCode) {
690
+ code = '`' + code + ' [INVALID CODE]`';
691
+ }
692
+ else {
693
+ console.warn(`Dropping binding "${key}" due to invalid code: ${code}`);
694
+ continue;
695
+ }
696
+ }
675
697
  bindings[useKey] = (0, bindings_1.createSingleBinding)({
676
- code: blockBindings[key].code || blockBindings[key],
698
+ code,
677
699
  });
678
700
  }
679
701
  else if (useKey.includes('style') && useKey.includes('.')) {
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.7.6",
25
+ "version": "0.8.0",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {