{"_id":"@alien-dom/unocss-extractor","name":"@alien-dom/unocss-extractor","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alien-dom/unocss-extractor","version":"0.1.0","type":"module","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/alloc/alien-dom.git","directory":"packages/unocss-extractor"},"devDependencies":{"@types/estree-jsx":"^1.0.5","@types/node":"^18.15.11","@unocss/core":"^0.61.0","tsup":"^6.7.0"},"dependencies":{"estree-walker":"^3.0.3","meriyah":"^4.5.0","sucrase":"^3.34.0"},"scripts":{"build":"rimraf dist && tsup-node src/index.ts --format esm --dts","dev":"tsup-node src/index.ts --format esm --dts --watch --sourcemap"},"description":"A custom extractor for UnoCSS created to avoid false positives in `alien-dom` projects (specifically, their JSX and TSX modules).","bugs":{"url":"https://github.com/alloc/alien-dom/issues"},"homepage":"https://github.com/alloc/alien-dom#readme","_id":"@alien-dom/unocss-extractor@0.1.0","_integrity":"sha512-F93g6lSXQPGksFue9twnbSRfQU68A0YmPU3EldVv30D3yxxZUqOBPm5+IeWGnGcy7xtC2KeV9iaqZXSOiK+u8g==","_resolved":"/private/var/folders/9p/k7vwjbvj5qz6xbp6hn52mk540000gn/T/611ba5f503e947e4451ac770d8e65270/alien-dom-unocss-extractor-0.1.0.tgz","_from":"file:alien-dom-unocss-extractor-0.1.0.tgz","_nodeVersion":"22.0.0","_npmVersion":"10.5.1","dist":{"integrity":"sha512-F93g6lSXQPGksFue9twnbSRfQU68A0YmPU3EldVv30D3yxxZUqOBPm5+IeWGnGcy7xtC2KeV9iaqZXSOiK+u8g==","shasum":"a9bf7758e357038fd23d05a196d2f775f0987db6","tarball":"https://registry.npmjs.org/@alien-dom/unocss-extractor/-/unocss-extractor-0.1.0.tgz","fileCount":4,"unpackedSize":5404,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjGqAsXKSuLV7YbQzI/Dtv6wfGTIBuE5mU4JtXou91qAIhAKvhrbkiAd+85jaPSBaXYz1K4p3XE665Jc0sUjo9MnZ4"}]},"_npmUser":{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"},"directories":{},"maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unocss-extractor_0.1.0_1718308937825_0.2728507712077741"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-13T20:02:17.710Z","0.1.0":"2024-06-13T20:02:18.012Z","modified":"2024-06-13T20:02:18.309Z"},"maintainers":[{"name":"aleclarson","email":"alec.stanford.larson@gmail.com"}],"description":"A custom extractor for UnoCSS created to avoid false positives in `alien-dom` projects (specifically, their JSX and TSX modules).","homepage":"https://github.com/alloc/alien-dom#readme","repository":{"type":"git","url":"git+https://github.com/alloc/alien-dom.git","directory":"packages/unocss-extractor"},"bugs":{"url":"https://github.com/alloc/alien-dom/issues"},"readme":"# @alien-dom/unocss-extractor\n\nA custom extractor for UnoCSS created to avoid false positives in `alien-dom` projects (specifically, their JSX and TSX modules).\n\n## Install\n\n```sh\npnpm install @alien-dom/unocss-extractor -D\n```\n\n## Usage\n\nIn your `unocss.config.ts` module, import the custom extractor and use it in your configuration.\n\n```typescript\nimport { defineConfig } from '@unocss/vite'\nimport extractorDefault from '@alien-dom/unocss-extractor'\n\nexport default defineConfig({\n  extractorDefault,\n})\n```\n\n## How It Works\n\nThe extractor uses [`meriyah`](https://github.com/meriyah/meriyah) to quickly parse the abstract syntax tree (AST) of your JSX and TSX files. Since it doesn't support TypeScript, we must first strip the TypeScript syntax using [`sucrase`](https://github.com/alangpierce/sucrase).\n\nAny files that aren't JSX or TSX will use the default extractor provided by UnoCSS.\n\nOtherwise, the following rules are applied:\n\n1. All string literals (except those within a skipped AST node) are split into tokens using UnoCSS's default tokenizer.\n2. Property names of object literals within a \"class-like\" JSX attribute are added as tokens. This allows for the `{ flex: true }` syntax to be recognized by UnoCSS.\n3. String literals inside **conditions** are skipped.\n4. String literals inside `key` and \"style-like\" **JSX attribute values** are skipped.\n\n### Class-Like JSX Attributes\n\nA class-like attribute is one that is either named `class` exactly or ends with `Class` (e.g. `containerClass`).\n\nSimilarly, style-like attributes are those that are named `style` exactly or end with `Style` (e.g. `containerStyle`). These style-like attributes are ignored, so false positives are avoided.\n","readmeFilename":"README.md"}