@teacss/engine 0.9.3 → 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/LICENSE +22 -0
- package/README.md +28 -109
- package/binding-header.d.ts +9 -0
- package/binding.d.ts +29 -0
- package/binding.js +56 -55
- package/contract.d.ts +121 -16
- package/dist/entry.d.ts +20 -0
- package/dist/entry.js +279 -0
- package/dist/errors.d.ts +1 -7
- package/dist/errors.js +1 -13
- package/dist/fonts.d.ts +21 -0
- package/dist/fonts.js +32 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +4 -7
- package/dist/project.d.ts +80 -0
- package/dist/project.js +136 -0
- package/package.json +19 -49
- package/dist/config-view.d.ts +0 -36
- package/dist/config-view.js +0 -135
- package/dist/constants.d.ts +0 -22
- package/dist/constants.js +0 -23
- package/dist/countable-set.d.ts +0 -57
- package/dist/countable-set.js +0 -205
- package/dist/generator.d.ts +0 -163
- package/dist/generator.js +0 -893
- package/dist/result.d.ts +0 -83
- package/dist/result.js +0 -142
- package/dist/select.d.ts +0 -183
- package/dist/select.js +0 -741
- package/dist/transformer.d.ts +0 -44
- package/dist/transformer.js +0 -59
- package/dist/ts-fallback.d.ts +0 -41
- package/dist/ts-fallback.js +0 -79
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
|
+
Copyright (c) 2026-PRESENT Billgo <hi@billgo.me>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,94 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
## What this package is
|
|
4
4
|
|
|
5
|
-
`@teacss/engine` is the in-process Rust engine for TeaCSS
|
|
5
|
+
`@teacss/engine` is the in-process Rust engine for TeaCSS: a napi-rs binding, the contract types (`contract.d.ts`) and the project helper (`createProject`) that the shells published from this repository (`@teacss/vite`, `@teacss/astro`, `@teacss/rsbuild`, `@teacss/bun`, `@teacss/postcss`, `@teacss/inspector`) and the `teacss` command share. You do not install it yourself. The shells depend on it, and npm installs the platform package that matches your machine through `optionalDependencies`.
|
|
6
6
|
|
|
7
7
|
## Supported platforms
|
|
8
8
|
|
|
9
|
-
| Package | os / cpu / libc | Status | Minimum |
|
|
10
|
-
| --- | --- | --- | --- |
|
|
11
|
-
| @teacss/engine-darwin-arm64 | darwin / arm64 / - | required | macOS 11.0 |
|
|
12
|
-
| @teacss/engine-darwin-x64 | darwin / x64 / - | required | macOS 11.0 |
|
|
13
|
-
| @teacss/engine-linux-x64-gnu | linux / x64 / glibc | required | glibc 2.17 |
|
|
14
|
-
| @teacss/engine-linux-x64-musl | linux / x64 / musl | required | - |
|
|
15
|
-
| @teacss/engine-linux-arm64-gnu | linux / arm64 / glibc | required | glibc 2.17 |
|
|
16
|
-
| @teacss/engine-linux-arm64-musl | linux / arm64 / musl | optional | - |
|
|
17
|
-
| @teacss/engine-win32-x64-msvc | win32 / x64 / - | required | - |
|
|
18
|
-
| @teacss/engine-win32-arm64-msvc | win32 / arm64 / - | optional | - |
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- `package.json#engineCompat.defaultMode` sets what the option `"auto"` means. It is `"auto"`: `engine: "auto"`, which the first-party integrations pass, tries Rust and falls back to TypeScript when the configuration cannot run there. Releases up to 0.9.1 shipped `"opt-in"`, under which the option `"auto"` stayed on TypeScript and only `TEACSS_ENGINE=rust|auto` or `engine: "rust"` tried Rust.
|
|
28
|
-
- With `"auto"`, a configuration Rust cannot serve falls back to TypeScript with a machine-readable reason (see [Fallback reasons](#fallback-reasons)); with `"rust"`, the teacss-ts hook prints the same fallback as a warning, and throws instead when `TEACSS_ENGINE_STRICT=1` is set.
|
|
29
|
-
|
|
30
|
-
`selectEngineRequest` from `@teacss/engine/select` (which does not load the binding) stays on TypeScript in three cases: `mode: "ts"` (TypeScript chosen explicitly), `resolvedBy: "opt-in"` (the option `"auto"` while `defaultMode` is `"opt-in"`), and `reason: "engine-compat"` (the host `@teacss/core` is outside `engineCompat.core`).
|
|
31
|
-
|
|
32
|
-
## Fallback reasons
|
|
33
|
-
|
|
34
|
-
A fallback prints one line per reason and path per process: `[teacss] engine: falling back to the TypeScript engine (<reason> at <path>)`. In teacss-ts, `TEACSS_ENGINE_STATS=1` prints on exit how many generators ran on each engine and which reasons fell back. `TEACSS_ENGINE_DEBUG=1` makes this package print the translated request or the first failure to stderr. The facade stops at the first item it cannot translate, so fixing one reason can reveal the next.
|
|
35
|
-
|
|
36
|
-
To keep TypeScript for any configuration, set `TEACSS_ENGINE=ts` (it covers every integration), or write `engine: "ts"` in the configuration or in the host's defaults, for example `pluginTeacss(config, { engine: "ts" })`. A fallback is not an error: the TypeScript engine produces the same CSS it always has.
|
|
37
|
-
|
|
38
|
-
`<i>` is the preset's index after nested presets are flattened and ordered by `enforce`.
|
|
39
|
-
|
|
40
|
-
| Reason | Path | What it means and why | To run on Rust |
|
|
41
|
-
| --- | --- | --- | --- |
|
|
42
|
-
| `engine-unavailable` | `@teacss/engine` | Reported by the teacss-ts hook, not by this package: importing the facade failed, usually because no platform package matches the machine or the native binding did not load. | Install the platform package for your machine; see [Troubleshooting](#troubleshooting). `TEACSS_ENGINE=rust` throws with the loader's error instead of falling back. |
|
|
43
|
-
| `engine-compat` | `@teacss/core` | The host `@teacss/core` is outside `engineCompat.core`, so the pair was not tested together. `TEACSS_ENGINE=rust` throws `E_ENGINE_COMPAT` instead. | Align `@teacss/core` and `@teacss/engine`; check the lockfile for a second copy of either. |
|
|
44
|
-
| `unknown-key` | the key | A top-level config key the facade does not know, such as a typo or an option from a newer core. Rust cannot know what it means. | Remove or correct the key. |
|
|
45
|
-
| `rules`, `variants`, `extractors`, `extractorDefault`, `preflights`, `preprocess`, `postprocess`, `extendTheme`, `configResolved`, `autocomplete`, `cli` | the key | The key has a non-empty value. These hold functions or matchers that only JavaScript can run, and Rust does not execute JavaScript. | Remove the key from the configuration the integration loads, or express it statically with `shortcuts`, `theme`, `safelist` or a preset option. |
|
|
46
|
-
| `separators` | `separators` | Separators other than the default `[":", "-"]`; Rust parses only the default. | Remove `separators`. |
|
|
47
|
-
| `mergeSelectors` | `mergeSelectors` | `mergeSelectors: false`; Rust always merges selectors. | Remove it. |
|
|
48
|
-
| `details` | `details` | `details` is set; Rust does not support it. | Remove it. |
|
|
49
|
-
| `sortLayers` | `sortLayers` | A `sortLayers` function. | Remove it and order layers with `layers`. |
|
|
50
|
-
| `content` | `content` or `content.filesystem` | `content` is not an object, or `content.filesystem` is not an array of strings. | Use an array of glob strings. |
|
|
51
|
-
| `content.inline` | `content.inline` | Inline content sources, which only the TypeScript engine reads. | Move the content into files matched by `content.filesystem`. |
|
|
52
|
-
| `envMode` | `envMode` | A value other than `"dev"` or `"build"`. | Use one of the two. |
|
|
53
|
-
| `unmatched` | `unmatched` | A value other than `"warn"`, `"error"` or `"off"`. | Use one of the three. |
|
|
54
|
-
| `outputToCssLayers` | `outputToCssLayers` | Neither a boolean nor an object. | Use `true`, `false` or `{ allLayers }`. |
|
|
55
|
-
| `outputToCssLayers.cssLayerName` | `outputToCssLayers.cssLayerName` | A `cssLayerName` value; Rust does not support it. | Remove it. |
|
|
56
|
-
| `transformers` | `transformers` or `transformers[<n>]` | A transformer other than `@teacss/transformer-compile-class` and `@teacss/directives`, or a `transformers` value that is not an array. Other transformers run JavaScript over the source. | Remove the transformer, or keep TypeScript. |
|
|
57
|
-
| `transformers.compile-class` | `transformers[<n>]` | The config lists its own `transformerCompileClass()` and the last Standard preset does not enable `compileClass`, or there is no Standard preset. Its options live in a closure, and the classes it registers never reach Rust. | Enable compile-class through `presetStandard({ compileClass })`, or keep TypeScript. |
|
|
58
|
-
| `shortcuts`, `safelist`, `blocklist`, `theme`, `layers` | the key and the item inside it | A value that is not static data: a shortcut whose expansion is not a string, or that has a regular expression or meta; a `safelist` or `blocklist` item that is not a string; a theme leaf that is not a string or number, the removed `rolePalettes` or `themes` theme key, or a `defaultMode` or mode name that is empty or holds a NUL or a lone surrogate (Standard rejects these; the TypeScript engine raises its error); a layer order that is not a number. | Replace the item with static data. |
|
|
59
|
-
| `preset-not-instantiated` | `presets[<n>]` | A preset that is a function, a promise or not an object. | Call the factory (`presetStandard()`, not `presetStandard`) and await it before passing it. |
|
|
60
|
-
| `preset-cycle` | `presets[<n>]…` | A preset that contains itself through nested `presets`. | Break the cycle. |
|
|
61
|
-
| `accessor` | the key | A getter or setter on the config, the defaults or a preset. Translation would run it once and the TypeScript engine again. | Use plain data properties. |
|
|
62
|
-
| `standard.unknown-option` | `presets[<i>].options.<key>` | A Standard option other than `modeSelectors`, `containers`, `preflight`, `variablePrefix` and `compileClass`. | Remove the option. |
|
|
63
|
-
| `standard.compileClass.hashFn`, `standard.compileClass.trigger` | `presets[<i>].options.compileClass.…` | A custom hash function or trigger for compiled classes. | Remove it; `classPrefix`, `alwaysHash`, `keepUnknown` and `layer` are supported. |
|
|
64
|
-
| `icons.collections` | `presets[<i>].options.collections.<name>` | An icon collection other than the bundled `carbon`, `crypto`, `flagpack`, `logo` and `lucide`. | Use a bundled collection, or keep TypeScript. |
|
|
65
|
-
| `icons.customizations`, `icons.processor` | `presets[<i>].options.…` | Icon customizations or a processor, which run JavaScript. | Remove them. |
|
|
66
|
-
| `role-palettes-without-entry` | `presets[<i>]` | The `@teacss/config/role-palettes` preset in a configuration that did not come from an entry stylesheet. On Rust the preset needs the entry. | Load the configuration from its entry stylesheet through `@teacss/config`. |
|
|
67
|
-
| `preset.name` | `presets[<i>].name` | A preset without a string `name`. | Give the preset a name. |
|
|
68
|
-
| `preset.rules`, `preset.variants`, `preset.extractors`, `preset.preflights`, `preset.preprocess`, `preset.postprocess`, `preset.extendTheme`, `preset.configResolved`, `preset.transformers`, `preset.autocomplete`, `preset.extractorDefault` | `presets[<i>].<key>` | A preset that is not one of the built-in presets carries a dynamic field, as for the top-level keys above. | Remove the field from the preset, or keep TypeScript. |
|
|
69
|
-
| `preset.content` | `presets[<i>].content` | A preset's `content` holds something other than `pipeline`, such as `filesystem` or `inline`; Rust reads content globs only from the configuration. | Move the globs to the configuration's `content.filesystem`. |
|
|
70
|
-
| `preset.shortcuts`, `preset.safelist`, `preset.blocklist`, `preset.theme`, `preset.layers` | `presets[<i>].<key>…` | A preset field that is not static data, as for the top-level keys above. | Replace the item with static data. |
|
|
71
|
-
| `preset.enforce`, `preset.layer` | `presets[<i>].<key>` | `enforce` other than `"pre"` or `"post"`, or a `layer` that is not a string. | Correct the value. |
|
|
72
|
-
| `declarations-unsaved` | the declaration file | A declaration file whose text came from an unsaved editor buffer. Rust reads declaration files from disk. | Save the file. |
|
|
73
|
-
| `declarations-unavailable` | `content.filesystem` | Finding declaration files under `content.filesystem` failed: the `@teacss/config` source scanner could not be loaded, or it threw. | Install `@teacss/config`. |
|
|
74
|
-
|
|
75
|
-
`content.pipeline` never falls back, in the configuration or in a preset, whatever it holds (RegExp, functions or `false`). It only decides which modules the integration feeds in, so it stays on the facade's `config.content` and is not sent to Rust.
|
|
76
|
-
|
|
77
|
-
## Compatibility
|
|
78
|
-
|
|
79
|
-
| `engineCompat` field | Meaning |
|
|
80
|
-
| --- | --- |
|
|
81
|
-
| `core` | The `@teacss/core` versions this engine accepts, written as `>=A.B.C <X.Y.Z`; prereleases compare by SemVer, so `0.9.0-alpha.1 < 0.9.0` |
|
|
82
|
-
| `defaultMode` | What the option `"auto"` means: `"opt-in"` keeps TypeScript, `"auto"` (the current value) tries Rust |
|
|
83
|
-
| `oracle.teacssTs` / `oracle.commit` | The teacss-ts version and commit this release was compared against byte for byte |
|
|
84
|
-
|
|
85
|
-
| `@teacss/core` | `@teacss/engine` | `engineCompat.core` | Result |
|
|
86
|
-
| --- | --- | --- | --- |
|
|
87
|
-
| 0.9.0-alpha.3 | 0.9.0-alpha.3 | `>=0.9.0-alpha.0 <0.10.0` | Paired; selected by `defaultMode` |
|
|
88
|
-
| 0.9.1 | 0.9.0 | `>=0.9.0 <0.10.0` | Allowed; the comparison baseline may lag one 0.8.x release, and diagnostics print `oracle.teacssTs` |
|
|
89
|
-
| 0.10.0 | 0.9.4 | `>=0.9.0 <0.10.0` | Falls back to TypeScript with `engine-compat` |
|
|
90
|
-
| 0.8.2 | any 0.9.x | - | 0.8.2 has no engine hook, so the engine is never loaded |
|
|
91
|
-
|
|
92
|
-
The teacss-ts version this release is compared against is `package.json#engineCompat.oracle`.
|
|
9
|
+
| Rust target | Package | os / cpu / libc | Status | Minimum |
|
|
10
|
+
| --- | --- | --- | --- | --- |
|
|
11
|
+
| `aarch64-apple-darwin` | @teacss/engine-darwin-arm64 | darwin / arm64 / - | required | macOS 11.0 |
|
|
12
|
+
| `x86_64-apple-darwin` | @teacss/engine-darwin-x64 | darwin / x64 / - | required | macOS 11.0 |
|
|
13
|
+
| `x86_64-unknown-linux-gnu` | @teacss/engine-linux-x64-gnu | linux / x64 / glibc | required | glibc 2.17 |
|
|
14
|
+
| `x86_64-unknown-linux-musl` | @teacss/engine-linux-x64-musl | linux / x64 / musl | required | - |
|
|
15
|
+
| `aarch64-unknown-linux-gnu` | @teacss/engine-linux-arm64-gnu | linux / arm64 / glibc | required | glibc 2.17 |
|
|
16
|
+
| `aarch64-unknown-linux-musl` | @teacss/engine-linux-arm64-musl | linux / arm64 / musl | optional | - |
|
|
17
|
+
| `x86_64-pc-windows-msvc` | @teacss/engine-win32-x64-msvc | win32 / x64 / - | required | - |
|
|
18
|
+
| `aarch64-pc-windows-msvc` | @teacss/engine-win32-arm64-msvc | win32 / arm64 / - | optional | - |
|
|
19
|
+
|
|
20
|
+
Every package needs Node.js 26 or later. A required platform blocks a release when it fails to build or test; an optional one is published later if it fails.
|
|
21
|
+
|
|
22
|
+
A platform outside this matrix has no fallback: there is no wasm package, and the TypeScript engine is the only alternative. To run the Rust engine there, build it yourself from this repository with `cargo build -p teacss-napi --release`, rename the cdylib in `target/release/` to `teacss-engine.<os>-<cpu>[-<libc>].node` (the name the loader derives for your host, for example `teacss-engine.linux-riscv64-gnu.node`), and place it in `packages/engine/` next to `binding.js`. The loader tries that file before any platform package.
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
Configuration comes only from the CSS entry (`@presets`, `@source`, `@shortcut`, `@safelist`, `@custom` and the role directives such as `@primary`; see [the CSS entry](https://github.com/teacss/teacss-rs/blob/master/skills/teacss/references/setup.md#css-entry)) plus a shell's `ShellOptions`, a small static object (`root`, `entry`, `inline`, `envMode`, `unmatched`, `outputToCssLayers`, `shortcutsLayer`, `presetOptions`, `minify`) that maps onto `LoadProjectFromRootRequest`. [Build integrations](https://github.com/teacss/teacss-rs/blob/master/skills/teacss/references/integrations.md#options) describes each option and the options a shell adds on top. There is no `UserConfig`, no preset object and no translation layer: a key the request does not know is `E_INVALID_ARGUMENT`, and the one remaining unsupported case is an `@presets` name that is not `standard`, `official` or `icons`, which `loadProjectFromRoot` reports as `E_UNSUPPORTED` with `details.reason` `preset-not-builtin` and `details.path` `@presets[<i>]`. A project that needs JavaScript rules, variants or hooks runs on the TypeScript ecosystem (teacss-ts), which this package does not load.
|
|
93
27
|
|
|
94
28
|
## Direct use of the binding
|
|
95
29
|
|
|
@@ -97,29 +31,29 @@ The teacss-ts version this release is compared against is `package.json#engineCo
|
|
|
97
31
|
import { Engine, version } from "@teacss/engine/binding";
|
|
98
32
|
```
|
|
99
33
|
|
|
100
|
-
The types are in `binding.d.ts`. The binding is a tooling-level API and is not part of the
|
|
34
|
+
The types are in `binding.d.ts`. The binding is a tooling-level API and is not part of the stability promise; integrations go through the package root (`createProject` and the contract types).
|
|
101
35
|
|
|
102
36
|
## Troubleshooting
|
|
103
37
|
|
|
104
38
|
| Symptom | Cause | Fix |
|
|
105
39
|
| --- | --- | --- |
|
|
106
40
|
| `Failed to load native binding`, and the detail lists `Cannot find module '@teacss/engine-linux-x64-gnu'` | Optional dependencies were skipped at install time (`--omit=optional`, `--no-optional`, or a CI cache holding another platform's `node_modules`) | Run `npm ci` again without the omit, or install `@teacss/engine-<platform>` explicitly; pnpm users check `supportedArchitectures` |
|
|
107
|
-
| The same, but on Alpine with the detail trying a `-gnu` package | musl detection failed: gcompat makes `process.report.getReport()` report a glibc version, so the loader picked the gnu package | Remove gcompat, or install `@teacss/engine-linux-x64-musl` explicitly
|
|
41
|
+
| The same, but on Alpine with the detail trying a `-gnu` package | musl detection failed: gcompat makes `process.report.getReport()` report a glibc version, so the loader picked the gnu package | Remove gcompat, or install `@teacss/engine-linux-x64-musl` explicitly; if that does not help, report the detection case to napi-rs |
|
|
108
42
|
| `Module did not self-register` or a `NODE_MODULE_VERSION` mismatch | Cannot happen with a Node-API binary; it means the loaded `.node` is not this package's (for example an Electron with a Node-API version below 9, or an old Bun) | Upgrade the runtime |
|
|
109
|
-
| `dlopen` reports `GLIBC_2.xx not found` | glibc is older than the 2.17 build baseline | Not supported;
|
|
43
|
+
| `dlopen` reports `GLIBC_2.xx not found` | glibc is older than the 2.17 build baseline | Not supported; build the binding yourself (see [Supported platforms](#supported-platforms)) |
|
|
110
44
|
| macOS reports "code signature invalid" | The `.node` was copied from outside npm and carries the quarantine attribute | `xattr -d com.apple.quarantine <file>`; files installed by npm do not carry it |
|
|
111
|
-
| `
|
|
112
|
-
| An `engine-compat` fallback | `@teacss/core` and `@teacss/engine` are not a matching pair | Align the two versions; check the lockfile for more than one `@teacss/engine` |
|
|
113
|
-
| teacss-ts still uses TypeScript after a local `build:debug` | `bun link` points at an old directory, or `node_modules/@teacss/engine` is a registry copy | Check with `ls -l node_modules/@teacss/engine` that it is a symlink |
|
|
45
|
+
| A shell in this repository does not pick up a local `build:debug` | Its `node_modules/@teacss/engine` is a registry copy instead of the `file:../engine` link | `npm --prefix packages/<shell> ci` and check with `ls -l packages/<shell>/node_modules/@teacss/engine` that it is a symlink |
|
|
114
46
|
|
|
115
47
|
## Verifying a release
|
|
116
48
|
|
|
49
|
+
Every GitHub release carries `SHA256SUMS` over the `.node` files, the `teacss` binaries and the npm tarballs:
|
|
50
|
+
|
|
117
51
|
```sh
|
|
118
52
|
shasum -a 256 -c SHA256SUMS # Linux: sha256sum -c SHA256SUMS
|
|
119
|
-
npm view @teacss/engine --json | jq .dist.attestations
|
|
120
|
-
gh attestation verify teacss-engine.<platform>.node --owner teacss
|
|
121
53
|
```
|
|
122
54
|
|
|
55
|
+
Releases carry no npm provenance or GitHub attestation (v02.11 §1.3).
|
|
56
|
+
|
|
123
57
|
## Development
|
|
124
58
|
|
|
125
59
|
```sh
|
|
@@ -132,19 +66,4 @@ node -e 'import("./packages/engine/dist/index.js").then(m => console.log(m.versi
|
|
|
132
66
|
|
|
133
67
|
`build:debug` uses the `dev` profile and rebuilds incrementally in seconds. `npm run build` uses the release profile with `lto = "fat"`; use it only to reproduce the size budget or the import checks locally.
|
|
134
68
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```sh
|
|
138
|
-
# A: bun link (preferred)
|
|
139
|
-
cd /path/to/teacss-rs/packages/engine && bun link
|
|
140
|
-
cd /path/to/teacss-ts && bun link @teacss/engine
|
|
141
|
-
TEACSS_ENGINE=rust bun test packages-engine/core
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
```sh
|
|
145
|
-
# B: file: override (temporary; revert with git checkout package.json bun.lock)
|
|
146
|
-
cd /path/to/teacss-ts
|
|
147
|
-
bun add --dev @teacss/engine@file:../teacss-rs/packages/engine
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Either way the loader finds the `.node` next to `binding.js` first, so no platform package is needed. After a Rust change, run `build:debug` again; there is no need to link again.
|
|
69
|
+
The shells in this repository (`packages/{vite,astro,rsbuild,bun,postcss,inspector}`) depend on `@teacss/engine` through `file:../engine`, so `npm --prefix packages/<shell> ci` links them to this directory and they use the local build; the loader finds the `.node` next to `binding.js` first, so no platform package is needed. After a Rust change, run `build:debug` again.
|
package/binding-header.d.ts
CHANGED
|
@@ -6,17 +6,26 @@ import type {
|
|
|
6
6
|
EntryConfig,
|
|
7
7
|
EntryDiagnostic,
|
|
8
8
|
ExtractFileResult,
|
|
9
|
+
ExtractFilesUnionResult,
|
|
9
10
|
GenerateInput,
|
|
10
11
|
GenerateOptions,
|
|
11
12
|
GenerateResult,
|
|
13
|
+
IconifyJson,
|
|
12
14
|
InspectEntryRequest,
|
|
13
15
|
InspectEntryResult,
|
|
16
|
+
LoadProjectFromRootRequest,
|
|
17
|
+
LoadProjectFromRootResult,
|
|
14
18
|
LoadProjectRequest,
|
|
15
19
|
LoadProjectResult,
|
|
20
|
+
MatchedPosition,
|
|
16
21
|
ModuleUpdateResult,
|
|
22
|
+
OutputToCssLayersOptions,
|
|
17
23
|
ResolvedConfigView,
|
|
18
24
|
RuleInfo,
|
|
19
25
|
StringifiedUtil,
|
|
26
|
+
Suggestion,
|
|
27
|
+
SuggestOptions,
|
|
28
|
+
TokenInfo,
|
|
20
29
|
TransformResult,
|
|
21
30
|
UnmatchedDiagnostic,
|
|
22
31
|
VariantInfo,
|
package/binding.d.ts
CHANGED
|
@@ -6,17 +6,26 @@ import type {
|
|
|
6
6
|
EntryConfig,
|
|
7
7
|
EntryDiagnostic,
|
|
8
8
|
ExtractFileResult,
|
|
9
|
+
ExtractFilesUnionResult,
|
|
9
10
|
GenerateInput,
|
|
10
11
|
GenerateOptions,
|
|
11
12
|
GenerateResult,
|
|
13
|
+
IconifyJson,
|
|
12
14
|
InspectEntryRequest,
|
|
13
15
|
InspectEntryResult,
|
|
16
|
+
LoadProjectFromRootRequest,
|
|
17
|
+
LoadProjectFromRootResult,
|
|
14
18
|
LoadProjectRequest,
|
|
15
19
|
LoadProjectResult,
|
|
20
|
+
MatchedPosition,
|
|
16
21
|
ModuleUpdateResult,
|
|
22
|
+
OutputToCssLayersOptions,
|
|
17
23
|
ResolvedConfigView,
|
|
18
24
|
RuleInfo,
|
|
19
25
|
StringifiedUtil,
|
|
26
|
+
Suggestion,
|
|
27
|
+
SuggestOptions,
|
|
28
|
+
TokenInfo,
|
|
20
29
|
TransformResult,
|
|
21
30
|
UnmatchedDiagnostic,
|
|
22
31
|
VariantInfo,
|
|
@@ -34,13 +43,16 @@ export declare class Engine {
|
|
|
34
43
|
constructor()
|
|
35
44
|
inspectEntry(request: InspectEntryRequest): InspectEntryResult
|
|
36
45
|
loadProject(request: LoadProjectRequest): LoadProjectResult
|
|
46
|
+
loadProjectFromRoot(request: LoadProjectFromRootRequest): LoadProjectFromRootResult
|
|
37
47
|
programKey(): string
|
|
38
48
|
configView(): ResolvedConfigView
|
|
39
49
|
rules(): RuleInfo[]
|
|
40
50
|
variants(): VariantInfo[]
|
|
41
51
|
configFiles(): string[]
|
|
52
|
+
missingImports(): string[]
|
|
42
53
|
customThemeKeys(): string[]
|
|
43
54
|
updateModule(id: string, code: string): ModuleUpdateResult
|
|
55
|
+
updateModules(ids: string[], codes: string[]): ModuleUpdateResult[]
|
|
44
56
|
removeModule(id: string): boolean
|
|
45
57
|
clearModuleDefinitions(id: string): boolean
|
|
46
58
|
compileClassShortcuts(): Array<[string, string] | [string, string, { layer: string }]>
|
|
@@ -49,6 +61,7 @@ export declare class Engine {
|
|
|
49
61
|
extract(code: string, id?: string | undefined | null): string[]
|
|
50
62
|
extractCounted(code: string, id?: string | undefined | null): Array<{ token: string; count: number }>
|
|
51
63
|
extractFiles(paths: string[]): ExtractFileResult[]
|
|
64
|
+
extractFilesUnion(paths: string[]): ExtractFilesUnionResult
|
|
52
65
|
transformSource(id: string, code: string): TransformResult | null
|
|
53
66
|
transformStylesheet(id: string, code: string): TransformResult | null
|
|
54
67
|
generate(input: GenerateInput, options?: GenerateOptions | undefined | null): GenerateResult
|
|
@@ -57,6 +70,11 @@ export declare class Engine {
|
|
|
57
70
|
isTokenBlocked(raw: string): boolean
|
|
58
71
|
diagnoseUnmatched(tokens: string[]): UnmatchedDiagnostic[]
|
|
59
72
|
themeValue(path: string): string | null
|
|
73
|
+
suggest(input: string, options?: SuggestOptions | undefined | null): Suggestion[]
|
|
74
|
+
tokenInfo(token: string): TokenInfo | null
|
|
75
|
+
matchedPositions(id: string, code: string): MatchedPosition[]
|
|
76
|
+
equivalentTokens(token: string): string[]
|
|
77
|
+
parentOrders(): Array<[string, number]>
|
|
60
78
|
stats(): EngineStats
|
|
61
79
|
dispose(): void
|
|
62
80
|
}
|
|
@@ -69,6 +87,17 @@ export declare function expandClassGroups(code: string): string
|
|
|
69
87
|
|
|
70
88
|
export declare function hash(input: string): string
|
|
71
89
|
|
|
90
|
+
export declare function markers(): Markers
|
|
91
|
+
|
|
92
|
+
/** The scanner's marker strings (v10.2 §2.3), so the shells read them from one place. */
|
|
93
|
+
export interface Markers {
|
|
94
|
+
cssPlaceholder: string
|
|
95
|
+
includeComment: string
|
|
96
|
+
ignoreComment: string
|
|
97
|
+
skipStartComment: string
|
|
98
|
+
skipEndComment: string
|
|
99
|
+
}
|
|
100
|
+
|
|
72
101
|
export declare function parseEntry(css: string, file?: string | undefined | null): EntryConfig
|
|
73
102
|
|
|
74
103
|
export declare function splitClassTokens(body: string): string[]
|