react-code-locator 0.1.9 → 0.1.12
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/README.md +49 -44
- package/dist/babel.cjs +427 -40
- package/dist/babel.cjs.map +1 -1
- package/dist/babel.d.cts +12 -1
- package/dist/babel.d.ts +12 -1
- package/dist/babel.js +424 -29
- package/dist/babel.js.map +1 -1
- package/dist/babelInjectComponentSource.cjs +403 -38
- package/dist/babelInjectComponentSource.cjs.map +1 -1
- package/dist/babelInjectComponentSource.d.cts +3 -4
- package/dist/babelInjectComponentSource.d.ts +3 -4
- package/dist/babelInjectComponentSource.js +403 -28
- package/dist/babelInjectComponentSource.js.map +1 -1
- package/dist/client-sm5wi0uT.d.cts +15 -0
- package/dist/client-sm5wi0uT.d.ts +15 -0
- package/dist/client.cjs +160 -28
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -14
- package/dist/client.d.ts +1 -14
- package/dist/client.js +160 -28
- package/dist/client.js.map +1 -1
- package/dist/esbuild.cjs +615 -0
- package/dist/esbuild.cjs.map +1 -0
- package/dist/esbuild.d.cts +25 -0
- package/dist/esbuild.d.ts +25 -0
- package/dist/esbuild.js +588 -0
- package/dist/esbuild.js.map +1 -0
- package/dist/index.cjs +827 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +814 -29
- package/dist/index.js.map +1 -1
- package/dist/sourceAdapter-DLWo_ABo.d.cts +15 -0
- package/dist/sourceAdapter-DLWo_ABo.d.ts +15 -0
- package/dist/swc.cjs +588 -0
- package/dist/swc.cjs.map +1 -0
- package/dist/swc.d.cts +29 -0
- package/dist/swc.d.ts +29 -0
- package/dist/swc.js +559 -0
- package/dist/swc.js.map +1 -0
- package/dist/vite.cjs +525 -84
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +20 -6
- package/dist/vite.d.ts +20 -6
- package/dist/vite.js +520 -72
- package/dist/vite.js.map +1 -1
- package/dist/webpackRuntimeEntry.cjs +160 -28
- package/dist/webpackRuntimeEntry.cjs.map +1 -1
- package/dist/webpackRuntimeEntry.js +160 -28
- package/dist/webpackRuntimeEntry.js.map +1 -1
- package/package.json +12 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts","../src/runtime.ts"],"sourcesContent":["export const SOURCE_PROP = \"__componentSourceLoc\";\n\n","import { SOURCE_PROP } from \"./constants\";\n\nexport type TriggerKey = \"alt\" | \"meta\" | \"ctrl\" | \"shift\" | \"none\";\n\ntype ReactFiber = {\n return?: ReactFiber | null;\n type?: unknown;\n elementType?: unknown;\n pendingProps?: Record<string, unknown> | null;\n memoizedProps?: Record<string, unknown> | null;\n _debugOwner?: ReactFiber | null;\n _debugSource?: {\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n } | null;\n};\n\nexport type LocatorResult = {\n source: string;\n mode: \"jsx\" | \"component\";\n};\n\nexport type LocatorOptions = {\n triggerKey?: TriggerKey;\n onLocate?: (result: LocatorResult) => void;\n onError?: (error: unknown) => void;\n};\n\ntype StatusOverlay = {\n setStatus: (message: string, tone?: \"idle\" | \"success\" | \"error\") => void;\n setCopyValue: (value: string | null) => void;\n remove: () => void;\n};\n\nfunction isTriggerPressed(event: MouseEvent, triggerKey: TriggerKey) {\n if (triggerKey === \"none\") {\n return true;\n }\n\n if (triggerKey === \"alt\") {\n return event.altKey;\n }\n\n if (triggerKey === \"meta\") {\n return event.metaKey;\n }\n\n if (triggerKey === \"ctrl\") {\n return event.ctrlKey;\n }\n\n return event.shiftKey;\n}\n\nfunction getReactFiberKey(element: Element) {\n return Object.keys(element).find((key) => key.startsWith(\"__reactFiber$\") || key.startsWith(\"__reactInternalInstance$\"));\n}\n\nfunction getClosestReactFiber(target: Element | null) {\n let current = target;\n\n while (current) {\n const fiberKey = getReactFiberKey(current);\n if (fiberKey) {\n return (current as unknown as Record<string, unknown>)[fiberKey] as ReactFiber;\n }\n\n current = current.parentElement;\n }\n\n return null;\n}\n\nfunction getSourceFromType(type: unknown) {\n if (!type) {\n return null;\n }\n\n if (typeof type === \"function\") {\n const source = (type as unknown as Record<string, unknown>)[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n }\n\n if (typeof type !== \"object\") {\n return null;\n }\n\n const record = type as {\n type?: Record<string, unknown>;\n render?: Record<string, unknown>;\n [SOURCE_PROP]?: unknown;\n };\n\n const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction getSourceFromProps(props: Record<string, unknown> | null | undefined) {\n const source = props?.[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction resolveJsxSourceFromFiber(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source = getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction resolveComponentSourceFromFiber(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction getDirectDebugSource(fiber: ReactFiber | null) {\n const debugSource = fiber?._debugSource;\n if (debugSource?.fileName && typeof debugSource.lineNumber === \"number\") {\n return `${debugSource.fileName.replace(/\\\\/g, \"/\")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;\n }\n\n return null;\n}\n\nfunction resolveOwnerJsxSource(fiber: ReactFiber | null) {\n let current = fiber?._debugOwner ?? null;\n\n while (current) {\n const source =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n if (source) {\n return source;\n }\n\n current = current._debugOwner ?? null;\n }\n\n return null;\n}\n\nfunction resolveNearestJsxSource(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction createStatusOverlay(triggerKey: TriggerKey): StatusOverlay | null {\n if (typeof document === \"undefined\") {\n return null;\n }\n\n const element = document.createElement(\"div\");\n let currentText = \"\";\n let copyValue: string | null = null;\n let hideTimer: ReturnType<typeof setTimeout> | null = null;\n element.setAttribute(\"data-react-code-locator\", \"true\");\n Object.assign(element.style, {\n position: \"fixed\",\n right: \"12px\",\n bottom: \"12px\",\n zIndex: \"2147483647\",\n padding: \"8px 10px\",\n borderRadius: \"8px\",\n background: \"rgba(17, 24, 39, 0.92)\",\n color: \"#fff\",\n fontSize: \"12px\",\n lineHeight: \"1.4\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n boxShadow: \"0 8px 30px rgba(0, 0, 0, 0.25)\",\n pointerEvents: \"auto\",\n cursor: \"pointer\",\n maxWidth: \"min(70vw, 720px)\",\n wordBreak: \"break-all\",\n opacity: \"0\",\n transition: \"opacity 120ms ease\",\n });\n\n const show = (message: string, tone: \"idle\" | \"success\" | \"error\") => {\n currentText = message;\n element.textContent = message;\n element.style.background =\n tone === \"success\"\n ? \"rgba(6, 95, 70, 0.92)\"\n : tone === \"error\"\n ? \"rgba(153, 27, 27, 0.94)\"\n : \"rgba(17, 24, 39, 0.92)\";\n element.style.opacity = \"1\";\n element.style.pointerEvents = \"auto\";\n\n if (hideTimer) {\n clearTimeout(hideTimer);\n }\n\n hideTimer = setTimeout(() => {\n element.style.opacity = \"0\";\n element.style.pointerEvents = \"none\";\n }, 1500);\n };\n\n element.addEventListener(\"click\", async () => {\n if (!copyValue) {\n return;\n }\n\n try {\n await navigator.clipboard.writeText(copyValue);\n show(`[react-code-locator] copied`, \"success\");\n } catch {\n show(`[react-code-locator] copy failed`, \"error\");\n }\n });\n\n show(`[react-code-locator] enabled (${triggerKey}+click)`, \"idle\");\n\n const mount = () => {\n if (!element.isConnected && document.body) {\n document.body.appendChild(element);\n }\n };\n\n if (document.body) {\n mount();\n } else {\n document.addEventListener(\"DOMContentLoaded\", mount, { once: true });\n }\n\n return {\n setStatus(message, tone = \"idle\") {\n show(message, tone);\n },\n setCopyValue(value) {\n copyValue = value;\n },\n remove() {\n if (hideTimer) {\n clearTimeout(hideTimer);\n }\n element.remove();\n },\n };\n}\n\nexport function locateComponentSource(target: EventTarget | null): LocatorResult | null {\n const elementTarget =\n target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n const fiber = getClosestReactFiber(elementTarget);\n if (!fiber) {\n return null;\n }\n\n const jsxSource = resolveOwnerJsxSource(fiber) ?? resolveNearestJsxSource(fiber);\n if (jsxSource) {\n return {\n source: jsxSource,\n mode: \"jsx\",\n };\n }\n\n const componentSource = resolveComponentSourceFromFiber(fiber);\n if (!componentSource) {\n return null;\n }\n\n return {\n source: componentSource,\n mode: \"component\",\n };\n}\n\nexport function enableReactComponentJump(options: LocatorOptions = {}) {\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n const {\n triggerKey = \"shift\",\n onLocate = (result) => {\n console.log(`[react-code-locator] ${result.source}`);\n overlay?.setCopyValue(result.source);\n overlay?.setStatus(`[react-code-locator] ${result.source}`, \"success\");\n },\n onError = (error) => {\n console.error(\"[react-code-locator]\", error);\n const message = error instanceof Error ? error.message : String(error);\n overlay?.setCopyValue(null);\n overlay?.setStatus(`[react-code-locator] ${message}`, \"error\");\n },\n } = options;\n\n console.log(\"[react-code-locator] enabled\", { triggerKey });\n\n const handler = (event: MouseEvent) => {\n console.log(\"[react-code-locator] click\", {\n triggerKey,\n shiftKey: event.shiftKey,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n metaKey: event.metaKey,\n target: event.target,\n });\n\n if (!isTriggerPressed(event, triggerKey)) {\n return;\n }\n\n const result = locateComponentSource(event.target);\n if (!result) {\n onError(new Error(\"No React component source metadata found for clicked element.\"));\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n onLocate(result);\n };\n\n document.addEventListener(\"click\", handler, true);\n\n return () => {\n document.removeEventListener(\"click\", handler, true);\n overlay?.remove();\n };\n}\n"],"mappings":";AAAO,IAAM,cAAc;;;ACmC3B,SAAS,iBAAiB,OAAmB,YAAwB;AACnE,MAAI,eAAe,QAAQ;AACzB,WAAO;AAAA,EACT;AAEA,MAAI,eAAe,OAAO;AACxB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,eAAe,QAAQ;AACzB,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,MAAM;AACf;AAEA,SAAS,iBAAiB,SAAkB;AAC1C,SAAO,OAAO,KAAK,OAAO,EAAE,KAAK,CAAC,QAAQ,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,0BAA0B,CAAC;AACzH;AAEA,SAAS,qBAAqB,QAAwB;AACpD,MAAI,UAAU;AAEd,SAAO,SAAS;AACd,UAAM,WAAW,iBAAiB,OAAO;AACzC,QAAI,UAAU;AACZ,aAAQ,QAA+C,QAAQ;AAAA,IACjE;AAEA,cAAU,QAAQ;AAAA,EACpB;AAEA,SAAO;AACT;AAEA,SAAS,kBAAkB,MAAe;AACxC,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,YAAY;AAC9B,UAAMA,UAAU,KAA4C,WAAW;AACvE,WAAO,OAAOA,YAAW,WAAWA,UAAS;AAAA,EAC/C;AAEA,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AAMf,QAAM,SAAS,OAAO,WAAW,KAAK,OAAO,OAAO,WAAW,KAAK,OAAO,SAAS,WAAW;AAC/F,SAAO,OAAO,WAAW,WAAW,SAAS;AAC/C;AAEA,SAAS,mBAAmB,OAAmD;AAC7E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WAAW,CAAC;AAE1D,QAAM,UAAU,CAAC,UAAsB;AACrC,YAAQ,IAAI,8BAA8B;AAAA,MACxC;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,QAAQ,MAAM;AAAA,MACd,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,QAAQ,MAAM;AAAA,IAChB,CAAC;AAED,QAAI,CAAC,iBAAiB,OAAO,UAAU,GAAG;AACxC;AAAA,IACF;AAEA,UAAM,SAAS,sBAAsB,MAAM,MAAM;AACjD,QAAI,CAAC,QAAQ;AACX,cAAQ,IAAI,MAAM,+DAA+D,CAAC;AAClF;AAAA,IACF;AAEA,UAAM,eAAe;AACrB,UAAM,gBAAgB;AACtB,aAAS,MAAM;AAAA,EACjB;AAEA,WAAS,iBAAiB,SAAS,SAAS,IAAI;AAEhD,SAAO,MAAM;AACX,aAAS,oBAAoB,SAAS,SAAS,IAAI;AACnD,aAAS,OAAO;AAAA,EAClB;AACF;","names":["source"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/sourceMetadata.ts","../src/runtime.ts","../src/sourceAdapter.ts","../src/babelInjectComponentSource.ts","../src/babel.ts","../src/sourceTransform.ts","../src/viteClientInjector.ts","../src/vite.ts","../src/esbuild.ts","../src/swc.ts"],"sourcesContent":["export const SOURCE_PROP = \"__componentSourceLoc\";\nexport const JSX_SOURCE_PROP = \"$componentSourceLoc\";\nexport const JSX_SOURCE_REGISTRY_SYMBOL = \"react-code-locator.jsxSourceRegistry\";\n","export type SourceLocation = {\n line: number;\n column: number;\n};\n\nfunction normalizeSlashes(value: string) {\n return value.replace(/\\\\/g, \"/\");\n}\n\nfunction trimTrailingSlash(value: string) {\n return value.replace(/\\/+$/, \"\");\n}\n\nfunction splitPathSegments(value: string) {\n return normalizeSlashes(value).split(\"/\").filter(Boolean);\n}\n\nfunction computeRelativePath(fromPath: string, toPath: string) {\n const fromSegments = splitPathSegments(fromPath);\n const toSegments = splitPathSegments(toPath);\n\n let sharedIndex = 0;\n while (\n sharedIndex < fromSegments.length &&\n sharedIndex < toSegments.length &&\n fromSegments[sharedIndex] === toSegments[sharedIndex]\n ) {\n sharedIndex += 1;\n }\n\n const upSegments = new Array(Math.max(0, fromSegments.length - sharedIndex)).fill(\"..\");\n const downSegments = toSegments.slice(sharedIndex);\n const relativeSegments = [...upSegments, ...downSegments];\n return relativeSegments.length > 0 ? relativeSegments.join(\"/\") : \".\";\n}\n\nexport function normalizeProjectRoot(projectRoot?: string) {\n if (projectRoot) {\n return trimTrailingSlash(normalizeSlashes(projectRoot));\n }\n\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n return trimTrailingSlash(normalizeSlashes(process.cwd()));\n }\n\n return \"\";\n}\n\nexport function toRelativeSource(\n filename: string | undefined,\n loc: SourceLocation | null | undefined,\n projectRoot?: string,\n) {\n if (!filename || !loc) {\n return null;\n }\n\n const root = normalizeProjectRoot(projectRoot);\n const normalizedFilename = normalizeSlashes(filename);\n const relPath =\n root && normalizedFilename.startsWith(`${root}/`)\n ? normalizedFilename.slice(root.length + 1)\n : root\n ? computeRelativePath(root, normalizedFilename)\n : normalizedFilename;\n return `${relPath}:${loc.line}:${loc.column + 1}`;\n}\n\nexport function getSourceFile(source: string | null) {\n if (!source) {\n return null;\n }\n\n const match = source.match(/^(.*):\\d+:\\d+$/);\n return match?.[1] ?? null;\n}\n\nexport function isProjectLocalFile(filename: string | undefined, projectRoot?: string) {\n if (!filename) {\n return false;\n }\n\n const root = normalizeProjectRoot(projectRoot);\n const normalizedFilename = normalizeSlashes(filename);\n\n if (!root) {\n return (\n !normalizedFilename.startsWith(\"../\") &&\n !normalizedFilename.startsWith(\"/\") &&\n !/^[A-Za-z]:\\//.test(normalizedFilename)\n );\n }\n\n if (normalizedFilename.startsWith(`${root}/`) || normalizedFilename === root) {\n return true;\n }\n\n const relativePath = computeRelativePath(root, normalizedFilename);\n return !relativePath.startsWith(\"../\");\n}\n\nexport function isExternalToProjectRoot(filename: string | undefined, projectRoot?: string) {\n return !isProjectLocalFile(filename, projectRoot);\n}\n\nexport function isProjectLocalSource(source: string, projectRoot?: string) {\n const file = getSourceFile(source);\n return isProjectLocalFile(file ?? undefined, projectRoot);\n}\n","import {\n JSX_SOURCE_PROP,\n JSX_SOURCE_REGISTRY_SYMBOL,\n SOURCE_PROP,\n} from \"./constants\";\nimport { getSourceFile, isProjectLocalSource } from \"./sourceMetadata\";\n\nexport type TriggerKey = \"alt\" | \"meta\" | \"ctrl\" | \"shift\" | \"none\";\nexport type LocatorMode = \"direct\" | \"screen\" | \"implementation\";\n\ntype ReactFiber = {\n return?: ReactFiber | null;\n type?: unknown;\n elementType?: unknown;\n pendingProps?: Record<string, unknown> | null;\n memoizedProps?: Record<string, unknown> | null;\n _debugOwner?: ReactFiber | null;\n _debugSource?: {\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n } | null;\n};\n\nexport type LocatorResult = {\n source: string;\n mode: LocatorMode;\n};\n\nexport type LocatorOptions = {\n triggerKey?: TriggerKey;\n onLocate?: (result: LocatorResult) => void;\n onError?: (error: unknown) => void;\n};\n\ntype StatusOverlay = {\n setStatus: (message: string, tone?: \"idle\" | \"success\" | \"error\") => void;\n setCopyValue: (value: string | null) => void;\n setMode: (mode: LocatorMode) => void;\n remove: () => void;\n};\n\nfunction isTriggerPressed(event: MouseEvent, triggerKey: TriggerKey) {\n if (triggerKey === \"none\") {\n return true;\n }\n\n if (triggerKey === \"alt\") {\n return event.altKey;\n }\n\n if (triggerKey === \"meta\") {\n return event.metaKey;\n }\n\n if (triggerKey === \"ctrl\") {\n return event.ctrlKey;\n }\n\n return event.shiftKey;\n}\n\nfunction getReactFiberKey(element: Element) {\n return Object.keys(element).find((key) => key.startsWith(\"__reactFiber$\") || key.startsWith(\"__reactInternalInstance$\"));\n}\n\nfunction getClosestReactFiber(target: Element | null) {\n let current = target;\n\n while (current) {\n const fiberKey = getReactFiberKey(current);\n if (fiberKey) {\n return (current as unknown as Record<string, unknown>)[fiberKey] as ReactFiber;\n }\n\n current = current.parentElement;\n }\n\n return null;\n}\n\nfunction getSourceFromType(type: unknown) {\n if (!type) {\n return null;\n }\n\n if (typeof type === \"function\") {\n const source = (type as unknown as Record<string, unknown>)[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n }\n\n if (typeof type !== \"object\") {\n return null;\n }\n\n const record = type as {\n type?: Record<string, unknown>;\n render?: Record<string, unknown>;\n [SOURCE_PROP]?: unknown;\n };\n\n const source = record[SOURCE_PROP] ?? record.type?.[SOURCE_PROP] ?? record.render?.[SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction getSourceFromProps(props: Record<string, unknown> | null | undefined) {\n if (props && typeof props === \"object\") {\n const registry = (globalThis as Record<symbol, unknown>)[\n Symbol.for(JSX_SOURCE_REGISTRY_SYMBOL)\n ];\n if (registry instanceof WeakMap) {\n const intrinsicSource = registry.get(props as object);\n if (typeof intrinsicSource === \"string\") {\n return intrinsicSource;\n }\n }\n }\n\n const source = props?.[JSX_SOURCE_PROP];\n return typeof source === \"string\" ? source : null;\n}\n\nfunction resolveComponentSourceFromFiber(fiber: ReactFiber | null) {\n let current = fiber;\n\n while (current) {\n const source = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n if (source) {\n return source;\n }\n\n current = current.return ?? null;\n }\n\n return null;\n}\n\nfunction getDirectDebugSource(fiber: ReactFiber | null) {\n const debugSource = fiber?._debugSource;\n if (debugSource?.fileName && typeof debugSource.lineNumber === \"number\") {\n return `${debugSource.fileName.replace(/\\\\/g, \"/\")}:${debugSource.lineNumber}:${debugSource.columnNumber ?? 1}`;\n }\n\n return null;\n}\n\ntype SourceCandidate = {\n source: string;\n file: string;\n};\n\ntype ResolvedCandidates = {\n direct: string | null;\n screen: string | null;\n implementation: string | null;\n};\n\nfunction resolveSourceCandidates(fiber: ReactFiber | null): ResolvedCandidates {\n let current = fiber;\n const jsxCandidates: SourceCandidate[] = [];\n const componentCandidates: SourceCandidate[] = [];\n\n while (current) {\n const jsxSource =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n if (jsxSource) {\n const file = getSourceFile(jsxSource);\n if (file && !jsxCandidates.some((candidate) => candidate.source === jsxSource)) {\n jsxCandidates.push({ source: jsxSource, file });\n }\n }\n\n const componentSource = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n if (componentSource) {\n const file = getSourceFile(componentSource);\n if (file && !componentCandidates.some((candidate) => candidate.source === componentSource)) {\n componentCandidates.push({ source: componentSource, file });\n }\n }\n\n current = current.return ?? null;\n }\n\n const direct = jsxCandidates[0]?.source ?? null;\n const nearestProjectLocalComponentFile = componentCandidates.find((candidate) => isProjectLocalSource(candidate.source))?.file;\n let screen: string | null = null;\n if (nearestProjectLocalComponentFile) {\n const matchingJsxCandidate = jsxCandidates.find((candidate) => candidate.file === nearestProjectLocalComponentFile);\n if (matchingJsxCandidate) {\n screen = matchingJsxCandidate.source;\n } else {\n const matchingComponentCandidate = componentCandidates.find(\n (candidate) => candidate.file === nearestProjectLocalComponentFile,\n );\n if (matchingComponentCandidate) {\n screen = matchingComponentCandidate.source;\n }\n }\n }\n\n const implementationComponentCandidate =\n componentCandidates.find((candidate) => !isProjectLocalSource(candidate.source))?.source ?? null;\n const implementationJsxCandidate =\n jsxCandidates.find((candidate) => !isProjectLocalSource(candidate.source))?.source ?? null;\n\n const projectLocalJsxCandidate = jsxCandidates.find((candidate) => isProjectLocalSource(candidate.source))?.source ?? null;\n const screenFallback = screen ?? projectLocalJsxCandidate ?? componentCandidates.find((candidate) => isProjectLocalSource(candidate.source))?.source ?? null;\n\n return {\n direct: direct ?? screenFallback,\n screen: screenFallback,\n implementation: implementationComponentCandidate ?? implementationJsxCandidate ?? screenFallback,\n };\n}\n\nfunction getModeDescription(mode: LocatorMode) {\n if (mode === \"direct\") {\n return \"Direct JSX\";\n }\n\n if (mode === \"screen\") {\n return \"Screen source\";\n }\n\n return \"Implementation source\";\n}\n\nfunction createStatusOverlay(triggerKey: TriggerKey): StatusOverlay | null {\n if (typeof document === \"undefined\") {\n return null;\n }\n\n const element = document.createElement(\"div\");\n let copyValue: string | null = null;\n let currentMode: LocatorMode = \"screen\";\n let hideTimer: ReturnType<typeof setTimeout> | null = null;\n element.setAttribute(\"data-react-code-locator\", \"true\");\n Object.assign(element.style, {\n position: \"fixed\",\n right: \"12px\",\n bottom: \"12px\",\n zIndex: \"2147483647\",\n padding: \"8px 10px\",\n borderRadius: \"8px\",\n background: \"rgba(17, 24, 39, 0.92)\",\n color: \"#fff\",\n fontSize: \"12px\",\n lineHeight: \"1.4\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\",\n boxShadow: \"0 8px 30px rgba(0, 0, 0, 0.25)\",\n pointerEvents: \"auto\",\n cursor: \"pointer\",\n maxWidth: \"min(70vw, 720px)\",\n wordBreak: \"break-all\",\n opacity: \"0\",\n transition: \"opacity 120ms ease\",\n });\n\n const show = (message: string, tone: \"idle\" | \"success\" | \"error\") => {\n element.textContent = message;\n element.style.background =\n tone === \"success\"\n ? \"rgba(6, 95, 70, 0.92)\"\n : tone === \"error\"\n ? \"rgba(153, 27, 27, 0.94)\"\n : \"rgba(17, 24, 39, 0.92)\";\n element.style.opacity = \"1\";\n element.style.pointerEvents = \"auto\";\n\n if (hideTimer) {\n clearTimeout(hideTimer);\n }\n\n hideTimer = setTimeout(() => {\n element.style.opacity = \"0\";\n element.style.pointerEvents = \"none\";\n }, 2000);\n };\n\n element.addEventListener(\"click\", async () => {\n if (!copyValue) {\n return;\n }\n\n try {\n await navigator.clipboard.writeText(copyValue);\n show(`[react-code-locator] copied`, \"success\");\n } catch {\n show(`[react-code-locator] copy failed`, \"error\");\n }\n });\n\n show(`[react-code-locator] enabled (${triggerKey}+click, alt+1/2/3 to switch mode)`, \"idle\");\n\n const mount = () => {\n if (!element.isConnected && document.body) {\n document.body.appendChild(element);\n }\n };\n\n if (document.body) {\n mount();\n } else {\n document.addEventListener(\"DOMContentLoaded\", mount, { once: true });\n }\n\n return {\n setStatus(message, tone = \"idle\") {\n show(message, tone);\n },\n setCopyValue(value) {\n copyValue = value;\n },\n setMode(mode) {\n currentMode = mode;\n show(`[react-code-locator] ${getModeDescription(mode)}`, \"idle\");\n },\n remove() {\n if (hideTimer) {\n clearTimeout(hideTimer);\n }\n element.remove();\n },\n };\n}\n\nexport function locateComponentSource(target: EventTarget | null, mode: LocatorMode = \"screen\"): LocatorResult | null {\n const elementTarget =\n target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n const fiber = getClosestReactFiber(elementTarget);\n if (!fiber) {\n return null;\n }\n\n const candidates = resolveSourceCandidates(fiber);\n const source = candidates[mode] ?? candidates.screen ?? candidates.direct ?? candidates.implementation;\n if (source) {\n return {\n source,\n mode,\n };\n }\n\n const componentSource = resolveComponentSourceFromFiber(fiber);\n if (!componentSource) {\n return null;\n }\n\n return {\n source: componentSource,\n mode,\n };\n}\n\nexport function enableReactComponentJump(options: LocatorOptions = {}) {\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n let currentMode: LocatorMode = \"screen\";\n const {\n triggerKey = \"shift\",\n onLocate = (result) => {\n console.log(`[react-code-locator] ${result.source}`);\n overlay?.setCopyValue(result.source);\n overlay?.setStatus(`[react-code-locator] ${result.source}`, \"success\");\n },\n onError = (error) => {\n console.error(\"[react-code-locator]\", error);\n const message = error instanceof Error ? error.message : String(error);\n overlay?.setCopyValue(null);\n overlay?.setStatus(`[react-code-locator] ${message}`, \"error\");\n },\n } = options;\n\n console.log(\"[react-code-locator] enabled\", { triggerKey });\n\n const keyHandler = (event: KeyboardEvent) => {\n if (!event.altKey) {\n return;\n }\n\n if (event.code === \"Digit1\") {\n currentMode = \"direct\";\n overlay?.setMode(currentMode);\n event.preventDefault();\n return;\n }\n\n if (event.code === \"Digit2\") {\n currentMode = \"screen\";\n overlay?.setMode(currentMode);\n event.preventDefault();\n return;\n }\n\n if (event.code === \"Digit3\") {\n currentMode = \"implementation\";\n overlay?.setMode(currentMode);\n event.preventDefault();\n }\n };\n\n const handler = (event: MouseEvent) => {\n console.log(\"[react-code-locator] click\", {\n triggerKey,\n shiftKey: event.shiftKey,\n altKey: event.altKey,\n ctrlKey: event.ctrlKey,\n metaKey: event.metaKey,\n target: event.target,\n });\n\n if (!isTriggerPressed(event, triggerKey)) {\n return;\n }\n\n const result = locateComponentSource(event.target, currentMode);\n if (!result) {\n onError(new Error(\"No React component source metadata found for clicked element.\"));\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n onLocate(result);\n };\n\n document.addEventListener(\"click\", handler, true);\n document.addEventListener(\"keydown\", keyHandler, true);\n\n return () => {\n document.removeEventListener(\"click\", handler, true);\n document.removeEventListener(\"keydown\", keyHandler, true);\n overlay?.remove();\n };\n}\n","export type SourceInjectionOptions = {\n injectJsxSource?: boolean;\n injectComponentSource?: boolean;\n projectRoot?: string;\n};\n\nexport type SourceAdapterKind = \"babel\" | \"vite\" | \"esbuild\" | \"swc\";\n\nexport type SourceAdapterDescriptor<TConfig = unknown, TOptions = SourceInjectionOptions> = {\n kind: SourceAdapterKind;\n name: string;\n options: TOptions;\n config: TConfig;\n};\n\nexport function defineSourceAdapter<TConfig = unknown, TOptions = SourceInjectionOptions>(\n descriptor: SourceAdapterDescriptor<TConfig, TOptions>,\n) {\n return descriptor;\n}\n","import { types as t, type NodePath, type PluginObj } from \"@babel/core\";\nimport {\n JSX_SOURCE_PROP,\n JSX_SOURCE_REGISTRY_SYMBOL,\n SOURCE_PROP,\n} from \"./constants\";\nimport type { SourceInjectionOptions } from \"./sourceAdapter\";\nimport {\n isExternalToProjectRoot,\n toRelativeSource,\n} from \"./sourceMetadata\";\n\nexport type BabelInjectComponentSourceOptions = SourceInjectionOptions;\n\ntype BabelState = {\n file?: {\n opts?: {\n filename?: string;\n };\n };\n injectedIntrinsicHelper?: boolean;\n};\n\ntype BindingLike = {\n path: NodePath;\n};\n\nconst SOURCE_PROP_LOCAL = \"_componentSourceLoc\";\nconst SOURCE_PROPS_REST = \"__reactCodeLocatorProps\";\n\nfunction isComponentName(name: string) {\n return /^[A-Z]/.test(name);\n}\n\nfunction isCustomComponentTag(\n name: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n) {\n if (t.isJSXIdentifier(name)) {\n return isComponentName(name.name);\n }\n\n if (t.isJSXMemberExpression(name)) {\n return true;\n }\n\n return false;\n}\n\nfunction isIntrinsicElementTag(\n name: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n) {\n return t.isJSXIdentifier(name) && /^[a-z]/.test(name.name);\n}\n\nfunction isElementFactoryIdentifier(name: string) {\n return (\n name === \"jsx\" ||\n name === \"jsxs\" ||\n name === \"jsxDEV\" ||\n name === \"_jsx\" ||\n name === \"_jsxs\" ||\n name === \"_jsxDEV\" ||\n name === \"createElement\"\n );\n}\n\nfunction isReactElementFactoryCall(pathNode: NodePath<t.CallExpression>) {\n const callee = pathNode.node.callee;\n\n if (t.isIdentifier(callee)) {\n return isElementFactoryIdentifier(callee.name);\n }\n\n return (\n t.isMemberExpression(callee) &&\n t.isIdentifier(callee.object, { name: \"React\" }) &&\n t.isIdentifier(callee.property, { name: \"createElement\" })\n );\n}\n\nfunction getRootJsxIdentifierName(\n name: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName,\n): string | null {\n if (t.isJSXIdentifier(name)) {\n return name.name;\n }\n\n if (t.isJSXMemberExpression(name)) {\n return getRootJsxIdentifierName(name.object);\n }\n\n return null;\n}\n\nfunction isStyledModuleImport(binding: BindingLike | undefined) {\n if (!binding) {\n return false;\n }\n\n if (\n !binding.path.isImportSpecifier() &&\n !binding.path.isImportDefaultSpecifier() &&\n !binding.path.isImportNamespaceSpecifier()\n ) {\n return false;\n }\n\n const source = binding.path.parentPath.isImportDeclaration()\n ? binding.path.parentPath.node.source.value\n : null;\n if (typeof source !== \"string\") {\n return false;\n }\n\n const normalized = source.replace(/\\\\/g, \"/\");\n return (\n normalized === \"./styled\" ||\n normalized === \"../styled\" ||\n normalized.endsWith(\"/styled\")\n );\n}\n\nfunction isSupportedComponentInit(\n node: t.Expression | null | undefined,\n): boolean {\n if (!node) {\n return false;\n }\n\n if (t.isArrowFunctionExpression(node) || t.isFunctionExpression(node)) {\n return true;\n }\n\n if (!t.isCallExpression(node)) {\n return false;\n }\n\n if (\n t.isIdentifier(node.callee) &&\n (node.callee.name === \"memo\" || node.callee.name === \"forwardRef\")\n ) {\n return true;\n }\n\n return (\n t.isMemberExpression(node.callee) &&\n t.isIdentifier(node.callee.object, { name: \"React\" }) &&\n t.isIdentifier(node.callee.property) &&\n (node.callee.property.name === \"memo\" ||\n node.callee.property.name === \"forwardRef\")\n );\n}\n\nfunction hasSourcePropBinding(pattern: t.ObjectPattern) {\n return pattern.properties.some((property: t.ObjectPattern[\"properties\"][number]) => {\n if (!t.isObjectProperty(property)) {\n return false;\n }\n\n return (\n t.isIdentifier(property.key) && property.key.name === JSX_SOURCE_PROP\n );\n });\n}\n\nfunction injectSourcePropBinding(pattern: t.ObjectPattern) {\n if (hasSourcePropBinding(pattern)) {\n return;\n }\n\n const sourceBinding = t.objectProperty(\n t.identifier(JSX_SOURCE_PROP),\n t.identifier(SOURCE_PROP_LOCAL),\n false,\n false,\n );\n\n const restIndex = pattern.properties.findIndex((property: t.ObjectPattern[\"properties\"][number]) =>\n t.isRestElement(property),\n );\n if (restIndex === -1) {\n pattern.properties.push(sourceBinding);\n return;\n }\n\n pattern.properties.splice(restIndex, 0, sourceBinding);\n}\n\nfunction injectSourcePropIntoIdentifierParam(\n node:\n | t.FunctionDeclaration\n | t.FunctionExpression\n | t.ArrowFunctionExpression,\n param: t.Identifier,\n) {\n if (!t.isBlockStatement(node.body)) {\n node.body = t.blockStatement([t.returnStatement(node.body)]);\n }\n\n const alreadyInjected = node.body.body.some(\n (statement: t.Statement) =>\n t.isVariableDeclaration(statement) &&\n statement.declarations.some(\n (declaration: t.VariableDeclarator) =>\n t.isIdentifier(declaration.id) &&\n declaration.id.name === SOURCE_PROPS_REST,\n ),\n );\n if (alreadyInjected) {\n return;\n }\n\n node.body.body.unshift(\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(\n t.objectPattern([\n t.objectProperty(\n t.identifier(JSX_SOURCE_PROP),\n t.identifier(SOURCE_PROP_LOCAL),\n false,\n false,\n ),\n t.restElement(t.identifier(SOURCE_PROPS_REST)),\n ]),\n param,\n ),\n ]),\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.identifier(param.name),\n t.identifier(SOURCE_PROPS_REST),\n ),\n ),\n );\n}\n\nfunction injectSourcePropIntoFunctionParams(\n node:\n | t.FunctionDeclaration\n | t.FunctionExpression\n | t.ArrowFunctionExpression,\n) {\n const firstParam = node.params[0];\n if (!firstParam) {\n return;\n }\n\n if (t.isObjectPattern(firstParam)) {\n injectSourcePropBinding(firstParam);\n return;\n }\n\n if (t.isIdentifier(firstParam)) {\n injectSourcePropIntoIdentifierParam(node, firstParam);\n }\n}\n\nfunction injectSourcePropIntoExpression(node: t.Expression | null | undefined) {\n if (!node) {\n return;\n }\n\n if (t.isFunctionExpression(node) || t.isArrowFunctionExpression(node)) {\n injectSourcePropIntoFunctionParams(node);\n return;\n }\n\n if (!t.isCallExpression(node)) {\n return;\n }\n\n const firstArg = node.arguments[0];\n if (\n firstArg &&\n !t.isSpreadElement(firstArg) &&\n (t.isFunctionExpression(firstArg) || t.isArrowFunctionExpression(firstArg))\n ) {\n injectSourcePropIntoFunctionParams(firstArg);\n }\n}\n\nfunction getSourceValue(\n state: BabelState,\n loc: { line: number; column: number } | null | undefined,\n projectRoot?: string,\n) {\n const filename = state.file?.opts?.filename;\n if (!filename || !loc) {\n return null;\n }\n\n return toRelativeSource(filename, loc, projectRoot);\n}\n\nfunction buildAssignment(name: string, sourceValue: string) {\n return t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.identifier(name), t.identifier(SOURCE_PROP)),\n t.stringLiteral(sourceValue),\n ),\n );\n}\n\nfunction buildIntrinsicSourceHelper() {\n return t.functionDeclaration(\n t.identifier(\"_markIntrinsicElementSource\"),\n [t.identifier(\"element\"), t.identifier(\"source\")],\n t.blockStatement([\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(\n t.identifier(\"registryKey\"),\n t.callExpression(\n t.memberExpression(t.identifier(\"Symbol\"), t.identifier(\"for\")),\n [t.stringLiteral(JSX_SOURCE_REGISTRY_SYMBOL)],\n ),\n ),\n ]),\n t.variableDeclaration(\"let\", [\n t.variableDeclarator(\n t.identifier(\"registry\"),\n t.memberExpression(t.identifier(\"globalThis\"), t.identifier(\"registryKey\"), true),\n ),\n ]),\n t.ifStatement(\n t.unaryExpression(\n \"!\",\n t.binaryExpression(\"instanceof\", t.identifier(\"registry\"), t.identifier(\"WeakMap\")),\n ),\n t.blockStatement([\n t.expressionStatement(\n t.assignmentExpression(\n \"=\",\n t.identifier(\"registry\"),\n t.assignmentExpression(\n \"=\",\n t.memberExpression(t.identifier(\"globalThis\"), t.identifier(\"registryKey\"), true),\n t.newExpression(t.identifier(\"WeakMap\"), []),\n ),\n ),\n ),\n ]),\n ),\n t.ifStatement(\n t.logicalExpression(\n \"&&\",\n t.identifier(\"element\"),\n t.logicalExpression(\n \"&&\",\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", t.identifier(\"element\")), t.stringLiteral(\"object\")),\n t.binaryExpression(\n \"===\",\n t.unaryExpression(\"typeof\", t.memberExpression(t.identifier(\"element\"), t.identifier(\"props\"))),\n t.stringLiteral(\"object\"),\n ),\n ),\n ),\n t.blockStatement([\n t.expressionStatement(\n t.callExpression(\n t.memberExpression(t.identifier(\"registry\"), t.identifier(\"set\")),\n [t.memberExpression(t.identifier(\"element\"), t.identifier(\"props\")), t.identifier(\"source\")],\n ),\n ),\n ]),\n ),\n t.returnStatement(t.identifier(\"element\")),\n ]),\n );\n}\n\nfunction ensureIntrinsicSourceHelper(programPath: NodePath<t.Program>, state: BabelState) {\n if (state.injectedIntrinsicHelper) {\n return;\n }\n\n const alreadyExists = programPath.node.body.some(\n (node: t.Statement) =>\n t.isFunctionDeclaration(node) && t.isIdentifier(node.id, { name: \"_markIntrinsicElementSource\" }),\n );\n if (!alreadyExists) {\n programPath.unshiftContainer(\"body\", buildIntrinsicSourceHelper());\n }\n\n state.injectedIntrinsicHelper = true;\n}\n\nfunction visitDeclaration(\n declarationPath: NodePath,\n insertAfterPath: NodePath,\n state: BabelState,\n seen: Set<string>,\n projectRoot?: string,\n) {\n if (\n declarationPath.isFunctionDeclaration() ||\n declarationPath.isClassDeclaration()\n ) {\n const name = declarationPath.node.id?.name;\n if (!name || !isComponentName(name) || seen.has(name)) {\n return;\n }\n\n if (declarationPath.isFunctionDeclaration()) {\n injectSourcePropIntoFunctionParams(declarationPath.node);\n }\n\n const sourceValue = getSourceValue(\n state,\n declarationPath.node.loc?.start,\n projectRoot,\n );\n if (!sourceValue) {\n return;\n }\n\n seen.add(name);\n insertAfterPath.insertAfter(buildAssignment(name, sourceValue));\n return;\n }\n\n if (!declarationPath.isVariableDeclaration()) {\n return;\n }\n\n const assignments = declarationPath.node.declarations.flatMap(\n (declarator: t.VariableDeclarator) => {\n if (\n !t.isIdentifier(declarator.id) ||\n !isComponentName(declarator.id.name) ||\n seen.has(declarator.id.name)\n ) {\n return [];\n }\n\n if (!declarator.init) {\n return [];\n }\n\n if (!isSupportedComponentInit(declarator.init)) {\n return [];\n }\n\n injectSourcePropIntoExpression(declarator.init);\n\n const sourceValue = getSourceValue(\n state,\n declarator.loc?.start ?? declarator.init.loc?.start,\n projectRoot,\n );\n if (!sourceValue) {\n return [];\n }\n\n seen.add(declarator.id.name);\n return [buildAssignment(declarator.id.name, sourceValue)];\n },\n );\n\n if (assignments.length > 0) {\n insertAfterPath.insertAfter(assignments);\n }\n}\n\nexport function babelInjectComponentSource(\n options: BabelInjectComponentSourceOptions = {},\n): PluginObj<BabelState> {\n const {\n injectJsxSource = true,\n injectComponentSource = true,\n projectRoot,\n } = options;\n\n return {\n name: \"babel-inject-component-source\",\n visitor: {\n CallExpression(pathNode: NodePath<t.CallExpression>, state: BabelState) {\n if (!injectJsxSource) {\n return;\n }\n\n if (!isReactElementFactoryCall(pathNode)) {\n return;\n }\n\n if (\n pathNode.parentPath.isCallExpression() &&\n t.isIdentifier(pathNode.parentPath.node.callee, {\n name: \"_markIntrinsicElementSource\",\n })\n ) {\n return;\n }\n\n const sourceValue = getSourceValue(\n state,\n pathNode.node.loc?.start,\n projectRoot,\n );\n if (!sourceValue) {\n return;\n }\n\n const programPath = pathNode.findParent((parent: NodePath) => parent.isProgram());\n if (!programPath || !programPath.isProgram()) {\n return;\n }\n\n ensureIntrinsicSourceHelper(programPath, state);\n pathNode.replaceWith(\n t.callExpression(t.identifier(\"_markIntrinsicElementSource\"), [\n pathNode.node,\n t.stringLiteral(sourceValue),\n ]),\n );\n pathNode.skip();\n },\n JSXElement: {\n exit(pathNode: NodePath<t.JSXElement>, state: BabelState) {\n if (!injectJsxSource) {\n return;\n }\n\n if (!isIntrinsicElementTag(pathNode.node.openingElement.name)) {\n return;\n }\n\n if (\n pathNode.parentPath.isCallExpression() &&\n t.isIdentifier(pathNode.parentPath.node.callee, { name: \"_markIntrinsicElementSource\" })\n ) {\n return;\n }\n\n const sourceValue = getSourceValue(\n state,\n pathNode.node.openingElement.loc?.start,\n projectRoot,\n );\n if (!sourceValue) {\n return;\n }\n\n const programPath = pathNode.findParent((parent: NodePath) => parent.isProgram());\n if (!programPath || !programPath.isProgram()) {\n return;\n }\n\n ensureIntrinsicSourceHelper(programPath, state);\n\n const wrappedNode = t.callExpression(t.identifier(\"_markIntrinsicElementSource\"), [\n pathNode.node,\n t.stringLiteral(sourceValue),\n ]);\n\n if (pathNode.parentPath.isJSXElement() || pathNode.parentPath.isJSXFragment()) {\n pathNode.replaceWith(t.jsxExpressionContainer(wrappedNode));\n return;\n }\n\n if (pathNode.parentPath.isJSXExpressionContainer()) {\n pathNode.parentPath.replaceWith(t.jsxExpressionContainer(wrappedNode));\n return;\n }\n\n pathNode.replaceWith(wrappedNode);\n },\n },\n JSXOpeningElement(pathNode: NodePath<t.JSXOpeningElement>, state: BabelState) {\n if (!injectJsxSource) {\n return;\n }\n\n if (!isCustomComponentTag(pathNode.node.name)) {\n return;\n }\n\n const rootIdentifierName = getRootJsxIdentifierName(pathNode.node.name);\n if (\n rootIdentifierName &&\n isExternalToProjectRoot(state.file?.opts?.filename, projectRoot) &&\n isStyledModuleImport(pathNode.scope.getBinding(rootIdentifierName))\n ) {\n return;\n }\n\n const hasSourceProp = pathNode.node.attributes.some(\n (attr: t.JSXAttribute | t.JSXSpreadAttribute) =>\n t.isJSXAttribute(attr) &&\n t.isJSXIdentifier(attr.name) &&\n attr.name.name === JSX_SOURCE_PROP,\n );\n if (hasSourceProp) {\n return;\n }\n\n const filename = state.file?.opts?.filename;\n const loc = pathNode.node.loc?.start;\n if (!filename || !loc) {\n return;\n }\n\n pathNode.node.attributes.push(\n t.jsxAttribute(\n t.jsxIdentifier(JSX_SOURCE_PROP),\n t.stringLiteral(\n getSourceValue(state, loc, projectRoot) ??\n `${filename.replace(/\\\\/g, \"/\")}:${loc.line}:${loc.column + 1}`,\n ),\n ),\n );\n },\n Program(programPath: NodePath<t.Program>, state: BabelState) {\n if (!injectComponentSource) {\n return;\n }\n\n const seen = new Set<string>();\n\n for (const childPath of programPath.get(\"body\")) {\n if (\n childPath.isExportNamedDeclaration() ||\n childPath.isExportDefaultDeclaration()\n ) {\n const declarationPath = childPath.get(\"declaration\");\n if (!Array.isArray(declarationPath) && declarationPath.node) {\n visitDeclaration(declarationPath, childPath, state, seen, projectRoot);\n }\n continue;\n }\n\n visitDeclaration(childPath, childPath, state, seen, projectRoot);\n }\n },\n },\n };\n}\n","import { babelInjectComponentSource, type BabelInjectComponentSourceOptions } from \"./babelInjectComponentSource\";\nimport { defineSourceAdapter } from \"./sourceAdapter\";\n\nexport type BabelSourceAdapterConfig = {\n plugins: Array<[typeof babelInjectComponentSource, BabelInjectComponentSourceOptions]>;\n};\n\nexport { babelInjectComponentSource } from \"./babelInjectComponentSource\";\nexport type { BabelInjectComponentSourceOptions } from \"./babelInjectComponentSource\";\nexport type { SourceAdapterDescriptor, SourceAdapterKind, SourceInjectionOptions } from \"./sourceAdapter\";\n\nexport function createBabelSourceAdapter(options: BabelInjectComponentSourceOptions = {}) {\n return defineSourceAdapter<BabelSourceAdapterConfig, BabelInjectComponentSourceOptions>({\n kind: \"babel\",\n name: \"react-code-locator/babel\",\n options,\n config: {\n plugins: [[babelInjectComponentSource, options]],\n },\n });\n}\n\nexport const babelSourceAdapter = createBabelSourceAdapter();\n","import { transformAsync } from \"@babel/core\";\nimport { babelInjectComponentSource, type BabelInjectComponentSourceOptions } from \"./babelInjectComponentSource\";\n\nexport type SourceTransformOptions = BabelInjectComponentSourceOptions & {\n filename: string;\n sourceMaps?: boolean;\n};\n\nexport async function transformSourceWithLocator(\n code: string,\n options: SourceTransformOptions,\n) {\n const { filename, sourceMaps = true, ...pluginOptions } = options;\n const result = await transformAsync(code, {\n filename,\n babelrc: false,\n configFile: false,\n sourceMaps,\n parserOpts: {\n sourceType: \"module\",\n plugins: [\"jsx\", \"typescript\"],\n },\n generatorOpts: {\n retainLines: true,\n },\n plugins: [[babelInjectComponentSource, pluginOptions]],\n });\n\n return {\n code: result?.code ?? code,\n map: result?.map ?? null,\n };\n}\n","import type { Plugin, PluginOption } from \"vite\";\nimport type { LocatorOptions } from \"./runtime\";\n\nconst VIRTUAL_CLIENT_MODULE_ID = \"virtual:react-code-locator/client\";\nconst RESOLVED_VIRTUAL_CLIENT_MODULE_ID = `\\0${VIRTUAL_CLIENT_MODULE_ID}`;\n\nexport type ViteClientInjectorOptions = {\n command?: \"serve\" | \"build\";\n locator?: LocatorOptions;\n injectClient?: boolean;\n};\n\nfunction createClientInjector(locatorOptions: LocatorOptions = {}): Plugin {\n const serialized = JSON.stringify(locatorOptions);\n\n return {\n name: \"react-code-locator-client-injector\",\n apply: \"serve\",\n resolveId(id) {\n if (id === VIRTUAL_CLIENT_MODULE_ID) {\n return RESOLVED_VIRTUAL_CLIENT_MODULE_ID;\n }\n\n return null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_CLIENT_MODULE_ID) {\n return null;\n }\n\n return `\n import { enableReactComponentJump } from \"react-code-locator/client\";\n\n enableReactComponentJump(${serialized});\n `;\n },\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n attrs: {\n type: \"module\",\n src: `/@id/__x00__${VIRTUAL_CLIENT_MODULE_ID}`,\n },\n injectTo: \"head\",\n },\n ];\n },\n };\n}\n\nexport function createViteClientInjector(\n options: ViteClientInjectorOptions = {},\n): PluginOption[] {\n const { command = \"serve\", locator = {}, injectClient = true } = options;\n const isServe = command === \"serve\";\n\n return [isServe && injectClient ? createClientInjector(locator) : null].filter(Boolean);\n}\n","import { babelInjectComponentSource, type BabelInjectComponentSourceOptions } from \"./babelInjectComponentSource\";\nimport { defineSourceAdapter } from \"./sourceAdapter\";\nimport { transformSourceWithLocator } from \"./sourceTransform\";\nimport { createViteClientInjector, type ViteClientInjectorOptions } from \"./viteClientInjector\";\nimport type { Plugin } from \"vite\";\n\nexport type ViteSourceAdapterOptions = ViteClientInjectorOptions & {\n babel?: BabelInjectComponentSourceOptions;\n};\n\nexport type ViteSourceAdapterConfig = {\n plugins: Plugin[];\n};\n\nexport { createViteClientInjector as reactComponentJump } from \"./viteClientInjector\";\nexport { createViteClientInjector } from \"./viteClientInjector\";\nexport type { ViteClientInjectorOptions } from \"./viteClientInjector\";\nexport { babelInjectComponentSource } from \"./babelInjectComponentSource\";\nexport type { BabelInjectComponentSourceOptions } from \"./babelInjectComponentSource\";\nexport type { SourceAdapterDescriptor, SourceAdapterKind, SourceInjectionOptions } from \"./sourceAdapter\";\n\nfunction shouldTransformSource(id: string) {\n if (id.includes(\"/node_modules/\") || id.startsWith(\"\\0\")) {\n return false;\n }\n\n return /\\.[mc]?[jt]sx?$/.test(id);\n}\n\nexport function viteSourceTransformPlugin(\n options: BabelInjectComponentSourceOptions = {},\n): Plugin {\n return {\n name: \"react-code-locator-source-transform\",\n enforce: \"pre\",\n async transform(code, id) {\n if (!shouldTransformSource(id)) {\n return null;\n }\n\n return transformSourceWithLocator(code, {\n filename: id,\n ...options,\n });\n },\n };\n}\n\nexport function createViteSourceAdapter(options: ViteSourceAdapterOptions = {}) {\n const { babel = {}, ...viteOptions } = options;\n const plugins = [\n viteSourceTransformPlugin(babel),\n ...createViteClientInjector(viteOptions),\n ].filter(Boolean) as Plugin[];\n\n return defineSourceAdapter<ViteSourceAdapterConfig, ViteSourceAdapterOptions>({\n kind: \"vite\",\n name: \"react-code-locator/vite\",\n options,\n config: {\n plugins,\n },\n });\n}\n\nexport const viteSourceAdapter = createViteSourceAdapter();\n","import { readFile } from \"node:fs/promises\";\nimport { defineSourceAdapter, type SourceInjectionOptions } from \"./sourceAdapter\";\nimport { transformSourceWithLocator } from \"./sourceTransform\";\n\ntype EsbuildOnLoadResult = {\n contents: string;\n loader: \"js\" | \"jsx\" | \"ts\" | \"tsx\";\n};\n\ntype EsbuildPluginBuild = {\n onLoad: (\n options: { filter: RegExp },\n callback: (args: { path: string }) => Promise<EsbuildOnLoadResult | null>,\n ) => void;\n};\n\nexport type EsbuildPlugin = {\n name: string;\n setup: (build: EsbuildPluginBuild) => void;\n};\n\nexport type EsbuildSourceAdapterConfig = {\n plugins: EsbuildPlugin[];\n};\n\nfunction getEsbuildLoader(filename: string): EsbuildOnLoadResult[\"loader\"] {\n if (filename.endsWith(\".tsx\")) {\n return \"tsx\";\n }\n\n if (filename.endsWith(\".ts\")) {\n return \"ts\";\n }\n\n if (filename.endsWith(\".jsx\")) {\n return \"jsx\";\n }\n\n return \"js\";\n}\n\nexport function esbuildSourceTransformPlugin(\n options: SourceInjectionOptions = {},\n): EsbuildPlugin {\n return {\n name: \"react-code-locator-source-transform\",\n setup(build) {\n build.onLoad({ filter: /\\.[mc]?[jt]sx?$/ }, async ({ path }) => {\n if (path.includes(\"/node_modules/\")) {\n return null;\n }\n\n const code = await readFile(path, \"utf8\");\n const result = await transformSourceWithLocator(code, {\n filename: path,\n ...options,\n });\n\n return {\n contents: result.code,\n loader: getEsbuildLoader(path),\n };\n });\n },\n };\n}\n\nexport function createEsbuildSourceAdapter(options: SourceInjectionOptions = {}) {\n return defineSourceAdapter<EsbuildSourceAdapterConfig>({\n kind: \"esbuild\",\n name: \"react-code-locator/esbuild\",\n options,\n config: {\n plugins: [esbuildSourceTransformPlugin(options)],\n },\n });\n}\n\nexport const esbuildSourceAdapter = createEsbuildSourceAdapter();\n","import { defineSourceAdapter, type SourceInjectionOptions } from \"./sourceAdapter\";\nimport { transformSourceWithLocator } from \"./sourceTransform\";\n\nexport type SwcSourceTransformOptions = SourceInjectionOptions & {\n filename: string;\n sourceMaps?: boolean;\n};\n\nexport type SwcSourceTransform = (\n code: string,\n options: SwcSourceTransformOptions,\n) => Promise<{\n code: string;\n map: unknown;\n}>;\n\nexport type SwcSourceAdapterConfig = {\n transform: SwcSourceTransform;\n};\n\nexport async function transformSourceWithSwcLocator(\n code: string,\n options: SwcSourceTransformOptions,\n) {\n return transformSourceWithLocator(code, options);\n}\n\nexport function createSwcSourceAdapter(options: SourceInjectionOptions = {}) {\n const transform: SwcSourceTransform = (code, transformOptions) =>\n transformSourceWithSwcLocator(code, {\n ...options,\n ...transformOptions,\n });\n\n return defineSourceAdapter<SwcSourceAdapterConfig>({\n kind: \"swc\",\n name: \"react-code-locator/swc\",\n options,\n config: {\n transform,\n },\n });\n}\n\nexport const swcSourceAdapter = createSwcSourceAdapter();\n"],"mappings":";AAAO,IAAM,cAAc;AACpB,IAAM,kBAAkB;AACxB,IAAM,6BAA6B;;;ACG1C,SAAS,iBAAiB,OAAe;AACvC,SAAO,MAAM,QAAQ,OAAO,GAAG;AACjC;AAEA,SAAS,kBAAkB,OAAe;AACxC,SAAO,MAAM,QAAQ,QAAQ,EAAE;AACjC;AAEA,SAAS,kBAAkB,OAAe;AACxC,SAAO,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;AACX,YAAM,OAAO,EAAE,QAAQ,kBAAkB,GAAG,OAAO,EAAE,KAAK,MAAM;AAC9D,YAAI,KAAK,SAAS,gBAAgB,GAAG;AACnC,iBAAO;AAAA,QACT;AAEA,cAAM,OAAO,MAAM,SAAS,MAAM,MAAM;AACxC,cAAM,SAAS,MAAM,2BAA2B,MAAM;AAAA,UACpD,UAAU;AAAA,UACV,GAAG;AAAA,QACL,CAAC;AAED,eAAO;AAAA,UACL,UAAU,OAAO;AAAA,UACjB,QAAQ,iBAAiB,IAAI;AAAA,QAC/B;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,2BAA2B,UAAkC,CAAC,GAAG;AAC/E,SAAO,oBAAgD;AAAA,IACrD,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,CAAC,6BAA6B,OAAO,CAAC;AAAA,IACjD;AAAA,EACF,CAAC;AACH;AAEO,IAAM,uBAAuB,2BAA2B;;;AC1D/D,eAAsB,8BACpB,MACA,SACA;AACA,SAAO,2BAA2B,MAAM,OAAO;AACjD;AAEO,SAAS,uBAAuB,UAAkC,CAAC,GAAG;AAC3E,QAAM,YAAgC,CAAC,MAAM,qBAC3C,8BAA8B,MAAM;AAAA,IAClC,GAAG;AAAA,IACH,GAAG;AAAA,EACL,CAAC;AAEH,SAAO,oBAA4C;AAAA,IACjD,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,QAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,IAAM,mBAAmB,uBAAuB;","names":["source"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SourceInjectionOptions = {
|
|
2
|
+
injectJsxSource?: boolean;
|
|
3
|
+
injectComponentSource?: boolean;
|
|
4
|
+
projectRoot?: string;
|
|
5
|
+
};
|
|
6
|
+
type SourceAdapterKind = "babel" | "vite" | "esbuild" | "swc";
|
|
7
|
+
type SourceAdapterDescriptor<TConfig = unknown, TOptions = SourceInjectionOptions> = {
|
|
8
|
+
kind: SourceAdapterKind;
|
|
9
|
+
name: string;
|
|
10
|
+
options: TOptions;
|
|
11
|
+
config: TConfig;
|
|
12
|
+
};
|
|
13
|
+
declare function defineSourceAdapter<TConfig = unknown, TOptions = SourceInjectionOptions>(descriptor: SourceAdapterDescriptor<TConfig, TOptions>): SourceAdapterDescriptor<TConfig, TOptions>;
|
|
14
|
+
|
|
15
|
+
export { type SourceAdapterDescriptor as S, type SourceAdapterKind as a, type SourceInjectionOptions as b, defineSourceAdapter as d };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SourceInjectionOptions = {
|
|
2
|
+
injectJsxSource?: boolean;
|
|
3
|
+
injectComponentSource?: boolean;
|
|
4
|
+
projectRoot?: string;
|
|
5
|
+
};
|
|
6
|
+
type SourceAdapterKind = "babel" | "vite" | "esbuild" | "swc";
|
|
7
|
+
type SourceAdapterDescriptor<TConfig = unknown, TOptions = SourceInjectionOptions> = {
|
|
8
|
+
kind: SourceAdapterKind;
|
|
9
|
+
name: string;
|
|
10
|
+
options: TOptions;
|
|
11
|
+
config: TConfig;
|
|
12
|
+
};
|
|
13
|
+
declare function defineSourceAdapter<TConfig = unknown, TOptions = SourceInjectionOptions>(descriptor: SourceAdapterDescriptor<TConfig, TOptions>): SourceAdapterDescriptor<TConfig, TOptions>;
|
|
14
|
+
|
|
15
|
+
export { type SourceAdapterDescriptor as S, type SourceAdapterKind as a, type SourceInjectionOptions as b, defineSourceAdapter as d };
|