teacss 0.9.4 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -118
- package/bin/teacss.mjs +51 -1
- package/package.json +24 -29
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -1
- package/dist/core.d.ts +0 -2
- package/dist/core.js +0 -1
- package/dist/preset-icons.d.ts +0 -3
- package/dist/preset-icons.js +0 -1
- package/dist/preset-official.d.ts +0 -3
- package/dist/preset-official.js +0 -1
- package/dist/preset-standard.d.ts +0 -3
- package/dist/preset-standard.js +0 -1
package/README.md
CHANGED
|
@@ -1,119 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# teacss
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
It provides the `teacss` command and four subpaths: the `teacss/cli`
|
|
6
|
-
programmatic API, `teacss/core`, and the preset factories. The package has no
|
|
7
|
-
root entry; `import "teacss"` fails. Runtime class helpers live in
|
|
8
|
-
`@teacss/classes`.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
Install `teacss` as a development dependency with the adapter and host for the
|
|
13
|
-
project's build tool:
|
|
14
|
-
|
|
15
|
-
| Build tool | Development packages |
|
|
16
|
-
| -------------- | ------------------------------- |
|
|
17
|
-
| Vite | `@teacss/vite vite` |
|
|
18
|
-
| Astro | `@teacss/astro astro vite` |
|
|
19
|
-
| Rsbuild | `@teacss/rsbuild @rsbuild/core` |
|
|
20
|
-
| PostCSS | `@teacss/postcss postcss` |
|
|
21
|
-
| Bun Build | `@teacss/bun` |
|
|
22
|
-
| Standalone CLI | Included with `teacss` |
|
|
23
|
-
|
|
24
|
-
For example, `npm install --save-dev teacss @teacss/vite vite` sets up Vite.
|
|
25
|
-
For standalone output, install only `teacss` and run its CLI:
|
|
26
|
-
|
|
27
|
-
```sh
|
|
28
|
-
npx teacss "src/**/*.{ts,tsx,html}" --preset standard -o tea.css
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
`--preset standard` enables utilities when the project has no CSS entry. Add
|
|
32
|
-
`--watch` to rebuild as source files change, and include `tea.css` in the page.
|
|
33
|
-
|
|
34
|
-
The programmatic `build` API is available from `teacss/cli`:
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
import { build } from "teacss/cli";
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Example with Vite:
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { defineConfig } from "vite";
|
|
44
|
-
import { pluginTeacss } from "@teacss/vite";
|
|
45
|
-
|
|
46
|
-
export default defineConfig({ plugins: [pluginTeacss()] });
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```css
|
|
50
|
-
@presets "standard,icons,official";
|
|
51
|
-
@source "./src/**/*.{ts,tsx,html}";
|
|
52
|
-
@teacss;
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
import "virtual:teacss.css";
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Presets
|
|
60
|
-
|
|
61
|
-
Start with the recommended preset set. Remove any vocabulary the project does not
|
|
62
|
-
use:
|
|
63
|
-
|
|
64
|
-
```css
|
|
65
|
-
@presets "standard,icons,official";
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Official includes `article`, `article-hans` and `article-hant` for long-form content
|
|
69
|
-
and does not enable Standard. Preset factories are available from subpaths:
|
|
70
|
-
|
|
71
|
-
| Import | Export |
|
|
72
|
-
| ------------------------- | ------------------- |
|
|
73
|
-
| `teacss/preset-standard` | `presetStandard` |
|
|
74
|
-
| `teacss/preset-official` | `presetOfficial` |
|
|
75
|
-
| `teacss/preset-icons` | `presetIcons` |
|
|
76
|
-
| `teacss/core` | Core engine exports |
|
|
77
|
-
|
|
78
|
-
## Runtime classes
|
|
79
|
-
|
|
80
|
-
Install `@teacss/classes` as an application dependency to compose class
|
|
81
|
-
strings at runtime:
|
|
82
|
-
|
|
83
|
-
```sh
|
|
84
|
-
npm install @teacss/classes
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
import { cn, recipe, type ClassProp, type VariantProps } from "@teacss/classes";
|
|
89
|
-
|
|
90
|
-
cn("p:4 d:flex", "p:8"); // "d:flex p:8"
|
|
91
|
-
|
|
92
|
-
const badge = recipe({
|
|
93
|
-
defaults: "d:inline-flex p:2",
|
|
94
|
-
variants: {
|
|
95
|
-
tone: { accent: "bg-color:blue-500 text-color:white" },
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
type BadgeProps = VariantProps<typeof badge> & ClassProp;
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
`cn` understands Standard conflicts and merges all `icon:value` declarations
|
|
103
|
-
by prefix without validating values. `recipe` uses string or named-element
|
|
104
|
-
`defaults` for base styles, `variants` for conditional styles, and
|
|
105
|
-
`defaultVariants` for initial selections. It supports compounds and extension
|
|
106
|
-
within the same loaded classes module.
|
|
107
|
-
These functions and their `ClassDict`, `ClassValue`, `Merger`, `ClassProp`,
|
|
108
|
-
`RecipeIntrospection`, `Reciper`, and `VariantProps` types are exported only by
|
|
109
|
-
`@teacss/classes`.
|
|
110
|
-
|
|
111
|
-
Custom merger hooks, injected recipe mergers, and preset-only merge entries are
|
|
112
|
-
not supported. See the [migration guide](../../docs/guides/upgrading-to-0-6.md#2-classes-与-recipe)
|
|
113
|
-
when upgrading an integration that used them.
|
|
114
|
-
|
|
115
|
-
Standard constant tables come from `@teacss/preset-standard/constants`.
|
|
116
|
-
|
|
117
|
-
Pre-1.0. Syntax, configuration, and APIs may change before the stable release.
|
|
118
|
-
|
|
119
|
-
[MIT](LICENSE)
|
|
3
|
+
`teacss` is the TeaCSS command-line binary, compiled from the Rust engine in this repository. Install it with `npm i -D teacss`, then run `teacss build` to write the CSS for a project once or `teacss watch` to rewrite it on every change (`teacss --help` lists the options). A class token that matches no rule but is close to one is reported on stderr as `teacss: warning: unmatched token "bgcolor:red" (did you mean "bg-color:red"?)`, once per token, and the exit code stays 0; `--unmatched error` turns these into one `E_UNMATCHED` error with exit code 1, and `--unmatched off` silences them. The package itself is a launcher: it runs the binary of the `@teacss/command-<platform>` package that npm installed for your platform, and when none matches it prints the eight supported platforms and the `cargo install` command that builds the binary from source.
|
package/bin/teacss.mjs
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// Runs the `teacss` binary of the host's @teacss/command-<platform> package (v10.2 §4.2).
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
/** npm platform suffix → Rust target, as packages/engine/scripts/targets.ts names them. */
|
|
8
|
+
const SUPPORTED = [
|
|
9
|
+
["darwin-arm64", "aarch64-apple-darwin"],
|
|
10
|
+
["darwin-x64", "x86_64-apple-darwin"],
|
|
11
|
+
["linux-arm64-gnu", "aarch64-unknown-linux-gnu"],
|
|
12
|
+
["linux-arm64-musl", "aarch64-unknown-linux-musl"],
|
|
13
|
+
["linux-x64-gnu", "x86_64-unknown-linux-gnu"],
|
|
14
|
+
["linux-x64-musl", "x86_64-unknown-linux-musl"],
|
|
15
|
+
["win32-arm64-msvc", "aarch64-pc-windows-msvc"],
|
|
16
|
+
["win32-x64-msvc", "x86_64-pc-windows-msvc"],
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const INSTALL_HINT = "cargo install --git https://github.com/teacss/teacss-rs teacss-command";
|
|
20
|
+
|
|
21
|
+
/** `<os>-<cpu>[-<libc>]`; on Linux a glibc runtime version in the process report means gnu, its absence musl. */
|
|
22
|
+
function hostSuffix() {
|
|
23
|
+
const { platform, arch } = process;
|
|
24
|
+
if (platform === "linux") {
|
|
25
|
+
const glibc = process.report?.getReport()?.header?.glibcVersionRuntime;
|
|
26
|
+
return `linux-${arch}-${glibc ? "gnu" : "musl"}`;
|
|
27
|
+
}
|
|
28
|
+
if (platform === "win32") return `win32-${arch}-msvc`;
|
|
29
|
+
return `${platform}-${arch}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function supportMatrix(suffix) {
|
|
33
|
+
const width = Math.max(...SUPPORTED.map(([name]) => name.length));
|
|
34
|
+
const rows = SUPPORTED.map(([name, triple]) => ` ${name.padEnd(width)} ${triple}`);
|
|
35
|
+
return [`teacss: no prebuilt binary for ${suffix}: package @teacss/command-${suffix} is not installed.`, "Supported platforms (npm package suffix, Rust target):", ...rows, `Build it from source instead: ${INSTALL_HINT}`, ""].join("\n");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const suffix = hostSuffix();
|
|
39
|
+
let packageDir;
|
|
40
|
+
try {
|
|
41
|
+
packageDir = dirname(createRequire(import.meta.url).resolve(`@teacss/command-${suffix}/package.json`));
|
|
42
|
+
} catch {
|
|
43
|
+
process.stderr.write(supportMatrix(suffix));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const binary = join(packageDir, process.platform === "win32" ? "teacss.exe" : "teacss");
|
|
48
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
49
|
+
if (result.error) {
|
|
50
|
+
process.stderr.write(`teacss: cannot run ${binary}: ${result.error.message}\n`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,45 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teacss",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TeaCSS
|
|
5
|
-
"homepage": "https://css.teasim.com",
|
|
6
|
-
"funding": "https://github.com/sponsors/billgo",
|
|
3
|
+
"version": "0.10.2",
|
|
4
|
+
"description": "TeaCSS command-line binary (teacss build, teacss watch), compiled from the Rust engine",
|
|
7
5
|
"license": "MIT",
|
|
8
|
-
"author": "Billgo <hi@billgo.me>",
|
|
9
|
-
"sideEffects": false,
|
|
10
6
|
"type": "module",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"./preset-official": "./dist/preset-official.js",
|
|
16
|
-
"./preset-standard": "./dist/preset-standard.js",
|
|
17
|
-
"./package.json": "./package.json"
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/teacss/teacss-rs.git",
|
|
10
|
+
"directory": "packages/command"
|
|
18
11
|
},
|
|
12
|
+
"homepage": "https://github.com/teacss/teacss-rs/tree/master/packages/command#readme",
|
|
19
13
|
"bin": {
|
|
20
|
-
"teacss": "
|
|
14
|
+
"teacss": "bin/teacss.mjs"
|
|
21
15
|
},
|
|
22
16
|
"files": [
|
|
23
17
|
"bin",
|
|
24
|
-
"
|
|
25
|
-
"README.md"
|
|
18
|
+
"LICENSE"
|
|
26
19
|
],
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"dev": "tsdown --watch"
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=26"
|
|
30
22
|
},
|
|
31
|
-
"
|
|
32
|
-
"@teacss/
|
|
33
|
-
"@teacss/
|
|
34
|
-
"@teacss/
|
|
35
|
-
"@teacss/
|
|
36
|
-
"@teacss/
|
|
37
|
-
"@teacss/
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@teacss/command-darwin-arm64": "0.10.2",
|
|
25
|
+
"@teacss/command-darwin-x64": "0.10.2",
|
|
26
|
+
"@teacss/command-linux-arm64-gnu": "0.10.2",
|
|
27
|
+
"@teacss/command-linux-arm64-musl": "0.10.2",
|
|
28
|
+
"@teacss/command-linux-x64-gnu": "0.10.2",
|
|
29
|
+
"@teacss/command-linux-x64-musl": "0.10.2",
|
|
30
|
+
"@teacss/command-win32-arm64-msvc": "0.10.2",
|
|
31
|
+
"@teacss/command-win32-x64-msvc": "0.10.2"
|
|
38
32
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "node --test \"tests/**/*.test.mjs\""
|
|
41
35
|
},
|
|
42
36
|
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
39
|
}
|
|
45
40
|
}
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{build as e,checkProject as t,initializeConfig as n}from"@teacss/cli";export{e as build,t as checkProject,n as initializeConfig};
|
package/dist/core.d.ts
DELETED
package/dist/core.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createGenerator as e}from"@teacss/core";export{e as createGenerator};
|
package/dist/preset-icons.d.ts
DELETED
package/dist/preset-icons.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"@teacss/preset-icons";export*from"@teacss/preset-icons";export{e as default};
|
package/dist/preset-official.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"@teacss/preset-official";export*from"@teacss/preset-official";export{e as default};
|
package/dist/preset-standard.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"@teacss/preset-standard";export*from"@teacss/preset-standard";export{e as default};
|