also looking at this
Merge @stacksjs/ts-css into this repo as packages/toolkit
#27
128 files
+9797
-201
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | # The release workflow uses this file only when both it and that secret exist, |
| 13 | 13 | # and otherwise falls back to a plain NPM_TOKEN secret. |
| 14 | 14 | |
| 15 | # npm token used to publish `ts-css`. Publishing a package that does not exist | |
| 15 | # npm token used to publish `@ts-css/core`. Publishing a package that does not exist | |
| 16 | 16 | # yet needs a token that can CREATE packages — an Automation token, or a |
| 17 | 17 | # granular token with read/write across all packages. A granular token scoped |
| 18 | 18 | # to existing packages returns 404 on the first publish. |
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | ## About |
| 4 | 4 | |
| 5 | `ts-css` (published unscoped on npm; CLI binary `cssx`, config file `css.config.ts`, class prefix `tc`) is an on-demand CSS engine built with Bun, with two front ends over one atomic output: | |
| 5 | `ts-css` (published on npm as `@ts-css/core`; CLI binary `cssx`, config file `css.config.ts`, class prefix `tc`) is an on-demand CSS engine built with Bun, with two front ends over one atomic output: | |
| 6 | 6 | |
| 7 | 7 | - **Utility classes** — Tailwind v4-compatible, with full variant support (responsive, state, dark mode, pseudo-elements), arbitrary values, shortcut aliases, and compile-class HTML optimization. |
| 8 | 8 | - **Style objects** — a StyleX-shaped typed API (`css.create`, `css.props`, `css.defineVars`, `css.createTheme`, `css.keyframes`) in `src/style/`, collected at build time by evaluating the modules that declare them. |
| @@ -11,7 +11,7 @@ A CSS engine with two front ends and one atomic output. | ||
| 11 | 11 | Write **utility classes** when you are laying out markup, and Tailwind v4 semantics apply unchanged. Write **typed style objects** when a style has to be computed, tokenised, or merged across a component boundary, and you get StyleX's authoring model. Both compile through the same pipeline into the same deduplicated atomic CSS, in one stylesheet, with nothing left at runtime. |
| 12 | 12 | |
| 13 | 13 | ```bash |
| 14 | bun add ts-css | |
| 14 | bun add @ts-css/core | |
| 15 | 15 | ``` |
| 16 | 16 | |
| 17 | 17 | ## Why two APIs |
| @@ -43,7 +43,7 @@ bunx cssx watch # rebuilds on change | ||
| 43 | 43 | |
| 44 | 44 | ```ts |
| 45 | 45 | // css.config.ts |
| 46 | import type { TsCssOptions } from 'ts-css' | |
| 46 | import type { TsCssOptions } from '@ts-css/core' | |
| 47 | 47 | |
| 48 | 48 | export default { |
| 49 | 49 | content: ['./src/**/*.{html,ts,tsx,stx}'], |
| @@ -57,7 +57,7 @@ export default { | ||
| 57 | 57 | ## Style objects |
| 58 | 58 | |
| 59 | 59 | ```ts |
| 60 | import { css } from 'ts-css' | |
| 60 | import { css } from '@ts-css/core' | |
| 61 | 61 | |
| 62 | 62 | const theme = css.defineVars({ |
| 63 | 63 | accent: '#0b7', |
| @@ -223,7 +223,7 @@ cssx clean # remove the output file | ||
| 223 | 223 | ## Configuration |
| 224 | 224 | |
| 225 | 225 | ```ts |
| 226 | import type { TsCssOptions } from 'ts-css' | |
| 226 | import type { TsCssOptions } from '@ts-css/core' | |
| 227 | 227 | |
| 228 | 228 | export default { |
| 229 | 229 | content: ['./src/**/*.{html,ts,tsx}'], |
| @@ -296,7 +296,7 @@ The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information. | ||
| 296 | 296 | Made with �� |
| 297 | 297 | |
| 298 | 298 | <!-- Badges --> |
| 299 | [npm-version-src]: https://img.shields.io/npm/v/ts-css?style=flat-square | |
| 300 | [npm-version-href]: https://npmjs.com/package/ts-css | |
| 299 | [npm-version-src]: https://img.shields.io/npm/v/@ts-css/core?style=flat-square | |
| 300 | [npm-version-href]: https://npmjs.com/package/@ts-css/core | |
| 301 | 301 | [github-actions-src]: https://img.shields.io/github/actions/workflow/status/cwcss/crosswind/ci.yml?style=flat-square&branch=main |
| 302 | 302 | [github-actions-href]: https://github.com/cwcss/crosswind/actions?query=workflow%3Aci |
| @@ -157,7 +157,7 @@ const transpiler = new Bun.Transpiler({ loader: 'ts' }) | ||
| 157 | 157 | |
| 158 | 158 | const tsCssSources = new Map(WORKLOADS.map(w => [ |
| 159 | 159 | w.name, |
| 160 | `import { css } from 'ts-css'\nexport const styles = css.create(${w.literal})\n`, | |
| 160 | `import { css } from '@ts-css/core'\nexport const styles = css.create(${w.literal})\n`, | |
| 161 | 161 | ])) |
| 162 | 162 | |
| 163 | 163 | /** |
| @@ -3,13 +3,13 @@ | ||
| 3 | 3 | "configVersion": 1, |
| 4 | 4 | "workspaces": { |
| 5 | 5 | "": { |
| 6 | "name": "ts-css", | |
| 6 | "name": "@ts-css/core", | |
| 7 | 7 | "devDependencies": { |
| 8 | 8 | "better-dx": "^0.2.15", |
| 9 | 9 | }, |
| 10 | 10 | }, |
| 11 | 11 | "packages/ts-css": { |
| 12 | "name": "ts-css", | |
| 12 | "name": "@ts-css/core", | |
| 13 | 13 | "version": "0.3.0", |
| 14 | 14 | "bin": { |
| 15 | 15 | "cssx": "./dist/cli.js", |
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | }, |
| 21 | 21 | }, |
| 22 | 22 | "packages/vscode": { |
| 23 | "name": "ts-css-vscode", | |
| 23 | "name": "@ts-css/vscode", | |
| 24 | 24 | "version": "0.3.0", |
| 25 | 25 | }, |
| 26 | 26 | }, |
| @@ -35,11 +35,11 @@ | ||
| 35 | 35 | |
| 36 | 36 | "@stacksjs/bunpress": ["@stacksjs/bunpress@0.2.14", "", { "dependencies": { "@cwcss/crosswind": "^0.2.16", "@stacksjs/clapp": "^0.2.0", "@stacksjs/stx": "^0.2.171", "@stacksjs/ts-i18n": "^0.1.11", "bunfig": "^0.15.17", "ts-syntax-highlighter": "^0.2.14" }, "peerDependencies": { "@stacksjs/ts-cloud": "^0.7.51" }, "optionalPeers": ["@stacksjs/ts-cloud"], "bin": { "bunpress": "./dist/bin/cli.js" } }, "sha512-o0Bf8b7kXKSyH5xXrVrdA46gPzMVssLBnbP82t8WzF17gIveFLNW+CzEZe3n9o+Ui2wiy2+6IF5SwGfrdTtWcQ=="], |
| 37 | 37 | |
| 38 | "@stacksjs/clapp": ["@stacksjs/clapp@0.2.13", "", {}, "sha512-wh6Ybgga1S/3P+GRDb2kBiOK97+Ay7TKTiaLKfhpgd+V04+BAHg23xDlZUNkpllhoRdFimeHpWahuwghoNYbUg=="], | |
| 38 | "@stacksjs/clapp": ["@stacksjs/clapp@0.2.15", "", {}, "sha512-EM2fWrFZaU+paHZ4X0RGNZTnBYVgwdkbTnYdLD72yoc8JXUH5Wl88IZcn/JZoFPrViNgXlhYgI3xEK4Fryd3Xw=="], | |
| 39 | 39 | |
| 40 | 40 | "@stacksjs/clarity": ["@stacksjs/clarity@0.3.33", "", { "dependencies": { "bunfig": "^0.15.6" }, "bin": { "clarity": "./dist/bin/cli.js" } }, "sha512-+5GLKnAI/M/z64UfNLLfQqx/kp+frmRY+NZXYwwGwbrkud/xlsEGDWEExdhqOhqEDMWdb1oafw/ubGAPg1PaFw=="], |
| 41 | 41 | |
| 42 | "@stacksjs/desktop": ["@stacksjs/desktop@0.2.237", "", { "dependencies": { "craft-native": ">=0.0.76" } }, "sha512-hpC2xTRn6uxgNPMomJBURQG7TYJPxWFoLzpzJePzKVpi0o2lEt4vZRxAGdZRQgc0ZTm9QCP3pTqRR+k3t0bEbw=="], | |
| 42 | "@stacksjs/desktop": ["@stacksjs/desktop@0.2.249", "", { "dependencies": { "craft-native": ">=0.0.76" } }, "sha512-mQfxzJW2wGzTFffa1NIYVA0qSbJH7QSHocYJbKZxBSQR5qD8u3SXfpxDNg3YcgoHCj6CfH/BsuSg5jqaiyRTpw=="], | |
| 43 | 43 | |
| 44 | 44 | "@stacksjs/dtsx": ["@stacksjs/dtsx@0.11.10", "", { "dependencies": { "@stacksjs/clapp": "^0.2.0" }, "bin": { "dtsx": "./dist/bin/cli.js" } }, "sha512-NOSSGv7mdxzmijmKHxTZDmgZp7vCYrRKWpDwNqwTc97MTv5csjo3uukf7A/c+s7pSzJd+HxqsTCZ7IznjfEtmw=="], |
| 45 | 45 | |
| @@ -47,9 +47,9 @@ | ||
| 47 | 47 | |
| 48 | 48 | "@stacksjs/logsmith": ["@stacksjs/logsmith@0.2.11", "", { "dependencies": { "@stacksjs/clapp": "^0.2.0", "bunfig": "^0.15.6", "pickier": "^0.1.9" }, "bin": { "@stacksjs/logsmith": "./dist/bin/cli.js", "logsmith": "./dist/bin/cli.js" } }, "sha512-wqqAxewpsHVDzpC+IRy+yYyGXGlv1j5GCqYTh8fL7d3LLhnRPN72PEQywM357burtORvdkFHfOzk3Ih1SMvuiw=="], |
| 49 | 49 | |
| 50 | "@stacksjs/sanitizer": ["@stacksjs/sanitizer@0.2.237", "", {}, "sha512-hx51XqFdkoeVEKGXj083SGyY57BnWFRu8yWTrPk/FZlVqwup8XQGyiF0FTcf/u2z4pyRzpQ/pDCgsTQsh+d6tQ=="], | |
| 50 | "@stacksjs/sanitizer": ["@stacksjs/sanitizer@0.2.249", "", {}, "sha512-u7xHcDDeyj+IfDsqAEGpuFoZeRWuKfpnpexfyjPCOvBhJlFWIYKvFVY9QjuKN/kFQxDv5hYK9vkROpZAIVSzNQ=="], | |
| 51 | 51 | |
| 52 | "@stacksjs/stx": ["@stacksjs/stx@0.2.237", "", { "dependencies": { "@cwcss/crosswind": "^0.2.19", "@stacksjs/clapp": "^0.2.0", "@stacksjs/desktop": "0.2.237", "@stacksjs/sanitizer": "0.2.237", "@stacksjs/ts-i18n": "^0.1.11", "bun-plugin-stx": "0.2.237", "bunfig": "^0.15.17", "stx-router": "0.2.237", "ts-broadcasting": "^0.0.9", "ts-images": "^0.2.11", "ts-syntax-highlighter": "^0.2.1" }, "bin": { "stx": "./dist/cli.js" } }, "sha512-trsm4du5m4doOJwZztrVgYlClUxwi5wzfb79V/o5Vu5iw9WIdFbfwiOz/zcxDeoqBp6+eAVqD0bY1Jvq7/wABQ=="], | |
| 52 | "@stacksjs/stx": ["@stacksjs/stx@0.2.249", "", { "dependencies": { "@cwcss/crosswind": "^0.2.19", "@stacksjs/clapp": "^0.2.14", "@stacksjs/desktop": "0.2.249", "@stacksjs/sanitizer": "0.2.249", "@stacksjs/ts-i18n": "^0.1.11", "bun-plugin-stx": "0.2.249", "bunfig": "^0.15.17", "stx-router": "0.2.249", "ts-broadcasting": "^0.0.9", "ts-images": "^0.2.11", "ts-syntax-highlighter": "^0.2.1" }, "bin": { "stx": "./dist/cli.js" } }, "sha512-3r2RgvcrnJZ4FKwsjFMyOPwpyKtBV8RWnTVGby5C9XCKe0d/DsF125+A/8LAXTjB4z32NUYRDVnSpvhd1vRxPA=="], | |
| 53 | 53 | |
| 54 | 54 | "@stacksjs/ts-avif": ["@stacksjs/ts-avif@0.1.4", "", {}, "sha512-+ri7xxHLxaFGRJPihI7irDZpdLEIrEFpR7Em+ojfDbTjXQmXtQBqN/9WKNhBdQ1BZ2M1ckjdgnxmfege86QQ5Q=="], |
| 55 | 55 | |
| @@ -67,6 +67,10 @@ | ||
| 67 | 67 | |
| 68 | 68 | "@stacksjs/ts-webp": ["@stacksjs/ts-webp@0.1.3", "", {}, "sha512-0PFmmBLKCxIc+8pNEwfvoXfS5uH47y7rXpVaGEfj6VQGPoQCAWUmheppCeJ66YCdSVR1dezR/4MGTZCnT+uZow=="], |
| 69 | 69 | |
| 70 | "@ts-css/core": ["@ts-css/core@workspace:packages/ts-css"], | |
| 71 | ||
| 72 | "@ts-css/vscode": ["@ts-css/vscode@workspace:packages/vscode"], | |
| 73 | ||
| 70 | 74 | "@types/bun": ["@types/bun@1.4.0", "", { "dependencies": { "bun-types": "1.4.0" } }, "sha512-K+lZULY23vRgK/CfTjFIV+tyifaNdSMlPh9j+6mQ/cLfpOznLyAuzgV/JQysyECpkBQLVMSyvjlr2fBUSA9wFQ=="], |
| 71 | 75 | |
| 72 | 76 | "@types/node": ["@types/node@26.4.0", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-faiGnoIrLH/V8cibOMEAZ8pMw6oXqSukl29ra4mN8GdaB2ZewzeaLj+INpV5N+Z1eKWzY+IzaIZH2EIR6YZRNQ=="], |
| @@ -119,13 +123,13 @@ | ||
| 119 | 123 | |
| 120 | 124 | "bun-plugin-dtsx": ["bun-plugin-dtsx@0.11.10", "", { "dependencies": { "@stacksjs/dtsx": "0.11.10" } }, "sha512-qQrEBIV1pzhDmrxmhTHhgVK5gqE5CfpO8C9NCp7zUaN48c4IJVrpqXbeNWch7sAT/Hf4GhVMWau7T65xySm59Q=="], |
| 121 | 125 | |
| 122 | "bun-plugin-stx": ["bun-plugin-stx@0.2.237", "", { "dependencies": { "@stacksjs/stx": "^0.2.227", "stx-router": "^0.2.227" }, "bin": { "serve": "./dist/serve.js", "stx-serve": "./dist/serve.js" } }, "sha512-LYBUiSNKtdkTHVeiUAYFPrrNGJWu4o/jLjOi2K1MiWDuOCqaQ6VHZItuw52nR4suVHOL5hbVJWRS93sQ+7dXxA=="], | |
| 126 | "bun-plugin-stx": ["bun-plugin-stx@0.2.249", "", { "dependencies": { "@stacksjs/stx": "^0.2.227", "stx-router": "^0.2.227" }, "bin": { "serve": "./dist/serve.js", "stx-serve": "./dist/serve.js" } }, "sha512-TQ6UEPX54pATWLq27VnkQCAiOBbiM1roOPye6nbSjgmRj54mqz9we0HPfepfj+ahYvkniEiwIVw9Ym3xCXNjzQ=="], | |
| 123 | 127 | |
| 124 | 128 | "bun-types": ["bun-types@1.4.0", "", { "dependencies": { "@types/node": "*" } }, "sha512-iIKw23BspnQQYd3prITOBxeUsxBHnwzX6YJfGMuNOZzeNcMmVqzIIVGRm1l69ogaPQmb4wB6BN8mA5bE9YuC5Q=="], |
| 125 | 129 | |
| 126 | 130 | "bunfig": ["bunfig@0.15.17", "", { "dependencies": { "@stacksjs/clapp": "^0.2.0", "@stacksjs/clarity": "^0.3.24" }, "bin": { "bunfig": "./bin/cli.js" } }, "sha512-nJAYGUq29lMmKindrIQIU5MD0JFFRoVFt+PBoNEvvVO9gKS3WgsYQVQLzN0gzHNnZtOZSR9p7jTBiRCwjQpr1g=="], |
| 127 | 131 | |
| 128 | "craft-native": ["craft-native@0.0.77", "", { "bin": { "craft-sdk": "./dist/cli.js" } }, "sha512-hBqFxZC22GVt8wv3srd/rsDTKykSzM/aFJDDM8+W/Mk8CuZDFjlOIkRSnyJqZwyVf4bvkRzdegd9fiOfnwUNOg=="], | |
| 132 | "craft-native": ["craft-native@0.0.83", "", { "bin": { "craft-sdk": "./dist/cli.js" } }, "sha512-6FWJmaTG8TYpxKvj7gCYhkylq8jeY6anE75zNcxGbZDRt5AeaKpLBIdCo2AlCHkw1amuFUdahrJ6vPZdInGbQQ=="], | |
| 129 | 133 | |
| 130 | 134 | "data-uri-to-buffer": ["data-uri-to-buffer@6.0.2", "", {}, "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw=="], |
| 131 | 135 | |
| @@ -137,14 +141,10 @@ | ||
| 137 | 141 | |
| 138 | 142 | "sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="], |
| 139 | 143 | |
| 140 | "stx-router": ["stx-router@0.2.237", "", {}, "sha512-sEuFmBW4YIgaF79AkBrqhBmkN6t6sdFISCHlalxoLb+QK4xyesc7CXnk6UOcLTkfEP89ojHyvM/8yvK2bqYdFg=="], | |
| 144 | "stx-router": ["stx-router@0.2.249", "", {}, "sha512-zKCQH2S/qj2FbxYhreS9UdCw0vKGiD1lx//ZohPaXqmIIKdha4gL219DyV7gfdQKrZbjOGEf6N7dN+tvu42gbQ=="], | |
| 141 | 145 | |
| 142 | 146 | "ts-broadcasting": ["ts-broadcasting@0.0.9", "", { "bin": { "broadcast": "./dist/bin/cli.js" } }, "sha512-OA95bHPe3M/24Gx8FpbUV0+NzGwvemG2LP64s1p/zATagX8xJckeziru03ccjW0ExWaD+W5tC1GRIqS6lfbB4A=="], |
| 143 | 147 | |
| 144 | "ts-css": ["ts-css@workspace:packages/ts-css"], | |
| 145 | ||
| 146 | "ts-css-vscode": ["ts-css-vscode@workspace:packages/vscode"], | |
| 147 | ||
| 148 | 148 | "ts-error-handling": ["ts-error-handling@0.1.3", "", {}, "sha512-Agm8wbQL1YVvnffVDSUKMgImZBoR4UVFjzPaIwPxa0z7YwsowKV8R57pCDIjLP/dTHRBetg7ZfdTeuNVb21OfA=="], |
| 149 | 149 | |
| 150 | 150 | "ts-gif": ["ts-gif@0.1.2", "", { "dependencies": { "data-uri-to-buffer": "^6.0.2" } }, "sha512-jbraplO1qqJtrtkFeepNPUGPad7w8FQHWIQFsn1OJbHeWKUbdqdkrX18XzNXI5Fw7+s6A3nbNTdj+Ukn4d3f8g=="], |
| @@ -153,7 +153,7 @@ | ||
| 153 | 153 | |
| 154 | 154 | "ts-jpeg": ["ts-jpeg@0.3.5", "", {}, "sha512-etdIfMDRDYDF44kDu++z0M5GbR7ph9IKmubSXQop1O8NTUc+xjxE8dPt/niosHRUhMiQ4gaLtuFh0DH6QvfopA=="], |
| 155 | 155 | |
| 156 | "ts-pantry": ["ts-pantry@0.11.44", "", { "bin": { "ts-pantry": "./dist/bin/cli.js" } }, "sha512-xnvzhbhwdRk75aUyyXiSkSICRJNcUYR+xXtLUmRRufZiEBf4T1zrIPiEdgPWDhN0PYLCeA7GNi098yHxMcVvqg=="], | |
| 156 | "ts-pantry": ["ts-pantry@0.11.45", "", { "bin": { "ts-pantry": "./dist/bin/cli.js" } }, "sha512-wh8pGg7EYrK0bR2rz71SFMniJSq9OFNMZTVkxvk04ywedSP8ECjYLpEg/MK1VRGJjW2/FfIZskkxVQq211jjSw=="], | |
| 157 | 157 | |
| 158 | 158 | "ts-syntax-highlighter": ["ts-syntax-highlighter@0.2.17", "", { "bin": { "ts-syntax-highlighter": "./dist/bin/cli.js" } }, "sha512-cHxkTRvqYabO9axIrw6KUkMweIHzXmVmcVmO+Yi2NEa9nxQa15zoISvvlKYPzK4OLsUS5I4uVaLz0Oivc3oOSw=="], |
| 159 | 159 | |
| @@ -16,7 +16,7 @@ While ts-css includes comprehensive built-in utilities, you can add custom rules | ||
| 16 | 16 | Define custom rules in your configuration: |
| 17 | 17 | |
| 18 | 18 | ```typescript |
| 19 | import type { TsCssOptions } from 'ts-css' | |
| 19 | import type { TsCssOptions } from '@ts-css/core' | |
| 20 | 20 | |
| 21 | 21 | const config = { |
| 22 | 22 | rules: [ |
| @@ -234,7 +234,7 @@ const config = { | ||
| 234 | 234 | ```### Using Theme Values |
| 235 | 235 | |
| 236 | 236 | Access theme values in custom rules:```typescript |
| 237 | import type { TsCssOptions } from 'ts-css' | |
| 237 | import type { TsCssOptions } from '@ts-css/core' | |
| 238 | 238 | |
| 239 | 239 | const config = { |
| 240 | 240 | theme: { |
| @@ -15,7 +15,7 @@ cd my-app | ||
| 15 | 15 | |
| 16 | 16 | # Install ts-css |
| 17 | 17 | |
| 18 | bun add ts-css | |
| 18 | bun add @ts-css/core | |
| 19 | 19 | |
| 20 | 20 | # Initialize ts-css |
| 21 | 21 | |
| @@ -23,7 +23,7 @@ bunx cssx init | ||
| 23 | 23 | ```**Configuration:**```typescript |
| 24 | 24 | |
| 25 | 25 | // css.config.ts |
| 26 | import type { TsCssOptions } from 'ts-css' | |
| 26 | import type { TsCssOptions } from '@ts-css/core' | |
| 27 | 27 | |
| 28 | 28 | const config = { |
| 29 | 29 | content: ['./src/**/*.{js,jsx,ts,tsx}'], |
| @@ -90,7 +90,7 @@ bun install | ||
| 90 | 90 | |
| 91 | 91 | # Install ts-css |
| 92 | 92 | |
| 93 | bun add ts-css | |
| 93 | bun add @ts-css/core | |
| 94 | 94 | bunx cssx init |
| 95 | 95 | |
| 96 | 96 | ```**Configuration:**```typescript |
| @@ -118,7 +118,7 @@ cd my-app | ||
| 118 | 118 | |
| 119 | 119 | # Install ts-css |
| 120 | 120 | |
| 121 | bun add ts-css | |
| 121 | bun add @ts-css/core | |
| 122 | 122 | bunx cssx init |
| 123 | 123 | ```**Configuration:**```typescript |
| 124 | 124 | |
| @@ -191,7 +191,7 @@ bun install | ||
| 191 | 191 | |
| 192 | 192 | # Install ts-css |
| 193 | 193 | |
| 194 | bun add ts-css | |
| 194 | bun add @ts-css/core | |
| 195 | 195 | bunx cssx init |
| 196 | 196 | |
| 197 | 197 | ```**Configuration:**```typescript |
| @@ -263,7 +263,7 @@ bun install | ||
| 263 | 263 | |
| 264 | 264 | # Install ts-css |
| 265 | 265 | |
| 266 | bun add ts-css | |
| 266 | bun add @ts-css/core | |
| 267 | 267 | bunx cssx init |
| 268 | 268 | ```**Configuration:**```typescript |
| 269 | 269 | |
| @@ -307,7 +307,7 @@ bun install | ||
| 307 | 307 | |
| 308 | 308 | # Install ts-css |
| 309 | 309 | |
| 310 | bun add ts-css | |
| 310 | bun add @ts-css/core | |
| 311 | 311 | bunx cssx init |
| 312 | 312 | ```**Configuration:**```typescript |
| 313 | 313 | |
| @@ -358,7 +358,7 @@ const config = { | ||
| 358 | 358 | bun create vite my-app --template svelte-ts |
| 359 | 359 | cd my-app |
| 360 | 360 | bun install |
| 361 | bun add ts-css | |
| 361 | bun add @ts-css/core | |
| 362 | 362 | bunx cssx init |
| 363 | 363 | |
| 364 | 364 | ```**Configuration:**```typescript |
| @@ -377,7 +377,7 @@ bun install | ||
| 377 | 377 | |
| 378 | 378 | # Install ts-css |
| 379 | 379 | |
| 380 | bun add ts-css | |
| 380 | bun add @ts-css/core | |
| 381 | 381 | bunx cssx init |
| 382 | 382 | |
| 383 | 383 | ```**Configuration:**```typescript |
| @@ -444,7 +444,7 @@ bun install | ||
| 444 | 444 | |
| 445 | 445 | # Install ts-css |
| 446 | 446 | |
| 447 | bun add ts-css | |
| 447 | bun add @ts-css/core | |
| 448 | 448 | bunx cssx init |
| 449 | 449 | ```**Configuration:**```typescript |
| 450 | 450 | |
| @@ -471,7 +471,7 @@ bun install | ||
| 471 | 471 | |
| 472 | 472 | # Install ts-css |
| 473 | 473 | |
| 474 | bun add ts-css | |
| 474 | bun add @ts-css/core | |
| 475 | 475 | bunx cssx init |
| 476 | 476 | |
| 477 | 477 | ```**Configuration:**```typescript |
| @@ -491,7 +491,7 @@ import './styles.css' | ||
| 491 | 491 | |
| 492 | 492 | # Install ts-css |
| 493 | 493 | |
| 494 | bun add ts-css | |
| 494 | bun add @ts-css/core | |
| 495 | 495 | bunx cssx init |
| 496 | 496 | ```**Configuration:**```typescript |
| 497 | 497 | |
| @@ -525,7 +525,7 @@ const config = { | ||
| 525 | 525 | |
| 526 | 526 | # In your Hugo project |
| 527 | 527 | |
| 528 | bun add ts-css | |
| 528 | bun add @ts-css/core | |
| 529 | 529 | bunx cssx init |
| 530 | 530 | ```**Configuration:**```typescript |
| 531 | 531 | |
| @@ -31,7 +31,7 @@ const config = { | ||
| 31 | 31 | ### Basic Preset Structure |
| 32 | 32 | |
| 33 | 33 | A preset is an object that implements the`Preset`interface:```typescript |
| 34 | import type { Preset } from 'ts-css' | |
| 34 | import type { Preset } from '@ts-css/core' | |
| 35 | 35 | |
| 36 | 36 | export const myPreset: Preset = { |
| 37 | 37 | name: 'my-preset', |
| @@ -54,7 +54,7 @@ export const myPreset: Preset = { | ||
| 54 | 54 | |
| 55 | 55 | ```### Simple Example```typescript |
| 56 | 56 | // presets/minimal.ts |
| 57 | import type { Preset } from 'ts-css' | |
| 57 | import type { Preset } from '@ts-css/core' | |
| 58 | 58 | |
| 59 | 59 | export const minimalPreset: Preset = { |
| 60 | 60 | name: 'minimal', |
| @@ -82,7 +82,7 @@ export const minimalPreset: Preset = { | ||
| 82 | 82 | ### Single Preset```typescript |
| 83 | 83 | |
| 84 | 84 | // css.config.ts |
| 85 | import type { TsCssOptions } from 'ts-css' | |
| 85 | import type { TsCssOptions } from '@ts-css/core' | |
| 86 | 86 | import { minimalPreset } from './presets/minimal' |
| 87 | 87 | |
| 88 | 88 | const config = { |
| @@ -133,7 +133,7 @@ const config = { | ||
| 133 | 133 | ### Design System Preset```typescript |
| 134 | 134 | |
| 135 | 135 | // presets/design-system.ts |
| 136 | import type { Preset } from 'ts-css' | |
| 136 | import type { Preset } from '@ts-css/core' | |
| 137 | 137 | |
| 138 | 138 | export const designSystemPreset: Preset = { |
| 139 | 139 | name: 'design-system', |
| @@ -212,7 +212,7 @@ export const designSystemPreset: Preset = { | ||
| 212 | 212 | ```### Component Library Preset```typescript |
| 213 | 213 | |
| 214 | 214 | // presets/components.ts |
| 215 | import type { Preset } from 'ts-css' | |
| 215 | import type { Preset } from '@ts-css/core' | |
| 216 | 216 | |
| 217 | 217 | export const componentsPreset: Preset = { |
| 218 | 218 | name: 'components', |
| @@ -254,7 +254,7 @@ export const componentsPreset: Preset = { | ||
| 254 | 254 | |
| 255 | 255 | ```### Utility Preset```typescript |
| 256 | 256 | // presets/utilities.ts |
| 257 | import type { Preset } from 'ts-css' | |
| 257 | import type { Preset } from '@ts-css/core' | |
| 258 | 258 | |
| 259 | 259 | export const utilitiesPreset: Preset = { |
| 260 | 260 | name: 'utilities', |
| @@ -307,7 +307,7 @@ export const utilitiesPreset: Preset = { | ||
| 307 | 307 | ```### Framework-Specific Preset```typescript |
| 308 | 308 | |
| 309 | 309 | // presets/react.ts |
| 310 | import type { Preset } from 'ts-css' | |
| 310 | import type { Preset } from '@ts-css/core' | |
| 311 | 311 | |
| 312 | 312 | export const reactPreset: Preset = { |
| 313 | 313 | name: 'react', |
| @@ -360,7 +360,7 @@ my-ts-css-preset/ | ||
| 360 | 360 | |
| 361 | 361 | ```typescript |
| 362 | 362 | // src/index.ts |
| 363 | import type { Preset } from 'ts-css' | |
| 363 | import type { Preset } from '@ts-css/core' | |
| 364 | 364 | |
| 365 | 365 | export const myPreset: Preset = { |
| 366 | 366 | name: 'my-preset', |
| @@ -389,10 +389,10 @@ export default myPreset | ||
| 389 | 389 | "prepublishOnly": "bun run build" |
| 390 | 390 | }, |
| 391 | 391 | "peerDependencies": { |
| 392 | "ts-css": ">=1.0.0" | |
| 392 | "@ts-css/core": ">=1.0.0" | |
| 393 | 393 | }, |
| 394 | 394 | "devDependencies": { |
| 395 | "ts-css": "latest", | |
| 395 | "@ts-css/core": "latest", | |
| 396 | 396 | "typescript": "latest" |
| 397 | 397 | } |
| 398 | 398 | } |
| @@ -459,7 +459,7 @@ const config = { | ||
| 459 | 459 | |
| 460 | 460 | ### Preset with Custom Preflight```typescript |
| 461 | 461 | |
| 462 | import type { Preflight, Preset } from 'ts-css' | |
| 462 | import type { Preflight, Preset } from '@ts-css/core' | |
| 463 | 463 | |
| 464 | 464 | const customPreflight: Preflight = { |
| 465 | 465 | getCSS: () => `/*Custom reset*/*{ |
| @@ -593,7 +593,7 @@ const config = { | ||
| 593 | 593 | } |
| 594 | 594 | ```### Type Errors**Problem:**TypeScript errors when creating preset**Solution:**Import and use the`Preset`type:```typescript |
| 595 | 595 | |
| 596 | import type { Preset } from 'ts-css' | |
| 596 | import type { Preset } from '@ts-css/core' | |
| 597 | 597 | |
| 598 | 598 | export const myPreset: Preset = { |
| 599 | 599 | name: 'my-preset', |
| @@ -8,7 +8,7 @@ The theme configuration defines the design tokens that utilities are generated f | ||
| 8 | 8 | |
| 9 | 9 | ```typescript |
| 10 | 10 | // css.config.ts |
| 11 | import type { TsCssOptions } from 'ts-css' | |
| 11 | import type { TsCssOptions } from '@ts-css/core' | |
| 12 | 12 | |
| 13 | 13 | const config = { |
| 14 | 14 | theme: { |
| @@ -339,7 +339,7 @@ const config = { | ||
| 339 | 339 | </div> |
| 340 | 340 | ```## Complete Theme Example```typescript |
| 341 | 341 | |
| 342 | import type { TsCssOptions } from 'ts-css' | |
| 342 | import type { TsCssOptions } from '@ts-css/core' | |
| 343 | 343 | |
| 344 | 344 | const config = { |
| 345 | 345 | theme: { |
| @@ -530,7 +530,7 @@ const config = { | ||
| 530 | 530 | ```### Extending Default Theme |
| 531 | 531 | |
| 532 | 532 | Merge with the default theme:```typescript |
| 533 | import { defaultConfig } from 'ts-css' | |
| 533 | import { defaultConfig } from '@ts-css/core' | |
| 534 | 534 | |
| 535 | 535 | const config = { |
| 536 | 536 | theme: { |
| @@ -5,12 +5,12 @@ This document provides a complete reference for ts-css's programmatic API. Use t | ||
| 5 | 5 | ## Installation |
| 6 | 6 | |
| 7 | 7 | ```bash |
| 8 | bun add ts-css | |
| 8 | bun add @ts-css/core | |
| 9 | 9 | ```## Core Functions |
| 10 | 10 | |
| 11 | 11 | ### `build(config: TsCssConfig): Promise<BuildResult>`Build CSS from content files and return the result.**Parameters:**-`config` - Complete ts-css configuration object**Returns:**`Promise<BuildResult>`**Example:**```typescript |
| 12 | 12 | |
| 13 | import { build } from 'ts-css' | |
| 13 | import { build } from '@ts-css/core' | |
| 14 | 14 | |
| 15 | 15 | const result = await build({ |
| 16 | 16 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -39,7 +39,7 @@ console.log(`Built ${result.classes.size} classes in ${result.duration}ms`) | ||
| 39 | 39 | console.log(`Generated CSS:\n${result.css}`) |
| 40 | 40 | |
| 41 | 41 | ```###`buildAndWrite(config: TsCssConfig): Promise<BuildResult>`Build CSS and write it to the output file.**Parameters:**-`config` - Complete ts-css configuration object**Returns:**`Promise<BuildResult>`**Example:**```typescript |
| 42 | import { buildAndWrite } from 'ts-css' | |
| 42 | import { buildAndWrite } from '@ts-css/core' | |
| 43 | 43 | |
| 44 | 44 | const result = await buildAndWrite({ |
| 45 | 45 | content: ['./src/**/*.tsx'], |
| @@ -53,13 +53,13 @@ console.log(`File size: ${result.css.length} bytes`) | ||
| 53 | 53 | ```###`writeCSS(css: string, outputPath: string): Promise<void>`Write CSS string to a file.**Parameters:**-`css`- CSS content to write |
| 54 | 54 | |
| 55 | 55 | -`outputPath` - Path to output file**Returns:**`Promise<void>`**Example:**```typescript |
| 56 | import { build, writeCSS } from 'ts-css' | |
| 56 | import { build, writeCSS } from '@ts-css/core' | |
| 57 | 57 | |
| 58 | 58 | const result = await build(config) |
| 59 | 59 | await writeCSS(result.css, './custom/path/output.css') |
| 60 | 60 | |
| 61 | 61 | ```###`writeTransformedFiles(transformedFiles: Map<string, string>): Promise<void>`Write transformed files to disk (used with compile class transformer).**Parameters:**-`transformedFiles` - Map of file paths to transformed content**Returns:**`Promise<void>`**Example:**```typescript |
| 62 | import { build, writeTransformedFiles } from 'ts-css' | |
| 62 | import { build, writeTransformedFiles } from '@ts-css/core' | |
| 63 | 63 | |
| 64 | 64 | const result = await build({ |
| 65 | 65 | // ... config with compileClass enabled |
| @@ -79,7 +79,7 @@ Class responsible for generating CSS from utility classes.**Constructor:**```typ | ||
| 79 | 79 | new CSSGenerator(config: TsCssConfig) |
| 80 | 80 | |
| 81 | 81 | ```**Methods:**#### `generate(className: string): void`Generate CSS for a single utility class.```typescript |
| 82 | import { CSSGenerator } from 'ts-css' | |
| 82 | import { CSSGenerator } from '@ts-css/core' | |
| 83 | 83 | |
| 84 | 84 | const generator = new CSSGenerator(config) |
| 85 | 85 | generator.generate('bg-blue-500') |
| @@ -96,7 +96,7 @@ const prettyCSS = generator.toCSS(false) // Formatted | ||
| 96 | 96 | generator.reset() |
| 97 | 97 | ```**Complete example:**```typescript |
| 98 | 98 | |
| 99 | import { CSSGenerator, defaultConfig } from 'ts-css' | |
| 99 | import { CSSGenerator, defaultConfig } from '@ts-css/core' | |
| 100 | 100 | |
| 101 | 101 | const config = { |
| 102 | 102 | ...defaultConfig, |
| @@ -133,7 +133,7 @@ new Scanner( | ||
| 133 | 133 | |
| 134 | 134 | -`classes`- Set of found utility classes |
| 135 | 135 | -`transformedFiles` - Map of transformed files (if transformer provided)**Example:**```typescript |
| 136 | import { Scanner } from 'ts-css' | |
| 136 | import { Scanner } from '@ts-css/core' | |
| 137 | 137 | |
| 138 | 138 | const scanner = new Scanner(['./src/**/*.tsx']) |
| 139 | 139 | const { classes, transformedFiles } = await scanner.scan() |
| @@ -147,7 +147,7 @@ for (const className of classes) { | ||
| 147 | 147 | |
| 148 | 148 | ### `parseClass(className: string): ParsedClass`Parse a utility class string into its components.**Parameters:**-`className` - Class name to parse**Returns:**`ParsedClass` object**Example:**```typescript |
| 149 | 149 | |
| 150 | import { parseClass } from 'ts-css' | |
| 150 | import { parseClass } from '@ts-css/core' | |
| 151 | 151 | |
| 152 | 152 | const parsed = parseClass('md:hover:bg-blue-500') |
| 153 | 153 | |
| @@ -172,7 +172,7 @@ console.log(arbitrary.value) // '500px' | ||
| 172 | 172 | ### `defaultConfig` |
| 173 | 173 | |
| 174 | 174 | The default ts-css configuration object.**Example:**```typescript |
| 175 | import { defaultConfig } from 'ts-css' | |
| 175 | import { defaultConfig } from '@ts-css/core' | |
| 176 | 176 | |
| 177 | 177 | // Extend default config |
| 178 | 178 | const config = { |
| @@ -188,7 +188,7 @@ const config = { | ||
| 188 | 188 | |
| 189 | 189 | ```###`loadConfig(options): Promise<TsCssConfig>`Load configuration from file (used internally by CLI).**Parameters:**-`options.name`- Config name (default: 'css') |
| 190 | 190 | -`options.defaultConfig` - Default configuration**Returns:**`Promise<TsCssConfig>`**Example:**```typescript |
| 191 | import { defaultConfig, loadConfig } from 'ts-css' | |
| 191 | import { defaultConfig, loadConfig } from '@ts-css/core' | |
| 192 | 192 | |
| 193 | 193 | const config = await loadConfig({ |
| 194 | 194 | name: 'css', |
| @@ -208,7 +208,7 @@ new CompileClassTransformer(config?: { | ||
| 208 | 208 | ```**Methods:**#### `getCompiledClasses(): Map<string, { className: string, utilities: string[] }>` |
| 209 | 209 | |
| 210 | 210 | Get all compiled classes.**Example:**```typescript |
| 211 | import { CompileClassTransformer } from 'ts-css' | |
| 211 | import { CompileClassTransformer } from '@ts-css/core' | |
| 212 | 212 | |
| 213 | 213 | const transformer = new CompileClassTransformer({ |
| 214 | 214 | trigger: ':tc:', |
| @@ -324,7 +324,7 @@ interface VariantConfig { | ||
| 324 | 324 | |
| 325 | 325 | ### Custom Build Pipeline```typescript |
| 326 | 326 | |
| 327 | import { CSSGenerator, Scanner, writeCSS } from 'ts-css' | |
| 327 | import { CSSGenerator, Scanner, writeCSS } from '@ts-css/core' | |
| 328 | 328 | |
| 329 | 329 | async function customBuild() { |
| 330 | 330 | // 1. Configure |
| @@ -361,7 +361,7 @@ async function customBuild() { | ||
| 361 | 361 | await customBuild() |
| 362 | 362 | |
| 363 | 363 | ```### Analyze Utility Usage```typescript |
| 364 | import { parseClass, Scanner } from 'ts-css' | |
| 364 | import { parseClass, Scanner } from '@ts-css/core' | |
| 365 | 365 | |
| 366 | 366 | async function analyzeUtilities() { |
| 367 | 367 | const scanner = new Scanner(['./src/**/*.tsx']) |
| @@ -389,7 +389,7 @@ await analyzeUtilities() | ||
| 389 | 389 | ```### Watch Mode Implementation```typescript |
| 390 | 390 | |
| 391 | 391 | import { watch } from 'node:fs' |
| 392 | import { buildAndWrite } from 'ts-css' | |
| 392 | import { buildAndWrite } from '@ts-css/core' | |
| 393 | 393 | |
| 394 | 394 | async function watchMode(config: TsCssConfig) { |
| 395 | 395 | console.log('Watching for changes...') |
| @@ -419,7 +419,7 @@ async function watchMode(config: TsCssConfig) { | ||
| 419 | 419 | await watchMode(config) |
| 420 | 420 | |
| 421 | 421 | ```### Framework Plugin```typescript |
| 422 | import { buildAndWrite } from 'ts-css' | |
| 422 | import { buildAndWrite } from '@ts-css/core' | |
| 423 | 423 | |
| 424 | 424 | // Usage in vite.config.ts |
| 425 | 425 | import { defineConfig } from 'vite' |
| @@ -457,7 +457,7 @@ export default defineConfig({ | ||
| 457 | 457 | }) |
| 458 | 458 | ```### Generate Multiple Themes```typescript |
| 459 | 459 | |
| 460 | import { build, writeCSS } from 'ts-css' | |
| 460 | import { build, writeCSS } from '@ts-css/core' | |
| 461 | 461 | |
| 462 | 462 | const baseConfig = { |
| 463 | 463 | content: ['./src/**/*.tsx'], |
| @@ -494,7 +494,7 @@ for (const [name, theme] of Object.entries(themes)) { | ||
| 494 | 494 | |
| 495 | 495 | ```### Testing Utilities```typescript |
| 496 | 496 | import { expect, test } from 'bun:test' |
| 497 | import { CSSGenerator, defaultConfig, parseClass } from 'ts-css' | |
| 497 | import { CSSGenerator, defaultConfig, parseClass } from '@ts-css/core' | |
| 498 | 498 | |
| 499 | 499 | test('parses utility class', () => { |
| 500 | 500 | const parsed = parseClass('md:hover:bg-blue-500') |
| @@ -519,7 +519,7 @@ test('handles important modifier', () => { | ||
| 519 | 519 | }) |
| 520 | 520 | ```## Error Handling```typescript |
| 521 | 521 | |
| 522 | import { buildAndWrite } from 'ts-css' | |
| 522 | import { buildAndWrite } from '@ts-css/core' | |
| 523 | 523 | |
| 524 | 524 | try { |
| 525 | 525 | const result = await buildAndWrite(config) |
| @@ -543,7 +543,7 @@ catch (error) { | ||
| 543 | 543 | |
| 544 | 544 | ### Caching Results```typescript |
| 545 | 545 | |
| 546 | import { build } from 'ts-css' | |
| 546 | import { build } from '@ts-css/core' | |
| 547 | 547 | |
| 548 | 548 | const cache = new Map<string, BuildResult>() |
| 549 | 549 | |
| @@ -562,7 +562,7 @@ async function buildWithCache(config: TsCssConfig) { | ||
| 562 | 562 | } |
| 563 | 563 | ```### Parallel Builds```typescript |
| 564 | 564 | |
| 565 | import { build, writeCSS } from 'ts-css' | |
| 565 | import { build, writeCSS } from '@ts-css/core' | |
| 566 | 566 | |
| 567 | 567 | const configs = [ |
| 568 | 568 | { output: './dist/app.css', content: ['./src/app/**/*.tsx'] }, |
| @@ -10,7 +10,7 @@ Create a configuration file using the init command: | ||
| 10 | 10 | cssx init |
| 11 | 11 | ```This creates a basic`css.config.ts`file:```typescript |
| 12 | 12 | |
| 13 | import type { TsCssOptions } from 'ts-css' | |
| 13 | import type { TsCssOptions } from '@ts-css/core' | |
| 14 | 14 | |
| 15 | 15 | const config = { |
| 16 | 16 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -238,7 +238,7 @@ const config = { | ||
| 238 | 238 | |
| 239 | 239 | ```**Creating a Preset:**```typescript |
| 240 | 240 | // presets/custom.ts |
| 241 | import type { TsCssOptions } from 'ts-css' | |
| 241 | import type { TsCssOptions } from '@ts-css/core' | |
| 242 | 242 | |
| 243 | 243 | export const myCustomPreset: Partial<TsCssConfig> = { |
| 244 | 244 | theme: { |
| @@ -252,7 +252,7 @@ export const myCustomPreset: Partial<TsCssConfig> = { | ||
| 252 | 252 | } |
| 253 | 253 | ```## Complete Configuration Example```typescript |
| 254 | 254 | |
| 255 | import type { TsCssOptions } from 'ts-css' | |
| 255 | import type { TsCssOptions } from '@ts-css/core' | |
| 256 | 256 | |
| 257 | 257 | const config = { |
| 258 | 258 | // Required |
| @@ -306,7 +306,7 @@ export default config | ||
| 306 | 306 | ```## Environment-Specific Configuration |
| 307 | 307 | |
| 308 | 308 | You can create different configurations for different environments:```typescript |
| 309 | import type { TsCssOptions } from 'ts-css' | |
| 309 | import type { TsCssOptions } from '@ts-css/core' | |
| 310 | 310 | |
| 311 | 311 | const isDev = process.env.NODE_ENV === 'development' |
| 312 | 312 | const isProd = process.env.NODE_ENV === 'production' |
| @@ -327,7 +327,7 @@ export default config | ||
| 327 | 327 | ```## TypeScript Support |
| 328 | 328 | |
| 329 | 329 | ts-css provides full TypeScript support with type checking and autocomplete:```typescript |
| 330 | import type { TsCssOptions } from 'ts-css' | |
| 330 | import type { TsCssOptions } from '@ts-css/core' | |
| 331 | 331 | |
| 332 | 332 | // Use satisfies for type checking while preserving literal types |
| 333 | 333 | const config = { |
| @@ -10,11 +10,11 @@ Install ts-css globally or locally: | ||
| 10 | 10 | |
| 11 | 11 | # Global (use anywhere) |
| 12 | 12 | |
| 13 | bun add --global ts-css | |
| 13 | bun add --global @ts-css/core | |
| 14 | 14 | |
| 15 | 15 | # Local (project-specific) |
| 16 | 16 | |
| 17 | bun add ts-css | |
| 17 | bun add @ts-css/core | |
| 18 | 18 | ```## Commands |
| 19 | 19 | |
| 20 | 20 | ### `build`Build CSS from your content files.```bash |
| @@ -125,7 +125,7 @@ Next steps: | ||
| 125 | 125 | |
| 126 | 126 | ```**Generated file:**```typescript |
| 127 | 127 | |
| 128 | import type { TsCssOptions } from 'ts-css' | |
| 128 | import type { TsCssOptions } from '@ts-css/core' | |
| 129 | 129 | |
| 130 | 130 | const config = { |
| 131 | 131 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -403,7 +403,7 @@ cssx build --config ./css.test.config.ts | ||
| 403 | 403 | ```### Programmatic Usage |
| 404 | 404 | |
| 405 | 405 | While the CLI is convenient, you can also use ts-css programmatically:```typescript |
| 406 | import { build, buildAndWrite } from 'ts-css' | |
| 406 | import { build, buildAndWrite } from '@ts-css/core' | |
| 407 | 407 | |
| 408 | 408 | // Build only (get result) |
| 409 | 409 | const result = await build({ |
| @@ -459,7 +459,7 @@ const config = { | ||
| 459 | 459 | ### Command Not Found**Problem:**`command not found: cssx`**Solutions:**1. Install globally |
| 460 | 460 | |
| 461 | 461 | ```bash |
| 462 | bun add --global ts-css | |
| 462 | bun add --global @ts-css/core | |
| 463 | 463 | ```2. Or use with package runner:```bash |
| 464 | 464 | bunx cssx build |
| 465 | 465 | |
| @@ -494,7 +494,7 @@ const config = { | ||
| 494 | 494 | ls -la ./src/**/*.tsx |
| 495 | 495 | ```3. Validate config:```typescript |
| 496 | 496 | // Use type checking |
| 497 | import type { TsCssOptions } from 'ts-css' | |
| 497 | import type { TsCssOptions } from '@ts-css/core' | |
| 498 | 498 | |
| 499 | 499 | const config = { |
| 500 | 500 | content: ['./src/**/*.tsx'], |
| @@ -30,7 +30,7 @@ Add the`:tc:`trigger to mark utility groups for compilation:```html | ||
| 30 | 30 | |
| 31 | 31 | Configure the transformer in your config:```typescript |
| 32 | 32 | // css.config.ts |
| 33 | import type { TsCssOptions } from 'ts-css' | |
| 33 | import type { TsCssOptions } from '@ts-css/core' | |
| 34 | 34 | |
| 35 | 35 | const config = { |
| 36 | 36 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -8,7 +8,7 @@ Use TypeScript for your configuration file to get autocompletion and type checki | ||
| 8 | 8 | |
| 9 | 9 | ```typescript |
| 10 | 10 | // css.config.ts |
| 11 | import type { TsCssOptions } from 'ts-css' | |
| 11 | import type { TsCssOptions } from '@ts-css/core' | |
| 12 | 12 | |
| 13 | 13 | const config = { |
| 14 | 14 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -31,7 +31,7 @@ export default config | ||
| 31 | 31 | ```## Type Checking |
| 32 | 32 | |
| 33 | 33 | The`satisfies`keyword provides type checking while preserving literal types:```typescript |
| 34 | import type { TsCssOptions } from 'ts-css' | |
| 34 | import type { TsCssOptions } from '@ts-css/core' | |
| 35 | 35 | |
| 36 | 36 | // ✅ Type-safe with autocompletion |
| 37 | 37 | const config = { |
| @@ -107,7 +107,7 @@ Get IntelliSense and autocompletion in your IDE: | ||
| 107 | 107 | 1. Install the TypeScript extension (comes pre-installed) |
| 108 | 108 | 2. Create`css.config.ts`with the type import:```typescript |
| 109 | 109 | |
| 110 | import type { TsCssOptions } from 'ts-css' | |
| 110 | import type { TsCssOptions } from '@ts-css/core' | |
| 111 | 111 | |
| 112 | 112 | const config = { |
| 113 | 113 | // Press Ctrl+Space here for autocompletion |
| @@ -161,8 +161,8 @@ const config = { | ||
| 161 | 161 | |
| 162 | 162 | ### Build Function```typescript |
| 163 | 163 | |
| 164 | import type { BuildResult, TsCssConfig } from 'ts-css' | |
| 165 | import { build } from 'ts-css' | |
| 164 | import type { BuildResult, TsCssConfig } from '@ts-css/core' | |
| 165 | import { build } from '@ts-css/core' | |
| 166 | 166 | |
| 167 | 167 | const result: BuildResult = await build({ |
| 168 | 168 | content: ['./src/**/*.tsx'], |
| @@ -185,7 +185,7 @@ interface BuildResult { | ||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | ```### Using with async/await```typescript |
| 188 | import { build, buildAndWrite } from 'ts-css' | |
| 188 | import { build, buildAndWrite } from '@ts-css/core' | |
| 189 | 189 | |
| 190 | 190 | async function buildStyles() { |
| 191 | 191 | // With build |
| @@ -207,7 +207,7 @@ async function buildStyles() { | ||
| 207 | 207 | ```## Custom Rules with Types |
| 208 | 208 | |
| 209 | 209 | Define type-safe custom rules:```typescript |
| 210 | import type { CustomRule, TsCssConfig } from 'ts-css' | |
| 210 | import type { CustomRule, TsCssConfig } from '@ts-css/core' | |
| 211 | 211 | |
| 212 | 212 | const customRules: CustomRule[] = [ |
| 213 | 213 | // Pattern and handler with types |
| @@ -229,7 +229,7 @@ const config = { | ||
| 229 | 229 | ```## Preset Types |
| 230 | 230 | |
| 231 | 231 | Create type-safe presets:```typescript |
| 232 | import type { Preset, Theme } from 'ts-css' | |
| 232 | import type { Preset, Theme } from '@ts-css/core' | |
| 233 | 233 | |
| 234 | 234 | const myPreset: Preset = { |
| 235 | 235 | name: 'my-design-system', |
| @@ -264,7 +264,7 @@ const config = { | ||
| 264 | 264 | ### Custom Theme Values |
| 265 | 265 | |
| 266 | 266 | Extend the theme with custom properties:```typescript |
| 267 | import type { TsCssOptions, Theme } from 'ts-css' | |
| 267 | import type { TsCssOptions, Theme } from '@ts-css/core' | |
| 268 | 268 | |
| 269 | 269 | interface CustomTheme extends Theme { |
| 270 | 270 | customSpacing: Record<string, string> |
| @@ -286,7 +286,7 @@ const config = { | ||
| 286 | 286 | ```### Custom Config |
| 287 | 287 | |
| 288 | 288 | Create a custom config interface:```typescript |
| 289 | import type { TsCssOptions } from 'ts-css' | |
| 289 | import type { TsCssOptions } from '@ts-css/core' | |
| 290 | 290 | |
| 291 | 291 | interface MyConfig extends Partial<TsCssConfig> { |
| 292 | 292 | // Add custom properties |
| @@ -310,7 +310,7 @@ const config: MyConfig = { | ||
| 310 | 310 | ```## Type Guards |
| 311 | 311 | |
| 312 | 312 | Use type guards for runtime type checking:```typescript |
| 313 | import type { TsCssOptions } from 'ts-css' | |
| 313 | import type { TsCssOptions } from '@ts-css/core' | |
| 314 | 314 | |
| 315 | 315 | function isValidConfig(config: unknown): config is TsCssConfig { |
| 316 | 316 | return ( |
| @@ -333,7 +333,7 @@ if (isValidConfig(config)) { | ||
| 333 | 333 | ```## Generics |
| 334 | 334 | |
| 335 | 335 | Use generics for flexible, type-safe functions:```typescript |
| 336 | import type { TsCssOptions } from 'ts-css' | |
| 336 | import type { TsCssOptions } from '@ts-css/core' | |
| 337 | 337 | |
| 338 | 338 | function createConfig<T extends Partial<TsCssConfig>>(config: T): T { |
| 339 | 339 | return { |
| @@ -356,12 +356,12 @@ const config = createConfig({ | ||
| 356 | 356 | |
| 357 | 357 | Extend ts-css types globally:```typescript |
| 358 | 358 | // Now use in config |
| 359 | import type { TsCssOptions } from 'ts-css' | |
| 359 | import type { TsCssOptions } from '@ts-css/core' | |
| 360 | 360 | |
| 361 | 361 | // types/ts-css.d.ts |
| 362 | import 'ts-css' | |
| 362 | import '@ts-css/core' | |
| 363 | 363 | |
| 364 | declare module 'ts-css' { | |
| 364 | declare module '@ts-css/core' { | |
| 365 | 365 | interface TsCssConfig { |
| 366 | 366 | // Add your custom properties |
| 367 | 367 | customFeature?: { |
| @@ -392,8 +392,8 @@ const config = { | ||
| 392 | 392 | |
| 393 | 393 | ### Vite```typescript |
| 394 | 394 | |
| 395 | import type { TsCssOptions } from 'ts-css' | |
| 396 | import { build } from 'ts-css' | |
| 395 | import type { TsCssOptions } from '@ts-css/core' | |
| 396 | import { build } from '@ts-css/core' | |
| 397 | 397 | // vite.config.ts |
| 398 | 398 | import { defineConfig } from 'vite' |
| 399 | 399 | |
| @@ -415,10 +415,10 @@ export default defineConfig({ | ||
| 415 | 415 | }) |
| 416 | 416 | ```### Next.js```typescript |
| 417 | 417 | |
| 418 | import type { TsCssOptions } from 'ts-css' | |
| 418 | import type { TsCssOptions } from '@ts-css/core' | |
| 419 | 419 | // next.config.ts |
| 420 | 420 | import type { NextConfig } from 'next' |
| 421 | import { buildAndWrite } from 'ts-css' | |
| 421 | import { buildAndWrite } from '@ts-css/core' | |
| 422 | 422 | |
| 423 | 423 | const tsCssConfig: TsCssConfig = { |
| 424 | 424 | content: ['./src/**/*.tsx', './app/**/*.tsx'], |
| @@ -446,7 +446,7 @@ import type { | ||
| 446 | 446 | ParsedClass, |
| 447 | 447 | Preset, |
| 448 | 448 | Theme, |
| 449 | } from 'ts-css' | |
| 449 | } from '@ts-css/core' | |
| 450 | 450 | |
| 451 | 451 | // Extract specific types |
| 452 | 452 | type ConfigColors = Theme['colors'] |
| @@ -460,10 +460,10 @@ type PartialTheme = Partial<Theme> | ||
| 460 | 460 | ### 1. Always Use Type Imports```typescript |
| 461 | 461 | |
| 462 | 462 | // ✅ Type-only import |
| 463 | import type { TsCssOptions } from 'ts-css' | |
| 463 | import type { TsCssOptions } from '@ts-css/core' | |
| 464 | 464 | |
| 465 | 465 | // ❌ Value import (unnecessary) |
| 466 | import { TsCssConfig } from 'ts-css' | |
| 466 | import { TsCssConfig } from '@ts-css/core' | |
| 467 | 467 | |
| 468 | 468 | ```### 2. Use`satisfies`for Validation```typescript |
| 469 | 469 | // ✅ Validates types while preserving literals |
| @@ -478,7 +478,7 @@ const config: Partial<TsCssConfig> = { | ||
| 478 | 478 | ```### 3. Separate Type Definitions```typescript |
| 479 | 479 | |
| 480 | 480 | // types/ts-css.ts |
| 481 | import type { TsCssOptions, Preset } from 'ts-css' | |
| 481 | import type { TsCssOptions, Preset } from '@ts-css/core' | |
| 482 | 482 | |
| 483 | 483 | // css.config.ts |
| 484 | 484 | import type { MyConfig } from './types/ts-css' |
| @@ -528,14 +528,14 @@ bun add --dev typescript | ||
| 528 | 528 | |
| 529 | 529 | # Ensure types are imported |
| 530 | 530 | |
| 531 | import type { TsCssOptions } from 'ts-css' | |
| 531 | import type { TsCssOptions } from '@ts-css/core' | |
| 532 | 532 | |
| 533 | 533 | ```### Autocomplete Not Working**Problem:**No autocompletion in IDE**Solutions:**1. Restart TypeScript server |
| 534 | 534 | |
| 535 | 535 | 2. Check tsconfig.json includes the config file |
| 536 | 536 | 3. Ensure proper imports:```typescript |
| 537 | 537 | |
| 538 | import type { TsCssOptions } from 'ts-css' | |
| 538 | import type { TsCssOptions } from '@ts-css/core' | |
| 539 | 539 | ``` |
| 540 | 540 | |
| 541 | 541 | ## Related*[Configuration](../config.md) - Full configuration guide*[Custom Rules](../advanced/custom-rules.md) - Creating custom utilities*[Presets](../advanced/presets.md) - Reusable configurations*[API Reference](../api-reference.md) - Programmatic API |
| @@ -33,7 +33,7 @@ When you start watch mode, ts-css: | ||
| 33 | 33 | |
| 34 | 34 | Watch mode uses the content patterns from your configuration file:```typescript |
| 35 | 35 | // css.config.ts |
| 36 | import type { TsCssOptions } from 'ts-css' | |
| 36 | import type { TsCssOptions } from '@ts-css/core' | |
| 37 | 37 | |
| 38 | 38 | const config = { |
| 39 | 39 | content: [ |
| @@ -9,31 +9,31 @@ Install ts-css as a development dependency in your project: | ||
| 9 | 9 | ::: code-group |
| 10 | 10 | |
| 11 | 11 | ```sh [bun] |
| 12 | bun add ts-css | |
| 12 | bun add @ts-css/core | |
| 13 | 13 | |
| 14 | 14 | # or |
| 15 | 15 | |
| 16 | bun install --dev ts-css | |
| 16 | bun install --dev @ts-css/core | |
| 17 | 17 | ``` |
| 18 | 18 | |
| 19 | 19 | ```sh [npm] |
| 20 | npm install ts-css | |
| 20 | npm install @ts-css/core | |
| 21 | 21 | |
| 22 | 22 | # or |
| 23 | 23 | |
| 24 | npm i -D ts-css | |
| 24 | npm i -D @ts-css/core | |
| 25 | 25 | ``` |
| 26 | 26 | |
| 27 | 27 | ```sh [pnpm] |
| 28 | pnpm add ts-css | |
| 28 | pnpm add @ts-css/core | |
| 29 | 29 | |
| 30 | 30 | # or |
| 31 | 31 | |
| 32 | pnpm add -D ts-css | |
| 32 | pnpm add -D @ts-css/core | |
| 33 | 33 | ``` |
| 34 | 34 | |
| 35 | 35 | ```sh [yarn] |
| 36 | yarn add ts-css | |
| 36 | yarn add @ts-css/core | |
| 37 | 37 | ```::: |
| 38 | 38 | |
| 39 | 39 | ### Global Installation |
| @@ -41,29 +41,29 @@ yarn add ts-css | ||
| 41 | 41 | For global installation (to use the CLI anywhere): |
| 42 | 42 | |
| 43 | 43 | ::: code-group```sh [bun] |
| 44 | bun add --global ts-css | |
| 44 | bun add --global @ts-css/core | |
| 45 | 45 | |
| 46 | 46 | ``` |
| 47 | 47 | |
| 48 | 48 | ```sh [npm] |
| 49 | 49 | |
| 50 | npm install --global ts-css | |
| 50 | npm install --global @ts-css/core | |
| 51 | 51 | |
| 52 | 52 | # or |
| 53 | 53 | |
| 54 | npm i -g ts-css | |
| 54 | npm i -g @ts-css/core | |
| 55 | 55 | |
| 56 | 56 | ``` |
| 57 | 57 | |
| 58 | 58 | ```sh [pnpm] |
| 59 | 59 | |
| 60 | pnpm add --global ts-css | |
| 60 | pnpm add --global @ts-css/core | |
| 61 | 61 | |
| 62 | 62 | ``` |
| 63 | 63 | |
| 64 | 64 | ```sh [yarn] |
| 65 | 65 | |
| 66 | yarn global add ts-css | |
| 66 | yarn global add @ts-css/core | |
| 67 | 67 | |
| 68 | 68 | ```::: |
| 69 | 69 | |
| @@ -85,7 +85,7 @@ cssx watch | ||
| 85 | 85 | ```## Configuration |
| 86 | 86 | |
| 87 | 87 | The`cssx init`command creates a basic`css.config.ts`file:```typescript |
| 88 | import type { TsCssOptions } from 'ts-css' | |
| 88 | import type { TsCssOptions } from '@ts-css/core' | |
| 89 | 89 | |
| 90 | 90 | const config = { |
| 91 | 91 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -102,7 +102,7 @@ export default config | ||
| 102 | 102 | |
| 103 | 103 | # Install ts-css |
| 104 | 104 | |
| 105 | bun add ts-css | |
| 105 | bun add @ts-css/core | |
| 106 | 106 | |
| 107 | 107 | # Create config |
| 108 | 108 | |
| @@ -110,7 +110,7 @@ cssx init | ||
| 110 | 110 | ```Update your`css.config.ts`: |
| 111 | 111 | |
| 112 | 112 | ```typescript |
| 113 | import type { TsCssOptions } from 'ts-css' | |
| 113 | import type { TsCssOptions } from '@ts-css/core' | |
| 114 | 114 | |
| 115 | 115 | const config = { |
| 116 | 116 | content: [ |
| @@ -143,7 +143,7 @@ import './styles/styles.css' | ||
| 143 | 143 | |
| 144 | 144 | # Install ts-css |
| 145 | 145 | |
| 146 | bun add ts-css | |
| 146 | bun add @ts-css/core | |
| 147 | 147 | |
| 148 | 148 | # Create config |
| 149 | 149 | |
| @@ -151,7 +151,7 @@ cssx init | ||
| 151 | 151 | ```Update your`css.config.ts`: |
| 152 | 152 | |
| 153 | 153 | ```typescript |
| 154 | import type { TsCssOptions } from 'ts-css' | |
| 154 | import type { TsCssOptions } from '@ts-css/core' | |
| 155 | 155 | |
| 156 | 156 | const config = { |
| 157 | 157 | content: [ |
| @@ -174,7 +174,7 @@ export default config | ||
| 174 | 174 | |
| 175 | 175 | # Install ts-css |
| 176 | 176 | |
| 177 | bun add ts-css | |
| 177 | bun add @ts-css/core | |
| 178 | 178 | |
| 179 | 179 | # Create config |
| 180 | 180 | |
| @@ -182,7 +182,7 @@ cssx init | ||
| 182 | 182 | ```Update your`css.config.ts`: |
| 183 | 183 | |
| 184 | 184 | ```typescript |
| 185 | import type { TsCssOptions } from 'ts-css' | |
| 185 | import type { TsCssOptions } from '@ts-css/core' | |
| 186 | 186 | |
| 187 | 187 | const config = { |
| 188 | 188 | content: [ |
| @@ -203,7 +203,7 @@ export default config | ||
| 203 | 203 | |
| 204 | 204 | # Install ts-css |
| 205 | 205 | |
| 206 | bun add ts-css | |
| 206 | bun add @ts-css/core | |
| 207 | 207 | |
| 208 | 208 | # Create config |
| 209 | 209 | |
| @@ -211,7 +211,7 @@ cssx init | ||
| 211 | 211 | ```Update your`css.config.ts`: |
| 212 | 212 | |
| 213 | 213 | ```typescript |
| 214 | import type { TsCssOptions } from 'ts-css' | |
| 214 | import type { TsCssOptions } from '@ts-css/core' | |
| 215 | 215 | |
| 216 | 216 | const config = { |
| 217 | 217 | content: [ |
| @@ -235,7 +235,7 @@ import '/styles.css' | ||
| 235 | 235 | |
| 236 | 236 | # Install ts-css globally |
| 237 | 237 | |
| 238 | bun add --global ts-css | |
| 238 | bun add --global @ts-css/core | |
| 239 | 239 | |
| 240 | 240 | # Create config |
| 241 | 241 | |
| @@ -243,7 +243,7 @@ cssx init | ||
| 243 | 243 | ```Update your`css.config.ts`: |
| 244 | 244 | |
| 245 | 245 | ```typescript |
| 246 | import type { TsCssOptions } from 'ts-css' | |
| 246 | import type { TsCssOptions } from '@ts-css/core' | |
| 247 | 247 | |
| 248 | 248 | const config = { |
| 249 | 249 | content: ['./src/**/*.html'], |
| @@ -397,11 +397,11 @@ If you get permission errors when installing globally:```bash | ||
| 397 | 397 | |
| 398 | 398 | # Use sudo on macOS/Linux |
| 399 | 399 | |
| 400 | sudo bun add --global ts-css | |
| 400 | sudo bun add --global @ts-css/core | |
| 401 | 401 | |
| 402 | 402 | # Or install locally and use npx |
| 403 | 403 | |
| 404 | bun add ts-css | |
| 404 | bun add @ts-css/core | |
| 405 | 405 | bunx cssx build |
| 406 | 406 | |
| 407 | 407 | ```### TypeScript Errors |
| @@ -412,7 +412,7 @@ If you encounter TypeScript errors in your config file: | ||
| 412 | 412 | |
| 413 | 413 | bun add --dev typescript |
| 414 | 414 | ```2. Use the`satisfies`keyword for type checking:```typescript |
| 415 | import type { TsCssOptions } from 'ts-css' | |
| 415 | import type { TsCssOptions } from '@ts-css/core' | |
| 416 | 416 | |
| 417 | 417 | const config = { |
| 418 | 418 | content: ['./src/**/*.tsx'], |
| @@ -130,15 +130,15 @@ Install ts-css via your package manager:```bash | ||
| 130 | 130 | |
| 131 | 131 | # Using Bun (recommended) |
| 132 | 132 | |
| 133 | bun add ts-css | |
| 133 | bun add @ts-css/core | |
| 134 | 134 | |
| 135 | 135 | # Using npm |
| 136 | 136 | |
| 137 | npm install ts-css | |
| 137 | npm install @ts-css/core | |
| 138 | 138 | |
| 139 | 139 | # Using pnpm |
| 140 | 140 | |
| 141 | pnpm add ts-css | |
| 141 | pnpm add @ts-css/core | |
| 142 | 142 | |
| 143 | 143 | ```### Configuration |
| 144 | 144 | |
| @@ -146,7 +146,7 @@ Create a configuration file:```bash | ||
| 146 | 146 | cssx init |
| 147 | 147 | ```This creates a`css.config.ts`file:```typescript |
| 148 | 148 | |
| 149 | import type { TsCssOptions } from 'ts-css' | |
| 149 | import type { TsCssOptions } from '@ts-css/core' | |
| 150 | 150 | |
| 151 | 151 | const config = { |
| 152 | 152 | content: ['./src/**/*.{html,js,ts,jsx,tsx}'], |
| @@ -5,7 +5,7 @@ A Bun plugin that automatically generates and injects Crosswind CSS into your HT | ||
| 5 | 5 | ## Installation |
| 6 | 6 | |
| 7 | 7 | ```bash |
| 8 | bun add ts-css | |
| 8 | bun add @ts-css/core | |
| 9 | 9 | ``` |
| 10 | 10 | |
| 11 | 11 | ## Quick Start**1. Create your HTML file**(`src/template.html`) |
| @@ -32,7 +32,7 @@ document.body.innerHTML = template | ||
| 32 | 32 | ```**3. Build with the plugin**: |
| 33 | 33 | |
| 34 | 34 | ```typescript |
| 35 | import { plugin } from 'ts-css' | |
| 35 | import { plugin } from '@ts-css/core' | |
| 36 | 36 | |
| 37 | 37 | await Bun.build({ |
| 38 | 38 | entrypoints: ['./src/index.ts'], |
| @@ -49,7 +49,7 @@ await Bun.build({ | ||
| 49 | 49 | |
| 50 | 50 | ### Basic Configuration```typescript |
| 51 | 51 | |
| 52 | import { plugin } from 'ts-css' | |
| 52 | import { plugin } from '@ts-css/core' | |
| 53 | 53 | |
| 54 | 54 | await Bun.build({ |
| 55 | 55 | entrypoints: ['./src/index.ts'], |
| @@ -62,7 +62,7 @@ await Bun.build({ | ||
| 62 | 62 | }) |
| 63 | 63 | |
| 64 | 64 | ```### Custom Theme```typescript |
| 65 | import { plugin } from 'ts-css' | |
| 65 | import { plugin } from '@ts-css/core' | |
| 66 | 66 | |
| 67 | 67 | await Bun.build({ |
| 68 | 68 | entrypoints: ['./src/index.ts'], |
| @@ -92,7 +92,7 @@ await Bun.build({ | ||
| 92 | 92 | }) |
| 93 | 93 | ```### Advanced Configuration```typescript |
| 94 | 94 | |
| 95 | import { plugin } from 'ts-css' | |
| 95 | import { plugin } from '@ts-css/core' | |
| 96 | 96 | |
| 97 | 97 | await Bun.build({ |
| 98 | 98 | entrypoints: ['./src/index.ts'], |
| @@ -186,7 +186,7 @@ The plugin is highly performant: | ||
| 186 | 186 | ## TypeScript Support |
| 187 | 187 | |
| 188 | 188 | The plugin is fully typed. Import the types:```typescript |
| 189 | import type { TsCssPluginOptions } from 'ts-css' | |
| 189 | import type { TsCssPluginOptions } from '@ts-css/core' | |
| 190 | 190 | |
| 191 | 191 | const options: TsCssPluginOptions = { |
| 192 | 192 | config: { |
| @@ -197,7 +197,7 @@ const options: TsCssPluginOptions = { | ||
| 197 | 197 | |
| 198 | 198 | The plugin also respects`crosswind.config.ts`in your project root:```typescript |
| 199 | 199 | // crosswind.config.ts |
| 200 | import type { TsCssOptions } from 'ts-css' | |
| 200 | import type { TsCssOptions } from '@ts-css/core' | |
| 201 | 201 | |
| 202 | 202 | export default { |
| 203 | 203 | minify: true, |
| @@ -5,7 +5,7 @@ A CSS engine with two front ends and one atomic output: Tailwind-compatible **ut | ||
| 5 | 5 | ## Installation |
| 6 | 6 | |
| 7 | 7 | ```bash |
| 8 | bun add ts-css | |
| 8 | bun add @ts-css/core | |
| 9 | 9 | ``` |
| 10 | 10 | |
| 11 | 11 | ## Quick Start |
| @@ -13,7 +13,7 @@ bun add ts-css | ||
| 13 | 13 | ### Programmatic API |
| 14 | 14 | |
| 15 | 15 | ```typescript |
| 16 | import { CSSGenerator, defaultConfig } from 'ts-css' | |
| 16 | import { CSSGenerator, defaultConfig } from '@ts-css/core' | |
| 17 | 17 | |
| 18 | 18 | const gen = new CSSGenerator(defaultConfig) |
| 19 | 19 | gen.generate('flex') |
| @@ -32,7 +32,7 @@ const css = gen.toCSS(true) // true = include preflight | ||
| 32 | 32 | ### Build API |
| 33 | 33 | |
| 34 | 34 | ```typescript |
| 35 | import { build } from 'ts-css' | |
| 35 | import { build } from '@ts-css/core' | |
| 36 | 36 | |
| 37 | 37 | const result = await build({ |
| 38 | 38 | content: ['./src/**/*.html', './src/**/*.tsx'], |
| @@ -44,7 +44,7 @@ const result = await build({ | ||
| 44 | 44 | ### Style API |
| 45 | 45 | |
| 46 | 46 | ```typescript |
| 47 | import { css } from 'ts-css' | |
| 47 | import { css } from '@ts-css/core' | |
| 48 | 48 | |
| 49 | 49 | const theme = css.defineVars({ |
| 50 | 50 | accent: '#0b7', |
| @@ -101,7 +101,7 @@ cssx build --minify | ||
| 101 | 101 | Create a `css.config.ts` in your project root: |
| 102 | 102 | |
| 103 | 103 | ```typescript |
| 104 | import type { TsCssConfig } from 'ts-css' | |
| 104 | import type { TsCssConfig } from '@ts-css/core' | |
| 105 | 105 | |
| 106 | 106 | export default { |
| 107 | 107 | content: ['./src/**/*.{html,tsx,stx}'], |
| @@ -588,7 +588,7 @@ Prefix with `!` to apply `!important`: | ||
| 588 | 588 | ## Presets |
| 589 | 589 | |
| 590 | 590 | ```typescript |
| 591 | import type { Preset } from 'ts-css' | |
| 591 | import type { Preset } from '@ts-css/core' | |
| 592 | 592 | |
| 593 | 593 | const myPreset: Preset = { |
| 594 | 594 | name: 'my-preset', |
| @@ -309,7 +309,7 @@ cli | ||
| 309 | 309 | process.exit(1) |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | const defaultConfig = `import type { TsCssOptions } from 'ts-css' | |
| 312 | const defaultConfig = `import type { TsCssOptions } from '@ts-css/core' | |
| 313 | 313 | |
| 314 | 314 | const config = { |
| 315 | 315 | content: ['./src/**/*.{html,js,ts,jsx,tsx,stx}'], |
| @@ -20,7 +20,7 @@ The plugin works by intercepting HTML imports in your TypeScript/JavaScript code | ||
| 20 | 20 | |
| 21 | 21 | ### Basic Setup```typescript |
| 22 | 22 | |
| 23 | import { plugin } from 'ts-css' | |
| 23 | import { plugin } from '@ts-css/core' | |
| 24 | 24 | |
| 25 | 25 | await Bun.build({ |
| 26 | 26 | entrypoints: ['./src/index.ts'], |
| @@ -36,7 +36,7 @@ import html from './index.html' | ||
| 36 | 36 | document.body.innerHTML = html |
| 37 | 37 | ```### With Custom Configuration```typescript |
| 38 | 38 | |
| 39 | import { plugin } from 'ts-css' | |
| 39 | import { plugin } from '@ts-css/core' | |
| 40 | 40 | |
| 41 | 41 | await Bun.build({ |
| 42 | 42 | entrypoints: ['./src/index.ts'], |
| @@ -51,7 +51,7 @@ import { renderStyles, resetStyles } from './registry' | ||
| 51 | 51 | * |
| 52 | 52 | * @example |
| 53 | 53 | * ```ts |
| 54 | * import { css } from 'ts-css' | |
| 54 | * import { css } from '@ts-css/core' | |
| 55 | 55 | * |
| 56 | 56 | * const styles = css.create({ card: { padding: 16 } }) |
| 57 | 57 | * <div {...css.props(styles.card)} /> |
| @@ -28,11 +28,11 @@ TAG="${1:-$(git tag --list 'v*' --sort=-v:refname | head -1)}" | ||
| 28 | 28 | VERSION="${TAG#v}" |
| 29 | 29 | |
| 30 | 30 | echo "Repository : $REPO" |
| 31 | echo "Release tag: $TAG (ts-css@$VERSION)" | |
| 31 | echo "Release tag: $TAG (@ts-css/core@$VERSION)" | |
| 32 | 32 | echo |
| 33 | 33 | echo "Paste the npm token, then press Enter. It will not be displayed." |
| 34 | 34 | echo "It needs permission to CREATE packages (Automation, or granular with" |
| 35 | echo "read/write on all packages) — 'ts-css' does not exist on npm yet." | |
| 35 | echo "read/write on all packages) — '@ts-css/core' does not exist on npm yet." | |
| 36 | 36 | printf 'npm token: ' |
| 37 | 37 | read -rs NPM_TOKEN_VALUE |
| 38 | 38 | echo |
| @@ -62,7 +62,7 @@ if [[ "$WHOAMI_STATUS" != "200" ]]; then | ||
| 62 | 62 | echo "npm rejected the token (HTTP $WHOAMI_STATUS)." >&2 |
| 63 | 63 | echo "Create a fresh one at https://www.npmjs.com/settings/~/tokens" >&2 |
| 64 | 64 | echo "It must be an Automation token, or granular with read/write on ALL" >&2 |
| 65 | echo "packages — 'ts-css' does not exist yet, so a token scoped to existing" >&2 | |
| 65 | echo "packages — '@ts-css/core' does not exist yet, so a token scoped to existing" >&2 | |
| 66 | 66 | echo "packages cannot create it." >&2 |
| 67 | 67 | exit 1 |
| 68 | 68 | fi |
| @@ -129,11 +129,11 @@ fi | ||
| 129 | 129 | # publish step has previously reported errors while the run itself succeeded, |
| 130 | 130 | # and the registry is the only authority on whether the version exists. |
| 131 | 131 | echo |
| 132 | echo "Confirming ts-css@$VERSION on the registry ..." | |
| 132 | echo "Confirming @ts-css/core@$VERSION on the registry ..." | |
| 133 | 133 | for attempt in 1 2 3 4 5 6; do |
| 134 | STATUS="$(curl -s -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/ts-css/$VERSION" || echo 000)" | |
| 134 | STATUS="$(curl -s -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/@ts-css%2Fcore/$VERSION" || echo 000)" | |
| 135 | 135 | if [[ "$STATUS" == "200" ]]; then |
| 136 | echo " ts-css@$VERSION is live: https://www.npmjs.com/package/ts-css/v/$VERSION" | |
| 136 | echo " @ts-css/core@$VERSION is live: https://www.npmjs.com/package/@ts-css/core/v/$VERSION" | |
| 137 | 137 | PUBLISHED=1 |
| 138 | 138 | break |
| 139 | 139 | fi |
| @@ -143,7 +143,7 @@ done | ||
| 143 | 143 | |
| 144 | 144 | if [[ "${PUBLISHED:-0}" != "1" ]]; then |
| 145 | 145 | echo >&2 |
| 146 | echo "The workflow finished but ts-css@$VERSION is not on the registry." >&2 | |
| 146 | echo "The workflow finished but @ts-css/core@$VERSION is not on the registry." >&2 | |
| 147 | 147 | echo "Inspect the publish step with:" >&2 |
| 148 | 148 | echo " gh run view $RUN_ID --log --repo $REPO | grep -A5 'Publish to npm'" >&2 |
| 149 | 149 | exit 1 |