@builder.io/mitosis
Advanced tools
Comparing version
@@ -16,2 +16,8 @@ import { MitosisComponent, MitosisState } from '../../types/mitosis-component'; | ||
includeMeta?: boolean; | ||
/** | ||
* When `true`, invalid bindings will be escaped as strings with special comments. | ||
* This can then be used to have LLMs such as Claude attempt to repair the broken code. | ||
* Defaults to `false`. | ||
*/ | ||
escapeInvalidCode?: boolean; | ||
}; | ||
@@ -18,0 +24,0 @@ export declare const builderElementToMitosisNode: (block: BuilderElement, options: BuilderToMitosisOptions, _internalOptions?: InternalOptions) => MitosisNode; |
@@ -130,5 +130,16 @@ "use strict"; | ||
} | ||
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]; | ||
const verifyCode = verifyIsValid(code); | ||
if (!verifyCode.valid) { | ||
if (options.escapeInvalidCode) { | ||
code = '`' + code + ' [INVALID CODE]`'; | ||
} | ||
else { | ||
console.warn(`Dropping binding "${key}" due to invalid code: ${code}`); | ||
continue; | ||
} | ||
} | ||
if (key.includes('style')) { | ||
const styleProperty = key.split('.')[1]; | ||
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]); | ||
styleBindings[styleProperty] = convertExportDefaultToReturn(code); | ||
/** | ||
@@ -156,3 +167,3 @@ * responsiveStyles that are bound need to be merged into media queries. | ||
...responsiveStyles[objKey], | ||
[prop]: block.bindings[key], | ||
[prop]: code, | ||
}; | ||
@@ -677,4 +688,15 @@ } | ||
if (!useKey.includes('.')) { | ||
let code = blockBindings[key].code || blockBindings[key]; | ||
const verifyCode = verifyIsValid(code); | ||
if (!verifyCode.valid) { | ||
if (options.escapeInvalidCode) { | ||
code = '`' + code + ' [INVALID CODE]`'; | ||
} | ||
else { | ||
console.warn(`Dropping binding "${key}" due to invalid code: ${code}`); | ||
continue; | ||
} | ||
} | ||
bindings[useKey] = (0, bindings_1.createSingleBinding)({ | ||
code: blockBindings[key].code || blockBindings[key], | ||
code, | ||
}); | ||
@@ -681,0 +703,0 @@ } |
@@ -25,3 +25,3 @@ { | ||
}, | ||
"version": "0.7.6", | ||
"version": "0.8.0", | ||
"homepage": "https://github.com/BuilderIO/mitosis", | ||
@@ -28,0 +28,0 @@ "main": "./dist/src/index.js", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1140814
0.1%27156
0.1%