@builder.io/mitosis 0.9.4 → 0.9.5
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.
|
@@ -7,9 +7,6 @@ const strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-prop
|
|
|
7
7
|
const convertConsoleLogToPrint = (code) => {
|
|
8
8
|
if (!code)
|
|
9
9
|
return code;
|
|
10
|
-
if (code.includes('console.log')) {
|
|
11
|
-
console.log('Converting console.log to print');
|
|
12
|
-
}
|
|
13
10
|
// Match console.log statements with various argument patterns
|
|
14
11
|
return code.replace(/console\.log\s*\(\s*(.*?)\s*\)/g, (match, args) => {
|
|
15
12
|
// Handle empty console.log()
|
|
@@ -26,9 +23,47 @@ exports.convertConsoleLogToPrint = convertConsoleLogToPrint;
|
|
|
26
23
|
const ensureSwiftStringFormat = (code) => {
|
|
27
24
|
if (!code)
|
|
28
25
|
return code;
|
|
29
|
-
//
|
|
30
|
-
// This
|
|
31
|
-
|
|
26
|
+
// We need a more reliable approach to handle nested quotes
|
|
27
|
+
// This uses a state machine approach to track whether we're inside double quotes
|
|
28
|
+
let result = '';
|
|
29
|
+
let insideDoubleQuotes = false;
|
|
30
|
+
for (let i = 0; i < code.length; i++) {
|
|
31
|
+
const char = code[i];
|
|
32
|
+
const prevChar = i > 0 ? code[i - 1] : '';
|
|
33
|
+
// Handle quote state tracking
|
|
34
|
+
if (char === '"' && prevChar !== '\\') {
|
|
35
|
+
insideDoubleQuotes = !insideDoubleQuotes;
|
|
36
|
+
result += char;
|
|
37
|
+
}
|
|
38
|
+
// Only replace single quotes when not inside double quotes
|
|
39
|
+
else if (char === "'" && prevChar !== '\\' && !insideDoubleQuotes) {
|
|
40
|
+
// Start of a single-quoted string
|
|
41
|
+
result += '"';
|
|
42
|
+
// Find the end of the single-quoted string, accounting for escaped quotes
|
|
43
|
+
let j = i + 1;
|
|
44
|
+
while (j < code.length) {
|
|
45
|
+
if (code[j] === "'" && code[j - 1] !== '\\') {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
j++;
|
|
49
|
+
}
|
|
50
|
+
// Add the string content
|
|
51
|
+
result += code.substring(i + 1, j);
|
|
52
|
+
// Add closing double quote if we found the end
|
|
53
|
+
if (j < code.length) {
|
|
54
|
+
result += '"';
|
|
55
|
+
i = j; // Skip to the end of the single-quoted string
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// If no closing quote was found, just add the single quote as is
|
|
59
|
+
result = result.substring(0, result.length - 1) + "'";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
result += char;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
32
67
|
};
|
|
33
68
|
exports.ensureSwiftStringFormat = ensureSwiftStringFormat;
|
|
34
69
|
const stripStateAndProps = ({ json, options, }) => {
|