react-code-locator 0.2.9 → 0.2.10

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/dist/client.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},K=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!_.call(t,o)&&o!==n&&C(t,o,{get:()=>e[o],enumerable:!(r=F(e,o))||r.enumerable});return t};var j=t=>K(C({},"__esModule",{value:!0}),t);var G={};$(G,{enableReactComponentJump:()=>O,locateComponentSource:()=>L});module.exports=j(G);var g="__componentSourceLoc",w="$componentSourceLoc",v="react-code-locator.jsxSourceRegistry";function E(t){return t.replace(/\\/g,"/")}function D(t){return t.replace(/\/+$/,"")}function k(t){return E(t).split("/").filter(Boolean)}function z(t,e){let n=k(t),r=k(e),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;let s=new Array(Math.max(0,n.length-o)).fill(".."),u=r.slice(o),i=[...s,...u];return i.length>0?i.join("/"):"."}function N(t){return t?D(E(t)):""}function b(t){return t?t.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function J(t,e){if(!t)return!1;let n=N(e),r=E(t);return n?r.startsWith(`${n}/`)||r===n?!0:!z(n,r).startsWith("../"):!r.startsWith("../")&&!r.startsWith("/")&&!/^[A-Za-z]:\//.test(r)}function f(t,e){let n=b(t);return J(n??void 0,e)}function W(t,e){return e==="none"?!0:e==="alt"?t.altKey:e==="meta"?t.metaKey:e==="ctrl"?t.ctrlKey:t.shiftKey}function I(t){return Object.keys(t).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))}function U(t){let e=t;for(;e;){let n=I(e);if(n)return e[n];e=e.parentElement}return null}function h(t){if(!t)return null;if(typeof t=="function"){let r=t[g];return typeof r=="string"?r:null}if(typeof t!="object")return null;let e=t,n=e[g]??e.type?.[g]??e.render?.[g];return typeof n=="string"?n:null}function P(t){if(t&&typeof t=="object"){let n=globalThis[Symbol.for(v)];if(n instanceof WeakMap){let r=n.get(t);if(typeof r=="string")return r}}let e=t?.[w];return typeof e=="string"?e:null}function V(t){let e=t;for(;e;){let n=h(e.type)??h(e.elementType);if(n)return n;e=e.return??null}return null}function X(t){let e=t?._debugSource;return e?.fileName&&typeof e.lineNumber=="number"?`${e.fileName.replace(/\\/g,"/")}:${e.lineNumber}:${e.columnNumber??1}`:null}function M(t,e){if(!e||!t)return t;let n=t.match(/^(.*):(\d+):(\d+)$/);if(!n)return t;let[,r,o,s]=n,u=r.replace(/\\/g,"/"),i=e.replace(/\\/g,"/").replace(/\/$/,"");return u.startsWith(i+"/")?`${u.slice(i.length+1)}:${o}:${s}`:t}function B(t,e){let n=t,r=[],o=[];for(;n;){let l=P(n.pendingProps)??P(n.memoizedProps)??X(n),d=M(l??"",e)||l;if(d){let p=b(d);p&&!r.some(x=>x.source===d)&&r.push({source:d,file:p})}let y=h(n.type)??h(n.elementType),S=M(y??"",e)||y;if(S){let p=b(S);p&&!o.some(x=>x.source===S)&&o.push({source:S,file:p})}n=n.return??null}let s=r[0]?.source??null,u=o.find(l=>f(l.source))?.file,i=null;if(u){let l=r.find(d=>d.file===u);if(l)i=l.source;else{let d=o.find(y=>y.file===u);d&&(i=d.source)}}let a=o.find(l=>!f(l.source))?.source??null,c=r.find(l=>!f(l.source))?.source??null,m=r.find(l=>f(l.source))?.source??null,R=i??m??o.find(l=>f(l.source))?.source??null;return{direct:s??R,screen:R,implementation:a??c??R}}function Y(t){return t==="direct"?"Direct JSX":t==="screen"?"Screen source":"Implementation source"}function A(t){if(typeof document>"u")return null;let e=document.createElement("div"),n=null,r="screen",o=null;e.setAttribute("data-react-code-locator","true"),Object.assign(e.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let s=(i,a)=>{e.textContent=i,e.style.background=a==="success"?"rgba(6, 95, 70, 0.92)":a==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",e.style.opacity="1",e.style.pointerEvents="auto",o&&clearTimeout(o),o=setTimeout(()=>{e.style.opacity="0",e.style.pointerEvents="none"},2e3)};e.addEventListener("click",async()=>{if(n)try{await navigator.clipboard.writeText(n),s("[react-code-locator] copied","success")}catch{s("[react-code-locator] copy failed","error")}}),s(`[react-code-locator] enabled (${t}+click, alt+1/2/3 to switch mode)`,"idle");let u=()=>{!e.isConnected&&document.body&&document.body.appendChild(e)};return document.body?u():document.addEventListener("DOMContentLoaded",u,{once:!0}),{setStatus(i,a="idle"){s(i,a)},setCopyValue(i){n=i},setMode(i){r=i,s(`[react-code-locator] ${Y(i)}`,"idle")},remove(){o&&clearTimeout(o),e.remove()}}}function L(t,e="screen",n){let r=t instanceof Element?t:t instanceof Node?t.parentElement:null,o=U(r);if(!o)return null;let s=B(o,n),u=s[e]??s.screen??s.direct??s.implementation;if(u)return{source:u,mode:e};let i=V(o);return i?{source:i,mode:e}:null}function O(t={}){if(process.env.NODE_ENV!=="development")return;let e=A(t.triggerKey??"shift"),n="screen",{triggerKey:r="shift",projectRoot:o,onLocate:s=c=>{console.log(`[react-code-locator] ${c.source}`),e?.setCopyValue(c.source),e?.setStatus(`[react-code-locator] ${c.source}`,"success")},onError:u=c=>{console.error("[react-code-locator]",c);let m=c instanceof Error?c.message:String(c);e?.setCopyValue(null),e?.setStatus(`[react-code-locator] ${m}`,"error")}}=t;console.log("[react-code-locator] enabled",{triggerKey:r});let i=c=>{if(c.altKey){if(c.code==="Digit1"){n="direct",e?.setMode(n),c.preventDefault();return}if(c.code==="Digit2"){n="screen",e?.setMode(n),c.preventDefault();return}c.code==="Digit3"&&(n="implementation",e?.setMode(n),c.preventDefault())}},a=c=>{if(console.log("[react-code-locator] click",{triggerKey:r,shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,target:c.target}),!W(c,r))return;let m=L(c.target,n,o);if(!m){u(new Error("No React component source metadata found for clicked element."));return}c.preventDefault(),c.stopPropagation(),s(m)};return document.addEventListener("click",a,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("click",a,!0),document.removeEventListener("keydown",i,!0),e?.remove()}}0&&(module.exports={enableReactComponentJump,locateComponentSource});
1
+ "use strict";var C=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var n in e)C(t,n,{get:e[n],enumerable:!0})},K=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!_.call(t,o)&&o!==n&&C(t,o,{get:()=>e[o],enumerable:!(r=F(e,o))||r.enumerable});return t};var j=t=>K(C({},"__esModule",{value:!0}),t);var G={};$(G,{enableReactComponentJump:()=>O,locateComponentSource:()=>L});module.exports=j(G);var g="__componentSourceLoc",w="$componentSourceLoc",v="react-code-locator.jsxSourceRegistry";function E(t){return t.replace(/\\/g,"/")}function D(t){return t.replace(/\/+$/,"")}function k(t){return E(t).split("/").filter(Boolean)}function z(t,e){let n=k(t),r=k(e),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;let s=new Array(Math.max(0,n.length-o)).fill(".."),l=r.slice(o),i=[...s,...l];return i.length>0?i.join("/"):"."}function N(t){return t?D(E(t)):""}function b(t){return t?t.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function J(t,e){if(!t)return!1;let n=N(e),r=E(t);return n?r.startsWith(`${n}/`)||r===n?!0:!z(n,r).startsWith("../"):!r.startsWith("../")&&!r.startsWith("/")&&!/^[A-Za-z]:\//.test(r)}function f(t,e){let n=b(t);return J(n??void 0,e)}function W(t,e){return e==="none"?!0:e==="alt"?t.altKey:e==="meta"?t.metaKey:e==="ctrl"?t.ctrlKey:t.shiftKey}function U(t){return Object.keys(t).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))}function I(t){let e=t;for(;e;){let n=U(e);if(n)return e[n];e=e.parentElement}return null}function h(t){if(!t)return null;if(typeof t=="function"){let r=t[g];return typeof r=="string"?r:null}if(typeof t!="object")return null;let e=t,n=e[g]??e.type?.[g]??e.render?.[g];return typeof n=="string"?n:null}function P(t){if(t&&typeof t=="object"){let n=globalThis[Symbol.for(v)];if(n instanceof WeakMap){let r=n.get(t);if(typeof r=="string")return r}}let e=t?.[w];return typeof e=="string"?e:null}function V(t){let e=t;for(;e;){let n=h(e.type)??h(e.elementType);if(n)return n;e=e.return??null}return null}function B(t){let e=t?._debugSource;return e?.fileName&&typeof e.lineNumber=="number"?`${e.fileName.replace(/\\/g,"/")}:${e.lineNumber}:${e.columnNumber??1}`:null}function M(t,e){if(!e||!t)return t;let n=t.match(/^(.*):(\d+):(\d+)$/);if(!n)return t;let[,r,o,s]=n,l=r.replace(/\\/g,"/"),i=e.replace(/\\/g,"/").replace(/\/$/,"");return l.startsWith(i+"/")?`${l.slice(i.length+1)}:${o}:${s}`:t}function X(t,e){let n=t,r=[],o=[];for(;n;){let u=P(n.pendingProps)??P(n.memoizedProps)??B(n),d=M(u??"",e)||u;if(d){let p=b(d);p&&!r.some(x=>x.source===d)&&r.push({source:d,file:p})}let y=h(n.type)??h(n.elementType),S=M(y??"",e)||y;if(S){let p=b(S);p&&!o.some(x=>x.source===S)&&o.push({source:S,file:p})}n=n.return??null}console.log("[react-code-locator] DEBUG candidates",{jsxCandidates:r,componentCandidates:o,projectRoot:e});let s=r[0]?.source??null,l=o.find(u=>f(u.source))?.file,i=null;if(l){let u=r.find(d=>d.file===l);if(u)i=u.source;else{let d=o.find(y=>y.file===l);d&&(i=d.source)}}let a=o.find(u=>!f(u.source))?.source??null,c=r.find(u=>!f(u.source))?.source??null,m=r.find(u=>f(u.source))?.source??null,R=i??m??o.find(u=>f(u.source))?.source??null;return{direct:s??R,screen:R,implementation:a??c??R}}function Y(t){return t==="direct"?"Direct JSX":t==="screen"?"Screen source":"Implementation source"}function A(t){if(typeof document>"u")return null;let e=document.createElement("div"),n=null,r="screen",o=null;e.setAttribute("data-react-code-locator","true"),Object.assign(e.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let s=(i,a)=>{e.textContent=i,e.style.background=a==="success"?"rgba(6, 95, 70, 0.92)":a==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",e.style.opacity="1",e.style.pointerEvents="auto",o&&clearTimeout(o),o=setTimeout(()=>{e.style.opacity="0",e.style.pointerEvents="none"},2e3)};e.addEventListener("click",async()=>{if(n)try{await navigator.clipboard.writeText(n),s("[react-code-locator] copied","success")}catch{s("[react-code-locator] copy failed","error")}}),s(`[react-code-locator] enabled (${t}+click, alt+1/2/3 to switch mode)`,"idle");let l=()=>{!e.isConnected&&document.body&&document.body.appendChild(e)};return document.body?l():document.addEventListener("DOMContentLoaded",l,{once:!0}),{setStatus(i,a="idle"){s(i,a)},setCopyValue(i){n=i},setMode(i){r=i,s(`[react-code-locator] ${Y(i)}`,"idle")},remove(){o&&clearTimeout(o),e.remove()}}}function L(t,e="screen",n){let r=t instanceof Element?t:t instanceof Node?t.parentElement:null,o=I(r);if(!o)return null;let s=X(o,n),l=s[e]??s.screen??s.direct??s.implementation;if(l)return{source:l,mode:e};let i=V(o);return i?{source:i,mode:e}:null}function O(t={}){if(process.env.NODE_ENV!=="development")return;let e=A(t.triggerKey??"shift"),n="screen",{triggerKey:r="shift",projectRoot:o,onLocate:s=c=>{console.log(`[react-code-locator] ${c.source}`),e?.setCopyValue(c.source),e?.setStatus(`[react-code-locator] ${c.source}`,"success")},onError:l=c=>{console.error("[react-code-locator]",c);let m=c instanceof Error?c.message:String(c);e?.setCopyValue(null),e?.setStatus(`[react-code-locator] ${m}`,"error")}}=t;console.log("[react-code-locator] enabled",{triggerKey:r});let i=c=>{if(c.altKey){if(c.code==="Digit1"){n="direct",e?.setMode(n),c.preventDefault();return}if(c.code==="Digit2"){n="screen",e?.setMode(n),c.preventDefault();return}c.code==="Digit3"&&(n="implementation",e?.setMode(n),c.preventDefault())}},a=c=>{if(console.log("[react-code-locator] click",{triggerKey:r,shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,target:c.target}),!W(c,r))return;let m=L(c.target,n,o);if(!m){l(new Error("No React component source metadata found for clicked element."));return}c.preventDefault(),c.stopPropagation(),s(m)};return document.addEventListener("click",a,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("click",a,!0),document.removeEventListener("keydown",i,!0),e?.remove()}}0&&(module.exports={enableReactComponentJump,locateComponentSource});
2
2
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts","../src/constants.ts","../src/sourceMetadata.ts","../src/runtime.ts"],"sourcesContent":["export { enableReactComponentJump, locateComponentSource } from \"./runtime\";\nexport type { LocatorMode, LocatorOptions, LocatorResult, TriggerKey } from \"./runtime\";\n","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 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 projectRoot?: string;\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\nfunction normalizeSource(source: string, projectRoot: string | undefined): string {\n if (!projectRoot || !source) return source;\n const match = source.match(/^(.*):(\\d+):(\\d+)$/);\n if (!match) return source;\n const [, file, line, col] = match;\n const normalizedFile = file.replace(/\\\\/g, \"/\");\n const normalizedRoot = projectRoot.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n if (normalizedFile.startsWith(normalizedRoot + \"/\")) {\n return `${normalizedFile.slice(normalizedRoot.length + 1)}:${line}:${col}`;\n }\n return source;\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, projectRoot?: string): ResolvedCandidates {\n let current = fiber;\n const jsxCandidates: SourceCandidate[] = [];\n const componentCandidates: SourceCandidate[] = [];\n\n while (current) {\n const rawJsxSource =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n const jsxSource = normalizeSource(rawJsxSource ?? \"\", projectRoot) || rawJsxSource;\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 rawComponentSource = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n const componentSource = normalizeSource(rawComponentSource ?? \"\", projectRoot) || rawComponentSource;\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\", projectRoot?: string): 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, projectRoot);\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 if (process.env.NODE_ENV !== \"development\") return;\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n let currentMode: LocatorMode = \"screen\";\n const {\n triggerKey = \"shift\",\n projectRoot,\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, projectRoot);\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 over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oB,UAAWD,EAAY,EAAI,EACxDL,GAAS,OAAO,CAClB,CACF","names":["client_exports","__export","enableReactComponentJump","locateComponentSource","__toCommonJS","SOURCE_PROP","JSX_SOURCE_PROP","JSX_SOURCE_REGISTRY_SYMBOL","normalizeSlashes","value","trimTrailingSlash","splitPathSegments","computeRelativePath","fromPath","toPath","fromSegments","toSegments","sharedIndex","upSegments","downSegments","relativeSegments","normalizeProjectRoot","projectRoot","getSourceFile","source","isProjectLocalFile","filename","projectRoot","root","normalizeProjectRoot","normalizedFilename","normalizeSlashes","computeRelativePath","isProjectLocalSource","source","projectRoot","file","getSourceFile","isProjectLocalFile","isTriggerPressed","event","triggerKey","getReactFiberKey","element","key","getClosestReactFiber","target","current","fiberKey","getSourceFromType","type","source","SOURCE_PROP","record","getSourceFromProps","props","registry","JSX_SOURCE_REGISTRY_SYMBOL","intrinsicSource","JSX_SOURCE_PROP","resolveComponentSourceFromFiber","fiber","getDirectDebugSource","debugSource","normalizeSource","projectRoot","match","file","line","col","normalizedFile","normalizedRoot","resolveSourceCandidates","jsxCandidates","componentCandidates","rawJsxSource","jsxSource","getSourceFile","candidate","rawComponentSource","componentSource","direct","nearestProjectLocalComponentFile","isProjectLocalSource","screen","matchingJsxCandidate","matchingComponentCandidate","implementationComponentCandidate","implementationJsxCandidate","projectLocalJsxCandidate","screenFallback","getModeDescription","mode","createStatusOverlay","copyValue","currentMode","hideTimer","show","message","tone","mount","value","locateComponentSource","elementTarget","candidates","enableReactComponentJump","options","overlay","onLocate","result","onError","error","keyHandler","handler"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/constants.ts","../src/sourceMetadata.ts","../src/runtime.ts"],"sourcesContent":["export { enableReactComponentJump, locateComponentSource } from \"./runtime\";\nexport type { LocatorMode, LocatorOptions, LocatorResult, TriggerKey } from \"./runtime\";\n","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 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 projectRoot?: string;\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\nfunction normalizeSource(source: string, projectRoot: string | undefined): string {\n if (!projectRoot || !source) return source;\n const match = source.match(/^(.*):(\\d+):(\\d+)$/);\n if (!match) return source;\n const [, file, line, col] = match;\n const normalizedFile = file.replace(/\\\\/g, \"/\");\n const normalizedRoot = projectRoot.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n if (normalizedFile.startsWith(normalizedRoot + \"/\")) {\n return `${normalizedFile.slice(normalizedRoot.length + 1)}:${line}:${col}`;\n }\n return source;\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, projectRoot?: string): ResolvedCandidates {\n let current = fiber;\n const jsxCandidates: SourceCandidate[] = [];\n const componentCandidates: SourceCandidate[] = [];\n\n while (current) {\n const rawJsxSource =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n const jsxSource = normalizeSource(rawJsxSource ?? \"\", projectRoot) || rawJsxSource;\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 rawComponentSource = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n const componentSource = normalizeSource(rawComponentSource ?? \"\", projectRoot) || rawComponentSource;\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 console.log(\"[react-code-locator] DEBUG candidates\", {\n jsxCandidates,\n componentCandidates,\n projectRoot,\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\", projectRoot?: string): 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, projectRoot);\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 if (process.env.NODE_ENV !== \"development\") return;\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n let currentMode: LocatorMode = \"screen\";\n const {\n triggerKey = \"shift\",\n projectRoot,\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, projectRoot);\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"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,0BAAAC,IAAA,eAAAC,EAAAJ,GCAO,IAAMK,EAAc,uBACdC,EAAkB,sBAClBC,EAA6B,uCCG1C,SAASC,EAAiBC,EAAe,CACvC,OAAOA,EAAM,QAAQ,MAAO,GAAG,CACjC,CAEA,SAASC,EAAkBD,EAAe,CACxC,OAAOA,EAAM,QAAQ,OAAQ,EAAE,CACjC,CAEA,SAASE,EAAkBF,EAAe,CACxC,OAAOD,EAAiBC,CAAK,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,CAC1D,CAEA,SAASG,EAAoBC,EAAkBC,EAAgB,CAC7D,IAAMC,EAAeJ,EAAkBE,CAAQ,EACzCG,EAAaL,EAAkBG,CAAM,EAEvCG,EAAc,EAClB,KACEA,EAAcF,EAAa,QAC3BE,EAAcD,EAAW,QACzBD,EAAaE,CAAW,IAAMD,EAAWC,CAAW,GAEpDA,GAAe,EAGjB,IAAMC,EAAa,IAAI,MAAM,KAAK,IAAI,EAAGH,EAAa,OAASE,CAAW,CAAC,EAAE,KAAK,IAAI,EAChFE,EAAeH,EAAW,MAAMC,CAAW,EAC3CG,EAAmB,CAAC,GAAGF,EAAY,GAAGC,CAAY,EACxD,OAAOC,EAAiB,OAAS,EAAIA,EAAiB,KAAK,GAAG,EAAI,GACpE,CAEO,SAASC,EAAqBC,EAAsB,CACzD,OAAIA,EACKZ,EAAkBF,EAAiBc,CAAW,CAAC,EAEjD,EACT,CAsBO,SAASC,EAAcC,EAAuB,CACnD,OAAKA,EAISA,EAAO,MAAM,gBAAgB,IAC5B,CAAC,GAAK,KAJZ,IAKX,CAEO,SAASC,EAAmBC,EAA8BC,EAAsB,CACrF,GAAI,CAACD,EACH,MAAO,GAGT,IAAME,EAAOC,EAAqBF,CAAW,EAC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CACjB,EAEA,gBAAS,iBAAiB,QAASI,EAAS,EAAI,EAChD,SAAS,iBAAiB,UAAWD,EAAY,EAAI,EAE9C,IAAM,CACX,SAAS,oBAAoB,QAASC,EAAS,EAAI,EACnD,SAAS,oBAAoB,UAAWD,EAAY,EAAI,EACxDL,GAAS,OAAO,CAClB,CACF","names":["client_exports","__export","enableReactComponentJump","locateComponentSource","__toCommonJS","SOURCE_PROP","JSX_SOURCE_PROP","JSX_SOURCE_REGISTRY_SYMBOL","normalizeSlashes","value","trimTrailingSlash","splitPathSegments","computeRelativePath","fromPath","toPath","fromSegments","toSegments","sharedIndex","upSegments","downSegments","relativeSegments","normalizeProjectRoot","projectRoot","getSourceFile","source","isProjectLocalFile","filename","projectRoot","root","normalizeProjectRoot","normalizedFilename","normalizeSlashes","computeRelativePath","isProjectLocalSource","source","projectRoot","file","getSourceFile","isProjectLocalFile","isTriggerPressed","event","triggerKey","getReactFiberKey","element","key","getClosestReactFiber","target","current","fiberKey","getSourceFromType","type","source","SOURCE_PROP","record","getSourceFromProps","props","registry","JSX_SOURCE_REGISTRY_SYMBOL","intrinsicSource","JSX_SOURCE_PROP","resolveComponentSourceFromFiber","fiber","getDirectDebugSource","debugSource","normalizeSource","projectRoot","match","file","line","col","normalizedFile","normalizedRoot","resolveSourceCandidates","jsxCandidates","componentCandidates","rawJsxSource","jsxSource","getSourceFile","candidate","rawComponentSource","componentSource","direct","nearestProjectLocalComponentFile","isProjectLocalSource","screen","matchingJsxCandidate","matchingComponentCandidate","implementationComponentCandidate","implementationJsxCandidate","projectLocalJsxCandidate","screenFallback","getModeDescription","mode","createStatusOverlay","copyValue","currentMode","hideTimer","show","message","tone","mount","value","locateComponentSource","elementTarget","candidates","enableReactComponentJump","options","overlay","onLocate","result","onError","error","keyHandler","handler"]}
package/dist/client.js CHANGED
@@ -1,2 +1,2 @@
1
- var g="__componentSourceLoc",E="$componentSourceLoc",L="react-code-locator.jsxSourceRegistry";function C(t){return t.replace(/\\/g,"/")}function M(t){return t.replace(/\/+$/,"")}function w(t){return C(t).split("/").filter(Boolean)}function O(t,e){let n=w(t),r=w(e),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;let s=new Array(Math.max(0,n.length-o)).fill(".."),u=r.slice(o),i=[...s,...u];return i.length>0?i.join("/"):"."}function F(t){return t?M(C(t)):""}function b(t){return t?t.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function T(t,e){if(!t)return!1;let n=F(e),r=C(t);return n?r.startsWith(`${n}/`)||r===n?!0:!O(n,r).startsWith("../"):!r.startsWith("../")&&!r.startsWith("/")&&!/^[A-Za-z]:\//.test(r)}function f(t,e){let n=b(t);return T(n??void 0,e)}function _(t,e){return e==="none"?!0:e==="alt"?t.altKey:e==="meta"?t.metaKey:e==="ctrl"?t.ctrlKey:t.shiftKey}function $(t){return Object.keys(t).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))}function K(t){let e=t;for(;e;){let n=$(e);if(n)return e[n];e=e.parentElement}return null}function h(t){if(!t)return null;if(typeof t=="function"){let r=t[g];return typeof r=="string"?r:null}if(typeof t!="object")return null;let e=t,n=e[g]??e.type?.[g]??e.render?.[g];return typeof n=="string"?n:null}function v(t){if(t&&typeof t=="object"){let n=globalThis[Symbol.for(L)];if(n instanceof WeakMap){let r=n.get(t);if(typeof r=="string")return r}}let e=t?.[E];return typeof e=="string"?e:null}function j(t){let e=t;for(;e;){let n=h(e.type)??h(e.elementType);if(n)return n;e=e.return??null}return null}function D(t){let e=t?._debugSource;return e?.fileName&&typeof e.lineNumber=="number"?`${e.fileName.replace(/\\/g,"/")}:${e.lineNumber}:${e.columnNumber??1}`:null}function k(t,e){if(!e||!t)return t;let n=t.match(/^(.*):(\d+):(\d+)$/);if(!n)return t;let[,r,o,s]=n,u=r.replace(/\\/g,"/"),i=e.replace(/\\/g,"/").replace(/\/$/,"");return u.startsWith(i+"/")?`${u.slice(i.length+1)}:${o}:${s}`:t}function z(t,e){let n=t,r=[],o=[];for(;n;){let l=v(n.pendingProps)??v(n.memoizedProps)??D(n),d=k(l??"",e)||l;if(d){let p=b(d);p&&!r.some(x=>x.source===d)&&r.push({source:d,file:p})}let y=h(n.type)??h(n.elementType),S=k(y??"",e)||y;if(S){let p=b(S);p&&!o.some(x=>x.source===S)&&o.push({source:S,file:p})}n=n.return??null}let s=r[0]?.source??null,u=o.find(l=>f(l.source))?.file,i=null;if(u){let l=r.find(d=>d.file===u);if(l)i=l.source;else{let d=o.find(y=>y.file===u);d&&(i=d.source)}}let a=o.find(l=>!f(l.source))?.source??null,c=r.find(l=>!f(l.source))?.source??null,m=r.find(l=>f(l.source))?.source??null,R=i??m??o.find(l=>f(l.source))?.source??null;return{direct:s??R,screen:R,implementation:a??c??R}}function N(t){return t==="direct"?"Direct JSX":t==="screen"?"Screen source":"Implementation source"}function J(t){if(typeof document>"u")return null;let e=document.createElement("div"),n=null,r="screen",o=null;e.setAttribute("data-react-code-locator","true"),Object.assign(e.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let s=(i,a)=>{e.textContent=i,e.style.background=a==="success"?"rgba(6, 95, 70, 0.92)":a==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",e.style.opacity="1",e.style.pointerEvents="auto",o&&clearTimeout(o),o=setTimeout(()=>{e.style.opacity="0",e.style.pointerEvents="none"},2e3)};e.addEventListener("click",async()=>{if(n)try{await navigator.clipboard.writeText(n),s("[react-code-locator] copied","success")}catch{s("[react-code-locator] copy failed","error")}}),s(`[react-code-locator] enabled (${t}+click, alt+1/2/3 to switch mode)`,"idle");let u=()=>{!e.isConnected&&document.body&&document.body.appendChild(e)};return document.body?u():document.addEventListener("DOMContentLoaded",u,{once:!0}),{setStatus(i,a="idle"){s(i,a)},setCopyValue(i){n=i},setMode(i){r=i,s(`[react-code-locator] ${N(i)}`,"idle")},remove(){o&&clearTimeout(o),e.remove()}}}function P(t,e="screen",n){let r=t instanceof Element?t:t instanceof Node?t.parentElement:null,o=K(r);if(!o)return null;let s=z(o,n),u=s[e]??s.screen??s.direct??s.implementation;if(u)return{source:u,mode:e};let i=j(o);return i?{source:i,mode:e}:null}function W(t={}){if(process.env.NODE_ENV!=="development")return;let e=J(t.triggerKey??"shift"),n="screen",{triggerKey:r="shift",projectRoot:o,onLocate:s=c=>{console.log(`[react-code-locator] ${c.source}`),e?.setCopyValue(c.source),e?.setStatus(`[react-code-locator] ${c.source}`,"success")},onError:u=c=>{console.error("[react-code-locator]",c);let m=c instanceof Error?c.message:String(c);e?.setCopyValue(null),e?.setStatus(`[react-code-locator] ${m}`,"error")}}=t;console.log("[react-code-locator] enabled",{triggerKey:r});let i=c=>{if(c.altKey){if(c.code==="Digit1"){n="direct",e?.setMode(n),c.preventDefault();return}if(c.code==="Digit2"){n="screen",e?.setMode(n),c.preventDefault();return}c.code==="Digit3"&&(n="implementation",e?.setMode(n),c.preventDefault())}},a=c=>{if(console.log("[react-code-locator] click",{triggerKey:r,shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,target:c.target}),!_(c,r))return;let m=P(c.target,n,o);if(!m){u(new Error("No React component source metadata found for clicked element."));return}c.preventDefault(),c.stopPropagation(),s(m)};return document.addEventListener("click",a,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("click",a,!0),document.removeEventListener("keydown",i,!0),e?.remove()}}export{W as enableReactComponentJump,P as locateComponentSource};
1
+ var g="__componentSourceLoc",E="$componentSourceLoc",L="react-code-locator.jsxSourceRegistry";function C(t){return t.replace(/\\/g,"/")}function M(t){return t.replace(/\/+$/,"")}function w(t){return C(t).split("/").filter(Boolean)}function O(t,e){let n=w(t),r=w(e),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o+=1;let s=new Array(Math.max(0,n.length-o)).fill(".."),l=r.slice(o),i=[...s,...l];return i.length>0?i.join("/"):"."}function F(t){return t?M(C(t)):""}function b(t){return t?t.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function T(t,e){if(!t)return!1;let n=F(e),r=C(t);return n?r.startsWith(`${n}/`)||r===n?!0:!O(n,r).startsWith("../"):!r.startsWith("../")&&!r.startsWith("/")&&!/^[A-Za-z]:\//.test(r)}function f(t,e){let n=b(t);return T(n??void 0,e)}function _(t,e){return e==="none"?!0:e==="alt"?t.altKey:e==="meta"?t.metaKey:e==="ctrl"?t.ctrlKey:t.shiftKey}function $(t){return Object.keys(t).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))}function K(t){let e=t;for(;e;){let n=$(e);if(n)return e[n];e=e.parentElement}return null}function h(t){if(!t)return null;if(typeof t=="function"){let r=t[g];return typeof r=="string"?r:null}if(typeof t!="object")return null;let e=t,n=e[g]??e.type?.[g]??e.render?.[g];return typeof n=="string"?n:null}function v(t){if(t&&typeof t=="object"){let n=globalThis[Symbol.for(L)];if(n instanceof WeakMap){let r=n.get(t);if(typeof r=="string")return r}}let e=t?.[E];return typeof e=="string"?e:null}function j(t){let e=t;for(;e;){let n=h(e.type)??h(e.elementType);if(n)return n;e=e.return??null}return null}function D(t){let e=t?._debugSource;return e?.fileName&&typeof e.lineNumber=="number"?`${e.fileName.replace(/\\/g,"/")}:${e.lineNumber}:${e.columnNumber??1}`:null}function k(t,e){if(!e||!t)return t;let n=t.match(/^(.*):(\d+):(\d+)$/);if(!n)return t;let[,r,o,s]=n,l=r.replace(/\\/g,"/"),i=e.replace(/\\/g,"/").replace(/\/$/,"");return l.startsWith(i+"/")?`${l.slice(i.length+1)}:${o}:${s}`:t}function z(t,e){let n=t,r=[],o=[];for(;n;){let u=v(n.pendingProps)??v(n.memoizedProps)??D(n),d=k(u??"",e)||u;if(d){let p=b(d);p&&!r.some(x=>x.source===d)&&r.push({source:d,file:p})}let y=h(n.type)??h(n.elementType),S=k(y??"",e)||y;if(S){let p=b(S);p&&!o.some(x=>x.source===S)&&o.push({source:S,file:p})}n=n.return??null}console.log("[react-code-locator] DEBUG candidates",{jsxCandidates:r,componentCandidates:o,projectRoot:e});let s=r[0]?.source??null,l=o.find(u=>f(u.source))?.file,i=null;if(l){let u=r.find(d=>d.file===l);if(u)i=u.source;else{let d=o.find(y=>y.file===l);d&&(i=d.source)}}let a=o.find(u=>!f(u.source))?.source??null,c=r.find(u=>!f(u.source))?.source??null,m=r.find(u=>f(u.source))?.source??null,R=i??m??o.find(u=>f(u.source))?.source??null;return{direct:s??R,screen:R,implementation:a??c??R}}function N(t){return t==="direct"?"Direct JSX":t==="screen"?"Screen source":"Implementation source"}function J(t){if(typeof document>"u")return null;let e=document.createElement("div"),n=null,r="screen",o=null;e.setAttribute("data-react-code-locator","true"),Object.assign(e.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let s=(i,a)=>{e.textContent=i,e.style.background=a==="success"?"rgba(6, 95, 70, 0.92)":a==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",e.style.opacity="1",e.style.pointerEvents="auto",o&&clearTimeout(o),o=setTimeout(()=>{e.style.opacity="0",e.style.pointerEvents="none"},2e3)};e.addEventListener("click",async()=>{if(n)try{await navigator.clipboard.writeText(n),s("[react-code-locator] copied","success")}catch{s("[react-code-locator] copy failed","error")}}),s(`[react-code-locator] enabled (${t}+click, alt+1/2/3 to switch mode)`,"idle");let l=()=>{!e.isConnected&&document.body&&document.body.appendChild(e)};return document.body?l():document.addEventListener("DOMContentLoaded",l,{once:!0}),{setStatus(i,a="idle"){s(i,a)},setCopyValue(i){n=i},setMode(i){r=i,s(`[react-code-locator] ${N(i)}`,"idle")},remove(){o&&clearTimeout(o),e.remove()}}}function P(t,e="screen",n){let r=t instanceof Element?t:t instanceof Node?t.parentElement:null,o=K(r);if(!o)return null;let s=z(o,n),l=s[e]??s.screen??s.direct??s.implementation;if(l)return{source:l,mode:e};let i=j(o);return i?{source:i,mode:e}:null}function W(t={}){if(process.env.NODE_ENV!=="development")return;let e=J(t.triggerKey??"shift"),n="screen",{triggerKey:r="shift",projectRoot:o,onLocate:s=c=>{console.log(`[react-code-locator] ${c.source}`),e?.setCopyValue(c.source),e?.setStatus(`[react-code-locator] ${c.source}`,"success")},onError:l=c=>{console.error("[react-code-locator]",c);let m=c instanceof Error?c.message:String(c);e?.setCopyValue(null),e?.setStatus(`[react-code-locator] ${m}`,"error")}}=t;console.log("[react-code-locator] enabled",{triggerKey:r});let i=c=>{if(c.altKey){if(c.code==="Digit1"){n="direct",e?.setMode(n),c.preventDefault();return}if(c.code==="Digit2"){n="screen",e?.setMode(n),c.preventDefault();return}c.code==="Digit3"&&(n="implementation",e?.setMode(n),c.preventDefault())}},a=c=>{if(console.log("[react-code-locator] click",{triggerKey:r,shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,target:c.target}),!_(c,r))return;let m=P(c.target,n,o);if(!m){l(new Error("No React component source metadata found for clicked element."));return}c.preventDefault(),c.stopPropagation(),s(m)};return document.addEventListener("click",a,!0),document.addEventListener("keydown",i,!0),()=>{document.removeEventListener("click",a,!0),document.removeEventListener("keydown",i,!0),e?.remove()}}export{W as enableReactComponentJump,P as locateComponentSource};
2
2
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts","../src/sourceMetadata.ts","../src/runtime.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 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 projectRoot?: string;\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\nfunction normalizeSource(source: string, projectRoot: string | undefined): string {\n if (!projectRoot || !source) return source;\n const match = source.match(/^(.*):(\\d+):(\\d+)$/);\n if (!match) return source;\n const [, file, line, col] = match;\n const normalizedFile = file.replace(/\\\\/g, \"/\");\n const normalizedRoot = projectRoot.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n if (normalizedFile.startsWith(normalizedRoot + \"/\")) {\n return `${normalizedFile.slice(normalizedRoot.length + 1)}:${line}:${col}`;\n }\n return source;\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, projectRoot?: string): ResolvedCandidates {\n let current = fiber;\n const jsxCandidates: SourceCandidate[] = [];\n const componentCandidates: SourceCandidate[] = [];\n\n while (current) {\n const rawJsxSource =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n const jsxSource = normalizeSource(rawJsxSource ?? \"\", projectRoot) || rawJsxSource;\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 rawComponentSource = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n const componentSource = normalizeSource(rawComponentSource ?? \"\", projectRoot) || rawComponentSource;\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\", projectRoot?: string): 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, projectRoot);\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 if (process.env.NODE_ENV !== \"development\") return;\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n let currentMode: LocatorMode = \"screen\";\n const {\n triggerKey = \"shift\",\n projectRoot,\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, projectRoot);\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"],"mappings":"AAAO,IAAMA,EAAc,uBACdC,EAAkB,sBAClBC,EAA6B,uCCG1C,SAASC,EAAiBC,EAAe,CACvC,OAAOA,EAAM,QAAQ,MAAO,GAAG,CACjC,CAEA,SAASC,EAAkBD,EAAe,CACxC,OAAOA,EAAM,QAAQ,OAAQ,EAAE,CACjC,CAEA,SAASE,EAAkBF,EAAe,CACxC,OAAOD,EAAiBC,CAAK,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,CAC1D,CAEA,SAASG,EAAoBC,EAAkBC,EAAgB,CAC7D,IAAMC,EAAeJ,EAAkBE,CAAQ,EACzCG,EAAaL,EAAkBG,CAAM,EAEvCG,EAAc,EAClB,KACEA,EAAcF,EAAa,QAC3BE,EAAcD,EAAW,QACzBD,EAAaE,CAAW,IAAMD,EAAWC,CAAW,GAEpDA,GAAe,EAGjB,IAAMC,EAAa,IAAI,MAAM,KAAK,IAAI,EAAGH,EAAa,OAASE,CAAW,CAAC,EAAE,KAAK,IAAI,EAChFE,EAAeH,EAAW,MAAMC,CAAW,EAC3CG,EAAmB,CAAC,GAAGF,EAAY,GAAGC,CAAY,EACxD,OAAOC,EAAiB,OAAS,EAAIA,EAAiB,KAAK,GAAG,EAAI,GACpE,CAEO,SAASC,EAAqBC,EAAsB,CACzD,OAAIA,EACKZ,EAAkBF,EAAiBc,CAAW,CAAC,EAEjD,EACT,CAsBO,SAASC,EAAcC,EAAuB,CACnD,OAAKA,EAISA,EAAO,MAAM,gBAAgB,IAC5B,CAAC,GAAK,KAJZ,IAKX,CAEO,SAASC,EAAmBC,EAA8BC,EAAsB,CACrF,GAAI,CAACD,EACH,MAAO,GAGT,I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ChD,SAAS,iBAAiB,UAAWD,EAAY,EAAI,EAE9C,IAAM,CACX,SAAS,oBAAoB,QAASC,EAAS,EAAI,EACnD,SAAS,oBAAoB,UAAWD,EAAY,EAAI,EACxDL,GAAS,OAAO,CAClB,CACF","names":["SOURCE_PROP","JSX_SOURCE_PROP","JSX_SOURCE_REGISTRY_SYMBOL","normalizeSlashes","value","trimTrailingSlash","splitPathSegments","computeRelativePath","fromPath","toPath","fromSegments","toSegments","sharedIndex","upSegments","downSegments","relativeSegments","normalizeProjectRoot","projectRoot","getSourceFile","source","isProjectLocalFile","filename","projectRoot","root","normalizeProjectRoot","normalizedFilename","normalizeSlashes","computeRelativePath","isProjectLocalSource","source","projectRoot","file","getSourceFile","isProjectLocalFile","isTriggerPressed","event","triggerKey","getReactFiberKey","element","key","getClosestReactFiber","target","current","fiberKey","getSourceFromType","type","source","SOURCE_PROP","record","getSourceFromProps","props","registry","JSX_SOURCE_REGISTRY_SYMBOL","intrinsicSource","JSX_SOURCE_PROP","resolveComponentSourceFromFiber","fiber","getDirectDebugSource","debugSource","normalizeSource","projectRoot","match","file","line","col","normalizedFile","normalizedRoot","resolveSourceCandidates","jsxCandidates","componentCandidates","rawJsxSource","jsxSource","getSourceFile","candidate","rawComponentSource","componentSource","direct","nearestProjectLocalComponentFile","isProjectLocalSource","screen","matchingJsxCandidate","matchingComponentCandidate","implementationComponentCandidate","implementationJsxCandidate","projectLocalJsxCandidate","screenFallback","getModeDescription","mode","createStatusOverlay","copyValue","currentMode","hideTimer","show","message","tone","mount","value","locateComponentSource","elementTarget","candidates","enableReactComponentJump","options","overlay","onLocate","result","onError","error","keyHandler","handler"]}
1
+ {"version":3,"sources":["../src/constants.ts","../src/sourceMetadata.ts","../src/runtime.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 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 projectRoot?: string;\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\nfunction normalizeSource(source: string, projectRoot: string | undefined): string {\n if (!projectRoot || !source) return source;\n const match = source.match(/^(.*):(\\d+):(\\d+)$/);\n if (!match) return source;\n const [, file, line, col] = match;\n const normalizedFile = file.replace(/\\\\/g, \"/\");\n const normalizedRoot = projectRoot.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n if (normalizedFile.startsWith(normalizedRoot + \"/\")) {\n return `${normalizedFile.slice(normalizedRoot.length + 1)}:${line}:${col}`;\n }\n return source;\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, projectRoot?: string): ResolvedCandidates {\n let current = fiber;\n const jsxCandidates: SourceCandidate[] = [];\n const componentCandidates: SourceCandidate[] = [];\n\n while (current) {\n const rawJsxSource =\n getSourceFromProps(current.pendingProps) ?? getSourceFromProps(current.memoizedProps) ?? getDirectDebugSource(current);\n const jsxSource = normalizeSource(rawJsxSource ?? \"\", projectRoot) || rawJsxSource;\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 rawComponentSource = getSourceFromType(current.type) ?? getSourceFromType(current.elementType);\n const componentSource = normalizeSource(rawComponentSource ?? \"\", projectRoot) || rawComponentSource;\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 console.log(\"[react-code-locator] DEBUG candidates\", {\n jsxCandidates,\n componentCandidates,\n projectRoot,\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\", projectRoot?: string): 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, projectRoot);\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 if (process.env.NODE_ENV !== \"development\") return;\n const overlay = createStatusOverlay(options.triggerKey ?? \"shift\");\n let currentMode: LocatorMode = \"screen\";\n const {\n triggerKey = \"shift\",\n projectRoot,\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, projectRoot);\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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,EAAS,EAAI,EACnD,SAAS,oBAAoB,UAAWD,EAAY,EAAI,EACxDL,GAAS,OAAO,CAClB,CACF","names":["SOURCE_PROP","JSX_SOURCE_PROP","JSX_SOURCE_REGISTRY_SYMBOL","normalizeSlashes","value","trimTrailingSlash","splitPathSegments","computeRelativePath","fromPath","toPath","fromSegments","toSegments","sharedIndex","upSegments","downSegments","relativeSegments","normalizeProjectRoot","projectRoot","getSourceFile","source","isProjectLocalFile","filename","projectRoot","root","normalizeProjectRoot","normalizedFilename","normalizeSlashes","computeRelativePath","isProjectLocalSource","source","projectRoot","file","getSourceFile","isProjectLocalFile","isTriggerPressed","event","triggerKey","getReactFiberKey","element","key","getClosestReactFiber","target","current","fiberKey","getSourceFromType","type","source","SOURCE_PROP","record","getSourceFromProps","props","registry","JSX_SOURCE_REGISTRY_SYMBOL","intrinsicSource","JSX_SOURCE_PROP","resolveComponentSourceFromFiber","fiber","getDirectDebugSource","debugSource","normalizeSource","projectRoot","match","file","line","col","normalizedFile","normalizedRoot","resolveSourceCandidates","jsxCandidates","componentCandidates","rawJsxSource","jsxSource","getSourceFile","candidate","rawComponentSource","componentSource","direct","nearestProjectLocalComponentFile","isProjectLocalSource","screen","matchingJsxCandidate","matchingComponentCandidate","implementationComponentCandidate","implementationJsxCandidate","projectLocalJsxCandidate","screenFallback","getModeDescription","mode","createStatusOverlay","copyValue","currentMode","hideTimer","show","message","tone","mount","value","locateComponentSource","elementTarget","candidates","enableReactComponentJump","options","overlay","onLocate","result","onError","error","keyHandler","handler"]}
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@ Defaulting to 2020, but this will stop working in the future.`)),a.ecmaVersion=1
8
8
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},xe.readEscapedChar=function(t){var a=this.input.charCodeAt(++this.pos);switch(++this.pos,a){case 110:return`
9
9
  `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return o(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),t){var c=this.pos-1;this.invalidStringToken(c,"Invalid escape sequence in template string")}default:if(a>=48&&a<=55){var p=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],v=parseInt(p,8);return v>255&&(p=p.slice(0,-1),v=parseInt(p,8)),this.pos+=p.length-1,a=this.input.charCodeAt(this.pos),(p!=="0"||a===56||a===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-p.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(v)}return ne(a)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(a)}},xe.readHexChar=function(t){var a=this.pos,c=this.readInt(16,t);return c===null&&this.invalidStringToken(a,"Bad character escape sequence"),c},xe.readWord1=function(){this.containsEsc=!1;for(var t="",a=!0,c=this.pos,p=this.options.ecmaVersion>=6;this.pos<this.input.length;){var v=this.fullCharCodeAtPos();if(_(v,p))this.pos+=v<=65535?1:2;else if(v===92){this.containsEsc=!0,t+=this.input.slice(c,this.pos);var T=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var O=this.readCodePoint();(a?F:_)(O,p)||this.invalidStringToken(T,"Invalid Unicode escape"),t+=o(O),c=this.pos}else break;a=!1}return t+this.input.slice(c,this.pos)},xe.readWord=function(){var t=this.readWord1(),a=d.name;return this.keywords.test(t)&&(a=z[t]),this.finishToken(a,t)};var gr="8.16.0";be.acorn={Parser:be,version:gr,defaultOptions:w,Position:y,SourceLocation:C,getLineInfo:A,Node:Wt,TokenType:k,tokTypes:d,keywordTypes:z,TokContext:We,tokContexts:Ce,isIdentifierChar:_,isIdentifierStart:F,Token:yi,isNewLine:ne,lineBreak:re,lineBreakG:X,nonASCIIwhitespace:Z};function zo(t,a){return be.parse(t,a)}function Xo(t,a,c){return be.parseExpressionAt(t,a,c)}function Jo(t,a){return be.tokenizer(t,a)}e.Node=Wt,e.Parser=be,e.Position=y,e.SourceLocation=C,e.TokContext=We,e.Token=yi,e.TokenType=k,e.defaultOptions=w,e.getLineInfo=A,e.isIdentifierChar=_,e.isIdentifierStart=F,e.isNewLine=ne,e.keywordTypes=z,e.lineBreak=re,e.lineBreakG=X,e.nonASCIIwhitespace=Z,e.parse=zo,e.parseExpressionAt=Xo,e.tokContexts=Ce,e.tokTypes=d,e.tokenizer=Jo,e.version=gr}))});var Zn=at((wp,Fs)=>{"use strict";var fl=Xn(),dl=/^[\da-fA-F]+$/,ml=/^\d+$/,Qn=new WeakMap;function Yn(e){e=e.Parser.acorn||e;let i=Qn.get(e);if(!i){let s=e.tokTypes,n=e.TokContext,u=e.TokenType,l=new n("<tag",!1),m=new n("</tag",!1),g=new n("<tag>...</tag>",!0,!0),S={tc_oTag:l,tc_cTag:m,tc_expr:g},h={jsxName:new u("jsxName"),jsxText:new u("jsxText",{beforeExpr:!0}),jsxTagStart:new u("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new u("jsxTagEnd")};h.jsxTagStart.updateContext=function(){this.context.push(g),this.context.push(l),this.exprAllowed=!1},h.jsxTagEnd.updateContext=function(P){let E=this.context.pop();E===l&&P===s.slash||E===m?(this.context.pop(),this.exprAllowed=this.curContext()===g):this.exprAllowed=!0},i={tokContexts:S,tokTypes:h},Qn.set(e,i)}return i}function ni(e){if(!e)return e;if(e.type==="JSXIdentifier")return e.name;if(e.type==="JSXNamespacedName")return e.namespace.name+":"+e.name.name;if(e.type==="JSXMemberExpression")return ni(e.object)+"."+ni(e.property)}Fs.exports=function(e){return e=e||{},function(i){return xl({allowNamespaces:e.allowNamespaces!==!1,allowNamespacedObjects:!!e.allowNamespacedObjects},i)}};Object.defineProperty(Fs.exports,"tokTypes",{get:function(){return Yn(Ds()).tokTypes},configurable:!0,enumerable:!0});function xl(e,i){let s=i.acorn||Ds(),n=Yn(s),u=s.tokTypes,l=n.tokTypes,m=s.tokContexts,g=n.tokContexts.tc_oTag,S=n.tokContexts.tc_cTag,h=n.tokContexts.tc_expr,P=s.isNewLine,E=s.isIdentifierStart,F=s.isIdentifierChar;return class extends i{static get acornJsx(){return n}jsx_readToken(){let _="",k=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");let D=this.input.charCodeAt(this.pos);switch(D){case 60:case 123:return this.pos===this.start?D===60&&this.exprAllowed?(++this.pos,this.finishToken(l.jsxTagStart)):this.getTokenFromCode(D):(_+=this.input.slice(k,this.pos),this.finishToken(l.jsxText,_));case 38:_+=this.input.slice(k,this.pos),_+=this.jsx_readEntity(),k=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(D===62?"&gt;":"&rbrace;")+'` or `{"'+this.input[this.pos]+'"}`?');default:P(D)?(_+=this.input.slice(k,this.pos),_+=this.jsx_readNewLine(!0),k=this.pos):++this.pos}}}jsx_readNewLine(_){let k=this.input.charCodeAt(this.pos),D;return++this.pos,k===13&&this.input.charCodeAt(this.pos)===10?(++this.pos,D=_?`
10
10
  `:`\r
11
- `):D=String.fromCharCode(k),this.options.locations&&(++this.curLine,this.lineStart=this.pos),D}jsx_readString(_){let k="",D=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");let R=this.input.charCodeAt(this.pos);if(R===_)break;R===38?(k+=this.input.slice(D,this.pos),k+=this.jsx_readEntity(),D=this.pos):P(R)?(k+=this.input.slice(D,this.pos),k+=this.jsx_readNewLine(!1),D=this.pos):++this.pos}return k+=this.input.slice(D,this.pos++),this.finishToken(u.string,k)}jsx_readEntity(){let _="",k=0,D,R=this.input[this.pos];R!=="&"&&this.raise(this.pos,"Entity must start with an ampersand");let H=++this.pos;for(;this.pos<this.input.length&&k++<10;){if(R=this.input[this.pos++],R===";"){_[0]==="#"?_[1]==="x"?(_=_.substr(2),dl.test(_)&&(D=String.fromCharCode(parseInt(_,16)))):(_=_.substr(1),ml.test(_)&&(D=String.fromCharCode(parseInt(_,10)))):D=fl[_];break}_+=R}return D||(this.pos=H,"&")}jsx_readWord(){let _,k=this.pos;do _=this.input.charCodeAt(++this.pos);while(F(_)||_===45);return this.finishToken(l.jsxName,this.input.slice(k,this.pos))}jsx_parseIdentifier(){let _=this.startNode();return this.type===l.jsxName?_.name=this.value:this.type.keyword?_.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(_,"JSXIdentifier")}jsx_parseNamespacedName(){let _=this.start,k=this.startLoc,D=this.jsx_parseIdentifier();if(!e.allowNamespaces||!this.eat(u.colon))return D;var R=this.startNodeAt(_,k);return R.namespace=D,R.name=this.jsx_parseIdentifier(),this.finishNode(R,"JSXNamespacedName")}jsx_parseElementName(){if(this.type===l.jsxTagEnd)return"";let _=this.start,k=this.startLoc,D=this.jsx_parseNamespacedName();for(this.type===u.dot&&D.type==="JSXNamespacedName"&&!e.allowNamespacedObjects&&this.unexpected();this.eat(u.dot);){let R=this.startNodeAt(_,k);R.object=D,R.property=this.jsx_parseIdentifier(),D=this.finishNode(R,"JSXMemberExpression")}return D}jsx_parseAttributeValue(){switch(this.type){case u.braceL:let _=this.jsx_parseExpressionContainer();return _.expression.type==="JSXEmptyExpression"&&this.raise(_.start,"JSX attributes must only be assigned a non-empty expression"),_;case l.jsxTagStart:case u.string:return this.parseExprAtom();default:this.raise(this.start,"JSX value should be either an expression or a quoted JSX text")}}jsx_parseEmptyExpression(){let _=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(_,"JSXEmptyExpression",this.start,this.startLoc)}jsx_parseExpressionContainer(){let _=this.startNode();return this.next(),_.expression=this.type===u.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(u.braceR),this.finishNode(_,"JSXExpressionContainer")}jsx_parseAttribute(){let _=this.startNode();return this.eat(u.braceL)?(this.expect(u.ellipsis),_.argument=this.parseMaybeAssign(),this.expect(u.braceR),this.finishNode(_,"JSXSpreadAttribute")):(_.name=this.jsx_parseNamespacedName(),_.value=this.eat(u.eq)?this.jsx_parseAttributeValue():null,this.finishNode(_,"JSXAttribute"))}jsx_parseOpeningElementAt(_,k){let D=this.startNodeAt(_,k);D.attributes=[];let R=this.jsx_parseElementName();for(R&&(D.name=R);this.type!==u.slash&&this.type!==l.jsxTagEnd;)D.attributes.push(this.jsx_parseAttribute());return D.selfClosing=this.eat(u.slash),this.expect(l.jsxTagEnd),this.finishNode(D,R?"JSXOpeningElement":"JSXOpeningFragment")}jsx_parseClosingElementAt(_,k){let D=this.startNodeAt(_,k),R=this.jsx_parseElementName();return R&&(D.name=R),this.expect(l.jsxTagEnd),this.finishNode(D,R?"JSXClosingElement":"JSXClosingFragment")}jsx_parseElementAt(_,k){let D=this.startNodeAt(_,k),R=[],H=this.jsx_parseOpeningElementAt(_,k),z=null;if(!H.selfClosing){e:for(;;)switch(this.type){case l.jsxTagStart:if(_=this.start,k=this.startLoc,this.next(),this.eat(u.slash)){z=this.jsx_parseClosingElementAt(_,k);break e}R.push(this.jsx_parseElementAt(_,k));break;case l.jsxText:R.push(this.parseExprAtom());break;case u.braceL:R.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}ni(z.name)!==ni(H.name)&&this.raise(z.start,"Expected corresponding JSX closing tag for <"+ni(H.name)+">")}let G=H.name?"Element":"Fragment";return D["opening"+G]=H,D["closing"+G]=z,D.children=R,this.type===u.relational&&this.value==="<"&&this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(D,"JSX"+G)}jsx_parseText(){let _=this.parseLiteral(this.value);return _.type="JSXText",_}jsx_parseElement(){let _=this.start,k=this.startLoc;return this.next(),this.jsx_parseElementAt(_,k)}parseExprAtom(_){return this.type===l.jsxText?this.jsx_parseText():this.type===l.jsxTagStart?this.jsx_parseElement():super.parseExprAtom(_)}readToken(_){let k=this.curContext();if(k===h)return this.jsx_readToken();if(k===g||k===S){if(E(_))return this.jsx_readWord();if(_==62)return++this.pos,this.finishToken(l.jsxTagEnd);if((_===34||_===39)&&k==g)return this.jsx_readString(_)}return _===60&&this.exprAllowed&&this.input.charCodeAt(this.pos+1)!==33?(++this.pos,this.finishToken(l.jsxTagStart)):super.readToken(_)}updateContext(_){if(this.type==u.braceL){var k=this.curContext();k==g?this.context.push(m.b_expr):k==h?this.context.push(m.b_tmpl):super.updateContext(_),this.exprAllowed=!0}else if(this.type===u.slash&&_===l.jsxTagStart)this.context.length-=2,this.context.push(S),this.exprAllowed=!1;else return super.updateContext(_)}}}});var Ll={};vr(Ll,{default:()=>yo,enableReactComponentJump:()=>kr,esbuildPlugin:()=>So,locateComponentSource:()=>es,rollupPlugin:()=>bo,rspackPlugin:()=>Co,vitePlugin:()=>go,webpackPlugin:()=>vo});module.exports=iu(Ll);var dt="__componentSourceLoc",Kt="$componentSourceLoc",Sr="react-code-locator.jsxSourceRegistry";function Zi(e){return e.replace(/\\/g,"/")}function su(e){return e.replace(/\/+$/,"")}function Cr(e){return Zi(e).split("/").filter(Boolean)}function ru(e,i){let s=Cr(e),n=Cr(i),u=0;for(;u<s.length&&u<n.length&&s[u]===n[u];)u+=1;let l=new Array(Math.max(0,s.length-u)).fill(".."),m=n.slice(u),g=[...l,...m];return g.length>0?g.join("/"):"."}function au(e){return e?su(Zi(e)):""}function bi(e){return e?e.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function nu(e,i){if(!e)return!1;let s=au(i),n=Zi(e);return s?n.startsWith(`${s}/`)||n===s?!0:!ru(s,n).startsWith("../"):!n.startsWith("../")&&!n.startsWith("/")&&!/^[A-Za-z]:\//.test(n)}function Nt(e,i){let s=bi(e);return nu(s??void 0,i)}function ou(e,i){return i==="none"?!0:i==="alt"?e.altKey:i==="meta"?e.metaKey:i==="ctrl"?e.ctrlKey:e.shiftKey}function uu(e){return Object.keys(e).find(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"))}function cu(e){let i=e;for(;i;){let s=uu(i);if(s)return i[s];i=i.parentElement}return null}function Si(e){if(!e)return null;if(typeof e=="function"){let n=e[dt];return typeof n=="string"?n:null}if(typeof e!="object")return null;let i=e,s=i[dt]??i.type?.[dt]??i.render?.[dt];return typeof s=="string"?s:null}function _r(e){if(e&&typeof e=="object"){let s=globalThis[Symbol.for(Sr)];if(s instanceof WeakMap){let n=s.get(e);if(typeof n=="string")return n}}let i=e?.[Kt];return typeof i=="string"?i:null}function hu(e){let i=e;for(;i;){let s=Si(i.type)??Si(i.elementType);if(s)return s;i=i.return??null}return null}function lu(e){let i=e?._debugSource;return i?.fileName&&typeof i.lineNumber=="number"?`${i.fileName.replace(/\\/g,"/")}:${i.lineNumber}:${i.columnNumber??1}`:null}function Ar(e,i){if(!i||!e)return e;let s=e.match(/^(.*):(\d+):(\d+)$/);if(!s)return e;let[,n,u,l]=s,m=n.replace(/\\/g,"/"),g=i.replace(/\\/g,"/").replace(/\/$/,"");return m.startsWith(g+"/")?`${m.slice(g.length+1)}:${u}:${l}`:e}function pu(e,i){let s=e,n=[],u=[];for(;s;){let F=_r(s.pendingProps)??_r(s.memoizedProps)??lu(s),_=Ar(F??"",i)||F;if(_){let R=bi(_);R&&!n.some(H=>H.source===_)&&n.push({source:_,file:R})}let k=Si(s.type)??Si(s.elementType),D=Ar(k??"",i)||k;if(D){let R=bi(D);R&&!u.some(H=>H.source===D)&&u.push({source:D,file:R})}s=s.return??null}let l=n[0]?.source??null,m=u.find(F=>Nt(F.source))?.file,g=null;if(m){let F=n.find(_=>_.file===m);if(F)g=F.source;else{let _=u.find(k=>k.file===m);_&&(g=_.source)}}let S=u.find(F=>!Nt(F.source))?.source??null,h=n.find(F=>!Nt(F.source))?.source??null,P=n.find(F=>Nt(F.source))?.source??null,E=g??P??u.find(F=>Nt(F.source))?.source??null;return{direct:l??E,screen:E,implementation:S??h??E}}function fu(e){return e==="direct"?"Direct JSX":e==="screen"?"Screen source":"Implementation source"}function du(e){if(typeof document>"u")return null;let i=document.createElement("div"),s=null,n="screen",u=null;i.setAttribute("data-react-code-locator","true"),Object.assign(i.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let l=(g,S)=>{i.textContent=g,i.style.background=S==="success"?"rgba(6, 95, 70, 0.92)":S==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",i.style.opacity="1",i.style.pointerEvents="auto",u&&clearTimeout(u),u=setTimeout(()=>{i.style.opacity="0",i.style.pointerEvents="none"},2e3)};i.addEventListener("click",async()=>{if(s)try{await navigator.clipboard.writeText(s),l("[react-code-locator] copied","success")}catch{l("[react-code-locator] copy failed","error")}}),l(`[react-code-locator] enabled (${e}+click, alt+1/2/3 to switch mode)`,"idle");let m=()=>{!i.isConnected&&document.body&&document.body.appendChild(i)};return document.body?m():document.addEventListener("DOMContentLoaded",m,{once:!0}),{setStatus(g,S="idle"){l(g,S)},setCopyValue(g){s=g},setMode(g){n=g,l(`[react-code-locator] ${fu(g)}`,"idle")},remove(){u&&clearTimeout(u),i.remove()}}}function es(e,i="screen",s){let n=e instanceof Element?e:e instanceof Node?e.parentElement:null,u=cu(n);if(!u)return null;let l=pu(u,s),m=l[i]??l.screen??l.direct??l.implementation;if(m)return{source:m,mode:i};let g=hu(u);return g?{source:g,mode:i}:null}function kr(e={}){if(process.env.NODE_ENV!=="development")return;let i=du(e.triggerKey??"shift"),s="screen",{triggerKey:n="shift",projectRoot:u,onLocate:l=h=>{console.log(`[react-code-locator] ${h.source}`),i?.setCopyValue(h.source),i?.setStatus(`[react-code-locator] ${h.source}`,"success")},onError:m=h=>{console.error("[react-code-locator]",h);let P=h instanceof Error?h.message:String(h);i?.setCopyValue(null),i?.setStatus(`[react-code-locator] ${P}`,"error")}}=e;console.log("[react-code-locator] enabled",{triggerKey:n});let g=h=>{if(h.altKey){if(h.code==="Digit1"){s="direct",i?.setMode(s),h.preventDefault();return}if(h.code==="Digit2"){s="screen",i?.setMode(s),h.preventDefault();return}h.code==="Digit3"&&(s="implementation",i?.setMode(s),h.preventDefault())}},S=h=>{if(console.log("[react-code-locator] click",{triggerKey:n,shiftKey:h.shiftKey,altKey:h.altKey,ctrlKey:h.ctrlKey,metaKey:h.metaKey,target:h.target}),!ou(h,n))return;let P=es(h.target,s,u);if(!P){m(new Error("No React component source metadata found for clicked element."));return}h.preventDefault(),h.stopPropagation(),l(P)};return document.addEventListener("click",S,!0),document.addEventListener("keydown",g,!0),()=>{document.removeEventListener("click",S,!0),document.removeEventListener("keydown",g,!0),i?.remove()}}var Yr=require("path"),Zr=ft(zr(),1);function Ge(e){return e=e||[],Array.isArray(e)?e:[e]}var Wu=/\\/g;function Ai(e){return e.replace(Wu,"/")}var $u=/^(?:\/|(?:[A-Z]:)?[/\\|])/i;function Gu(e){return $u.test(e)}function Ku(e,i){return e.startsWith("**")||Gu(e)?Ai(e):Ai((0,Yr.resolve)(i,e))}function Xr(e){if(e instanceof RegExp)return s=>{let n=Ai(s),u=e.test(n);return e.lastIndex=0,u};let i=(0,Zr.default)(Ku(e,process.cwd()),{dot:!0});return s=>i(Ai(s))}function Jr(e){return e instanceof RegExp?i=>{let s=e.test(i);return e.lastIndex=0,s}:i=>i.includes(e)}function ea(e,i){if(!(!e&&!i))return s=>e?.some(n=>n(s))?!1:i?.some(n=>n(s))?!0:!(i&&i.length>0)}function ta(e){return typeof e=="string"||e instanceof RegExp?{include:[e]}:Array.isArray(e)?{include:e}:{exclude:e.exclude?Ge(e.exclude):void 0,include:e.include?Ge(e.include):void 0}}function ia(e){if(!e)return;let{exclude:i,include:s}=ta(e),n=i?.map(Xr),u=s?.map(Xr);return ea(n,u)}function zu(e){if(!e)return;let{exclude:i,include:s}=ta(e),n=i?.map(Jr),u=s?.map(Jr);return ea(n,u)}function Xu(e){let i=ia(e);return i?s=>!!i(s):void 0}function Ju(e,i){if(!e&&!i)return;let s=ia(e),n=zu(i);return(u,l)=>{let m=!0;return s&&(m&&=s(u)),m?(n&&(m&&=n(l)),m):!1}}function Te(e,i){let s,n;if(typeof i=="function")s=i;else{s=i.handler;let u=i.filter;e==="resolveId"||e==="load"?n=Xu(u?.id):n=Ju(u?.id,u?.code)}return{handler:s,filter:n||(()=>!0)}}var Qr;function mt(e,i={}){if(!Qr)throw new Error("Parse implementation is not set. Please call setParseImpl first.");return Qr(e,i)}var ki=require("path");function hs(e,i,s){if(e.resource==null)return[];let n=Rt(e.resource+(e.resourceQuery||""));if(i.transformInclude&&!i.transformInclude(n))return[];let{filter:u}=Te("load",i.transform);return u(n)?[{loader:s,options:{plugin:i},ident:i.name}]:[]}function Rt(e){return(0,ki.isAbsolute)(e)?(0,ki.normalize)(e):e}var sa=require("path"),ra=require("buffer");function Ei(e,i,s,n){return{getNativeBuildContext(){return{framework:"rspack",compiler:e,compilation:i,loaderContext:s,inputSourceMap:n}},addWatchFile(u){let l=(0,sa.resolve)(process.cwd(),u);i.fileDependencies.add(l),s?.addDependency(l)},getWatchFiles(){return Array.from(i.fileDependencies)},parse:mt,emitFile(u){let l=u.fileName||u.name;if(u.source&&l){let{sources:m}=i.compiler.webpack;i.emitAsset(l,new m.RawSource(typeof u.source=="string"?u.source:ra.Buffer.from(u.source)))}}}}function aa(e){let i=new Error(typeof e=="string"?e:e.message);return typeof e=="object"&&(i.stack=e.stack,i.cause=e.meta),i}var Mt=require("path"),Ot=ft(require("fs"),1);function na(e,i){return(0,Mt.resolve)(i.__virtualModulePrefix,encodeURIComponent(e))}function oa(e,i){return decodeURIComponent((0,Mt.basename)(e))}function ls(e,i){return(0,Mt.dirname)(e)===i.__virtualModulePrefix}var ua=class nt{name="FakeVirtualModulesPlugin";static counters=new Map;static initCleanup=!1;constructor(i){this.plugin=i,nt.initCleanup||(nt.initCleanup=!0,process.once("exit",()=>{nt.counters.forEach((s,n)=>{Ot.default.rmSync(n,{recursive:!0,force:!0})})}))}apply(i){let s=this.plugin.__virtualModulePrefix;Ot.default.existsSync(s)||Ot.default.mkdirSync(s,{recursive:!0});let n=nt.counters.get(s)??0;nt.counters.set(s,n+1),i.hooks.shutdown.tap(this.name,()=>{let u=(nt.counters.get(s)??1)-1;u===0?(nt.counters.delete(s),Ot.default.rmSync(s,{recursive:!0,force:!0})):nt.counters.set(s,u)})}async writeModule(i){return Ot.default.promises.writeFile(i,"")}};var ca=require("module"),ha=require("path"),la=require("buffer"),pa=ft(require("process"),1),Zu={};function ps(e){return{addWatchFile(i){(e.fileDependencies??e.compilationDependencies).add(i)},getWatchFiles(){return Array.from(e.fileDependencies??e.compilationDependencies)}}}var Qu=(0,ca.createRequire)(Zu.url);function Yu(e){return new(Qu("webpack")).sources.RawSource(typeof e=="string"?e:la.Buffer.from(e.buffer))}function wi(e,i,s,n,u){return{parse:mt,addWatchFile(l){e.addWatchFile((0,ha.resolve)(pa.default.cwd(),l))},emitFile(l){let m=l.fileName||l.name;if(l.source&&m){if(!s)throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");s.emitAsset(m,Yu(l.source))}},getWatchFiles(){return e.getWatchFiles()},getNativeBuildContext(){return{framework:"webpack",compiler:i,compilation:s,loaderContext:n,inputSourceMap:u}}}}function fa(e){let i=new Error(typeof e=="string"?e:e.message);return typeof e=="object"&&(i.stack=e.stack,i.cause=e.meta),i}var tn=require("module"),Se=ft(require("path"),1),tt=ft(require("fs"),1),_s=require("buffer");var ga=44,ec=59,da="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",va=new Uint8Array(64),ba=new Uint8Array(128);for(let e=0;e<da.length;e++){let i=da.charCodeAt(e);va[e]=i,ba[i]=e}function Qt(e,i){let s=0,n=0,u=0;do{let m=e.next();u=ba[m],s|=(u&31)<<n,n+=5}while(u&32);let l=s&1;return s>>>=1,l&&(s=-2147483648|-s),i+s}function Yt(e,i,s){let n=i-s;n=n<0?-n<<1|1:n<<1;do{let u=n&31;n>>>=5,n>0&&(u|=32),e.write(va[u])}while(n>0);return i}function ma(e,i){return e.pos>=i?!1:e.peek()!==ga}var xa=1024*16,ya=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString()}}:{decode(e){let i="";for(let s=0;s<e.length;s++)i+=String.fromCharCode(e[s]);return i}},tc=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(xa)}write(e){let{buffer:i}=this;i[this.pos++]=e,this.pos===xa&&(this.out+=ya.decode(i),this.pos=0)}flush(){let{buffer:e,out:i,pos:s}=this;return s>0?i+ya.decode(e.subarray(0,s)):i}},ic=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:i,pos:s}=this,n=i.indexOf(e,s);return n===-1?i.length:n}};function Sa(e){let{length:i}=e,s=new ic(e),n=[],u=0,l=0,m=0,g=0,S=0;do{let h=s.indexOf(";"),P=[],E=!0,F=0;for(u=0;s.pos<h;){let _;u=Qt(s,u),u<F&&(E=!1),F=u,ma(s,h)?(l=Qt(s,l),m=Qt(s,m),g=Qt(s,g),ma(s,h)?(S=Qt(s,S),_=[u,l,m,g,S]):_=[u,l,m,g]):_=[u],P.push(_),s.pos++}E||sc(P),n.push(P),s.pos=h+1}while(s.pos<=i);return n}function sc(e){e.sort(rc)}function rc(e,i){return e[0]-i[0]}function fs(e){let i=new tc,s=0,n=0,u=0,l=0;for(let m=0;m<e.length;m++){let g=e[m];if(m>0&&i.write(ec),g.length===0)continue;let S=0;for(let h=0;h<g.length;h++){let P=g[h];h>0&&i.write(ga),S=Yt(i,P[0],S),P.length!==1&&(s=Yt(i,P[1],s),n=Yt(i,P[2],n),u=Yt(i,P[3],u),P.length!==4&&(l=Yt(i,P[4],l)))}}return i.flush()}var ac=/^[\w+.-]+:\/\//,nc=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,oc=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function uc(e){return ac.test(e)}function cc(e){return e.startsWith("//")}function Aa(e){return e.startsWith("/")}function hc(e){return e.startsWith("file:")}function Ca(e){return/^[.?#]/.test(e)}function Ti(e){let i=nc.exec(e);return ka(i[1],i[2]||"",i[3],i[4]||"",i[5]||"/",i[6]||"",i[7]||"")}function lc(e){let i=oc.exec(e),s=i[2];return ka("file:","",i[1]||"","",Aa(s)?s:"/"+s,i[3]||"",i[4]||"")}function ka(e,i,s,n,u,l,m){return{scheme:e,user:i,host:s,port:n,path:u,query:l,hash:m,type:7}}function _a(e){if(cc(e)){let s=Ti("http:"+e);return s.scheme="",s.type=6,s}if(Aa(e)){let s=Ti("http://foo.com"+e);return s.scheme="",s.host="",s.type=5,s}if(hc(e))return lc(e);if(uc(e))return Ti(e);let i=Ti("http://foo.com/"+e);return i.scheme="",i.host="",i.type=e?e.startsWith("?")?3:e.startsWith("#")?2:4:1,i}function pc(e){if(e.endsWith("/.."))return e;let i=e.lastIndexOf("/");return e.slice(0,i+1)}function fc(e,i){Ea(i,i.type),e.path==="/"?e.path=i.path:e.path=pc(i.path)+e.path}function Ea(e,i){let s=i<=4,n=e.path.split("/"),u=1,l=0,m=!1;for(let S=1;S<n.length;S++){let h=n[S];if(!h){m=!0;continue}if(m=!1,h!=="."){if(h===".."){l?(m=!0,l--,u--):s&&(n[u++]=h);continue}n[u++]=h,l++}}let g="";for(let S=1;S<u;S++)g+="/"+n[S];(!g||m&&!g.endsWith("/.."))&&(g+="/"),e.path=g}function wa(e,i){if(!e&&!i)return"";let s=_a(e),n=s.type;if(i&&n!==7){let l=_a(i),m=l.type;switch(n){case 1:s.hash=l.hash;case 2:s.query=l.query;case 3:case 4:fc(s,l);case 5:s.user=l.user,s.host=l.host,s.port=l.port;case 6:s.scheme=l.scheme}m>n&&(n=m)}Ea(s,n);let u=s.query+s.hash;switch(n){case 2:case 3:return u;case 4:{let l=s.path.slice(1);return l?Ca(i||e)&&!Ca(l)?"./"+l+u:l+u:u||"."}case 5:return s.path+u;default:return s.scheme+"//"+s.user+s.host+s.port+s.path+u}}function dc(e){if(!e)return"";let i=e.lastIndexOf("/");return e.slice(0,i+1)}function mc(e,i){let s=dc(e),n=i?i+"/":"";return u=>wa(n+(u||""),s)}var xt=0;function xc(e,i){let s=Ta(e,0);if(s===e.length)return e;i||(e=e.slice());for(let n=s;n<e.length;n=Ta(e,n+1))e[n]=gc(e[n],i);return e}function Ta(e,i){for(let s=i;s<e.length;s++)if(!yc(e[s]))return s;return e.length}function yc(e){for(let i=1;i<e.length;i++)if(e[i][xt]<e[i-1][xt])return!1;return!0}function gc(e,i){return i||(e=e.slice()),e.sort(vc)}function vc(e,i){return e[xt]-i[xt]}var Pi=!1;function bc(e,i,s,n){for(;s<=n;){let u=s+(n-s>>1),l=e[u][xt]-i;if(l===0)return Pi=!0,u;l<0?s=u+1:n=u-1}return Pi=!1,s-1}function Sc(e,i,s){for(let n=s+1;n<e.length&&e[n][xt]===i;s=n++);return s}function Cc(e,i,s){for(let n=s-1;n>=0&&e[n][xt]===i;s=n--);return s}function _c(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function Ac(e,i,s,n){let{lastKey:u,lastNeedle:l,lastIndex:m}=s,g=0,S=e.length-1;if(n===u){if(i===l)return Pi=m!==-1&&e[m][xt]===i,m;i>=l?g=m===-1?0:m:S=m}return s.lastKey=n,s.lastNeedle=i,s.lastIndex=bc(e,i,g,S)}function kc(e){return typeof e=="string"?JSON.parse(e):e}var Pa=-1,Ec=1,Ii=class{constructor(e,i){let s=typeof e=="string";if(!s&&e._decodedMemo)return e;let n=kc(e),{version:u,file:l,names:m,sourceRoot:g,sources:S,sourcesContent:h}=n;this.version=u,this.file=l,this.names=m||[],this.sourceRoot=g,this.sources=S,this.sourcesContent=h,this.ignoreList=n.ignoreList||n.x_google_ignoreList||void 0;let P=mc(i,g);this.resolvedSources=S.map(P);let{mappings:E}=n;if(typeof E=="string")this._encoded=E,this._decoded=void 0;else if(Array.isArray(E))this._encoded=void 0,this._decoded=xc(E,s);else throw n.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(n)}`);this._decodedMemo=_c(),this._bySources=void 0,this._bySourceMemos=void 0}};function Ni(e){var i;return(i=e)._decoded||(i._decoded=Sa(e._encoded))}function Ia(e,i,s){let n=Ni(e);if(i>=n.length)return null;let u=n[i],l=wc(u,e._decodedMemo,i,s,Ec);return l===-1?null:u[l]}function wc(e,i,s,n,u){let l=Ac(e,n,i,s);return Pi?l=(u===Pa?Sc:Cc)(e,n,l):u===Pa&&l++,l===-1||l===e.length?-1:l}var ds=class{constructor(){this._indexes={__proto__:null},this.array=[]}};function La(e,i){return e._indexes[i]}function Zt(e,i){let s=La(e,i);if(s!==void 0)return s;let{array:n,_indexes:u}=e,l=n.push(i);return u[i]=l-1}function Tc(e,i){let s=La(e,i);if(s===void 0)return;let{array:n,_indexes:u}=e;for(let l=s+1;l<n.length;l++){let m=n[l];n[l-1]=m,u[m]--}u[i]=void 0,n.pop()}var Pc=0,Ic=1,Nc=2,Lc=3,Rc=4,Ra=-1,Oa=class{constructor({file:e,sourceRoot:i}={}){this._names=new ds,this._sources=new ds,this._sourcesContent=[],this._mappings=[],this.file=e,this.sourceRoot=i,this._ignoreList=new ds}};var Ma=(e,i,s,n,u,l,m,g)=>Oc(!0,e,i,s,n,u,l,m,g);function Va(e,i,s){let{_sources:n,_sourcesContent:u}=e,l=Zt(n,i);u[l]=s}function Da(e,i,s=!0){let{_sources:n,_sourcesContent:u,_ignoreList:l}=e,m=Zt(n,i);m===u.length&&(u[m]=null),s?Zt(l,m):Tc(l,m)}function ms(e){let{_mappings:i,_sources:s,_sourcesContent:n,_names:u,_ignoreList:l}=e;return Dc(i),{version:3,file:e.file||void 0,names:u.array,sourceRoot:e.sourceRoot||void 0,sources:s.array,sourcesContent:n,mappings:i,ignoreList:l.array}}function Fa(e){let i=ms(e);return Object.assign({},i,{mappings:fs(i.mappings)})}function Oc(e,i,s,n,u,l,m,g,S){let{_mappings:h,_sources:P,_sourcesContent:E,_names:F}=i,_=Mc(h,s),k=Vc(_,n);if(!u)return e&&Fc(_,k)?void 0:Na(_,k,[n]);let D=Zt(P,u),R=g?Zt(F,g):Ra;if(D===E.length&&(E[D]=S??null),!(e&&Bc(_,k,D,l,m,R)))return Na(_,k,g?[n,D,l,m,R]:[n,D,l,m])}function Mc(e,i){for(let s=e.length;s<=i;s++)e[s]=[];return e[i]}function Vc(e,i){let s=e.length;for(let n=s-1;n>=0;s=n--){let u=e[n];if(i>=u[Pc])break}return s}function Na(e,i,s){for(let n=e.length;n>i;n--)e[n]=e[n-1];e[i]=s}function Dc(e){let{length:i}=e,s=i;for(let n=s-1;n>=0&&!(e[n].length>0);s=n,n--);s<i&&(e.length=s)}function Fc(e,i){return i===0?!0:e[i-1].length===1}function Bc(e,i,s,n,u,l){if(i===0)return!1;let m=e[i-1];return m.length===1?!1:s===m[Ic]&&n===m[Nc]&&u===m[Lc]&&l===(m.length===5?m[Rc]:Ra)}var Ba=ja("",-1,-1,"",null,!1),jc=[];function ja(e,i,s,n,u,l){return{source:e,line:i,column:s,name:n,content:u,ignore:l}}function Ua(e,i,s,n,u){return{map:e,sources:i,source:s,content:n,ignore:u}}function Ha(e,i){return Ua(e,i,"",null,!1)}function Uc(e,i,s){return Ua(null,jc,e,i,s)}function Hc(e){let i=new Oa({file:e.map.file}),{sources:s,map:n}=e,u=n.names,l=Ni(n);for(let m=0;m<l.length;m++){let g=l[m];for(let S=0;S<g.length;S++){let h=g[S],P=h[0],E=Ba;if(h.length!==1){let z=s[h[1]];if(E=qa(z,h[2],h[3],h.length===5?u[h[4]]:""),E==null)continue}let{column:F,line:_,name:k,content:D,source:R,ignore:H}=E;Ma(i,m,P,R,_,F,k),R&&D!=null&&Va(i,R,D),H&&Da(i,R,!0)}}return i}function qa(e,i,s,n){if(!e.map)return ja(e.source,i,s,n,e.content,e.ignore);let u=Ia(e.map,i,s);return u==null?null:u.length===1?Ba:qa(e.sources[u[1]],u[2],u[3],u.length===5?e.map.names[u[4]]:n)}function qc(e){return Array.isArray(e)?e:[e]}function Wc(e,i){let s=qc(e).map(l=>new Ii(l,"")),n=s.pop();for(let l=0;l<s.length;l++)if(s[l].sources.length>1)throw new Error(`Transformation map ${l} must have exactly one source file.
11
+ `):D=String.fromCharCode(k),this.options.locations&&(++this.curLine,this.lineStart=this.pos),D}jsx_readString(_){let k="",D=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");let R=this.input.charCodeAt(this.pos);if(R===_)break;R===38?(k+=this.input.slice(D,this.pos),k+=this.jsx_readEntity(),D=this.pos):P(R)?(k+=this.input.slice(D,this.pos),k+=this.jsx_readNewLine(!1),D=this.pos):++this.pos}return k+=this.input.slice(D,this.pos++),this.finishToken(u.string,k)}jsx_readEntity(){let _="",k=0,D,R=this.input[this.pos];R!=="&"&&this.raise(this.pos,"Entity must start with an ampersand");let H=++this.pos;for(;this.pos<this.input.length&&k++<10;){if(R=this.input[this.pos++],R===";"){_[0]==="#"?_[1]==="x"?(_=_.substr(2),dl.test(_)&&(D=String.fromCharCode(parseInt(_,16)))):(_=_.substr(1),ml.test(_)&&(D=String.fromCharCode(parseInt(_,10)))):D=fl[_];break}_+=R}return D||(this.pos=H,"&")}jsx_readWord(){let _,k=this.pos;do _=this.input.charCodeAt(++this.pos);while(F(_)||_===45);return this.finishToken(l.jsxName,this.input.slice(k,this.pos))}jsx_parseIdentifier(){let _=this.startNode();return this.type===l.jsxName?_.name=this.value:this.type.keyword?_.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(_,"JSXIdentifier")}jsx_parseNamespacedName(){let _=this.start,k=this.startLoc,D=this.jsx_parseIdentifier();if(!e.allowNamespaces||!this.eat(u.colon))return D;var R=this.startNodeAt(_,k);return R.namespace=D,R.name=this.jsx_parseIdentifier(),this.finishNode(R,"JSXNamespacedName")}jsx_parseElementName(){if(this.type===l.jsxTagEnd)return"";let _=this.start,k=this.startLoc,D=this.jsx_parseNamespacedName();for(this.type===u.dot&&D.type==="JSXNamespacedName"&&!e.allowNamespacedObjects&&this.unexpected();this.eat(u.dot);){let R=this.startNodeAt(_,k);R.object=D,R.property=this.jsx_parseIdentifier(),D=this.finishNode(R,"JSXMemberExpression")}return D}jsx_parseAttributeValue(){switch(this.type){case u.braceL:let _=this.jsx_parseExpressionContainer();return _.expression.type==="JSXEmptyExpression"&&this.raise(_.start,"JSX attributes must only be assigned a non-empty expression"),_;case l.jsxTagStart:case u.string:return this.parseExprAtom();default:this.raise(this.start,"JSX value should be either an expression or a quoted JSX text")}}jsx_parseEmptyExpression(){let _=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(_,"JSXEmptyExpression",this.start,this.startLoc)}jsx_parseExpressionContainer(){let _=this.startNode();return this.next(),_.expression=this.type===u.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(u.braceR),this.finishNode(_,"JSXExpressionContainer")}jsx_parseAttribute(){let _=this.startNode();return this.eat(u.braceL)?(this.expect(u.ellipsis),_.argument=this.parseMaybeAssign(),this.expect(u.braceR),this.finishNode(_,"JSXSpreadAttribute")):(_.name=this.jsx_parseNamespacedName(),_.value=this.eat(u.eq)?this.jsx_parseAttributeValue():null,this.finishNode(_,"JSXAttribute"))}jsx_parseOpeningElementAt(_,k){let D=this.startNodeAt(_,k);D.attributes=[];let R=this.jsx_parseElementName();for(R&&(D.name=R);this.type!==u.slash&&this.type!==l.jsxTagEnd;)D.attributes.push(this.jsx_parseAttribute());return D.selfClosing=this.eat(u.slash),this.expect(l.jsxTagEnd),this.finishNode(D,R?"JSXOpeningElement":"JSXOpeningFragment")}jsx_parseClosingElementAt(_,k){let D=this.startNodeAt(_,k),R=this.jsx_parseElementName();return R&&(D.name=R),this.expect(l.jsxTagEnd),this.finishNode(D,R?"JSXClosingElement":"JSXClosingFragment")}jsx_parseElementAt(_,k){let D=this.startNodeAt(_,k),R=[],H=this.jsx_parseOpeningElementAt(_,k),z=null;if(!H.selfClosing){e:for(;;)switch(this.type){case l.jsxTagStart:if(_=this.start,k=this.startLoc,this.next(),this.eat(u.slash)){z=this.jsx_parseClosingElementAt(_,k);break e}R.push(this.jsx_parseElementAt(_,k));break;case l.jsxText:R.push(this.parseExprAtom());break;case u.braceL:R.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}ni(z.name)!==ni(H.name)&&this.raise(z.start,"Expected corresponding JSX closing tag for <"+ni(H.name)+">")}let G=H.name?"Element":"Fragment";return D["opening"+G]=H,D["closing"+G]=z,D.children=R,this.type===u.relational&&this.value==="<"&&this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(D,"JSX"+G)}jsx_parseText(){let _=this.parseLiteral(this.value);return _.type="JSXText",_}jsx_parseElement(){let _=this.start,k=this.startLoc;return this.next(),this.jsx_parseElementAt(_,k)}parseExprAtom(_){return this.type===l.jsxText?this.jsx_parseText():this.type===l.jsxTagStart?this.jsx_parseElement():super.parseExprAtom(_)}readToken(_){let k=this.curContext();if(k===h)return this.jsx_readToken();if(k===g||k===S){if(E(_))return this.jsx_readWord();if(_==62)return++this.pos,this.finishToken(l.jsxTagEnd);if((_===34||_===39)&&k==g)return this.jsx_readString(_)}return _===60&&this.exprAllowed&&this.input.charCodeAt(this.pos+1)!==33?(++this.pos,this.finishToken(l.jsxTagStart)):super.readToken(_)}updateContext(_){if(this.type==u.braceL){var k=this.curContext();k==g?this.context.push(m.b_expr):k==h?this.context.push(m.b_tmpl):super.updateContext(_),this.exprAllowed=!0}else if(this.type===u.slash&&_===l.jsxTagStart)this.context.length-=2,this.context.push(S),this.exprAllowed=!1;else return super.updateContext(_)}}}});var Ll={};vr(Ll,{default:()=>yo,enableReactComponentJump:()=>kr,esbuildPlugin:()=>So,locateComponentSource:()=>es,rollupPlugin:()=>bo,rspackPlugin:()=>Co,vitePlugin:()=>go,webpackPlugin:()=>vo});module.exports=iu(Ll);var dt="__componentSourceLoc",Kt="$componentSourceLoc",Sr="react-code-locator.jsxSourceRegistry";function Zi(e){return e.replace(/\\/g,"/")}function su(e){return e.replace(/\/+$/,"")}function Cr(e){return Zi(e).split("/").filter(Boolean)}function ru(e,i){let s=Cr(e),n=Cr(i),u=0;for(;u<s.length&&u<n.length&&s[u]===n[u];)u+=1;let l=new Array(Math.max(0,s.length-u)).fill(".."),m=n.slice(u),g=[...l,...m];return g.length>0?g.join("/"):"."}function au(e){return e?su(Zi(e)):""}function bi(e){return e?e.match(/^(.*):\d+:\d+$/)?.[1]??null:null}function nu(e,i){if(!e)return!1;let s=au(i),n=Zi(e);return s?n.startsWith(`${s}/`)||n===s?!0:!ru(s,n).startsWith("../"):!n.startsWith("../")&&!n.startsWith("/")&&!/^[A-Za-z]:\//.test(n)}function Nt(e,i){let s=bi(e);return nu(s??void 0,i)}function ou(e,i){return i==="none"?!0:i==="alt"?e.altKey:i==="meta"?e.metaKey:i==="ctrl"?e.ctrlKey:e.shiftKey}function uu(e){return Object.keys(e).find(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"))}function cu(e){let i=e;for(;i;){let s=uu(i);if(s)return i[s];i=i.parentElement}return null}function Si(e){if(!e)return null;if(typeof e=="function"){let n=e[dt];return typeof n=="string"?n:null}if(typeof e!="object")return null;let i=e,s=i[dt]??i.type?.[dt]??i.render?.[dt];return typeof s=="string"?s:null}function _r(e){if(e&&typeof e=="object"){let s=globalThis[Symbol.for(Sr)];if(s instanceof WeakMap){let n=s.get(e);if(typeof n=="string")return n}}let i=e?.[Kt];return typeof i=="string"?i:null}function hu(e){let i=e;for(;i;){let s=Si(i.type)??Si(i.elementType);if(s)return s;i=i.return??null}return null}function lu(e){let i=e?._debugSource;return i?.fileName&&typeof i.lineNumber=="number"?`${i.fileName.replace(/\\/g,"/")}:${i.lineNumber}:${i.columnNumber??1}`:null}function Ar(e,i){if(!i||!e)return e;let s=e.match(/^(.*):(\d+):(\d+)$/);if(!s)return e;let[,n,u,l]=s,m=n.replace(/\\/g,"/"),g=i.replace(/\\/g,"/").replace(/\/$/,"");return m.startsWith(g+"/")?`${m.slice(g.length+1)}:${u}:${l}`:e}function pu(e,i){let s=e,n=[],u=[];for(;s;){let F=_r(s.pendingProps)??_r(s.memoizedProps)??lu(s),_=Ar(F??"",i)||F;if(_){let R=bi(_);R&&!n.some(H=>H.source===_)&&n.push({source:_,file:R})}let k=Si(s.type)??Si(s.elementType),D=Ar(k??"",i)||k;if(D){let R=bi(D);R&&!u.some(H=>H.source===D)&&u.push({source:D,file:R})}s=s.return??null}console.log("[react-code-locator] DEBUG candidates",{jsxCandidates:n,componentCandidates:u,projectRoot:i});let l=n[0]?.source??null,m=u.find(F=>Nt(F.source))?.file,g=null;if(m){let F=n.find(_=>_.file===m);if(F)g=F.source;else{let _=u.find(k=>k.file===m);_&&(g=_.source)}}let S=u.find(F=>!Nt(F.source))?.source??null,h=n.find(F=>!Nt(F.source))?.source??null,P=n.find(F=>Nt(F.source))?.source??null,E=g??P??u.find(F=>Nt(F.source))?.source??null;return{direct:l??E,screen:E,implementation:S??h??E}}function fu(e){return e==="direct"?"Direct JSX":e==="screen"?"Screen source":"Implementation source"}function du(e){if(typeof document>"u")return null;let i=document.createElement("div"),s=null,n="screen",u=null;i.setAttribute("data-react-code-locator","true"),Object.assign(i.style,{position:"fixed",right:"12px",bottom:"12px",zIndex:"2147483647",padding:"8px 10px",borderRadius:"8px",background:"rgba(17, 24, 39, 0.92)",color:"#fff",fontSize:"12px",lineHeight:"1.4",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.25)",pointerEvents:"auto",cursor:"pointer",maxWidth:"min(70vw, 720px)",wordBreak:"break-all",opacity:"0",transition:"opacity 120ms ease"});let l=(g,S)=>{i.textContent=g,i.style.background=S==="success"?"rgba(6, 95, 70, 0.92)":S==="error"?"rgba(153, 27, 27, 0.94)":"rgba(17, 24, 39, 0.92)",i.style.opacity="1",i.style.pointerEvents="auto",u&&clearTimeout(u),u=setTimeout(()=>{i.style.opacity="0",i.style.pointerEvents="none"},2e3)};i.addEventListener("click",async()=>{if(s)try{await navigator.clipboard.writeText(s),l("[react-code-locator] copied","success")}catch{l("[react-code-locator] copy failed","error")}}),l(`[react-code-locator] enabled (${e}+click, alt+1/2/3 to switch mode)`,"idle");let m=()=>{!i.isConnected&&document.body&&document.body.appendChild(i)};return document.body?m():document.addEventListener("DOMContentLoaded",m,{once:!0}),{setStatus(g,S="idle"){l(g,S)},setCopyValue(g){s=g},setMode(g){n=g,l(`[react-code-locator] ${fu(g)}`,"idle")},remove(){u&&clearTimeout(u),i.remove()}}}function es(e,i="screen",s){let n=e instanceof Element?e:e instanceof Node?e.parentElement:null,u=cu(n);if(!u)return null;let l=pu(u,s),m=l[i]??l.screen??l.direct??l.implementation;if(m)return{source:m,mode:i};let g=hu(u);return g?{source:g,mode:i}:null}function kr(e={}){if(process.env.NODE_ENV!=="development")return;let i=du(e.triggerKey??"shift"),s="screen",{triggerKey:n="shift",projectRoot:u,onLocate:l=h=>{console.log(`[react-code-locator] ${h.source}`),i?.setCopyValue(h.source),i?.setStatus(`[react-code-locator] ${h.source}`,"success")},onError:m=h=>{console.error("[react-code-locator]",h);let P=h instanceof Error?h.message:String(h);i?.setCopyValue(null),i?.setStatus(`[react-code-locator] ${P}`,"error")}}=e;console.log("[react-code-locator] enabled",{triggerKey:n});let g=h=>{if(h.altKey){if(h.code==="Digit1"){s="direct",i?.setMode(s),h.preventDefault();return}if(h.code==="Digit2"){s="screen",i?.setMode(s),h.preventDefault();return}h.code==="Digit3"&&(s="implementation",i?.setMode(s),h.preventDefault())}},S=h=>{if(console.log("[react-code-locator] click",{triggerKey:n,shiftKey:h.shiftKey,altKey:h.altKey,ctrlKey:h.ctrlKey,metaKey:h.metaKey,target:h.target}),!ou(h,n))return;let P=es(h.target,s,u);if(!P){m(new Error("No React component source metadata found for clicked element."));return}h.preventDefault(),h.stopPropagation(),l(P)};return document.addEventListener("click",S,!0),document.addEventListener("keydown",g,!0),()=>{document.removeEventListener("click",S,!0),document.removeEventListener("keydown",g,!0),i?.remove()}}var Yr=require("path"),Zr=ft(zr(),1);function Ge(e){return e=e||[],Array.isArray(e)?e:[e]}var Wu=/\\/g;function Ai(e){return e.replace(Wu,"/")}var $u=/^(?:\/|(?:[A-Z]:)?[/\\|])/i;function Gu(e){return $u.test(e)}function Ku(e,i){return e.startsWith("**")||Gu(e)?Ai(e):Ai((0,Yr.resolve)(i,e))}function Xr(e){if(e instanceof RegExp)return s=>{let n=Ai(s),u=e.test(n);return e.lastIndex=0,u};let i=(0,Zr.default)(Ku(e,process.cwd()),{dot:!0});return s=>i(Ai(s))}function Jr(e){return e instanceof RegExp?i=>{let s=e.test(i);return e.lastIndex=0,s}:i=>i.includes(e)}function ea(e,i){if(!(!e&&!i))return s=>e?.some(n=>n(s))?!1:i?.some(n=>n(s))?!0:!(i&&i.length>0)}function ta(e){return typeof e=="string"||e instanceof RegExp?{include:[e]}:Array.isArray(e)?{include:e}:{exclude:e.exclude?Ge(e.exclude):void 0,include:e.include?Ge(e.include):void 0}}function ia(e){if(!e)return;let{exclude:i,include:s}=ta(e),n=i?.map(Xr),u=s?.map(Xr);return ea(n,u)}function zu(e){if(!e)return;let{exclude:i,include:s}=ta(e),n=i?.map(Jr),u=s?.map(Jr);return ea(n,u)}function Xu(e){let i=ia(e);return i?s=>!!i(s):void 0}function Ju(e,i){if(!e&&!i)return;let s=ia(e),n=zu(i);return(u,l)=>{let m=!0;return s&&(m&&=s(u)),m?(n&&(m&&=n(l)),m):!1}}function Te(e,i){let s,n;if(typeof i=="function")s=i;else{s=i.handler;let u=i.filter;e==="resolveId"||e==="load"?n=Xu(u?.id):n=Ju(u?.id,u?.code)}return{handler:s,filter:n||(()=>!0)}}var Qr;function mt(e,i={}){if(!Qr)throw new Error("Parse implementation is not set. Please call setParseImpl first.");return Qr(e,i)}var ki=require("path");function hs(e,i,s){if(e.resource==null)return[];let n=Rt(e.resource+(e.resourceQuery||""));if(i.transformInclude&&!i.transformInclude(n))return[];let{filter:u}=Te("load",i.transform);return u(n)?[{loader:s,options:{plugin:i},ident:i.name}]:[]}function Rt(e){return(0,ki.isAbsolute)(e)?(0,ki.normalize)(e):e}var sa=require("path"),ra=require("buffer");function Ei(e,i,s,n){return{getNativeBuildContext(){return{framework:"rspack",compiler:e,compilation:i,loaderContext:s,inputSourceMap:n}},addWatchFile(u){let l=(0,sa.resolve)(process.cwd(),u);i.fileDependencies.add(l),s?.addDependency(l)},getWatchFiles(){return Array.from(i.fileDependencies)},parse:mt,emitFile(u){let l=u.fileName||u.name;if(u.source&&l){let{sources:m}=i.compiler.webpack;i.emitAsset(l,new m.RawSource(typeof u.source=="string"?u.source:ra.Buffer.from(u.source)))}}}}function aa(e){let i=new Error(typeof e=="string"?e:e.message);return typeof e=="object"&&(i.stack=e.stack,i.cause=e.meta),i}var Mt=require("path"),Ot=ft(require("fs"),1);function na(e,i){return(0,Mt.resolve)(i.__virtualModulePrefix,encodeURIComponent(e))}function oa(e,i){return decodeURIComponent((0,Mt.basename)(e))}function ls(e,i){return(0,Mt.dirname)(e)===i.__virtualModulePrefix}var ua=class nt{name="FakeVirtualModulesPlugin";static counters=new Map;static initCleanup=!1;constructor(i){this.plugin=i,nt.initCleanup||(nt.initCleanup=!0,process.once("exit",()=>{nt.counters.forEach((s,n)=>{Ot.default.rmSync(n,{recursive:!0,force:!0})})}))}apply(i){let s=this.plugin.__virtualModulePrefix;Ot.default.existsSync(s)||Ot.default.mkdirSync(s,{recursive:!0});let n=nt.counters.get(s)??0;nt.counters.set(s,n+1),i.hooks.shutdown.tap(this.name,()=>{let u=(nt.counters.get(s)??1)-1;u===0?(nt.counters.delete(s),Ot.default.rmSync(s,{recursive:!0,force:!0})):nt.counters.set(s,u)})}async writeModule(i){return Ot.default.promises.writeFile(i,"")}};var ca=require("module"),ha=require("path"),la=require("buffer"),pa=ft(require("process"),1),Zu={};function ps(e){return{addWatchFile(i){(e.fileDependencies??e.compilationDependencies).add(i)},getWatchFiles(){return Array.from(e.fileDependencies??e.compilationDependencies)}}}var Qu=(0,ca.createRequire)(Zu.url);function Yu(e){return new(Qu("webpack")).sources.RawSource(typeof e=="string"?e:la.Buffer.from(e.buffer))}function wi(e,i,s,n,u){return{parse:mt,addWatchFile(l){e.addWatchFile((0,ha.resolve)(pa.default.cwd(),l))},emitFile(l){let m=l.fileName||l.name;if(l.source&&m){if(!s)throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");s.emitAsset(m,Yu(l.source))}},getWatchFiles(){return e.getWatchFiles()},getNativeBuildContext(){return{framework:"webpack",compiler:i,compilation:s,loaderContext:n,inputSourceMap:u}}}}function fa(e){let i=new Error(typeof e=="string"?e:e.message);return typeof e=="object"&&(i.stack=e.stack,i.cause=e.meta),i}var tn=require("module"),Se=ft(require("path"),1),tt=ft(require("fs"),1),_s=require("buffer");var ga=44,ec=59,da="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",va=new Uint8Array(64),ba=new Uint8Array(128);for(let e=0;e<da.length;e++){let i=da.charCodeAt(e);va[e]=i,ba[i]=e}function Qt(e,i){let s=0,n=0,u=0;do{let m=e.next();u=ba[m],s|=(u&31)<<n,n+=5}while(u&32);let l=s&1;return s>>>=1,l&&(s=-2147483648|-s),i+s}function Yt(e,i,s){let n=i-s;n=n<0?-n<<1|1:n<<1;do{let u=n&31;n>>>=5,n>0&&(u|=32),e.write(va[u])}while(n>0);return i}function ma(e,i){return e.pos>=i?!1:e.peek()!==ga}var xa=1024*16,ya=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString()}}:{decode(e){let i="";for(let s=0;s<e.length;s++)i+=String.fromCharCode(e[s]);return i}},tc=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(xa)}write(e){let{buffer:i}=this;i[this.pos++]=e,this.pos===xa&&(this.out+=ya.decode(i),this.pos=0)}flush(){let{buffer:e,out:i,pos:s}=this;return s>0?i+ya.decode(e.subarray(0,s)):i}},ic=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:i,pos:s}=this,n=i.indexOf(e,s);return n===-1?i.length:n}};function Sa(e){let{length:i}=e,s=new ic(e),n=[],u=0,l=0,m=0,g=0,S=0;do{let h=s.indexOf(";"),P=[],E=!0,F=0;for(u=0;s.pos<h;){let _;u=Qt(s,u),u<F&&(E=!1),F=u,ma(s,h)?(l=Qt(s,l),m=Qt(s,m),g=Qt(s,g),ma(s,h)?(S=Qt(s,S),_=[u,l,m,g,S]):_=[u,l,m,g]):_=[u],P.push(_),s.pos++}E||sc(P),n.push(P),s.pos=h+1}while(s.pos<=i);return n}function sc(e){e.sort(rc)}function rc(e,i){return e[0]-i[0]}function fs(e){let i=new tc,s=0,n=0,u=0,l=0;for(let m=0;m<e.length;m++){let g=e[m];if(m>0&&i.write(ec),g.length===0)continue;let S=0;for(let h=0;h<g.length;h++){let P=g[h];h>0&&i.write(ga),S=Yt(i,P[0],S),P.length!==1&&(s=Yt(i,P[1],s),n=Yt(i,P[2],n),u=Yt(i,P[3],u),P.length!==4&&(l=Yt(i,P[4],l)))}}return i.flush()}var ac=/^[\w+.-]+:\/\//,nc=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,oc=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function uc(e){return ac.test(e)}function cc(e){return e.startsWith("//")}function Aa(e){return e.startsWith("/")}function hc(e){return e.startsWith("file:")}function Ca(e){return/^[.?#]/.test(e)}function Ti(e){let i=nc.exec(e);return ka(i[1],i[2]||"",i[3],i[4]||"",i[5]||"/",i[6]||"",i[7]||"")}function lc(e){let i=oc.exec(e),s=i[2];return ka("file:","",i[1]||"","",Aa(s)?s:"/"+s,i[3]||"",i[4]||"")}function ka(e,i,s,n,u,l,m){return{scheme:e,user:i,host:s,port:n,path:u,query:l,hash:m,type:7}}function _a(e){if(cc(e)){let s=Ti("http:"+e);return s.scheme="",s.type=6,s}if(Aa(e)){let s=Ti("http://foo.com"+e);return s.scheme="",s.host="",s.type=5,s}if(hc(e))return lc(e);if(uc(e))return Ti(e);let i=Ti("http://foo.com/"+e);return i.scheme="",i.host="",i.type=e?e.startsWith("?")?3:e.startsWith("#")?2:4:1,i}function pc(e){if(e.endsWith("/.."))return e;let i=e.lastIndexOf("/");return e.slice(0,i+1)}function fc(e,i){Ea(i,i.type),e.path==="/"?e.path=i.path:e.path=pc(i.path)+e.path}function Ea(e,i){let s=i<=4,n=e.path.split("/"),u=1,l=0,m=!1;for(let S=1;S<n.length;S++){let h=n[S];if(!h){m=!0;continue}if(m=!1,h!=="."){if(h===".."){l?(m=!0,l--,u--):s&&(n[u++]=h);continue}n[u++]=h,l++}}let g="";for(let S=1;S<u;S++)g+="/"+n[S];(!g||m&&!g.endsWith("/.."))&&(g+="/"),e.path=g}function wa(e,i){if(!e&&!i)return"";let s=_a(e),n=s.type;if(i&&n!==7){let l=_a(i),m=l.type;switch(n){case 1:s.hash=l.hash;case 2:s.query=l.query;case 3:case 4:fc(s,l);case 5:s.user=l.user,s.host=l.host,s.port=l.port;case 6:s.scheme=l.scheme}m>n&&(n=m)}Ea(s,n);let u=s.query+s.hash;switch(n){case 2:case 3:return u;case 4:{let l=s.path.slice(1);return l?Ca(i||e)&&!Ca(l)?"./"+l+u:l+u:u||"."}case 5:return s.path+u;default:return s.scheme+"//"+s.user+s.host+s.port+s.path+u}}function dc(e){if(!e)return"";let i=e.lastIndexOf("/");return e.slice(0,i+1)}function mc(e,i){let s=dc(e),n=i?i+"/":"";return u=>wa(n+(u||""),s)}var xt=0;function xc(e,i){let s=Ta(e,0);if(s===e.length)return e;i||(e=e.slice());for(let n=s;n<e.length;n=Ta(e,n+1))e[n]=gc(e[n],i);return e}function Ta(e,i){for(let s=i;s<e.length;s++)if(!yc(e[s]))return s;return e.length}function yc(e){for(let i=1;i<e.length;i++)if(e[i][xt]<e[i-1][xt])return!1;return!0}function gc(e,i){return i||(e=e.slice()),e.sort(vc)}function vc(e,i){return e[xt]-i[xt]}var Pi=!1;function bc(e,i,s,n){for(;s<=n;){let u=s+(n-s>>1),l=e[u][xt]-i;if(l===0)return Pi=!0,u;l<0?s=u+1:n=u-1}return Pi=!1,s-1}function Sc(e,i,s){for(let n=s+1;n<e.length&&e[n][xt]===i;s=n++);return s}function Cc(e,i,s){for(let n=s-1;n>=0&&e[n][xt]===i;s=n--);return s}function _c(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function Ac(e,i,s,n){let{lastKey:u,lastNeedle:l,lastIndex:m}=s,g=0,S=e.length-1;if(n===u){if(i===l)return Pi=m!==-1&&e[m][xt]===i,m;i>=l?g=m===-1?0:m:S=m}return s.lastKey=n,s.lastNeedle=i,s.lastIndex=bc(e,i,g,S)}function kc(e){return typeof e=="string"?JSON.parse(e):e}var Pa=-1,Ec=1,Ii=class{constructor(e,i){let s=typeof e=="string";if(!s&&e._decodedMemo)return e;let n=kc(e),{version:u,file:l,names:m,sourceRoot:g,sources:S,sourcesContent:h}=n;this.version=u,this.file=l,this.names=m||[],this.sourceRoot=g,this.sources=S,this.sourcesContent=h,this.ignoreList=n.ignoreList||n.x_google_ignoreList||void 0;let P=mc(i,g);this.resolvedSources=S.map(P);let{mappings:E}=n;if(typeof E=="string")this._encoded=E,this._decoded=void 0;else if(Array.isArray(E))this._encoded=void 0,this._decoded=xc(E,s);else throw n.sections?new Error("TraceMap passed sectioned source map, please use FlattenMap export instead"):new Error(`invalid source map: ${JSON.stringify(n)}`);this._decodedMemo=_c(),this._bySources=void 0,this._bySourceMemos=void 0}};function Ni(e){var i;return(i=e)._decoded||(i._decoded=Sa(e._encoded))}function Ia(e,i,s){let n=Ni(e);if(i>=n.length)return null;let u=n[i],l=wc(u,e._decodedMemo,i,s,Ec);return l===-1?null:u[l]}function wc(e,i,s,n,u){let l=Ac(e,n,i,s);return Pi?l=(u===Pa?Sc:Cc)(e,n,l):u===Pa&&l++,l===-1||l===e.length?-1:l}var ds=class{constructor(){this._indexes={__proto__:null},this.array=[]}};function La(e,i){return e._indexes[i]}function Zt(e,i){let s=La(e,i);if(s!==void 0)return s;let{array:n,_indexes:u}=e,l=n.push(i);return u[i]=l-1}function Tc(e,i){let s=La(e,i);if(s===void 0)return;let{array:n,_indexes:u}=e;for(let l=s+1;l<n.length;l++){let m=n[l];n[l-1]=m,u[m]--}u[i]=void 0,n.pop()}var Pc=0,Ic=1,Nc=2,Lc=3,Rc=4,Ra=-1,Oa=class{constructor({file:e,sourceRoot:i}={}){this._names=new ds,this._sources=new ds,this._sourcesContent=[],this._mappings=[],this.file=e,this.sourceRoot=i,this._ignoreList=new ds}};var Ma=(e,i,s,n,u,l,m,g)=>Oc(!0,e,i,s,n,u,l,m,g);function Va(e,i,s){let{_sources:n,_sourcesContent:u}=e,l=Zt(n,i);u[l]=s}function Da(e,i,s=!0){let{_sources:n,_sourcesContent:u,_ignoreList:l}=e,m=Zt(n,i);m===u.length&&(u[m]=null),s?Zt(l,m):Tc(l,m)}function ms(e){let{_mappings:i,_sources:s,_sourcesContent:n,_names:u,_ignoreList:l}=e;return Dc(i),{version:3,file:e.file||void 0,names:u.array,sourceRoot:e.sourceRoot||void 0,sources:s.array,sourcesContent:n,mappings:i,ignoreList:l.array}}function Fa(e){let i=ms(e);return Object.assign({},i,{mappings:fs(i.mappings)})}function Oc(e,i,s,n,u,l,m,g,S){let{_mappings:h,_sources:P,_sourcesContent:E,_names:F}=i,_=Mc(h,s),k=Vc(_,n);if(!u)return e&&Fc(_,k)?void 0:Na(_,k,[n]);let D=Zt(P,u),R=g?Zt(F,g):Ra;if(D===E.length&&(E[D]=S??null),!(e&&Bc(_,k,D,l,m,R)))return Na(_,k,g?[n,D,l,m,R]:[n,D,l,m])}function Mc(e,i){for(let s=e.length;s<=i;s++)e[s]=[];return e[i]}function Vc(e,i){let s=e.length;for(let n=s-1;n>=0;s=n--){let u=e[n];if(i>=u[Pc])break}return s}function Na(e,i,s){for(let n=e.length;n>i;n--)e[n]=e[n-1];e[i]=s}function Dc(e){let{length:i}=e,s=i;for(let n=s-1;n>=0&&!(e[n].length>0);s=n,n--);s<i&&(e.length=s)}function Fc(e,i){return i===0?!0:e[i-1].length===1}function Bc(e,i,s,n,u,l){if(i===0)return!1;let m=e[i-1];return m.length===1?!1:s===m[Ic]&&n===m[Nc]&&u===m[Lc]&&l===(m.length===5?m[Rc]:Ra)}var Ba=ja("",-1,-1,"",null,!1),jc=[];function ja(e,i,s,n,u,l){return{source:e,line:i,column:s,name:n,content:u,ignore:l}}function Ua(e,i,s,n,u){return{map:e,sources:i,source:s,content:n,ignore:u}}function Ha(e,i){return Ua(e,i,"",null,!1)}function Uc(e,i,s){return Ua(null,jc,e,i,s)}function Hc(e){let i=new Oa({file:e.map.file}),{sources:s,map:n}=e,u=n.names,l=Ni(n);for(let m=0;m<l.length;m++){let g=l[m];for(let S=0;S<g.length;S++){let h=g[S],P=h[0],E=Ba;if(h.length!==1){let z=s[h[1]];if(E=qa(z,h[2],h[3],h.length===5?u[h[4]]:""),E==null)continue}let{column:F,line:_,name:k,content:D,source:R,ignore:H}=E;Ma(i,m,P,R,_,F,k),R&&D!=null&&Va(i,R,D),H&&Da(i,R,!0)}}return i}function qa(e,i,s,n){if(!e.map)return ja(e.source,i,s,n,e.content,e.ignore);let u=Ia(e.map,i,s);return u==null?null:u.length===1?Ba:qa(e.sources[u[1]],u[2],u[3],u.length===5?e.map.names[u[4]]:n)}function qc(e){return Array.isArray(e)?e:[e]}function Wc(e,i){let s=qc(e).map(l=>new Ii(l,"")),n=s.pop();for(let l=0;l<s.length;l++)if(s[l].sources.length>1)throw new Error(`Transformation map ${l} must have exactly one source file.
12
12
  Did you specify these with the most recent transformation maps first?`);let u=Wa(n,i,"",0);for(let l=s.length-1;l>=0;l--)u=Ha(s[l],[u]);return u}function Wa(e,i,s,n){let{resolvedSources:u,sourcesContent:l,ignoreList:m}=e,g=n+1,S=u.map((h,P)=>{let E={importer:s,depth:g,source:h||"",content:void 0,ignore:void 0},F=i(E.source,E),{source:_,content:k,ignore:D}=E;if(F)return Wa(new Ii(F,_),i,_,g);let R=k!==void 0?k:l?l[P]:null,H=D!==void 0?D:m?m.includes(P):!1;return Uc(_,R,H)});return Ha(e,S)}var $c=class{constructor(e,i){let s=i.decodedMappings?ms(e):Fa(e);this.version=s.version,this.file=s.file,this.mappings=s.mappings,this.names=s.names,this.ignoreList=s.ignoreList,this.sourceRoot=s.sourceRoot,this.sources=s.sources,i.excludeContent||(this.sourcesContent=s.sourcesContent)}toString(){return JSON.stringify(this)}};function xs(e,i,s){let n=typeof s=="object"?s:{excludeContent:!!s,decodedMappings:!1},u=Wc(e,i);return new $c(Hc(u),n)}var sn=ft(require("querystring"),1),rn=ft(require("process"),1),ei={},Gc=(0,tn.createRequire)(ei.url),Kc={".js":"js",".mjs":"js",".cjs":"js",".jsx":"jsx",".ts":"ts",".cts":"ts",".mts":"ts",".tsx":"tsx",".css":"css",".less":"css",".stylus":"css",".scss":"css",".sass":"css",".json":"json",".txt":"text"};function zc(e){return Kc[Se.default.extname(e).toLowerCase()]||"js"}function Xc(e){let i=[];return{addWatchFile(s){i.push(s)},getWatchFiles(){return i},emitFile(s){let n=s.fileName||s.name,u=e?.config?.outdir;if(u&&s.source&&n){let l=Se.default.resolve(u,n),m=Se.default.dirname(l);tt.default.existsSync(m)||tt.default.mkdirSync(m,{recursive:!0}),tt.default.writeFileSync(l,s.source)}},parse:mt,getNativeBuildContext(){return{framework:"bun",build:e}}}}function ys(e){let i=[],s=[];return{errors:i,warnings:s,mixedContext:{...e,error(n){i.push(n)},warn(n){s.push(n)}}}}function Jc(e){return i=>{if(typeof Bun>"u")throw new ReferenceError("Bun is not supported in this environment");if(!Bun.semver.satisfies(Bun.version,">=1.2.22"))throw new Error("Bun 1.2.22 or higher is required, please upgrade Bun");let s={framework:"bun"},n=Ge(e(i,s));return{name:(n.length===1?n[0].name:s.bunHostName)??`unplugin-host:${n.map(u=>u.name).join(":")}`,async setup(u){let l=Xc(u);n.some(E=>E.buildStart)&&u.onStart(async()=>{for(let E of n)E.buildStart&&await E.buildStart.call(l)});let m=n.filter(E=>E.resolveId).map(E=>({plugin:E,...Te("resolveId",E.resolveId)})),g=n.filter(E=>E.load).map(E=>({plugin:E,...Te("load",E.load)})),S=n.filter(E=>E.transform||E.transformInclude).map(E=>({plugin:E,...Te("transform",E.transform)})),h=new Set;for(let E of n)E.resolveId&&E.load&&h.add(E.name);m.length&&u.onResolve({filter:/.*/},async E=>{if(!u.config?.external?.includes(E.path))for(let{plugin:F,handler:_,filter:k}of m){if(!k(E.path))continue;let{mixedContext:D,errors:R,warnings:H}=ys(l),z=E.kind==="entry-point-run"||E.kind==="entry-point-build",G=await _.call(D,E.path,z?void 0:E.importer,{isEntry:z});for(let d of H)console.warn("[unplugin]",typeof d=="string"?d:d.message);if(R.length>0){let d=R.map(re=>typeof re=="string"?re:re.message).join(`
13
13
  `);throw new Error(`[unplugin] ${F.name}: ${d}`)}if(typeof G=="string")return(0,Se.isAbsolute)(G)?{path:G}:{path:G,namespace:F.name};if(typeof G=="object"&&G!==null)return(0,Se.isAbsolute)(G.id)?{path:G.id,external:G.external}:{path:G.id,external:G.external,namespace:F.name}}});async function P(E,F,_){let k,D=!1,R=F==="file"?g:g.filter(H=>H.plugin.name===F);for(let{plugin:H,handler:z,filter:G}of R){if(H.loadInclude&&!H.loadInclude(E)||!G(E))continue;let{mixedContext:d,errors:re,warnings:X}=ys(l),ne=await z.call(d,E);for(let J of X)console.warn("[unplugin]",typeof J=="string"?J:J.message);if(re.length>0){let J=re.map(Z=>typeof Z=="string"?Z:Z.message).join(`
14
14
  `);throw new Error(`[unplugin] ${H.name}: ${J}`)}if(typeof ne=="string"){k=ne,D=!0;break}else if(typeof ne=="object"&&ne!==null){k=ne.code,D=!0;break}}if(!D&&F==="file"&&S.length>0&&(k=await Bun.file(E).text()),k!==void 0){let H=F==="file"?S:S.filter(z=>z.plugin.name===F);for(let{plugin:z,handler:G,filter:d}of H){if(z.transformInclude&&!z.transformInclude(E)||!d(E,k))continue;let{mixedContext:re,errors:X,warnings:ne}=ys(l),J=await G.call(re,k,E);for(let Z of ne)console.warn("[unplugin]",typeof Z=="string"?Z:Z.message);if(X.length>0){let Z=X.map(V=>typeof V=="string"?V:V.message).join(`