@promakeai/inspector-hook 1.2.6 → 1.2.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsxUpdater.d.ts","sourceRoot":"","sources":["../../src/utils/jsxUpdater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"jsxUpdater.d.ts","sourceRoot":"","sources":["../../src/utils/jsxUpdater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC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mB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACnC,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AA4CD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CA2MpB"}
|
package/dist/utils/jsxUpdater.js
CHANGED
|
@@ -153,6 +153,8 @@ function validateTagSyntax(tagContent) {
|
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
155
|
* Check if a JSX element has a proper closing tag and valid content (basic check)
|
|
156
|
+
* This is a simplified validation - we check for closing tag existence and balanced braces,
|
|
157
|
+
* but skip the complex nesting validation which can fail on valid JSX with components.
|
|
156
158
|
*/
|
|
157
159
|
function hasProperClosingTag(sourceCode, tagStart, tagEnd, tagName) {
|
|
158
160
|
// For self-closing tags, no closing tag needed
|
|
@@ -162,20 +164,16 @@ function hasProperClosingTag(sourceCode, tagStart, tagEnd, tagName) {
|
|
|
162
164
|
}
|
|
163
165
|
// Look for closing tag after the opening tag
|
|
164
166
|
const afterOpening = sourceCode.slice(tagEnd);
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
// Check the content between opening and closing tags for unmatched braces
|
|
172
|
-
const contentBetween = afterOpening.slice(0, closingMatch.index);
|
|
173
|
-
let braceDepth = 0;
|
|
167
|
+
// For the target tag, we need to find the MATCHING closing tag
|
|
168
|
+
// by tracking the depth of same-named tags
|
|
169
|
+
let depth = 1;
|
|
170
|
+
let i = 0;
|
|
174
171
|
let inString = false;
|
|
175
172
|
let stringChar = "";
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
173
|
+
let inJSXExpression = 0;
|
|
174
|
+
while (i < afterOpening.length && depth > 0) {
|
|
175
|
+
const char = afterOpening[i];
|
|
176
|
+
const prevChar = i > 0 ? afterOpening[i - 1] : "";
|
|
179
177
|
// Handle strings
|
|
180
178
|
if ((char === '"' || char === "'" || char === "`") && prevChar !== "\\") {
|
|
181
179
|
if (!inString) {
|
|
@@ -187,66 +185,40 @@ function hasProperClosingTag(sourceCode, tagStart, tagEnd, tagName) {
|
|
|
187
185
|
stringChar = "";
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
|
-
//
|
|
188
|
+
// Track JSX expression depth (to ignore > inside expressions like {x > 0})
|
|
191
189
|
if (!inString) {
|
|
192
190
|
if (char === "{") {
|
|
193
|
-
|
|
191
|
+
inJSXExpression++;
|
|
194
192
|
}
|
|
195
193
|
else if (char === "}") {
|
|
196
|
-
|
|
194
|
+
inJSXExpression--;
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const remainingCode = afterOpening.slice(i);
|
|
210
|
-
const nextTag = remainingCode.match(/^<\/?([A-Za-z_$][A-Za-z0-9_$]*)/);
|
|
211
|
-
if (!nextTag) {
|
|
212
|
-
// No more tags, move forward
|
|
213
|
-
i++;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
const isClosing = remainingCode.startsWith("</");
|
|
217
|
-
const foundTagName = nextTag[1];
|
|
218
|
-
if (isClosing) {
|
|
219
|
-
// Closing tag - should match top of stack
|
|
220
|
-
if (tagStack.length === 0 ||
|
|
221
|
-
tagStack[tagStack.length - 1] !== foundTagName) {
|
|
222
|
-
return false; // Mismatched closing tag
|
|
223
|
-
}
|
|
224
|
-
tagStack.pop();
|
|
225
|
-
// If this was our target tag's closing, we're done
|
|
226
|
-
if (tagStack.length === 0) {
|
|
227
|
-
break;
|
|
197
|
+
// Only look for tags outside of strings and JSX expressions
|
|
198
|
+
if (!inString && inJSXExpression === 0 && char === "<") {
|
|
199
|
+
const remainingCode = afterOpening.slice(i);
|
|
200
|
+
// Check for closing tag of our target element
|
|
201
|
+
const closingPattern = new RegExp(`^</${tagName}(?:\\s|>)`);
|
|
202
|
+
if (closingPattern.test(remainingCode)) {
|
|
203
|
+
depth--;
|
|
204
|
+
if (depth === 0) {
|
|
205
|
+
return true; // Found matching closing tag
|
|
206
|
+
}
|
|
228
207
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
208
|
+
// Check for opening tag of same element type (increases depth)
|
|
209
|
+
const openingPattern = new RegExp(`^<${tagName}(?:\\s|>|/)`);
|
|
210
|
+
if (openingPattern.test(remainingCode)) {
|
|
211
|
+
// Check if it's self-closing
|
|
212
|
+
const tagContent = remainingCode.match(/^<[^>]*>/);
|
|
213
|
+
if (tagContent && !tagContent[0].endsWith("/>")) {
|
|
214
|
+
depth++;
|
|
215
|
+
}
|
|
236
216
|
}
|
|
237
|
-
// If self-closing (/>), don't add to stack
|
|
238
217
|
}
|
|
239
|
-
|
|
240
|
-
const tagEnd = remainingCode.indexOf(">");
|
|
241
|
-
if (tagEnd === -1)
|
|
242
|
-
break;
|
|
243
|
-
i += tagEnd + 1;
|
|
244
|
-
}
|
|
245
|
-
// Stack should be empty if all tags matched properly
|
|
246
|
-
if (tagStack.length > 0) {
|
|
247
|
-
return false;
|
|
218
|
+
i++;
|
|
248
219
|
}
|
|
249
|
-
|
|
220
|
+
// If we found the matching closing tag, depth would be 0 and we'd have returned true
|
|
221
|
+
return false;
|
|
250
222
|
}
|
|
251
223
|
/**
|
|
252
224
|
* Update or add style attribute in JSX tag
|