@promakeai/inspector-hook 1.2.0 → 1.2.1

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;AA4YD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAkFvB;AAoGD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,qBAAqB,CAqDvB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,E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BAAmB;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"}
@@ -347,14 +347,9 @@ export function updateJSXSource(options) {
347
347
  message: `Could not find JSX element <${tagName}> at line ${lineNumber}, column ${columnNumber}`,
348
348
  };
349
349
  }
350
- // Verify tag name matches
351
- if (tagInfo.foundTagName.toLowerCase() !== tagName.toLowerCase()) {
352
- return {
353
- success: false,
354
- code: sourceCode,
355
- message: `Tag name mismatch: expected <${tagName}>, found <${tagInfo.foundTagName}>`,
356
- };
357
- }
350
+ // Check for tag name mismatch (warning only - continue anyway)
351
+ // This handles cases like Link component rendering as <a> in DOM
352
+ const tagNameMismatch = tagInfo.foundTagName.toLowerCase() !== tagName.toLowerCase();
358
353
  // Validate that the element has proper closing tag
359
354
  if (!hasProperClosingTag(sourceCode, tagInfo.start, tagInfo.end, tagInfo.foundTagName)) {
360
355
  return {
@@ -376,10 +371,14 @@ export function updateJSXSource(options) {
376
371
  const updatedCode = sourceCode.slice(0, tagInfo.start) +
377
372
  updatedTagContent +
378
373
  sourceCode.slice(tagInfo.end);
374
+ // Include warning in message if tag names didn't match
375
+ const message = tagNameMismatch
376
+ ? `JSX source updated successfully (note: expected <${tagName}>, found <${tagInfo.foundTagName}>)`
377
+ : "JSX source updated successfully";
379
378
  return {
380
379
  success: true,
381
380
  code: updatedCode,
382
- message: "JSX source updated successfully",
381
+ message,
383
382
  };
384
383
  }
385
384
  catch (error) {
@@ -609,15 +608,17 @@ export function updateTextContent(options) {
609
608
  message: `Could not find opening tag for <${tagName}>`,
610
609
  };
611
610
  }
611
+ // Use the found tag name for closing tag search (handles Link -> a mapping etc.)
612
+ const actualTagName = tagInfo.foundTagName;
612
613
  // Extract content between opening and closing tag
613
- const closingTagPattern = new RegExp(`</${tagName}\\s*>`);
614
+ const closingTagPattern = new RegExp(`</${actualTagName}\\s*>`);
614
615
  const afterOpening = sourceCode.slice(tagInfo.end);
615
616
  const closingMatch = closingTagPattern.exec(afterOpening);
616
617
  if (!closingMatch) {
617
618
  return {
618
619
  success: false,
619
620
  code: sourceCode,
620
- message: `Could not find closing tag for <${tagName}>`,
621
+ message: `Could not find closing tag for <${actualTagName}>`,
621
622
  };
622
623
  }
623
624
  const contentStart = tagInfo.end;
@@ -628,7 +629,7 @@ export function updateTextContent(options) {
628
629
  return {
629
630
  success: false,
630
631
  code: sourceCode,
631
- message: `Element <${tagName}> contains JS expressions or nested elements. Text update skipped.`,
632
+ message: `Element <${actualTagName}> contains JS expressions or nested elements. Text update skipped.`,
632
633
  };
633
634
  }
634
635
  // Replace the content
@@ -638,7 +639,7 @@ export function updateTextContent(options) {
638
639
  return {
639
640
  success: true,
640
641
  code: updatedCode,
641
- message: `Text content of <${tagName}> updated successfully`,
642
+ message: `Text content of <${actualTagName}> updated successfully`,
642
643
  };
643
644
  }
644
645
  catch (error) {
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "@promakeai/inspector-hook",
3
- "version": "1.2.0",
4
- "description": "React hook for controlling inspector in parent applications",
5
- "author": "Promake",
6
- "type": "module",
7
- "main": "./dist/index.js",
8
- "module": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js"
14
- },
15
- "./package.json": "./package.json"
16
- },
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "build": "tsc --build",
22
- "dev": "tsc --watch",
23
- "clean": "rm -rf dist",
24
- "lint": "tsc --build --force --dry",
25
- "test": "vitest run",
26
- "test:watch": "vitest",
27
- "test:coverage": "vitest run --coverage",
28
- "prepublishOnly": "bun run build",
29
- "release": "bun run build && npm publish --access public"
30
- },
31
- "keywords": [
32
- "react",
33
- "hook",
34
- "inspector",
35
- "iframe"
36
- ],
37
- "peerDependencies": {
38
- "react": ">=18.0.0",
39
- "react-dom": ">=18.0.0",
40
- "vite": ">=5.0.0"
41
- },
42
- "peerDependenciesMeta": {
43
- "vite": {
44
- "optional": true
45
- }
46
- },
47
- "devDependencies": {
48
- "@promakeai/inspector-types": "1.0.2",
49
- "vitest": "^1.0.0"
50
- },
51
- "publishConfig": {
52
- "access": "public"
53
- }
54
- }
1
+ {
2
+ "name": "@promakeai/inspector-hook",
3
+ "version": "1.2.1",
4
+ "description": "React hook for controlling inspector in parent applications",
5
+ "author": "Promake",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc --build",
22
+ "dev": "tsc --watch",
23
+ "clean": "rm -rf dist",
24
+ "lint": "tsc --build --force --dry",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "test:coverage": "vitest run --coverage",
28
+ "prepublishOnly": "bun run build",
29
+ "release": "bun run build && npm publish --access public"
30
+ },
31
+ "keywords": [
32
+ "react",
33
+ "hook",
34
+ "inspector",
35
+ "iframe"
36
+ ],
37
+ "peerDependencies": {
38
+ "react": ">=18.0.0",
39
+ "react-dom": ">=18.0.0",
40
+ "vite": ">=5.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "vite": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "devDependencies": {
48
+ "@promakeai/inspector-types": "1.0.2",
49
+ "vitest": "^1.0.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }