teacss 0.9.4 → 0.10.3

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 CHANGED
@@ -1,119 +1,3 @@
1
- # TeaCSS
1
+ # teacss
2
2
 
3
- The development tool package for TeaCSS.
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
- import "@teacss/cli/cli";
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.9.4",
4
- "description": "TeaCSS developer tooling with a CLI and engine and preset subpaths.",
5
- "homepage": "https://css.teasim.com",
6
- "funding": "https://github.com/sponsors/billgo",
3
+ "version": "0.10.3",
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
- "exports": {
12
- "./cli": "./dist/cli.js",
13
- "./core": "./dist/core.js",
14
- "./preset-icons": "./dist/preset-icons.js",
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": "./bin/teacss.mjs"
14
+ "teacss": "bin/teacss.mjs"
21
15
  },
22
16
  "files": [
23
17
  "bin",
24
- "dist",
25
- "README.md"
18
+ "LICENSE"
26
19
  ],
27
- "scripts": {
28
- "build": "bunx rimraf dist && bunx tsdown --config tsdown.config.mts",
29
- "dev": "tsdown --watch"
20
+ "engines": {
21
+ "node": ">=26"
30
22
  },
31
- "dependencies": {
32
- "@teacss/cli": "0.9.4",
33
- "@teacss/core": "0.9.4",
34
- "@teacss/engine": "0.9.4",
35
- "@teacss/preset-icons": "0.9.4",
36
- "@teacss/preset-official": "0.9.4",
37
- "@teacss/preset-standard": "0.9.4"
23
+ "optionalDependencies": {
24
+ "@teacss/command-darwin-arm64": "0.10.3",
25
+ "@teacss/command-darwin-x64": "0.10.3",
26
+ "@teacss/command-linux-arm64-gnu": "0.10.3",
27
+ "@teacss/command-linux-arm64-musl": "0.10.3",
28
+ "@teacss/command-linux-x64-gnu": "0.10.3",
29
+ "@teacss/command-linux-x64-musl": "0.10.3",
30
+ "@teacss/command-win32-arm64-msvc": "0.10.3",
31
+ "@teacss/command-win32-x64-msvc": "0.10.3"
38
32
  },
39
- "engines": {
40
- "node": ">=22.12.0"
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
@@ -1,2 +0,0 @@
1
- import { CliOptions, CliWatchSession, build, checkProject, initializeConfig } from "@teacss/cli";
2
- export { type CliOptions, type CliWatchSession, build, checkProject, initializeConfig };
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
@@ -1,2 +0,0 @@
1
- import { Preset, Rule, UserConfig, Variant, createGenerator } from "@teacss/core";
2
- export { type Preset, type Rule, type UserConfig, type Variant, createGenerator };
package/dist/core.js DELETED
@@ -1 +0,0 @@
1
- import{createGenerator as e}from"@teacss/core";export{e as createGenerator};
@@ -1,3 +0,0 @@
1
- import preset_icons_default from "@teacss/preset-icons";
2
- export * from "@teacss/preset-icons";
3
- export { preset_icons_default as default };
@@ -1 +0,0 @@
1
- import e from"@teacss/preset-icons";export*from"@teacss/preset-icons";export{e as default};
@@ -1,3 +0,0 @@
1
- import preset_official_default from "@teacss/preset-official";
2
- export * from "@teacss/preset-official";
3
- export { preset_official_default as default };
@@ -1 +0,0 @@
1
- import e from"@teacss/preset-official";export*from"@teacss/preset-official";export{e as default};
@@ -1,3 +0,0 @@
1
- import preset_standard_default from "@teacss/preset-standard";
2
- export * from "@teacss/preset-standard";
3
- export { preset_standard_default as default };
@@ -1 +0,0 @@
1
- import e from"@teacss/preset-standard";export*from"@teacss/preset-standard";export{e as default};