@treelocator/runtime 0.1.8 → 0.2.0
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.
- package/.turbo/turbo-build.log +8 -6
- package/.turbo/turbo-dev.log +32 -0
- package/.turbo/turbo-test.log +54 -10
- package/dist/adapters/createTreeNode.js +32 -4
- package/dist/adapters/nextjs/parseNextjsDataAttributes.d.ts +31 -0
- package/dist/adapters/nextjs/parseNextjsDataAttributes.js +106 -0
- package/dist/adapters/phoenix/__tests__/parsePhoenixComments.test.d.ts +4 -0
- package/dist/adapters/phoenix/__tests__/parsePhoenixComments.test.js +218 -0
- package/dist/adapters/phoenix/detectPhoenix.d.ts +11 -0
- package/dist/adapters/phoenix/detectPhoenix.js +38 -0
- package/dist/adapters/phoenix/index.d.ts +10 -0
- package/dist/adapters/phoenix/index.js +9 -0
- package/dist/adapters/phoenix/parsePhoenixComments.d.ts +35 -0
- package/dist/adapters/phoenix/parsePhoenixComments.js +131 -0
- package/dist/adapters/phoenix/types.d.ts +16 -0
- package/dist/adapters/phoenix/types.js +1 -0
- package/dist/adapters/react/getFiberLabel.js +2 -1
- package/dist/components/MaybeOutline.js +65 -3
- package/dist/functions/formatAncestryChain.d.ts +3 -0
- package/dist/functions/formatAncestryChain.js +104 -15
- package/dist/functions/formatAncestryChain.test.js +26 -20
- package/dist/functions/normalizeFilePath.d.ts +14 -0
- package/dist/functions/normalizeFilePath.js +40 -0
- package/dist/output.css +87 -15
- package/dist/types/ServerComponentInfo.d.ts +14 -0
- package/dist/types/ServerComponentInfo.js +1 -0
- package/package.json +4 -3
- package/src/adapters/createTreeNode.ts +35 -3
- package/src/adapters/nextjs/parseNextjsDataAttributes.ts +112 -0
- package/src/adapters/phoenix/__tests__/parsePhoenixComments.test.ts +264 -0
- package/src/adapters/phoenix/detectPhoenix.ts +44 -0
- package/src/adapters/phoenix/index.ts +11 -0
- package/src/adapters/phoenix/parsePhoenixComments.ts +140 -0
- package/src/adapters/phoenix/types.ts +16 -0
- package/src/adapters/react/getFiberLabel.ts +2 -1
- package/src/components/MaybeOutline.tsx +63 -4
- package/src/functions/formatAncestryChain.test.ts +26 -20
- package/src/functions/formatAncestryChain.ts +121 -15
- package/src/functions/normalizeFilePath.ts +41 -0
- package/src/types/ServerComponentInfo.ts +14 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert absolute file paths to relative paths for display.
|
|
3
|
+
*
|
|
4
|
+
* This ensures consistent path display across different sources:
|
|
5
|
+
* - React _debugSource may provide absolute paths
|
|
6
|
+
* - Next.js data-locatorjs attributes may have absolute paths
|
|
7
|
+
* - Phoenix comments use relative paths
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* - "/Users/name/project/src/App.tsx" → "src/App.tsx"
|
|
11
|
+
* - "/workspace/apps/next-16/app/page.tsx" → "app/page.tsx"
|
|
12
|
+
* - "src/components/Button.tsx" → "src/components/Button.tsx" (unchanged)
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeFilePath(filePath: string): string {
|
|
15
|
+
// If it's already relative (doesn't start with /), return as-is
|
|
16
|
+
if (!filePath.startsWith("/")) {
|
|
17
|
+
return filePath;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Find common project indicators to trim the path
|
|
21
|
+
const indicators = ["/app/", "/src/", "/pages/", "/components/", "/lib/"];
|
|
22
|
+
|
|
23
|
+
for (const indicator of indicators) {
|
|
24
|
+
const index = filePath.indexOf(indicator);
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
// Return from the indicator onwards (remove leading slash)
|
|
27
|
+
return filePath.substring(index + 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// If no indicator found, try to get just the last few path segments
|
|
32
|
+
const parts = filePath.split("/");
|
|
33
|
+
|
|
34
|
+
// Return last 3-4 segments if available (e.g., "apps/next-16/app/page.tsx")
|
|
35
|
+
if (parts.length > 3) {
|
|
36
|
+
return parts.slice(-4).join("/");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Last resort: return as-is
|
|
40
|
+
return filePath;
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a server-side component in the ancestry chain.
|
|
3
|
+
* Used for Phoenix LiveView, Rails ViewComponents, Next.js RSC, etc.
|
|
4
|
+
*/
|
|
5
|
+
export interface ServerComponentInfo {
|
|
6
|
+
/** Component name (e.g., "AppWeb.CoreComponents.button") or "@caller" for call site */
|
|
7
|
+
name: string;
|
|
8
|
+
/** File path (e.g., "lib/app_web/core_components.ex") */
|
|
9
|
+
filePath: string;
|
|
10
|
+
/** Line number in the source file */
|
|
11
|
+
line: number;
|
|
12
|
+
/** Type of server component annotation */
|
|
13
|
+
type: "component" | "caller";
|
|
14
|
+
}
|