{"id":29153195,"url":"https://github.com/jakub-hajduk/compuse","last_synced_at":"2026-06-19T02:31:52.285Z","repository":{"id":302096938,"uuid":"994093217","full_name":"jakub-hajduk/compuse","owner":"jakub-hajduk","description":"An engine for monitoring usage of web components. Maybe even all components ;).","archived":false,"fork":false,"pushed_at":"2026-02-06T17:38:26.000Z","size":97,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-07T01:44:43.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakub-hajduk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-01T07:26:29.000Z","updated_at":"2026-02-06T17:38:30.000Z","dependencies_parsed_at":"2025-06-30T15:30:06.237Z","dependency_job_id":"dd797c48-d58b-442c-92ba-ec8f3ee9cb2b","html_url":"https://github.com/jakub-hajduk/compuse","commit_stats":null,"previous_names":["jakub-hajduk/compuse"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jakub-hajduk/compuse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakub-hajduk%2Fcompuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakub-hajduk%2Fcompuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakub-hajduk%2Fcompuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakub-hajduk%2Fcompuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakub-hajduk","download_url":"https://codeload.github.com/jakub-hajduk/compuse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakub-hajduk%2Fcompuse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34515405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-01T01:04:57.046Z","updated_at":"2026-06-19T02:31:52.280Z","avatar_url":"https://github.com/jakub-hajduk.png","language":"TypeScript","funding_links":[],"categories":["Development Utilities"],"sub_categories":["Code Analysis"],"readme":"# Compuse\n\nCompuse is a library for analyzing component usage in your codebase. It provides a unified interface to extract detailed information about how components are used, regardless of whether you're working with React, Vue, Angular, Svelte, Lit-HTML, or plain HTML.\n\n## Features\n\n- **Framework Agnostic:** Analyze component usage across multiple frameworks with a single API.\n- **Detailed Analysis:** Extract component names, attributes, slots, and events.\n- **Code Fragments:** Get the exact code fragment for each component usage.\n- **Line Numbers:** Pinpoint the exact location of component usage in your code.\n- **Extensible:** Easily create your own analyzers to support custom frameworks or specific analysis needs.\n\n## Installation\n\nInstall Compuse using your favorite package manager:\n\n```bash\n# pnpm\npnpm add compuse\n\n# npm\nnpm install compuse\n\n# yarn\nyarn add compuse\n```\n\n## Usage\n\nThe core of Compuse is the `analyzeCode` generator function. It takes your code and a framework-specific analyzer as input and yields detailed `ComponentUsage` objects.\n\n### `analyzeCode(code, analyzer, options)`\n\n-   `code` (string): The source code to analyze.\n-   `analyzer` (Analyzer): The framework-specific analyzer to use.\n-   `options` (AnalyzeOptions): Optional configuration.\n    -   `components` (string[]): A list of component tags to exclusively analyze.\n\n### Example: Analyzing a React Component\n\n```typescript\nimport { analyzeCode, reactAnalyzer } from 'compuse';\n\nconst code = `\n  function App() {\n    return (\n      \u003cMyComponent\n        id=\"my-id\"\n        prop={someValue}\n        onClick={handleClick}\n      \u003e\n        \u003cdiv slot=\"header\"\u003eHeader\u003c/div\u003e\n        Default Content\n      \u003c/MyComponent\u003e\n    );\n  }\n`;\n\nfor (const usage of analyzeCode(code, reactAnalyzer)) {\n  console.log(usage);\n}\n```\n\nThis will output:\n\n```json\n{\n  \"component\": \"MyComponent\",\n  \"attributes\": [\n    { \"name\": \"id\", \"value\": \"my-id\", \"computed\": false },\n    { \"name\": \"prop\", \"value\": \"someValue\", \"computed\": true }\n  ],\n  \"events\": [\n    { \"name\": \"onClick\" }\n  ],\n  \"slots\": [\n    { \"name\": \"slot\", \"fragment\": \"\u003cdiv slot=\\\"header\\\"\u003eHeader\u003c/div\u003e\" },\n    { \"name\": \"default\", \"fragment\": \"Default Content\" }\n  ],\n  \"fragment\": \"\u003cMyComponent id=\\\"my-id\\\" prop={someValue} onClick={handleClick}\u003e\\n  \u003cdiv slot=\\\"header\\\"\u003eHeader\u003c/div\u003e\\n  Default Content\\n\u003c/MyComponent\u003e\",\n  \"lines\": { \"start\": 3, \"end\": 10 }\n}\n```\n\n### Supported Analyzers\n\nCompuse comes with built-in analyzers for popular frameworks:\n\n-   `angularAnalyzer`\n-   `htmlAnalyzer`\n-   `litHtmlAnalyzer`\n-   `reactAnalyzer`\n-   `svelteAnalyzer`\n-   `vueAnalyzer`\n\n### Creating a Custom Analyzer\n\nYou can create a custom analyzer by implementing the `Analyzer` interface. This is useful for supporting custom frameworks or extending the functionality of existing analyzers.\n\n```typescript\nimport type { Analyzer } from 'compuse';\nimport { parse } from 'fragmint';\nimport { customParsePlugin } from './custom-parse-plugin';\n\nexport const customAnalyzer: Analyzer = {\n  name: 'customAnalyzer',\n  parsePlugin: customParsePlugin, // A fragmint parse plugin\n\n  extractName(node) {\n    // Logic to extract the component name from an AST node\n    return node.tag;\n  },\n\n  extractAttributes(node) {\n    // Logic to extract attributes\n    return node.attributes || [];\n  },\n\n  extractEvents(node) {\n    // Logic to extract events\n    return (node.attributes || []).filter(attr =\u003e attr.name.startsWith('on-'));\n  },\n  \n  extractSlots(node) {\n    // Logic to extract slots\n    return (node.children || []).map(child =\u003e ({\n      name: child.attributes?.find(attr =\u003e attr.name === 'slot')?.value || 'default',\n      fragment: child.raw,\n    }));\n  },\n};\n```\n\n## Contributing\n\nContributions are welcome! Please see our `CONTRIBUTING.md` for more information.\n\n## License\n\nThis project is licensed under the ISC License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakub-hajduk%2Fcompuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakub-hajduk%2Fcompuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakub-hajduk%2Fcompuse/lists"}