@omfalos/mokosh 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var ft=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import B from"path";function w(t){switch(B.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function d(t){let e=B.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}import ut from"coffeescript";function gt(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function yt(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function dt(t,e){let r=e.source?.value;return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:d(r),type:"static"}:null}function xt(t,e){let r=e.variable?.base?.value==="require",s=e.args?.[0]?.base?.value;return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:d(s),type:"require"}}function ht(t,e,r){let s=e.constructor?.name;if(s==="ImportDeclaration"){let i=dt(t,e);i&&r.push(i)}else if(s==="Call"){let i=xt(t,e);i&&r.push(i)}}function F(t,e,r){if(!(!e||typeof e!="object")){ht(t,e,r);for(let s in e){if(s==="locationData")continue;let i=e[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let n of i)F(t,n,r);else F(t,i,r)}}}function j(t,e){let r=gt(e),s=yt(t,r),i=[];try{F(t,ut.nodes(e),i)}catch{}return{imports:i,exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:s}}import{AstBuilder as St,GherkinClassicTokenMatcher as Ct,Parser as Et}from"@cucumber/gherkin";import{IdGenerator as wt}from"@cucumber/messages";var z=new Map;function b(t,e){z.set(t,e)}function O(t){return z.get(t)}var bt=wt.uuid();function k(t,e){let r=new Set;try{let s=new St(bt),i=new Ct,a=new Et(s,i).parse(e);a.feature&&(a.feature.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.feature.children.forEach(c=>{c.scenario&&(c.scenario.tags.forEach(m=>{r.add(m.name.startsWith("@")?m.name.slice(1):m.name)}),c.scenario.examples.forEach(m=>{m.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),c.rule&&c.rule.children.forEach(m=>{m.scenario&&m.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}b("gherkin",k);import It from"path";import{parser as Pt}from"@lezer/go";var Nt=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Tt=/^\/\/go:build\s+(.+)$/,Ft=/^\/\/\s*\+build\s+(.+)$/;function q(t,e){let r=[],s=new Map,i=new Set,n=new Set,c=Pt.parse(e).cursor();do switch(c.name){case"LineComment":{let f=e.slice(c.from,c.to),x=f.match(Nt);x?.[1]&&i.add(x[1]);let S=f.match(Tt);S&&$(S[1],n);let E=f.match(Ft);E&&$(E[1],n);break}case"ImportSpec":{let f=c.node.getChild("String");if(f){let S=e.slice(f.from,f.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:S,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let f=c.node.getChild("DefName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(f){let x=e.slice(f.from,f.to);x!=="_"&&/^[A-Z]/.test(x)&&!s.has(x)&&s.set(x,{name:x})}break}}while(c.next());let m=r.some(f=>f.rawSpecifier==="testing"),p=It.basename(t).endsWith("_test.go")||i.has("test")||m?"test":"logic",h=new Set([...i,...n]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(h).map(f=>({name:f,kind:"comment-marker"})),category:p}}function $(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}import kt from"livescript";function C(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function Dt(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function vt(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var Lt=new Set(["first_line","first_column","last_line","last_column","line","column"]);function At(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let i=C(s);return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:d(i),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let i=s.args?.[0]?.value;if(typeof i=="string"){let n=C(i);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:d(n),type:"require"}}}}return null}function D(t,e){if(!t||typeof t!="object")return[];let r=[],s=At(t,e);s&&r.push(s);for(let i in t){if(Lt.has(i))continue;let n=t[i];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let a of n)r.push(...D(a,e));else r.push(...D(n,e))}return r}function V(t,e){let r=Dt(e),s=vt(t,r),i=[];try{i=D(kt.ast(e),t)}catch{}return{imports:i,exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:s}}import Rt from"luaparse";function Mt(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Wt(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function _t(t,e){let r=[];function s(i){if(!(!i||typeof i!="object")){if((i.type==="CallExpression"||i.type==="StringCallExpression")&&i.base?.type==="Identifier"&&i.base?.name==="require"){let n;if(i.type==="CallExpression"){let a=i.arguments?.[0];a?.type==="StringLiteral"&&(n=C(a.raw))}else if(i.type==="StringCallExpression"){let a=i.argument;a?.type==="StringLiteral"&&(n=C(a.raw))}n&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:d(n),type:"require"})}for(let n in i){if(n==="loc")continue;let a=i[n];if(a&&typeof a=="object")if(Array.isArray(a))for(let c of a)s(c);else s(a)}}}return s(t),r}function J(t,e){let r=Mt(e),s=Wt(t,r),i=[];try{let n=Rt.parse(e);i=_t(n,t)}catch{}return{imports:i,exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:s}}var Kt=["http://","https://","mailto:","//"],Bt="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",jt=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Bt})\\b`,"g"),G;async function zt(){return G??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),G}function Ot(t){let e=t.trim();return e.length===0||e.startsWith("#")||Kt.some(r=>e.startsWith(r))}function $t(t,e){let r=t.match(jt);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function U(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Ot(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...$t(t.value,e)),Array.isArray(t.children))for(let s of t.children)U(s,e,r)}async function Q(t,e){let s=(await zt()).parse(e),i=[];U(s,t,i);let n=new Set;return{imports:i.filter(c=>n.has(c.rawSpecifier)?!1:(n.add(c.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import qt from"path";import{parser as Vt}from"@lezer/python";var Jt=new Set(["pytest","unittest","nose","hypothesis"]);function Z(t,e){let r=[],s=[],i=new Set,n=qt.basename(t).toLowerCase(),c=Vt.parse(e).cursor();do switch(c.name){case"Comment":{let p=e.slice(c.from,c.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&i.add(p[1]);break}case"ImportStatement":{for(let p of Gt(c.node,e,t))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=c.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let f=c.node.getChild("VariableName");f&&s.push({name:e.slice(f.from,f.to)})}break}case"AssignStatement":{if(c.node.parent?.name==="Script"){let p=c.node.firstChild;p?.name==="VariableName"&&s.push({name:e.slice(p.from,p.to)})}break}}while(c.next());let m=Xt(n,r,i);return m==="test"&&i.add("test"),{imports:r,exports:s,tags:Array.from(i).map(p=>({name:p,kind:"comment-marker"})),category:m}}function Gt(t,e,r){let s=t.firstChild;return s?s.name==="from"?Ut(t,e,r):Qt(t,e,r):[]}function Ut(t,e,r){let s=t.firstChild;if(!s)return[];let i=s.nextSibling;for(;i&&i.name!=="import";)i=i.nextSibling;if(!i)return[];let n=e.slice(s.to,i.from).trim(),a=Zt(i.nextSibling,e);if(!a.length)return[];let c=0;for(;c<n.length&&n[c]===".";)c++;let m=n.slice(c);if(c===0)return[I(r,n,a,!0)];let p=c===1?"./":"../".repeat(c-1);return m?[I(r,p+m.replace(/\./g,"/"),a,!1)]:a[0]==="*"?[I(r,p.slice(0,-1),["*"],!1)]:a.map(h=>I(r,p+h,[h],!1))}function Qt(t,e,r){let s=[],i=t.firstChild?.nextSibling??null;for(;i;){if(i.name==="VariableName"){let n=e.slice(i.from,i.to);for(;i.nextSibling?.name==="."&&i.nextSibling.nextSibling?.name==="VariableName";)i=i.nextSibling.nextSibling,n+=`.${e.slice(i.from,i.to)}`;i.nextSibling?.name==="as"&&(i=i.nextSibling.nextSibling??i.nextSibling),s.push(I(r,n,["*"],!0))}i=i.nextSibling}return s}function Zt(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function I(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function Xt(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>Jt.has(s.rawSpecifier))?"test":"logic"}import Y from"path";import o from"typescript";var Ht=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Yt=[];function X(t){return[...Ht,...Yt].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var te=[".test.",".spec.","-test.","-spec."],ee=[];function v(){return[...te,...ee]}var re=["jest","vitest","playwright","cypress","@testing-library/"],se=[];function L(){return[...re,...se]}var ie=.8;function A(){return ie}import l from"typescript";function ne(t){let e=1;function r(s){switch(s.kind){case l.SyntaxKind.IfStatement:case l.SyntaxKind.ConditionalExpression:case l.SyntaxKind.ForStatement:case l.SyntaxKind.ForInStatement:case l.SyntaxKind.ForOfStatement:case l.SyntaxKind.WhileStatement:case l.SyntaxKind.DoStatement:case l.SyntaxKind.CatchClause:case l.SyntaxKind.CaseClause:e++;break;case l.SyntaxKind.BinaryExpression:{let i=s.operatorToken.kind;(i===l.SyntaxKind.AmpersandAmpersandToken||i===l.SyntaxKind.BarBarToken||i===l.SyntaxKind.QuestionQuestionToken)&&e++;break}}l.forEachChild(s,r)}return r(t),e}function oe(t){let e=0;function r(s,i,n){if(l.isIfStatement(s)){e+=n?1:1+i;let c=n?i:i+1;r(s.expression,c,!1),r(s.thenStatement,c,!1),s.elseStatement&&(l.isIfStatement(s.elseStatement)?r(s.elseStatement,i,!0):(e+=1,r(s.elseStatement,i+1,!1)));return}if(l.isForStatement(s)||l.isForInStatement(s)||l.isForOfStatement(s)||l.isWhileStatement(s)||l.isDoStatement(s)||l.isSwitchStatement(s)){e+=1+i,l.forEachChild(s,c=>r(c,i+1,!1));return}if(l.isCatchClause(s)){e+=1+i,l.forEachChild(s,c=>r(c,i,!1));return}if(l.isConditionalExpression(s)&&(e+=1),l.isBinaryExpression(s)){let c=s.operatorToken.kind;(c===l.SyntaxKind.AmpersandAmpersandToken||c===l.SyntaxKind.BarBarToken||c===l.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(i>0&&(l.isFunctionDeclaration(s)||l.isFunctionExpression(s)||l.isArrowFunction(s))){e+=1+i,l.forEachChild(s,c=>r(c,i+1,!1));return}l.forEachChild(s,c=>r(c,i,!1))}return r(t,0,!1),e}function R(t){return{complexity:ne(t),cognitiveComplexity:oe(t)}}import u from"typescript";var M=new Set(["test","describe","it"]);function H(t,e){ae(t,e),pe(t,e),le(t,e),me(t,e)}function ae(t,e){if((u.isFunctionDeclaration(t)||u.isVariableDeclaration(t))&&t.name&&u.isIdentifier(t.name)&&ce(t)){let r;if(u.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(u.isArrowFunction(s)||u.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function ce(t){if(u.isFunctionDeclaration(t))return u.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&u.isSourceFile(e.parent)}function pe(t,e){if(!u.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function le(t,e){if(!u.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),i=r.exec(s);for(;i!==null;)i[1]&&e.tags.add({name:i[1],kind:"comment-marker"}),i=r.exec(s)}function me(t,e){if(u.isCallExpression(t)&&fe(t.expression))for(let r of t.arguments)u.isObjectLiteralExpression(r)&&ue(r,e)}function fe(t){return u.isIdentifier(t)?M.has(t.text):!!(u.isPropertyAccessExpression(t)&&(M.has(t.name.text)||u.isIdentifier(t.expression)&&M.has(t.expression.text)))}function ue(t,e){for(let r of t.properties){if(!u.isPropertyAssignment(r)||!u.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,i=u.isArrayLiteralExpression(s)?s.elements.filter(u.isStringLiteral):r.name.text==="tag"&&u.isStringLiteral(s)?[s]:[];for(let n of i)e.tags.add({name:n.text.replace(/^@/,""),kind:"comment-marker"})}}function W(t,e,r){let s=[],i=new Map,n=new Set,a=o.createSourceFile(t,e,o.ScriptTarget.Latest,!0,r==="typescript"?o.ScriptKind.TSX:o.ScriptKind.JSX),c={filePath:t,imports:s,exports:i,tags:n,rawCallEdges:[],sourceFile:a,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},m=K=>{xe(K,c),o.forEachChild(K,m)};m(a);let p=Fe(t,c);(p==="test"||p==="barrel")&&n.add({name:p,kind:"comment-marker"}),p!=="test"&&ke(c,a);let h=a.statements[0],f=h?et(h):void 0,{complexity:x,cognitiveComplexity:S}=R(a),E=ge(a);return{imports:s,exports:Array.from(i.values()),tags:Array.from(n),category:p,rawCallEdges:c.rawCallEdges??[],complexity:x,cognitiveComplexity:S,...E.length>0?{functions:E}:{},...f!==void 0?{description:f}:{}}}function ge(t){let e=[],r=(i,n)=>{let{complexity:a,cognitiveComplexity:c}=R(n),m=t.getLineAndCharacterOfPosition(n.getStart(t)).line+1;e.push({name:i,line:m,complexity:a,cognitiveComplexity:c})},s=(i,n)=>{if(o.isFunctionDeclaration(i)&&i.name&&i.body?r(i.name.text,i):o.isVariableDeclaration(i)&&o.isIdentifier(i.name)&&i.initializer&&(o.isArrowFunction(i.initializer)||o.isFunctionExpression(i.initializer))?r(i.name.text,i.initializer):n&&o.isMethodDeclaration(i)&&o.isIdentifier(i.name)&&i.body?r(`${n}.${i.name.text}`,i):n&&o.isConstructorDeclaration(i)&&i.body?r(`${n}.constructor`,i):n&&o.isGetAccessorDeclaration(i)&&o.isIdentifier(i.name)&&i.body?r(`${n}.get ${i.name.text}`,i):n&&o.isSetAccessorDeclaration(i)&&o.isIdentifier(i.name)&&i.body&&r(`${n}.set ${i.name.text}`,i),o.isClassDeclaration(i)&&i.name){let a=i.name.text;o.forEachChild(i,c=>s(c,a));return}o.forEachChild(i,a=>s(a,n))};return s(t,void 0),e}function tt(t,e,r,s){let i={name:t},n=et(r);n!==void 0&&(i.doc=n);let a=ye(e);a!==void 0&&(i.flags=a);let c=de(e,s);return c!==void 0&&(i.signature=c),i}function et(t){let e=o.getJSDocCommentsAndTags(t);for(let r of e)if(o.isJSDoc(r)&&r.comment)return o.getTextOfJSDocComment(r.comment)||void 0}function ye(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=o.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function de(t,e){let r=o.createPrinter({removeComments:!0}),s=i=>r.printNode(o.EmitHint.Unspecified,i,e);if(o.isFunctionDeclaration(t)||o.isMethodDeclaration(t)){let i=t.parameters.map(s).join(", "),n=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(c=>c.name.text).join(", ")}>`:""}(${i}) => ${n}`}if(o.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(o.isArrowFunction(t.initializer)||o.isFunctionExpression(t.initializer))){let i=t.initializer,n=i.parameters.map(s).join(", "),a=i.type?s(i.type):"unknown";return`(${n}) => ${a}`}return}if(o.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(o.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(o.isTypeAliasDeclaration(t))return s(t.type);if(o.isEnumDeclaration(t))return`enum ${t.name.text}`}function xe(t,e){he(t,e),Se(t,e),Ee(t,e),we(t,e),Te(t,e),H(t,e)}function he(t,e){if(!o.isSourceFile(t))return;let r=t.statements.filter(s=>!o.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>o.isExportDeclaration(s)||o.isExportAssignment(s)||_(s)).length}function Se(t,e){if(o.isJsxElement(t)||o.isJsxSelfClosingElement(t)||o.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(o.isFunctionDeclaration(t)||o.isMethodDeclaration(t)||o.isArrowFunction(t)||o.isClassDeclaration(t)||o.isVariableStatement(t)||o.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}o.isExportDeclaration(t)&&!Ce(t)&&(e.hasTypesOnly=!1)}function Ce(t){return t.isTypeOnly?!0:!t.exportClause||!o.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function Ee(t,e){if(!o.isImportDeclaration(t)||!t.moduleSpecifier||!o.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(o.isNamedImports(t.importClause.namedBindings))for(let i of t.importClause.namedBindings.elements)r.push(i.name.text);else o.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:d(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function we(t,e){o.isExportDeclaration(t)?be(t,e):o.isExportAssignment(t)?e.exports.set("default",{name:"default"}):_(t)&&Ne(t,e)}function be(t,e){if(t.moduleSpecifier&&o.isStringLiteral(t.moduleSpecifier))Ie(t,t.moduleSpecifier.text,e);else if(t.exportClause&&o.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function Ie(t,e,r){let s=Pe(t),i={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:d(e),type:"re-export"};s.length>0&&(i.symbols=s),r.imports.push(i)}function Pe(t){return t.exportClause?o.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Ne(t,e){if((o.isFunctionDeclaration(t)||o.isClassDeclaration(t)||o.isInterfaceDeclaration(t)||o.isTypeAliasDeclaration(t)||o.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,tt(s,t,t,e.sourceFile));return}if(o.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(o.isIdentifier(s.name)){let i=s.name.text;e.exports.set(i,tt(i,s,t,e.sourceFile))}}}function Te(t,e){if(!o.isCallExpression(t))return;let r=t.arguments[0];!r||!o.isStringLiteral(r)||(t.expression.kind===o.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:d(r.text),type:"dynamic"}):o.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:d(r.text),type:"require"}))}function Fe(t,e){let r=Y.basename(t).toLowerCase(),s=Y.extname(t).toLowerCase();return v().some(n=>r.includes(n))?"test":X(r)?"config":e.imports.some(n=>L().some(a=>n.rawSpecifier.includes(a)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>A()?"barrel":"logic"}function _(t){return o.canHaveModifiers(t)&&o.getModifiers(t)?.some(e=>e.kind===o.SyntaxKind.ExportKeyword)===!0}function ke(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let i of e.statements){if(!o.isImportDeclaration(i)||!o.isStringLiteral(i.moduleSpecifier))continue;let n=i.moduleSpecifier.text,a=i.importClause;if(a&&(a.name&&s.set(a.name.text,n),a.namedBindings&&o.isNamedImports(a.namedBindings)))for(let c of a.namedBindings.elements)s.set(c.name.text,n)}if(s.size!==0)for(let i of e.statements){let n=ve(i);if(n){let a=Le(i);a&&N(a,n,s,r);continue}o.isClassDeclaration(i)&&i.name&&De(i,s,r)}}function De(t,e,r){let s=t.name.text;for(let i of t.members)o.isMethodDeclaration(i)&&i.body&&o.isIdentifier(i.name)?N(i.body,`${s}.${i.name.text}`,e,r):o.isConstructorDeclaration(i)&&i.body&&N(i.body,`${s}.constructor`,e,r)}function ve(t){if(_(t)){if(o.isFunctionDeclaration(t)&&t.name)return t.name.text;if(o.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(o.isIdentifier(e.name)&&e.initializer&&(o.isArrowFunction(e.initializer)||o.isFunctionExpression(e.initializer)))return e.name.text}}}function Le(t){if(o.isFunctionDeclaration(t))return t.body;if(o.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(o.isArrowFunction(e.initializer)||o.isFunctionExpression(e.initializer)))return e.initializer}}function N(t,e,r,s){if(o.isCallExpression(t)&&o.isIdentifier(t.expression)){let i=t.expression.text,n=r.get(i);n&&!s.some(a=>a.from===e&&a.to===i&&a.toSpecifier===n)&&s.push({from:e,to:i,toSpecifier:n})}o.forEachChild(t,i=>N(i,e,r,s))}function T(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import st from"postcss";import*as Ae from"postcss-less";var Re=Ae,it=new Set(["reference","inline"]);function rt(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Me(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function We(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let n=r[1]?.trim()??"",a=r[2]??"";if(!a)return null;let c=it.has(n)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:c,...rt(a)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),i=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return i?{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static",...rt(i)?{isExternal:!0}:{}}:null}function _e(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"";Me(n)&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static"}),i=s.exec(t)}return r}function nt(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let i=We(s.params,e);i&&r.push(i)}s.type==="decl"&&r.push(..._e(s.value,e))}),r}function Ke(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Be(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"",a=i[2]??"";if(a){let c=it.has(n)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:c})}i=s.exec(t)}return r}function ot(t,e){let r=st.parse(Ke(t));return{imports:nt(r,e),root:r}}function at(t,e){try{let r=Re.parse(t);return{imports:nt(r,e),root:r}}catch{return{imports:Be(t,e),root:st.parse("")}}}import{parse as je}from"postcss-scss";function ze(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Oe(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],i=t.match(/\bas\s+(\S+)/)?.[1];return i!==void 0?{specifier:r,alias:i}:{specifier:r}}function ct(t,e){let r=je(t),s=[];return r.walk(i=>{if(i.type!=="atrule")return;let{name:n,params:a}=i;if(n!=="import"&&n!=="use"&&n!=="forward")return;let{specifier:c,alias:m}=Oe(a);if(!c)return;let p={fromPath:e,toPath:"",rawSpecifier:c,isStyle:!0,type:n==="forward"?"re-export":"static",...ze(c)?{isExternal:!0}:{}};m&&(p.symbols=[m]),s.push(p)}),{imports:s,root:r}}function pt(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let a=i[1];a&&r.push({fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:"require"}),i=s.exec(t)}let n=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(i=n.exec(t);i!==null;){let a=i[1];a&&r.push({fromPath:e,toPath:"",rawSpecifier:a,isStyle:!0,type:"static"}),i=n.exec(t)}return r}function lt(t,e){if(e.length===0)return"ui";try{let r=ft("stylus");return new r.Parser(t).parse().nodes.some(n=>n.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function P(t,e){let r=w(t);if(r==="stylus"){let n=pt(e,t);return{imports:n,exports:[],tags:[],category:lt(e,n)}}if(r==="scss"){let{imports:n,root:a}=ct(e,t);return{imports:n,exports:[],tags:[],category:T(a,n)}}if(r==="less"){let{imports:n,root:a}=at(e,t);return{imports:n,exports:[],tags:[],category:T(a,n)}}let{imports:s,root:i}=ot(e,t);return{imports:s,exports:[],tags:[],category:T(i,s)}}for(let[t,e]of[["javascript",(r,s)=>W(r,s,"javascript")],["typescript",(r,s)=>W(r,s,"typescript")],["css",P],["scss",P],["less",P],["stylus",P],["coffeescript",j],["livescript",V],["lua",J],["python",Z],["go",q],["gherkin",k],["markdown",Q]])b(t,e);async function mt(t,e){let r=w(t),s=O(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}function $e(t){return mt(t.filePath,t.content)}export{$e as default};
1
+ var yt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import j from"path";function w(t){switch(j.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function y(t){let e=j.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}import xt from"coffeescript";function S(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function O(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return S(t.value)}}function E(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function ht(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function St(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Et(t,e){let r=O(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:y(r),type:"static"}:null}function Ct(t,e){let r=e.variable?.base?.value==="require",s=O(e.args?.[0]?.base);return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:y(s),type:"require"}}function z(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let i=E(r.variable);return i?[{name:i}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(i=>E(i.variable)??E(i)).filter(i=>!!i).map(i=>({name:i}));let s=E(r);return s?[{name:s}]:[]}function bt(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=E(t.variable)??E(t.variable?.base);return e?[{name:e}]:[]}function wt(t,e,r,s){let i=e.constructor?.name;if(i==="ImportDeclaration"){let n=Et(t,e);n&&r.push(n)}else if(i==="Call"){let n=Ct(t,e);n&&r.push(n)}else if(i==="Assign"){let n=E(e.variable?.base),o=e.variable?.properties?.[0]?.name?.value;n==="module"&&o==="exports"?s.push(...z(e,void 0)):n==="exports"&&typeof o=="string"&&s.push(...z(e,o))}else i==="ExportNamedDeclaration"&&e.clause?s.push(...bt(e.clause)):i==="ExportDefaultDeclaration"&&s.push({name:"default"})}function k(t,e,r,s){if(!(!e||typeof e!="object")){wt(t,e,r,s);for(let i in e){if(i==="locationData")continue;let n=e[i];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)k(t,o,r,s);else k(t,n,r,s)}}}function $(t,e){let r=ht(e),s=St(t,r),i=[],n=[];try{k(t,xt.nodes(e),i,n)}catch{}let o=new Set,c=n.filter(m=>o.has(m.name)?!1:(o.add(m.name),!0));return{imports:i,exports:c,tags:Array.from(r).map(m=>({name:m,kind:"comment-marker"})),category:s}}import{AstBuilder as Nt,GherkinClassicTokenMatcher as Tt,Parser as It}from"@cucumber/gherkin";import{IdGenerator as Pt}from"@cucumber/messages";var V=new Map;function N(t,e){V.set(t,e)}function q(t){return V.get(t)}var Ft=Pt.uuid();function v(t,e){let r=new Set;try{let s=new Nt(Ft),i=new Tt,o=new It(s,i).parse(e);o.feature&&(o.feature.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),o.feature.children.forEach(c=>{c.scenario&&(c.scenario.tags.forEach(m=>{r.add(m.name.startsWith("@")?m.name.slice(1):m.name)}),c.scenario.examples.forEach(m=>{m.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),c.rule&&c.rule.children.forEach(m=>{m.scenario&&m.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(s){console.warn(`[GherkinParser] Failed to parse ${t}:`,s)}return{imports:[],exports:[],tags:Array.from(r).map(s=>({name:s,kind:"comment-marker"})),category:"test"}}N("gherkin",v);import kt from"path";import{parser as vt}from"@lezer/go";var Dt=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Lt=/^\/\/go:build\s+(.+)$/,At=/^\/\/\s*\+build\s+(.+)$/;function G(t,e){let r=[],s=new Map,i=new Set,n=new Set,c=vt.parse(e).cursor();do switch(c.name){case"LineComment":{let f=e.slice(c.from,c.to),h=f.match(Dt);h?.[1]&&i.add(h[1]);let C=f.match(Lt);C&&J(C[1],n);let b=f.match(At);b&&J(b[1],n);break}case"ImportSpec":{let f=c.node.getChild("String");if(f){let C=e.slice(f.from,f.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:C,isExternal:!0,isStyle:!1,type:"static"})}break}case"FunctionDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let f=c.node.getChild("DefName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(f){let h=e.slice(f.from,f.to);h!=="_"&&/^[A-Z]/.test(h)&&!s.has(h)&&s.set(h,{name:h})}break}}while(c.next());let m=r.some(f=>f.rawSpecifier==="testing"),p=kt.basename(t).endsWith("_test.go")||i.has("test")||m?"test":"logic",x=new Set([...i,...n]);return{imports:r,exports:Array.from(s.values()),tags:Array.from(x).map(f=>({name:f,kind:"comment-marker"})),category:p}}function J(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}import Rt from"livescript";function Mt(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function Wt(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var _t=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Kt(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let i=S(s);return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:y(i),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let i=s.args?.[0]?.value;if(typeof i=="string"){let n=S(i);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:y(n),type:"require"}}}}return null}function D(t,e){if(!t||typeof t!="object")return[];let r=[],s=Kt(t,e);s&&r.push(s);for(let i in t){if(_t.has(i))continue;let n=t[i];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)r.push(...D(o,e));else r.push(...D(n,e))}return r}function Q(t,e){let r=Mt(e),s=Wt(t,r),i=[];try{i=D(Rt.ast(e),t)}catch{}return{imports:i,exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:s}}import Bt from"luaparse";function jt(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function zt(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function Ot(t,e){let r=[];function s(i){if(!(!i||typeof i!="object")){if((i.type==="CallExpression"||i.type==="StringCallExpression")&&i.base?.type==="Identifier"&&i.base?.name==="require"){let n;if(i.type==="CallExpression"){let o=i.arguments?.[0];o?.type==="StringLiteral"&&(n=S(o.raw))}else if(i.type==="StringCallExpression"){let o=i.argument;o?.type==="StringLiteral"&&(n=S(o.raw))}n&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:y(n),type:"require"})}for(let n in i){if(n==="loc")continue;let o=i[n];if(o&&typeof o=="object")if(Array.isArray(o))for(let c of o)s(c);else s(o)}}}return s(t),r}function $t(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((s,i)=>{r.init[i]?.type==="TableConstructorExpression"&&e.add(s.name)});return e}function Vt(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let s=[];for(let i of r.fields)i.type==="TableKeyString"&&s.push({name:i.key.name});return s}function qt(t){let e=t.body,r=$t(e),s=Vt(e);for(let n of e)if(n.type==="FunctionDeclaration")n.identifier?.type==="MemberExpression"?n.identifier.base.type==="Identifier"&&r.has(n.identifier.base.name)&&s.push({name:n.identifier.identifier.name}):n.identifier?.type==="Identifier"&&!n.isLocal&&s.push({name:n.identifier.name});else if(n.type==="AssignmentStatement")for(let o of n.variables)o.type==="MemberExpression"&&o.base.type==="Identifier"&&r.has(o.base.name)&&s.push({name:o.identifier.name});let i=new Set;return s.filter(n=>i.has(n.name)?!1:(i.add(n.name),!0))}function U(t,e){let r=jt(e),s=zt(t,r),i=[],n=[];try{let o=Bt.parse(e);i=Ot(o,t),n=qt(o)}catch{}return{imports:i,exports:n,tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var Jt=["http://","https://","mailto:","//"],Gt="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Qt=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Gt})\\b`,"g"),Z;async function Ut(){return Z??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Z}function Zt(t){let e=t.trim();return e.length===0||e.startsWith("#")||Jt.some(r=>e.startsWith(r))}function Xt(t,e){let r=t.match(Qt);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function X(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Zt(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...Xt(t.value,e)),Array.isArray(t.children))for(let s of t.children)X(s,e,r)}async function H(t,e){let s=(await Ut()).parse(e),i=[];X(s,t,i);let n=new Set;return{imports:i.filter(c=>n.has(c.rawSpecifier)?!1:(n.add(c.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import Ht from"path";import{parser as Yt}from"@lezer/python";var te=new Set(["pytest","unittest","nose","hypothesis"]);function Y(t,e){let r=[],s=[],i=new Set,n=Ht.basename(t).toLowerCase(),c=Yt.parse(e).cursor();do switch(c.name){case"Comment":{let p=e.slice(c.from,c.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);p?.[1]&&i.add(p[1]);break}case"ImportStatement":{for(let p of ee(c.node,e,t))r.push(p);break}case"FunctionDefinition":case"ClassDefinition":{let p=c.node.parent;if(p?.name==="Script"||p?.name==="DecoratedStatement"&&p.parent?.name==="Script"){let f=c.node.getChild("VariableName");f&&s.push({name:e.slice(f.from,f.to)})}break}case"AssignStatement":{if(c.node.parent?.name==="Script"){let p=c.node.firstChild;p?.name==="VariableName"&&s.push({name:e.slice(p.from,p.to)})}break}}while(c.next());let m=ne(n,r,i);return m==="test"&&i.add("test"),{imports:r,exports:s,tags:Array.from(i).map(p=>({name:p,kind:"comment-marker"})),category:m}}function ee(t,e,r){let s=t.firstChild;return s?s.name==="from"?re(t,e,r):se(t,e,r):[]}function re(t,e,r){let s=t.firstChild;if(!s)return[];let i=s.nextSibling;for(;i&&i.name!=="import";)i=i.nextSibling;if(!i)return[];let n=e.slice(s.to,i.from).trim(),o=ie(i.nextSibling,e);if(!o.length)return[];let c=0;for(;c<n.length&&n[c]===".";)c++;let m=n.slice(c);if(c===0)return[T(r,n,o,!0)];let p=c===1?"./":"../".repeat(c-1);return m?[T(r,p+m.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[T(r,p.slice(0,-1),["*"],!1)]:o.map(x=>T(r,p+x,[x],!1))}function se(t,e,r){let s=[],i=t.firstChild?.nextSibling??null;for(;i;){if(i.name==="VariableName"){let n=e.slice(i.from,i.to);for(;i.nextSibling?.name==="."&&i.nextSibling.nextSibling?.name==="VariableName";)i=i.nextSibling.nextSibling,n+=`.${e.slice(i.from,i.to)}`;i.nextSibling?.name==="as"&&(i=i.nextSibling.nextSibling??i.nextSibling),s.push(T(r,n,["*"],!0))}i=i.nextSibling}return s}function ie(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function T(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function ne(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>te.has(s.rawSpecifier))?"test":"logic"}import rt from"path";import a from"typescript";var oe=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],ae=[];function tt(t){return[...oe,...ae].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var ce=[".test.",".spec.","-test.","-spec."],pe=[];function L(){return[...ce,...pe]}var le=["jest","vitest","playwright","cypress","@testing-library/"],me=[];function A(){return[...le,...me]}var fe=.8;function R(){return fe}import l from"typescript";function ue(t){let e=1;function r(s){switch(s.kind){case l.SyntaxKind.IfStatement:case l.SyntaxKind.ConditionalExpression:case l.SyntaxKind.ForStatement:case l.SyntaxKind.ForInStatement:case l.SyntaxKind.ForOfStatement:case l.SyntaxKind.WhileStatement:case l.SyntaxKind.DoStatement:case l.SyntaxKind.CatchClause:case l.SyntaxKind.CaseClause:e++;break;case l.SyntaxKind.BinaryExpression:{let i=s.operatorToken.kind;(i===l.SyntaxKind.AmpersandAmpersandToken||i===l.SyntaxKind.BarBarToken||i===l.SyntaxKind.QuestionQuestionToken)&&e++;break}}l.forEachChild(s,r)}return r(t),e}function ge(t){let e=0;function r(s,i,n){if(l.isIfStatement(s)){e+=n?1:1+i;let c=n?i:i+1;r(s.expression,c,!1),r(s.thenStatement,c,!1),s.elseStatement&&(l.isIfStatement(s.elseStatement)?r(s.elseStatement,i,!0):(e+=1,r(s.elseStatement,i+1,!1)));return}if(l.isForStatement(s)||l.isForInStatement(s)||l.isForOfStatement(s)||l.isWhileStatement(s)||l.isDoStatement(s)||l.isSwitchStatement(s)){e+=1+i,l.forEachChild(s,c=>r(c,i+1,!1));return}if(l.isCatchClause(s)){e+=1+i,l.forEachChild(s,c=>r(c,i,!1));return}if(l.isConditionalExpression(s)&&(e+=1),l.isBinaryExpression(s)){let c=s.operatorToken.kind;(c===l.SyntaxKind.AmpersandAmpersandToken||c===l.SyntaxKind.BarBarToken||c===l.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(i>0&&(l.isFunctionDeclaration(s)||l.isFunctionExpression(s)||l.isArrowFunction(s))){e+=1+i,l.forEachChild(s,c=>r(c,i+1,!1));return}l.forEachChild(s,c=>r(c,i,!1))}return r(t,0,!1),e}function M(t){return{complexity:ue(t),cognitiveComplexity:ge(t)}}import u from"typescript";var W=new Set(["test","describe","it"]);function et(t,e){de(t,e),xe(t,e),he(t,e),Se(t,e)}function de(t,e){if((u.isFunctionDeclaration(t)||u.isVariableDeclaration(t))&&t.name&&u.isIdentifier(t.name)&&ye(t)){let r;if(u.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(u.isArrowFunction(s)||u.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function ye(t){if(u.isFunctionDeclaration(t))return u.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&u.isSourceFile(e.parent)}function xe(t,e){if(!u.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function he(t,e){if(!u.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),i=r.exec(s);for(;i!==null;)i[1]&&e.tags.add({name:i[1],kind:"comment-marker"}),i=r.exec(s)}function Se(t,e){if(u.isCallExpression(t)&&Ee(t.expression))for(let r of t.arguments)u.isObjectLiteralExpression(r)&&Ce(r,e)}function Ee(t){return u.isIdentifier(t)?W.has(t.text):!!(u.isPropertyAccessExpression(t)&&(W.has(t.name.text)||u.isIdentifier(t.expression)&&W.has(t.expression.text)))}function Ce(t,e){for(let r of t.properties){if(!u.isPropertyAssignment(r)||!u.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,i=u.isArrayLiteralExpression(s)?s.elements.filter(u.isStringLiteral):r.name.text==="tag"&&u.isStringLiteral(s)?[s]:[];for(let n of i)e.tags.add({name:n.text.replace(/^@/,""),kind:"comment-marker"})}}function _(t,e,r){let s=[],i=new Map,n=new Set,o=a.createSourceFile(t,e,a.ScriptTarget.Latest,!0,r==="typescript"?a.ScriptKind.TSX:a.ScriptKind.JSX),c={filePath:t,imports:s,exports:i,tags:n,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},m=B=>{Te(B,c),a.forEachChild(B,m)};m(o);let p=We(t,c);(p==="test"||p==="barrel")&&n.add({name:p,kind:"comment-marker"}),p!=="test"&&_e(c,o);let x=o.statements[0],f=x?it(x):void 0,{complexity:h,cognitiveComplexity:C}=M(o),b=be(o);return{imports:s,exports:Array.from(i.values()),tags:Array.from(n),category:p,rawCallEdges:c.rawCallEdges??[],complexity:h,cognitiveComplexity:C,...b.length>0?{functions:b}:{},...f!==void 0?{description:f}:{}}}function be(t){let e=[],r=(i,n)=>{let{complexity:o,cognitiveComplexity:c}=M(n),m=t.getLineAndCharacterOfPosition(n.getStart(t)).line+1;e.push({name:i,line:m,complexity:o,cognitiveComplexity:c})},s=(i,n)=>{if(a.isFunctionDeclaration(i)&&i.name&&i.body?r(i.name.text,i):a.isVariableDeclaration(i)&&a.isIdentifier(i.name)&&i.initializer&&(a.isArrowFunction(i.initializer)||a.isFunctionExpression(i.initializer))?r(i.name.text,i.initializer):n&&a.isMethodDeclaration(i)&&a.isIdentifier(i.name)&&i.body?r(`${n}.${i.name.text}`,i):n&&a.isConstructorDeclaration(i)&&i.body?r(`${n}.constructor`,i):n&&a.isGetAccessorDeclaration(i)&&a.isIdentifier(i.name)&&i.body?r(`${n}.get ${i.name.text}`,i):n&&a.isSetAccessorDeclaration(i)&&a.isIdentifier(i.name)&&i.body&&r(`${n}.set ${i.name.text}`,i),a.isClassDeclaration(i)&&i.name){let o=i.name.text;a.forEachChild(i,c=>s(c,o));return}a.forEachChild(i,o=>s(o,n))};return s(t,void 0),e}function st(t,e,r,s){let i={name:t},n=it(r);n!==void 0&&(i.doc=n);let o=we(e);o!==void 0&&(i.flags=o);let c=Ne(e,s);return c!==void 0&&(i.signature=c),i}function it(t){let e=a.getJSDocCommentsAndTags(t);for(let r of e)if(a.isJSDoc(r)&&r.comment)return a.getTextOfJSDocComment(r.comment)||void 0}function we(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=a.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function Ne(t,e){let r=a.createPrinter({removeComments:!0}),s=i=>r.printNode(a.EmitHint.Unspecified,i,e);if(a.isFunctionDeclaration(t)||a.isMethodDeclaration(t)){let i=t.parameters.map(s).join(", "),n=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(c=>c.name.text).join(", ")}>`:""}(${i}) => ${n}`}if(a.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(a.isArrowFunction(t.initializer)||a.isFunctionExpression(t.initializer))){let i=t.initializer,n=i.parameters.map(s).join(", "),o=i.type?s(i.type):"unknown";return`(${n}) => ${o}`}return}if(a.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(a.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(a.isTypeAliasDeclaration(t))return s(t.type);if(a.isEnumDeclaration(t))return`enum ${t.name.text}`}function Te(t,e){Ie(t,e),Pe(t,e),ke(t,e),ve(t,e),Me(t,e),et(t,e)}function Ie(t,e){if(!a.isSourceFile(t))return;let r=t.statements.filter(s=>!a.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>a.isExportDeclaration(s)||a.isExportAssignment(s)||K(s)).length}function Pe(t,e){if(a.isJsxElement(t)||a.isJsxSelfClosingElement(t)||a.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(a.isFunctionDeclaration(t)||a.isMethodDeclaration(t)||a.isArrowFunction(t)||a.isClassDeclaration(t)||a.isVariableStatement(t)||a.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}a.isExportDeclaration(t)&&!Fe(t)&&(e.hasTypesOnly=!1)}function Fe(t){return t.isTypeOnly?!0:!t.exportClause||!a.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function ke(t,e){if(!a.isImportDeclaration(t)||!t.moduleSpecifier||!a.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(a.isNamedImports(t.importClause.namedBindings))for(let i of t.importClause.namedBindings.elements)r.push(i.name.text);else a.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:y(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function ve(t,e){a.isExportDeclaration(t)?De(t,e):a.isExportAssignment(t)?e.exports.set("default",{name:"default"}):K(t)&&Re(t,e)}function De(t,e){if(t.moduleSpecifier&&a.isStringLiteral(t.moduleSpecifier))Le(t,t.moduleSpecifier.text,e);else if(t.exportClause&&a.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function Le(t,e,r){let s=Ae(t),i={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:y(e),type:"re-export"};s.length>0&&(i.symbols=s),r.imports.push(i)}function Ae(t){return t.exportClause?a.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function Re(t,e){if((a.isFunctionDeclaration(t)||a.isClassDeclaration(t)||a.isInterfaceDeclaration(t)||a.isTypeAliasDeclaration(t)||a.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,st(s,t,t,e.sourceFile));return}if(a.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(a.isIdentifier(s.name)){let i=s.name.text;e.exports.set(i,st(i,s,t,e.sourceFile))}}}function Me(t,e){if(!a.isCallExpression(t))return;let r=t.arguments[0];!r||!a.isStringLiteral(r)||(t.expression.kind===a.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:y(r.text),type:"dynamic"}):a.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:y(r.text),type:"require"}))}function We(t,e){let r=rt.basename(t).toLowerCase(),s=rt.extname(t).toLowerCase();return L().some(n=>r.includes(n))?"test":tt(r)?"config":e.imports.some(n=>A().some(o=>n.rawSpecifier.includes(o)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>R()?"barrel":"logic"}function K(t){return a.canHaveModifiers(t)&&a.getModifiers(t)?.some(e=>e.kind===a.SyntaxKind.ExportKeyword)===!0}function _e(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let i of e.statements){if(!a.isImportDeclaration(i)||!a.isStringLiteral(i.moduleSpecifier))continue;let n=i.moduleSpecifier.text,o=i.importClause;if(o&&(o.name&&s.set(o.name.text,n),o.namedBindings&&a.isNamedImports(o.namedBindings)))for(let c of o.namedBindings.elements)s.set(c.name.text,n)}if(s.size!==0)for(let i of e.statements){let n=Be(i);if(n){let o=je(i);o&&P(o,n,s,r);continue}a.isClassDeclaration(i)&&i.name&&Ke(i,s,r)}}function Ke(t,e,r){let s=t.name.text;for(let i of t.members)a.isMethodDeclaration(i)&&i.body&&a.isIdentifier(i.name)?P(i.body,`${s}.${i.name.text}`,e,r):a.isConstructorDeclaration(i)&&i.body&&P(i.body,`${s}.constructor`,e,r)}function Be(t){if(K(t)){if(a.isFunctionDeclaration(t)&&t.name)return t.name.text;if(a.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(a.isIdentifier(e.name)&&e.initializer&&(a.isArrowFunction(e.initializer)||a.isFunctionExpression(e.initializer)))return e.name.text}}}function je(t){if(a.isFunctionDeclaration(t))return t.body;if(a.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(a.isArrowFunction(e.initializer)||a.isFunctionExpression(e.initializer)))return e.initializer}}function P(t,e,r,s){if(a.isCallExpression(t)&&a.isIdentifier(t.expression)){let i=t.expression.text,n=r.get(i);n&&!s.some(o=>o.from===e&&o.to===i&&o.toSpecifier===n)&&s.push({from:e,to:i,toSpecifier:n})}a.forEachChild(t,i=>P(i,e,r,s))}function F(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import ot from"postcss";import*as ze from"postcss-less";var Oe=ze,at=new Set(["reference","inline"]);function nt(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function $e(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function Ve(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let n=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let c=at.has(n)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:c,...nt(o)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),i=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return i?{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static",...nt(i)?{isExternal:!0}:{}}:null}function qe(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"";$e(n)&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static"}),i=s.exec(t)}return r}function ct(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let i=Ve(s.params,e);i&&r.push(i)}s.type==="decl"&&r.push(...qe(s.value,e))}),r}function Je(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Ge(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"",o=i[2]??"";if(o){let c=at.has(n)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:c})}i=s.exec(t)}return r}function pt(t,e){let r=ot.parse(Je(t));return{imports:ct(r,e),root:r}}function Qe(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type!=="atrule")continue;let{value:i}=s;if(i===void 0)continue;let n=s.name;n&&(e.push({name:n}),r.push({name:n,kind:"variable"}))}return{exports:e,tags:r}}function lt(t,e){try{let r=Oe.parse(t),{exports:s,tags:i}=Qe(r);return{imports:ct(r,e),root:r,exports:s,tags:i}}catch{return{imports:Ge(t,e),root:ot.parse(""),exports:[],tags:[]}}}import{parse as Ue}from"postcss-scss";function mt(t){return t.startsWith("_")||t.startsWith("-")}function Ze(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Xe(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],i=t.match(/\bas\s+(\S+)/)?.[1];return i!==void 0?{specifier:r,alias:i}:{specifier:r}}function He(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type==="decl"&&s.prop.startsWith("$")){let i=s.prop.slice(1);if(!i||mt(i))continue;e.push({name:i}),r.push({name:i,kind:"variable"});continue}if(s.type==="atrule"&&(s.name==="mixin"||s.name==="function")){let n=s.params.match(/^([\w-]+)/)?.[1];if(!n||mt(n))continue;let o=s.params.trim();e.push(o.includes("(")?{name:n,signature:o}:{name:n}),r.push({name:n,kind:"function"})}}return{exports:e,tags:r}}function ft(t,e){let r=Ue(t),s=[];r.walk(o=>{if(o.type!=="atrule")return;let{name:c,params:m}=o;if(c!=="import"&&c!=="use"&&c!=="forward")return;let{specifier:p,alias:x}=Xe(m);if(!p)return;let f={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:c==="forward"?"re-export":"static",...Ze(p)?{isExternal:!0}:{}};x&&(f.symbols=[x]),s.push(f)});let{exports:i,tags:n}=He(r);return{imports:s,root:r,exports:i,tags:n}}function ut(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let o=i[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"require"}),i=s.exec(t)}let n=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(i=n.exec(t);i!==null;){let o=i[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),i=n.exec(t)}return r}function gt(t,e){if(e.length===0)return"ui";try{let r=yt("stylus");return new r.Parser(t).parse().nodes.some(n=>n.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function I(t,e){let r=w(t);if(r==="stylus"){let n=ut(e,t);return{imports:n,exports:[],tags:[],category:gt(e,n)}}if(r==="scss"){let{imports:n,root:o,exports:c,tags:m}=ft(e,t);return{imports:n,exports:c,tags:m,category:F(o,n)}}if(r==="less"){let{imports:n,root:o,exports:c,tags:m}=lt(e,t);return{imports:n,exports:c,tags:m,category:F(o,n)}}let{imports:s,root:i}=pt(e,t);return{imports:s,exports:[],tags:[],category:F(i,s)}}for(let[t,e]of[["javascript",(r,s)=>_(r,s,"javascript")],["typescript",(r,s)=>_(r,s,"typescript")],["css",I],["scss",I],["less",I],["stylus",I],["coffeescript",$],["livescript",Q],["lua",U],["python",Y],["go",G],["gherkin",v],["markdown",H]])N(t,e);async function dt(t,e){let r=w(t),s=q(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}function Ye(t){return dt(t.filePath,t.content)}export{Ye as default};
2
2
  //# sourceMappingURL=parse-worker.mjs.map