@builder.io/mitosis 0.2.0 → 0.2.2
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.
|
@@ -145,23 +145,23 @@ var processCodeBlockInTemplate = function (code) {
|
|
|
145
145
|
// contains helper calls as Angular doesn't support JS expressions in templates
|
|
146
146
|
if (code.startsWith('{')) {
|
|
147
147
|
// Objects cannot be spread out directly in Angular so we need to use `useObjectWrapper`
|
|
148
|
-
return "
|
|
148
|
+
return "useObjectWrapper(".concat(handleObjectBindings(code), ")");
|
|
149
149
|
}
|
|
150
150
|
else if (code.startsWith('Object.values')) {
|
|
151
151
|
var stripped = code.replace('Object.values', '');
|
|
152
|
-
return "
|
|
152
|
+
return "useObjectDotValues".concat(stripped);
|
|
153
153
|
}
|
|
154
154
|
else if (code.includes('JSON.stringify')) {
|
|
155
155
|
var obj = code.match(/JSON.stringify\([^)]*\)/g);
|
|
156
|
-
return "
|
|
156
|
+
return "useJsonStringify(".concat(obj, ")");
|
|
157
157
|
}
|
|
158
158
|
else if (code.includes(' as ')) {
|
|
159
159
|
var asIndex = code.indexOf('as');
|
|
160
160
|
var asCode = code.slice(0, asIndex - 1);
|
|
161
|
-
return "
|
|
161
|
+
return "$any".concat(asCode, ")");
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
|
-
return "
|
|
164
|
+
return "".concat(code);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
167
|
var processEventBinding = function (key, code, nodeName, customArg) {
|
|
@@ -212,7 +212,7 @@ var stringifyBinding = function (node, options, blockOptions) {
|
|
|
212
212
|
return " [attr.".concat(keyToUse, "]=\"").concat(code, "\" ");
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
|
-
return "[".concat(keyToUse, "]
|
|
215
|
+
return "[".concat(keyToUse, "]=\"").concat(processCodeBlockInTemplate(code), "\"");
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
};
|
|
@@ -229,7 +229,7 @@ var blockToSvelte = function (_a) {
|
|
|
229
229
|
var isComponent = Boolean(tagName[0] && (0, is_upper_case_1.isUpperCase)(tagName[0]));
|
|
230
230
|
if ((((_c = json.bindings.style) === null || _c === void 0 ? void 0 : _c.code) || json.properties.style) && !isComponent) {
|
|
231
231
|
var useValue = ((_d = json.bindings.style) === null || _d === void 0 ? void 0 : _d.code) || json.properties.style;
|
|
232
|
-
str += "
|
|
232
|
+
str += "style={stringifyStyles(".concat(useValue, ")}");
|
|
233
233
|
delete json.bindings.style;
|
|
234
234
|
delete json.properties.style;
|
|
235
235
|
}
|
|
@@ -269,8 +269,8 @@ var componentToSvelte = function (userProvidedOptions) {
|
|
|
269
269
|
if (usesWritable) {
|
|
270
270
|
svelteStoreImports.push('writable');
|
|
271
271
|
}
|
|
272
|
-
str += (0, dedent_1.dedent)(
|
|
273
|
-
// https://
|
|
272
|
+
str += (0, dedent_1.dedent)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n <script ", ">\n ", "\n ", "\n\n ", "\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "], ["\n <script ", ">\n ", "\n ", "\n\n ", "\n\n ", "\n ", "\n "
|
|
273
|
+
// https://github.com/sveltejs/svelte/issues/7311
|
|
274
274
|
, "\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n ", "\n\n ", "\n\n ", "\n\n "
|
|
275
275
|
// make sure this is after all other state/code is initialized
|
|
276
276
|
, "\n\n ", "\n </script>\n\n ", "\n\n ", "\n "])), tsLangAttribute, !svelteImports.length ? '' : "import { ".concat(svelteImports.sort().join(', '), " } from 'svelte'"), !svelteStoreImports.length
|
|
@@ -299,10 +299,9 @@ var componentToSvelte = function (userProvidedOptions) {
|
|
|
299
299
|
return propDeclaration;
|
|
300
300
|
})
|
|
301
301
|
.join('\n'),
|
|
302
|
-
// https://
|
|
302
|
+
// https://github.com/sveltejs/svelte/issues/7311
|
|
303
303
|
(0, helpers_1.hasStyle)(json)
|
|
304
|
-
? "\n
|
|
305
|
-
: '', getContextCode(json), functionsString.length < 4 ? '' : functionsString, getterString.length < 4 ? '' : getterString, refs.map(function (ref) { return "let ".concat(ref); }).join('\n'), options.stateType === 'proxies'
|
|
304
|
+
? (0, dedent_1.dedent)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n \tfunction stringifyStyles(stylesObj) {\n let styles = '';\n for (let key in stylesObj) {\n const dashedKey = key.replace(/[A-Z]/g, function(match) {\n return '-' + match.toLowerCase();\n });\n styles += dashedKey + \":\" + stylesObj[key] + \";\";\n }\n return styles;\n }\n "], ["\n \tfunction stringifyStyles(stylesObj) {\n let styles = '';\n for (let key in stylesObj) {\n const dashedKey = key.replace(/[A-Z]/g, function(match) {\n return '-' + match.toLowerCase();\n });\n styles += dashedKey + \":\" + stylesObj[key] + \";\";\n }\n return styles;\n }\n "]))) : '', getContextCode(json), functionsString.length < 4 ? '' : functionsString, getterString.length < 4 ? '' : getterString, refs.map(function (ref) { return "let ".concat(ref); }).join('\n'), options.stateType === 'proxies'
|
|
306
305
|
? dataString.length < 4
|
|
307
306
|
? ''
|
|
308
307
|
: "let state = onChange(".concat(dataString, ", () => state = state)")
|
|
@@ -374,4 +373,4 @@ var componentToSvelte = function (userProvidedOptions) {
|
|
|
374
373
|
};
|
|
375
374
|
};
|
|
376
375
|
exports.componentToSvelte = componentToSvelte;
|
|
377
|
-
var templateObject_1, templateObject_2;
|
|
376
|
+
var templateObject_1, templateObject_2, templateObject_3;
|