@teacss/config 0.3.0
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 +97 -0
- package/dist/index.d.ts +208 -0
- package/dist/index.js +1 -0
- package/dist/presetTransformDiskCache-Cp5NmI8Q.js +1 -0
- package/package.json +35 -0
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
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @teacss/config
|
|
2
|
+
|
|
3
|
+
**CSS-entry configuration for TeaCSS.**
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
TeaCSS does not use `teacss.config.*`. Configuration is resolved from the CSS
|
|
8
|
+
entry: `package.json` `teacss.entry`, then `index.css`, then `src/index.css`.
|
|
9
|
+
Only existing regular files qualify as entry candidates.
|
|
10
|
+
|
|
11
|
+
`@teacss/config` provides that discovery, directive parsing, preset resolution,
|
|
12
|
+
and recovery behavior to build and editor integrations. It does not scan
|
|
13
|
+
application modules, generate CSS, or own a build tool's watch lifecycle; those
|
|
14
|
+
consumers use its resolved config and source-dependency list.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```css
|
|
19
|
+
@preset "standard";
|
|
20
|
+
@source "./src/**/*.{ts,tsx}";
|
|
21
|
+
@custom { --color-brand-500: #58a6ff; }
|
|
22
|
+
@teacss;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The official preset roots have short names: `@preset "standard";`,
|
|
26
|
+
`@preset "articles";`, and `@preset "icons";`. They resolve from either the
|
|
27
|
+
application-facing `teacss` package or the matching scoped preset package. The
|
|
28
|
+
articles short name maps to `@teacss/preset-articles`. Explicit package and
|
|
29
|
+
local-file specifiers remain supported.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { createRecoveryConfigLoader } from "@teacss/config";
|
|
33
|
+
|
|
34
|
+
const loadConfig = createRecoveryConfigLoader();
|
|
35
|
+
const { config, sources } = await loadConfig(process.cwd());
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Integrations that watch discovery roots can import the frozen
|
|
39
|
+
`entryDiscoveryFiles` list. Its relative paths are ordered like entry
|
|
40
|
+
resolution, including `package.json` because its `teacss.entry` field can
|
|
41
|
+
change the selected CSS entry.
|
|
42
|
+
|
|
43
|
+
`sources` contains the CSS entry and the static same-package module graph behind
|
|
44
|
+
local relative or absolute `@preset` declarations, including ESM, TypeScript,
|
|
45
|
+
CommonJS, and JSON dependencies. Bare and external package dependency trees are
|
|
46
|
+
intentionally excluded. When no `package.json` exists, the local graph is
|
|
47
|
+
conservatively bounded to the preset entry directory. Integrations use this list
|
|
48
|
+
for watch invalidation and dependency messages. Local modules are evaluated
|
|
49
|
+
through Jiti with persistent filesystem and module caching disabled, so edits to
|
|
50
|
+
the preset entry or its tracked dependencies take effect on the next load in
|
|
51
|
+
Node and Bun. The lower-level `resolveEntryConfig` API exposes the same graph in
|
|
52
|
+
its `sources` result field.
|
|
53
|
+
|
|
54
|
+
To avoid repeating the same Jiti transform in fresh CLI or build processes,
|
|
55
|
+
local presets use a content-addressed transform cache under the nearest
|
|
56
|
+
`node_modules/.cache/teacss/preset-transform` directory. The cache stores only
|
|
57
|
+
transformed code and syntax-policy facts; preset modules and their dependencies
|
|
58
|
+
are still evaluated on every config load. Source bytes, transform mode, TeaCSS
|
|
59
|
+
and transformer implementation bytes, and the relevant runtime version all
|
|
60
|
+
participate in cache identity. Missing, untrusted, corrupt, or inaccessible
|
|
61
|
+
cache data is ignored without changing config behavior. The 256 final slots are
|
|
62
|
+
limited to 512 KiB each, for a steady-state maximum of 128 MiB. During one
|
|
63
|
+
config resolution, cache hits and successful writes are protected from
|
|
64
|
+
replacement so a full cache converges to the current preset graph without
|
|
65
|
+
rewriting warm hits. If one resolution needs more than 256 identities, excess
|
|
66
|
+
entries simply remain uncached. Set
|
|
67
|
+
`TEACSS_PRESET_TRANSFORM_CACHE=false` to disable this optimization, including
|
|
68
|
+
when measuring uncached transform performance.
|
|
69
|
+
|
|
70
|
+
Local preset entries may use top-level `await`. Transitive modules must remain
|
|
71
|
+
synchronous, and every local dependency must use static `import` / `export` or a
|
|
72
|
+
top-level literal CommonJS `require`. A literal `require` inside a function, a
|
|
73
|
+
non-literal `require`, and `require` combined with top-level `await` are rejected,
|
|
74
|
+
as is dynamic `import()`, because those forms cannot be represented as a
|
|
75
|
+
complete, concurrency-safe watch graph.
|
|
76
|
+
|
|
77
|
+
The recovery loader keeps the last valid config while files are temporarily
|
|
78
|
+
invalid during watch mode. Recovery state is isolated by resolved config path
|
|
79
|
+
or inline-config object identity. Superseded concurrent requests cannot replace
|
|
80
|
+
that state or report stale failures. If a local preset or static transitive
|
|
81
|
+
dependency is temporarily missing, its intended path remains in `sources` so
|
|
82
|
+
creating the file can trigger recovery. For an extensionless static dependency
|
|
83
|
+
specifier, the supported exact, extension, and directory-index candidates are
|
|
84
|
+
retained, so creating a file such as `missing.ts` also triggers recovery.
|
|
85
|
+
Consumers that resolve current in-memory CSS through `resolveEntryConfig` can
|
|
86
|
+
use `getConfigSourcesFromError(error)` to retain the same bounded missing-file
|
|
87
|
+
candidates while keeping their own last-valid config snapshot.
|
|
88
|
+
|
|
89
|
+
`parseEntry`, `scanTopLevelAtRules`, `scanCustomBlocks`, and `diagnoseCustom`
|
|
90
|
+
expose the same structural CSS-entry parsing used by build and editor
|
|
91
|
+
integrations. The scanners ignore directive-like text in comments, strings, and
|
|
92
|
+
nested CSS.
|
|
93
|
+
|
|
94
|
+
## Status
|
|
95
|
+
|
|
96
|
+
Pre-1.0. Keep config behavior aligned across build tools, the CLI, and editor
|
|
97
|
+
tooling.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Preset, UserConfig, UserConfigDefaults } from "@teacss/core";
|
|
2
|
+
//#region src/parseEntry.d.ts
|
|
3
|
+
interface EntrySource {
|
|
4
|
+
/** The glob pattern (with any leading `!` stripped). */
|
|
5
|
+
glob: string;
|
|
6
|
+
/** True when the `@source` value was `!`-prefixed (an exclude). */
|
|
7
|
+
exclude: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface EntryCustomDecl {
|
|
10
|
+
/** Custom-property name, e.g. `--color-brand-500`. */
|
|
11
|
+
property: string;
|
|
12
|
+
/** Raw value text, e.g. `#0f766e` or `0 1px 2px #0001, 0 2px 4px #0001`. */
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
interface EntryCustomBlock {
|
|
16
|
+
/** Mode name from the prelude (`@custom dark`); undefined for the base `@custom {}`. */
|
|
17
|
+
mode?: string;
|
|
18
|
+
declarations: EntryCustomDecl[];
|
|
19
|
+
}
|
|
20
|
+
interface EntryConfig {
|
|
21
|
+
/** `@preset "<spec>"` specifiers, in source order. */
|
|
22
|
+
presets: string[];
|
|
23
|
+
/** `@source "<glob>"` entries (`!`-prefixed → exclude). */
|
|
24
|
+
sources: EntrySource[];
|
|
25
|
+
/** `@custom {}` / `@custom <mode> {}` blocks, in source order. */
|
|
26
|
+
custom: EntryCustomBlock[];
|
|
27
|
+
/** Whether a `@teacss;` placeholder is present. */
|
|
28
|
+
hasTeacss: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parse the TeaCSS entry directives out of an entry CSS file. Pure and css-tree-free.
|
|
32
|
+
* The scanner ignores directive-shaped comments while declaration comments are
|
|
33
|
+
* removed only from returned `@custom` values. Native `@import` and other CSS
|
|
34
|
+
* are ignored. Resolving the returned data (loading presets, scanning sources,
|
|
35
|
+
* registering `@custom`) lives in the config/integration layer.
|
|
36
|
+
*/
|
|
37
|
+
declare function parseEntry(css: string): EntryConfig;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/customToTheme.d.ts
|
|
40
|
+
interface CustomToThemeResult {
|
|
41
|
+
/**
|
|
42
|
+
* Theme patch to deep-merge over the preset theme (pass as `createGenerator`'s
|
|
43
|
+
* `theme`). Base blocks land at `theme.<ns>...`; mode blocks at
|
|
44
|
+
* `theme.modes.<mode>.<ns>...`. The theme preflight emits the `:root` / `.<mode>`
|
|
45
|
+
* CSS from this, so no separate emission is needed.
|
|
46
|
+
*/
|
|
47
|
+
theme: Record<string, any>;
|
|
48
|
+
/** Var names whose prefix matched no namespace or used an illegal color step. */
|
|
49
|
+
unknown: string[];
|
|
50
|
+
}
|
|
51
|
+
interface Namespace {
|
|
52
|
+
/** Var-name prefix, e.g. `color`, `font-family`, `spacing`. */
|
|
53
|
+
prefix: string;
|
|
54
|
+
/** Theme object key, e.g. `colors`, `fontFamily`, `spacing`. */
|
|
55
|
+
key: string;
|
|
56
|
+
/** Colors are 2-level (`name` + `step`); every other scale is 1-level. */
|
|
57
|
+
twoLevel: boolean;
|
|
58
|
+
/** Semantic color roles share the `--color-*` var namespace with palette colors. */
|
|
59
|
+
semanticColor?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Build the var-prefix → theme-key table, longest prefix first so nested namespaces stay deterministic. */
|
|
62
|
+
declare function buildNamespaces(themeKeys: string[]): Namespace[];
|
|
63
|
+
type CustomClassification = {
|
|
64
|
+
ok: true;
|
|
65
|
+
nsKey: string;
|
|
66
|
+
twoLevel: boolean;
|
|
67
|
+
rest: string;
|
|
68
|
+
colorName?: string;
|
|
69
|
+
step?: string;
|
|
70
|
+
} | {
|
|
71
|
+
ok: false;
|
|
72
|
+
reason: "unknown-prefix" | "illegal-color-step";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Classify a `@custom` var name (without the leading `--`) against the namespace
|
|
76
|
+
* table: which theme key it registers into, or why it can't. Shared by the
|
|
77
|
+
* theme-patch builder and the LSP/build diagnostics so they never drift.
|
|
78
|
+
*/
|
|
79
|
+
declare function classifyCustomVar(name: string, namespaces: Namespace[]): CustomClassification;
|
|
80
|
+
/**
|
|
81
|
+
* Turn parsed `@custom {}` / `@custom <mode> {}` blocks into a theme patch.
|
|
82
|
+
* `themeKeys` are the scale-namespace keys of the resolved preset theme (e.g.
|
|
83
|
+
* `colors`, `spacing`, `radius`, `fontFamily`, ...) — they drive the closed
|
|
84
|
+
* var-prefix → namespace mapping. Pure: no generator, no I/O.
|
|
85
|
+
*/
|
|
86
|
+
declare function customToTheme(blocks: EntryCustomBlock[], themeKeys: string[]): CustomToThemeResult;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/diagnoseCustom.d.ts
|
|
89
|
+
interface CustomDiagnostic {
|
|
90
|
+
/** The custom-property name, e.g. `--colour-brand-500`. */
|
|
91
|
+
property: string;
|
|
92
|
+
/** Offset range of the property name in the source (for mapping to an editor range). */
|
|
93
|
+
start: number;
|
|
94
|
+
end: number;
|
|
95
|
+
reason: "unknown-prefix" | "illegal-color-step";
|
|
96
|
+
message: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Position-aware `@custom` diagnostics: for every `--x` declaration inside a
|
|
100
|
+
* `@custom {}` block that won't register (unknown namespace prefix, or an
|
|
101
|
+
* illegal color step), return its source range + a message.
|
|
102
|
+
* `themeKeys` are the scale-namespace keys of the resolved preset theme.
|
|
103
|
+
*
|
|
104
|
+
* Shares the classification with `customToTheme`, so the editor and the build
|
|
105
|
+
* agree on what registers. Pure: offsets in, no I/O — the caller maps offsets
|
|
106
|
+
* to an editor `Range`.
|
|
107
|
+
*/
|
|
108
|
+
declare function diagnoseCustom(css: string, themeKeys: string[]): CustomDiagnostic[];
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/resolveEntryConfig.d.ts
|
|
111
|
+
interface ResolveEntryResult {
|
|
112
|
+
/** UserConfig assembled from the entry — feed straight to `createGenerator`. */
|
|
113
|
+
config: UserConfig;
|
|
114
|
+
/** `@custom` var names that didn't register (decision 11 — for diagnostics/warnings). */
|
|
115
|
+
unknown: string[];
|
|
116
|
+
/** Whether the entry has a `@teacss;` placeholder. */
|
|
117
|
+
hasTeacss: boolean;
|
|
118
|
+
/** Absolute same-package modules behind local relative or absolute preset specifiers. */
|
|
119
|
+
sources: string[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Resolve a CSS entry into a `UserConfig` — the single source every integration
|
|
123
|
+
* uses. `@preset` → presets (no implicit default — an entry with no `@preset`
|
|
124
|
+
* gets no presets, and the caller warns); `@source` → `content.filesystem`
|
|
125
|
+
* (`!`-prefixed = exclude); `@custom` → a theme patch.
|
|
126
|
+
* Pure config, no generation. `base` is the entry file's directory (for `@preset`
|
|
127
|
+
* relative specifiers).
|
|
128
|
+
*/
|
|
129
|
+
declare function resolveEntryConfig(entryCss: string, base: string): Promise<ResolveEntryResult>;
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/resolvePresets.d.ts
|
|
132
|
+
declare function getPresetSourcesFromError(error: unknown): string[];
|
|
133
|
+
/**
|
|
134
|
+
* Resolve `@preset` specifiers into preset objects for `createGenerator`.
|
|
135
|
+
* Relative paths resolve against the CSS entry directory; bare names use Node
|
|
136
|
+
* resolution after mapping the exact built-in name `standard` to
|
|
137
|
+
* `@teacss/preset-standard`. Local preset modules are evaluated without a
|
|
138
|
+
* persistent runtime module cache so edits to either the entry or its bounded
|
|
139
|
+
* local dependency graph take effect on the next resolution. There is no
|
|
140
|
+
* implicit default preset.
|
|
141
|
+
*/
|
|
142
|
+
declare function resolvePresets<Theme extends object = object>(specifiers: string[], base: string): Promise<Preset<Theme>[]>;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/scanCustom.d.ts
|
|
145
|
+
interface ScannedCustomDeclaration {
|
|
146
|
+
property: string;
|
|
147
|
+
value: string;
|
|
148
|
+
/** Property-name offsets in the original source (`end` is exclusive). */
|
|
149
|
+
start: number;
|
|
150
|
+
end: number;
|
|
151
|
+
/** Offset of the declaration's `:` separator. */
|
|
152
|
+
colon: number;
|
|
153
|
+
/** Trimmed value offsets in the original source (`valueEnd` is exclusive). */
|
|
154
|
+
valueStart: number;
|
|
155
|
+
valueEnd: number;
|
|
156
|
+
}
|
|
157
|
+
interface ScannedCustomBlock {
|
|
158
|
+
mode?: string;
|
|
159
|
+
declarations: ScannedCustomDeclaration[];
|
|
160
|
+
/** Offsets of the block's opening and closing braces. */
|
|
161
|
+
open: number;
|
|
162
|
+
close: number;
|
|
163
|
+
}
|
|
164
|
+
interface ScannedTopLevelAtRule {
|
|
165
|
+
/** At-rule name without the leading `@`. */
|
|
166
|
+
name: string;
|
|
167
|
+
/** Trimmed text between the name and its terminator/opening brace. */
|
|
168
|
+
prelude: string;
|
|
169
|
+
/** Full at-rule offsets in the original source (`end` is exclusive). */
|
|
170
|
+
start: number;
|
|
171
|
+
end: number;
|
|
172
|
+
terminator: ";" | "block" | "eof";
|
|
173
|
+
}
|
|
174
|
+
/** Return string values from exact, top-level at-rules such as `@preset "…"`. */
|
|
175
|
+
declare function scanQuotedDirectives(css: string, directive: string): string[];
|
|
176
|
+
/** Whether an exact at-rule name occurs at the top level outside strings/comments. */
|
|
177
|
+
declare function hasTopLevelDirective(css: string, directive: string): boolean;
|
|
178
|
+
/** Scan complete top-level at-rules without matching text in comments, strings, or nested CSS. */
|
|
179
|
+
declare function scanTopLevelAtRules(css: string): ScannedTopLevelAtRule[];
|
|
180
|
+
/** Scan top-level `@custom` blocks without treating strings, comments, or nested CSS as directives. */
|
|
181
|
+
declare function scanCustomBlocks(css: string): ScannedCustomBlock[];
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/index.d.ts
|
|
184
|
+
interface LoadConfigResult<U> {
|
|
185
|
+
config: U;
|
|
186
|
+
/** Files that drive the config (CSS entry plus bounded local preset graph). */
|
|
187
|
+
sources: string[];
|
|
188
|
+
}
|
|
189
|
+
/** Relative files that can change CSS-entry discovery, in resolution order. */
|
|
190
|
+
declare const entryDiscoveryFiles: readonly ["package.json", "index.css", "src/index.css"];
|
|
191
|
+
/** Find the CSS entry: package.json override → index.css → src/index.css. */
|
|
192
|
+
declare function findEntry(root: string): string | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Resolve the TeaCSS config from the CSS entry. `configOrPath` is either an
|
|
195
|
+
* inline `UserConfig` (used as-is — programmatic / preset authors) or a root
|
|
196
|
+
* directory (or entry file) to discover the entry from. There is no
|
|
197
|
+
* `teacss.config.ts` — the CSS entry is the only config source. No entry found →
|
|
198
|
+
* empty config (just the caller's `defaults`). An entry that declares no
|
|
199
|
+
* `@preset` warns: config never reaches for a specific preset itself.
|
|
200
|
+
*/
|
|
201
|
+
declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
|
|
202
|
+
/**
|
|
203
|
+
* A config loader that recovers from errors by returning the last good result —
|
|
204
|
+
* useful in dev where the entry CSS may be momentarily broken between edits.
|
|
205
|
+
*/
|
|
206
|
+
declare function createRecoveryConfigLoader<U extends UserConfig>(): (cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults) => Promise<LoadConfigResult<U>>;
|
|
207
|
+
//#endregion
|
|
208
|
+
export { CustomClassification, CustomDiagnostic, CustomToThemeResult, EntryConfig, EntryCustomBlock, EntryCustomDecl, EntrySource, LoadConfigResult, Namespace, ResolveEntryResult, ScannedCustomBlock, ScannedCustomDeclaration, ScannedTopLevelAtRule, buildNamespaces, classifyCustomVar, createRecoveryConfigLoader, customToTheme, diagnoseCustom, entryDiscoveryFiles, findEntry, getPresetSourcesFromError as getConfigSourcesFromError, hasTopLevelDirective, loadConfig, parseEntry, resolveEntryConfig, resolvePresets, scanCustomBlocks, scanQuotedDirectives, scanTopLevelAtRules };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import t,{existsSync as n,realpathSync as r}from"node:fs";import{dirname as i,extname as a,isAbsolute as o,join as s,relative as c,resolve as l,sep as u}from"node:path";import d from"node:process";import{consola as f}from"consola";import{resolveConfig as p}from"@teacss/core";import{Buffer as m}from"node:buffer";import{readFile as h,stat as g}from"node:fs/promises";import{fileURLToPath as _,pathToFileURL as v}from"node:url";const y=[`100`,`150`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`850`,`900`,`950`],ee=new Set(y);function te(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function b(e){return e.map(e=>({key:e,prefix:e===`colors`||e===`semanticColors`?`color`:te(e),twoLevel:e===`colors`,semanticColor:e===`semanticColors`})).sort((e,t)=>t.prefix.length-e.prefix.length)}function x(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function S(e,t){let n=Object.hasOwn(e,t)?e[t]:void 0;if(typeof n==`object`&&n&&!Array.isArray(n))return n;let r={};return x(e,t,r),r}function C(e,t){let n=t.filter(t=>e===t.prefix||e.startsWith(`${t.prefix}-`)),r=n.find(e=>e.key===`colors`),i=n.find(e=>e.semanticColor);if(r&&i){let t=e===`color`?``:e.slice(6),n=t.lastIndexOf(`-`),a=n>0?t.slice(0,n):``,o=n>0?t.slice(n+1):``;return a&&ee.has(o)?{ok:!0,nsKey:r.key,twoLevel:!0,rest:t,colorName:a,step:o}:a&&/^\d+$/.test(o)?{ok:!1,reason:`illegal-color-step`}:t?{ok:!0,nsKey:i.key,twoLevel:!1,rest:t}:{ok:!1,reason:`unknown-prefix`}}let a=n[0];if(!a)return{ok:!1,reason:`unknown-prefix`};let o=e===a.prefix?``:e.slice(a.prefix.length+1);if(a.twoLevel){let e=o.lastIndexOf(`-`),t=e>0?o.slice(0,e):``,n=e>0?o.slice(e+1):``;return!t||!ee.has(n)?{ok:!1,reason:`illegal-color-step`}:{ok:!0,nsKey:a.key,twoLevel:!0,rest:o,colorName:t,step:n}}return{ok:!0,nsKey:a.key,twoLevel:!1,rest:o}}function w(e,t){let n=b(t),r={},i=[];for(let t of e){let e=t.mode?S(S(r,`modes`),t.mode):r;for(let{property:r,value:a}of t.declarations){let t=C(r.startsWith(`--`)?r.slice(2):r,n);if(!t.ok){i.push(r);continue}let o=S(e,t.nsKey);t.twoLevel?x(S(o,t.colorName),t.step,a):x(o,t.rest||`DEFAULT`,a)}}return{theme:r,unknown:i}}const ne=/[A-Za-z0-9-]/,re=/[\w-]/;function T(e,t,n){let r=e.indexOf(`*/`,t+2);return r<0||r>=n?n:r+2}function E(e,t,n){let r=e[t];for(let i=t+1;i<n;i++)if(e[i]===`\\`)i++;else if(e[i]===r)return i+1;return n}function D(e,t,n){let r=``;for(let i=t;i<n;i++)if(e[i]===`/`&&e[i+1]===`*`)i=T(e,i,n)-1,r+=` `;else if(e[i]===`"`||e[i]===`'`){let t=E(e,i,n);r+=e.slice(i,t),i=t-1}else r+=e[i];return r.trim()}function ie(e,t){let n=[],r=t.startsWith(`@`)?t.slice(1):t;for(let t of O(e)){if(t.name!==r||t.terminator!==`;`)continue;let e=t.prelude[0];if(e!==`"`&&e!==`'`)continue;let i=E(t.prelude,0,t.prelude.length);i!==t.prelude.length||i<=1||t.prelude[i-1]!==e||n.push(t.prelude.slice(1,i-1))}return n}function ae(e,t){let n=t.startsWith(`@`)?t.slice(1):t;return O(e).some(e=>e.name===n)}function oe(e,t){for(let n=t;n<e.length;n++)if(e[n]===`/`&&e[n+1]===`*`)n=T(e,n,e.length)-1;else if(e[n]===`"`||e[n]===`'`)n=E(e,n,e.length)-1;else if(e[n]===`{`)return n;else if(e[n]===`;`||e[n]===`}`)return-1;return-1}function se(e,t){let n=1;for(let r=t+1;r<e.length;r++)if(e[r]===`/`&&e[r+1]===`*`)r=T(e,r,e.length)-1;else if(e[r]===`"`||e[r]===`'`)r=E(e,r,e.length)-1;else if(e[r]===`{`)n++;else if(e[r]===`}`&&--n===0)return r;return-1}function O(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(e[r]===`/`&&e[r+1]===`*`){r=T(e,r,e.length)-1;continue}if(e[r]===`"`||e[r]===`'`){r=E(e,r,e.length)-1;continue}if(e[r]===`{`){n++;continue}if(e[r]===`}`){n=Math.max(0,n-1);continue}if(n!==0||e[r]!==`@`)continue;let i=r,a=i+1;for(;re.test(e[a]??``);)a++;if(a===i+1)continue;let o=e.slice(i+1,a),s=[],c=!1;for(let n=a;n<e.length;n++){let l=e[n];if(l===`/`&&e[n+1]===`*`)n=T(e,n,e.length)-1;else if(l===`"`||l===`'`)n=E(e,n,e.length)-1;else if(l===`(`)s.push(`)`);else if(l===`[`)s.push(`]`);else if(l===s.at(-1))s.pop();else if(s.length===0&&l===`;`){t.push({name:o,prelude:D(e,a,n),start:i,end:n+1,terminator:`;`}),r=n,c=!0;break}else if(s.length===0&&l===`{`){let s=se(e,n);s>=0&&(t.push({name:o,prelude:D(e,a,n),start:i,end:s+1,terminator:`block`}),r=s,c=!0);break}}if(!c&&D(e,a,e.length)===``){t.push({name:o,prelude:``,start:i,end:e.length,terminator:`eof`});break}}return t}function ce(e,t,n){let r=[];for(let i=t;i<n;i++){let t=e[i];if(t===`/`&&e[i+1]===`*`)i=T(e,i,n)-1;else if(t===`"`||t===`'`)i=E(e,i,n)-1;else if(t===`(`)r.push(`)`);else if(t===`[`)r.push(`]`);else if(t===`{`)r.push(`}`);else if(t===r.at(-1))r.pop();else if(t===`;`&&r.length===0)return i}return n}function le(e,t,n){let r=[];for(let i=t;i<n;){for(;i<n;)if(/\s/.test(e[i]))i++;else if(e[i]===`/`&&e[i+1]===`*`)i=T(e,i,n);else break;let t=ce(e,i,n);if(e[i]!==`-`||e[i+1]!==`-`){i=t+1;continue}let a=i+2;for(;a<n&&ne.test(e[a]);)a++;if(a===i+2){i=t+1;continue}let o=a;for(;o<n;)if(/\s/.test(e[o]))o++;else if(e[o]===`/`&&e[o+1]===`*`)o=T(e,o,n);else break;if(e[o]!==`:`){i=t+1;continue}let s=o+1,c=e.slice(s,t),l=c.trim(),u=s+c.length-c.trimStart().length,d=u+l.length;r.push({property:e.slice(i,a),value:l,start:i,end:a,colon:o,valueStart:u,valueEnd:d}),i=t+1}return r}function k(e){let t=[];for(let n of O(e)){if(n.name!==`custom`||n.terminator!==`block`)continue;let r=oe(e,n.start+7);if(r<0)continue;let i=n.end-1;t.push({mode:n.prelude||void 0,declarations:le(e,r+1,i),open:r,close:i})}return t}function ue(e){let t,n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r)a===`\\`?i++:a===r&&(r=null);else if(a===`"`||a===`'`)r=a;else if(a===`/`&&e[i+1]===`*`){let r=e.indexOf(`*/`,i+2),a=r<0?e.length:r+2;(t??=[]).push(e.slice(n,i),` `),n=a,i=a-1}}return t?`${t.join(``)}${e.slice(n)}`:e}function de(e){let t=e[0];if(t===`"`||t===`'`)for(let n=1;n<e.length;n++){let r=e[n];if(r===`\\`)n++;else if(r===t)return n===e.length-1?e.slice(1,n):void 0}}function A(e){let t=O(e),n=[],r=[],i=!1,a=!1;for(let e of t){if(e.name===`custom`&&e.terminator===`block`?i=!0:e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`&&(a=!0),e.terminator!==`;`||e.name!==`preset`&&e.name!==`source`)continue;let t=de(e.prelude)?.trim();if(!t)continue;if(e.name===`preset`){n.push(t);continue}let o=t.startsWith(`!`),s=o?t.slice(1):t;s&&r.push({glob:s,exclude:o})}return{presets:n,sources:r,custom:i?k(e).map(({mode:e,declarations:t})=>({mode:e,declarations:t.map(({property:e,value:t})=>({property:e,value:ue(t).trim()}))})):[],hasTeacss:a}}let fe;function pe(){return fe??=import(`jiti`).then(({createJiti:e})=>({createJiti:e,transformer:e(import.meta.url,{fsCache:!1,interopDefault:!0,moduleCache:!1})}))}const j=new Map,M=new WeakMap,N=16*1024*1024,P=new Map;let F=0;const I={articles:`@teacss/preset-articles`,icons:`@teacss/preset-icons`,standard:`@teacss/preset-standard`};function me(t,n){try{return n.resolve(t)}catch(r){let i;try{i=n.resolve(`teacss/package.json`)}catch{throw r}return e(i).resolve(t)}}function he(t,n){if(t.startsWith(`.`)||o(t))return l(n,t);let r=e(l(n,`_`)),i=Object.hasOwn(I,t)?I[t]:void 0;return i?me(i,r):r.resolve(t)}function L(e){return e.startsWith(`.`)||o(e)}function R(e){try{return r(e)}catch{return l(e)}}function z(e,t){let r=i(e),a=[];for(;;){if(t.has(r)){let e=t.get(r);for(let n of a)t.set(n,e);return e}if(a.push(r),n(l(r,`package.json`))){for(let e of a)t.set(e,r);return r}let e=i(r);if(e===r){for(let e of a)t.set(e,void 0);return}r=e}}function ge(e,t){let n=c(t,e);return n===``||!o(n)&&n!==`..`&&!n.startsWith(`..${u}`)}function B(e,t,n){let r=z(e,n);return t.packageRoot===void 0?r===void 0&&ge(e,t.fallbackRoot):r===t.packageRoot}function V(e,t,n,r,i){if(!e||n.has(e)||(n.add(e),!o(e.filename)))return;let a=R(e.filename);if(B(a,r,i)){t.add(a);for(let a of e.children)V(a,t,n,r,i)}}function _e(e){if(!e||typeof e!=`object`)return;let t,n,r;try{t=Reflect.get(e,`path`),n=Reflect.get(e,`url`),r=Reflect.get(e,`message`)}catch{return}if(typeof t==`string`&&o(t))return R(t);if(typeof n==`string`&&n.startsWith(`file:`))return R(_(n));if(typeof r!=`string`)return;let a=/Cannot find module ['"]([^'"]+)['"] from ['"]([^'"]+)['"]/.exec(r),s=/Cannot find module ['"]([^'"]+)['"][\s\S]*?Require stack:\s*\n- ([^\n]+)/.exec(r),c=a??s;if(!c)return;let u=c[1],d=c[2];if(!(!u||!d||!u.startsWith(`.`)&&!o(u)))return R(o(u)?u:l(i(d),u))}async function ve(e,t){let n=j.get(e)??Promise.resolve(),r,i=new Promise(e=>{r=e}),a=n.then(()=>i);j.set(e,a),await n;try{return{evaluation:t()}}finally{r(),j.get(e)===a&&j.delete(e)}}function ye(e){return()=>({visitor:{AwaitExpression(t){t.getFunctionParent()||(e.hasTopLevelAwait=!0)},CallExpression(t){t.node.callee?.type===`Identifier`&&t.node.callee.name===`jitiImport`&&(e.hasDynamicImport=!0);let n=t.node.arguments?.[0];if(t.node.callee?.type!==`Identifier`||t.node.callee.name!==`require`)return;let r=n?.type===`StringLiteral`&&typeof n.value==`string`;r&&e.dependencies.add(n.value),typeof t.node.start==`number`&&(r?t.getFunctionParent()?e.hasNestedRequire=!0:e.hasTopLevelRequire=!0:e.hasNonLiteralRequire=!0)},ForOfStatement(t){t.node.await&&!t.getFunctionParent()&&(e.hasTopLevelAwait=!0)}}})}function H(e,t,n){if(e.hasDynamicImport)throw Error(`Dynamic imports are not supported in local preset modules: "${t}". Use static imports so TeaCSS can track and reload the complete graph.`);if(e.hasNonLiteralRequire)throw Error(`CommonJS require() specifiers must be string literals in local preset modules: "${t}".`);if(e.hasNestedRequire)throw Error(`CommonJS require() is only supported at module top level in local preset modules: "${t}".`);if(e.hasTopLevelRequire&&e.hasTopLevelAwait)throw Error(`CommonJS require() cannot be combined with top-level await in a local preset module: "${t}". Use a static import instead.`);if(t!==n&&e.hasTopLevelAwait)throw Error(`Top-level await is only supported in the local preset entry module: "${t}".`)}const U=Symbol(`uncacheable transform option`);function W(e,t=new Set){if(e===null)return`n`;if(typeof e==`string`)return`s${JSON.stringify(e)}`;if(typeof e==`boolean`)return e?`b1`:`b0`;if(typeof e==`number`)return Number.isNaN(e)?`dNaN`:e===1/0?`dInfinity`:e===-1/0?`d-Infinity`:Object.is(e,-0)?`d-0`:`d${JSON.stringify(e)}`;if(e===void 0)return`u`;if(typeof e!=`object`||t.has(e))throw U;t.add(e);try{if(Array.isArray(e)){for(let t of Reflect.ownKeys(e)){if(t===`length`)continue;if(typeof t!=`string`)throw U;let n=Number(t),r=Object.getOwnPropertyDescriptor(e,t);if(!Number.isSafeInteger(n)||n<0||String(n)!==t||n>=e.length||!r?.enumerable||!(`value`in r))throw U}let n=Array.from({length:e.length},(n,r)=>{let i=Object.getOwnPropertyDescriptor(e,String(r));return i&&`value`in i?W(i.value,t):`h`});return`a${e.length}[${n.join(`,`)}]`}if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw U;return`o{${Reflect.ownKeys(e).map(t=>{if(typeof t!=`string`)throw U;let n=Object.getOwnPropertyDescriptor(e,t);if(!n?.enumerable||!(`value`in n))throw U;return[t,n.value]}).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>`${JSON.stringify(e)}:${W(n,t)}`).join(`,`)}}`}finally{t.delete(e)}}function be(e,t){return{...t,async:!1,interopDefault:t.interopDefault??!0,jsx:t.jsx??e.options.jsx,retainLines:t.retainLines??e.options.transformOptions?.retainLines}}function xe(e){if(!(e&&Object.getPrototypeOf(e)===Object.prototype&&Reflect.ownKeys(e).length===0))return e}function Se(e){try{return W({babel:xe(e.babel),interopDefault:e.interopDefault,jsx:e.jsx,retainLines:e.retainLines,ts:e.ts})}catch{return}}function Ce(e,t,n,r){let i=m.byteLength(e)+m.byteLength(t)+m.byteLength(n);for(let e of r.dependencies)i+=m.byteLength(e);return i}function G(e,t){let n=P.get(e);n&&(F-=n.bytes,P.delete(e));let r=Ce(e,t.source,t.code,t.facts);if(!(r>N))for(P.set(e,{...t,bytes:r}),F+=r;P.size>256||F>N;){let e=P.keys().next();if(e.done)break;let t=P.get(e.value);P.delete(e.value),t&&(F-=t.bytes)}}function we(e){return{...e,dependencies:Array.from(e.dependencies)}}function K(e,t,n,r,i,a){let o=t.filename?R(t.filename):n,s=be(e,t),c=Se(s),l=c===void 0?void 0:`${o}\0${c}`,u=l===void 0?void 0:P.get(l);if(l!==void 0&&u?.source===s.source)return P.delete(l),P.set(l,u),B(o,r,i)&&H(u.facts,o,n),{code:u.code,dependencies:u.facts.dependencies};let d=c===void 0?void 0:{filename:o,mode:c,source:s.source},f=d===void 0?void 0:a?.read(d);if(l!==void 0&&f){let e={...f.facts,dependencies:new Set(f.facts.dependencies)};return G(l,{code:f.code,facts:e,source:s.source}),B(o,r,i)&&H(e,o,n),{code:f.code,dependencies:e.dependencies}}let p={dependencies:new Set,hasDynamicImport:!1,hasNestedRequire:!1,hasNonLiteralRequire:!1,hasTopLevelAwait:!1,hasTopLevelRequire:!1},m=ye(p),h=Error.prepareStackTrace,g=Error.stackTraceLimit;try{let t=e.transform({...s,babel:{...s.babel,plugins:[...Array.isArray(s.babel?.plugins)?s.babel.plugins:[],m]}});return l!==void 0&&G(l,{code:t,facts:p,source:s.source}),B(o,r,i)&&H(p,o,n),d!==void 0&&a?.write(d,{code:t,facts:we(p)}),{code:t,dependencies:p.dependencies}}finally{Error.prepareStackTrace=h,Error.stackTraceLimit=g}}const Te=/\.[cm]?[jt]sx?$/;function q(e,t,n){let r=R(o(n)?n:l(i(t),n));if(a(r))return[r];let s=Array.from(new Set([``,...e.options.extensions??[],`.json`])),c=[r,l(r,`index`)].flatMap(e=>s.map(t=>`${e}${t}`));return c.push(l(r,`package.json`)),c}function Ee(t,n,r){if(r.startsWith(`node:`))return[];try{let i=L(r)?t.esmResolve(r,{parentURL:v(n).href,try:!0}):e(n).resolve(r);if(!i)return L(r)?q(t,n,r):[];let a=i.startsWith(`file:`)?_(i):i;return o(a)?[R(a)]:[]}catch{return L(r)?q(t,n,r):[]}}async function De(e,t,n,r,i,o,s){let c=[e],l;for(let u=0;u<c.length;u++){let d=c[u];if(!d||!Te.test(a(d)))continue;let f;try{f=await h(d,`utf8`)}catch(e){if(e.code===`ENOENT`)continue;throw e}d===e&&(l=f);let{dependencies:p}=K(n,{source:f,filename:d,async:d===e,ts:/\.[cm]?tsx?$/.test(d)},e,r,i,s);for(let e of p)for(let n of Ee(t,d,e))o.has(n)||!B(n,r,i)||(o.add(n),c.push(n))}return l}async function Oe(e,t){try{let{createPresetTransformDiskCache:n}=await import(`./presetTransformDiskCache-Cp5NmI8Q.js`);return n(e,import.meta.url,t)}catch{return}}function J(e,t){if(!e||typeof e!=`object`)return;let n=M.get(e)??[];M.set(e,Array.from(new Set([...n,...t])))}function Y(e){return e&&typeof e==`object`?[...M.get(e)??[]]:[]}async function ke(t,n,r){let a=R(t),o=e(a),s=Object.create(null),c=new Set([a]),l=new Map,u={packageRoot:z(a,l),fallbackRoot:i(a)},[{createJiti:d,transformer:f},p]=await Promise.all([pe(),Oe(a,r)]),m=d(a,{fsCache:!1,interopDefault:!0,moduleCache:!1,tryNative:!1,transform:e=>{let{code:t}=K(f,e,a,u,l,p);return{code:t}}}),g=()=>{let e=new Set;for(let t of Object.values(s))V(t,c,e,u,l);for(let t of c)V(o.cache[t],c,e,u,l)};try{let e=await De(a,m,f,u,l,c,p)??await h(a,`utf8`),{evaluation:t}=await ve(u.packageRoot??u.fallbackRoot,()=>{for(let e of c)delete o.cache[e];return m.evalModule(e,{async:!0,cache:s,filename:a,forceTranspile:!0})}),r=await t,i=r?.__esModule?r.default:r;if(i==null)throw Error(`@preset "${n}" has no default export (expected a Preset or preset factory)`);let d=typeof i==`function`?await i():i;return g(),{preset:d,sources:Array.from(c)}}catch(e){g();let t=_e(e);throw J(e,t&&B(t,u,l)?[...c,t]:Array.from(c)),e}}async function Ae(e){let t=await g(e),n=v(e);return n.searchParams.set(`version`,`${t.mtimeMs}:${t.ctimeMs}:${t.size}:${t.ino}`),(await import(n.href)).default}async function X(e,t){let n=[],r=new Set,i={protectedSlotsByDirectory:new Map};for(let a of e){let e=he(a,t);try{let t;if(L(a)){let t=await ke(e,a,i);for(let e of t.sources)r.add(e);n.push(t.preset);continue}else t=await Ae(e);if(t==null)throw Error(`@preset "${a}" has no default export (expected a Preset or preset factory)`);n.push(typeof t==`function`?await t():t)}catch(t){throw J(t,L(a)?[...r,R(e)]:r),t}}return{presets:n,sources:Array.from(r)}}async function je(e,t){return(await X(e,t)).presets}function Me(e){return Object.keys(e).filter(t=>t!==`modes`&&t!==`defaultMode`&&e[t]!=null&&typeof e[t]==`object`)}async function Z(e,t){let n=A(e),r=n.presets.length?await X(n.presets,t):{presets:[],sources:[]},i=r.presets,a=Me((await p({presets:i})).theme),{theme:o,unknown:s}=w(n.custom,a);return{config:{presets:i,theme:o,content:{filesystem:[...n.sources.filter(e=>!e.exclude).map(e=>e.glob),...n.sources.filter(e=>e.exclude).map(e=>`!${e.glob}`)]}},unknown:s,hasTeacss:n.hasTeacss,sources:r.sources}}const Ne=y.join(` `);function Pe(e,t){return t===`unknown-prefix`?`@custom var "${e}" matches no theme namespace — not registered (emitted as a plain :root var).`:`@custom var "${e}" has an illegal color step — palette steps are ${Ne}.`}function Fe(e,t){let n=b(t),r=[];for(let t of k(e))for(let e of t.declarations){let{property:t,start:i,end:a}=e,o=C(t.slice(2),n);o.ok||r.push({property:t,start:i,end:a,reason:o.reason,message:Pe(t,o.reason)})}return r}const Q=Object.freeze([`package.json`,`index.css`,`src/index.css`]),[Ie,...Le]=Q;function Re(e,t){let n={...e};for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(t,e)?.enumerable)continue;let r=Reflect.get(t,e);r!==void 0&&Object.defineProperty(n,e,{value:r,configurable:!0,enumerable:!0,writable:!0})}return n}function ze(e){try{let n=t.readFileSync(e,`utf8`);return n.includes(`@teacss`)?O(n).some(e=>e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`):!1}catch(e){if(e.code===`ENOENT`)return!1;throw e}}function Be(e){try{let n=JSON.parse(t.readFileSync(s(e,Ie),`utf8`))?.teacss?.entry;return typeof n==`string`?n:void 0}catch(e){if(e.code===`ENOENT`)return;throw e}}function Ve(e){let n=Be(e);if(n){let r=l(e,n);if(t.existsSync(r)&&t.statSync(r).isFile())return r}for(let n of Le){let r=s(e,n);if(t.existsSync(r)&&t.statSync(r).isFile()&&ze(r))return r}}async function $(e=d.cwd(),n=e,r={}){if(typeof n!=`string`)return{config:Re(r,n),sources:[]};let a=l(e,n),o=t.existsSync(a)&&t.statSync(a).isFile()?a:Ve(a);if(!o)return{config:{...r},sources:[]};let s;try{s=await Z(t.readFileSync(o,`utf8`),i(o))}catch(e){throw J(e,[o]),e}let{config:c}=s,u=Re(r,c);return c.presets?.length||(r.presets?.length?u.presets=r.presets:f.warn(`[@teacss/config] "${o}" declares no @preset — no utilities will be generated. Add one, e.g. \`@preset "standard";\``)),{config:u,sources:Array.from(new Set([o,...s.sources]))}}function He(){let e=new Map,t=new Map,n=new Map,r=new WeakMap,i=new WeakMap,a=new WeakMap,o=(e,n)=>e?t.get(e):n?i.get(n):void 0,s=(e,t)=>e?n.get(e):t?a.get(t):void 0,c=async(e,t)=>{for(;;){let n=o(e,t),r=s(e,t);if(!r)return;let i=await r;if(o(e,t)===n)return i}};return(o=d.cwd(),s=o,u={})=>{let p=typeof s==`string`?l(o,s):void 0,m=typeof s==`object`&&s?s:void 0,h=p?(t.get(p)??0)+1:m?(i.get(m)??0)+1:0;p?t.set(p,h):m&&i.set(m,h);let g=$(o,s,u).then(n=>(p&&t.get(p)===h?e.set(p,n):m&&i.get(m)===h&&r.set(m,n),n),async n=>{let a=p?t.get(p)===h:!m||i.get(m)===h;if(!a){let e=await c(p,m);if(e)return e}let o=p?e.get(p):m?r.get(m):void 0;if(!o)throw n;if(a){f.error(`[@teacss/config] Error resolving config from the CSS entry:`,n);let e=Array.from(new Set([...o.sources,...Y(n)]));return e.length===o.sources.length?o:{...o,sources:e}}return o});return p?n.set(p,g):m&&a.set(m,g),g}}export{b as buildNamespaces,C as classifyCustomVar,He as createRecoveryConfigLoader,w as customToTheme,Fe as diagnoseCustom,Q as entryDiscoveryFiles,Ve as findEntry,Y as getConfigSourcesFromError,ae as hasTopLevelDirective,$ as loadConfig,A as parseEntry,Z as resolveEntryConfig,je as resolvePresets,k as scanCustomBlocks,ie as scanQuotedDirectives,O as scanTopLevelAtRules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{accessSync as t,closeSync as n,constants as r,fstatSync as i,lstatSync as a,mkdirSync as o,openSync as s,readFileSync as c,renameSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";import{dirname as f,join as p,resolve as m}from"node:path";import{Buffer as h}from"node:buffer";import{fileURLToPath as g}from"node:url";import{createHash as _}from"node:crypto";const v=`teacss-preset-transform-v3`,y=[`.cache`,`teacss`,`preset-transform`],b=512*1024,x=e(import.meta.url),S=new Map;function C(e){return _(`sha256`).update(e).digest(`hex`)}function w(e,t){e.update(c(t))}function T(){let e=process.versions.node.split(`.`)[0]??process.versions.node;return typeof Bun>`u`?`node:${e}`:`bun:${Bun.version}:node:${e}`}function E(e){let t=T(),n=`${e}\0${t}`;if(S.has(n))return S.get(n);let r;try{let n=g(e),i=g(import.meta.url),a=m(f(n),`../package.json`),o=JSON.parse(c(a,`utf8`)),s=x.resolve(`jiti/package.json`),l=f(s),u=JSON.parse(c(s,`utf8`));if(typeof o.version!=`string`||typeof u.version!=`string`)throw TypeError(`Invalid package version`);let d=_(`sha256`);d.update(`${v}\0@teacss/config:${o.version}\0`),w(d,n),i!==n&&w(d,i),d.update(`\0jiti:${u.version}\0`),w(d,p(l,`lib`,`jiti.mjs`)),w(d,p(l,`dist`,`jiti.cjs`)),d.update(`\0babel\0`),w(d,p(l,`dist`,`babel.cjs`)),d.update(`\0runtime:${t}`),r=d.digest(`hex`)}catch{r=void 0}if(S.size>=8){let e=S.keys().next().value;e!==void 0&&S.delete(e)}return S.set(n,r),r}function D(){return/^(?:0|false)$/i.test(process.env.TEACSS_PRESET_TRANSFORM_CACHE??``)}function O(e){if(process.platform===`win32`)return!0;let t=process.getuid?.();return(t===void 0||e.uid===t)&&(e.mode&18)==0}function k(e){try{try{o(e,{mode:448})}catch(e){if(e.code!==`EEXIST`)return!1}let t=a(e);return t.isDirectory()&&O(t)}catch{return!1}}function A(e){let n=f(e);for(;;){let e=p(n,`node_modules`),i;try{i=a(e)}catch(e){if(e.code!==`ENOENT`)return}if(i!==void 0){if(!i.isDirectory()||!O(i))return;try{let n=e;for(let e of y)if(n=p(n,e),!k(n))return;return t(n,r.R_OK|r.W_OK),n}catch{return}}let o=f(n);if(o===n)return;n=o}}function j(e,t){return C(`${e}\0${t.filename}\0${t.mode}\0${C(t.source)}`)}function M(e,t){return(Number.parseInt(e.slice(0,2),16)%256+t*(Number.parseInt(e.slice(2,4),16)|1))%256}function N(e,t){return p(e,`${t.toString(16).padStart(2,`0`)}.json`)}function P(e,t,n,r){return JSON.stringify([e,t,n,r.dependencies,r.hasDynamicImport,r.hasNestedRequire,r.hasNonLiteralRequire,r.hasTopLevelAwait,r.hasTopLevelRequire])}function F(e){if(!e||typeof e!=`object`)return;let t=e;if(!Array.isArray(t.dependencies)||t.dependencies.length>4096)return;let n=0;for(let e of t.dependencies){if(typeof e!=`string`)return;let t=h.byteLength(e);if(t>16384||(n+=t,n>b))return}if(typeof t.hasDynamicImport==`boolean`&&typeof t.hasNestedRequire==`boolean`&&typeof t.hasNonLiteralRequire==`boolean`&&typeof t.hasTopLevelAwait==`boolean`&&typeof t.hasTopLevelRequire==`boolean`)return n}function I(e){return F(e)!==void 0}function L(e,t,o){let l=N(e,t);try{let e=a(l);if(!e.isFile()||!O(e))return{kind:`blocked`}}catch(e){return{kind:e.code===`ENOENT`?`empty`:`blocked`}}let u;try{u=s(l,r.O_RDONLY|(r.O_NOFOLLOW??0))}catch(e){return{kind:e.code===`ENOENT`?`empty`:`blocked`}}try{let e=i(u);if(!e.isFile()||!O(e))return{kind:`blocked`};if(e.size<=0||e.size>b)return{kind:`reusable`};let t;try{t=JSON.parse(c(u,`utf8`))}catch{return{kind:`reusable`}}if(!t||typeof t!=`object`)return{kind:`reusable`};let n=t;return n.schema!==v||n.fingerprint!==o||!/^[0-9a-f]{64}$/.test(n.fingerprint)||typeof n.key!=`string`||!/^[0-9a-f]{64}$/.test(n.key)?{kind:`reusable`}:{kind:`payload`,payload:n}}catch{return{kind:`blocked`}}finally{try{n(u)}catch{}}}function R(e,t,n,r){for(let i=0;i<256;i++){let a=M(n,i),o=L(e,a,t);if(o.kind===`empty`)return;if(o.kind!==`payload`||o.payload.key!==n)continue;let s=o.payload;if(!(typeof s.code!=`string`||!I(s.facts))&&s.checksum===C(P(t,n,s.code,s.facts)))return r.add(a),{code:s.code,facts:s.facts}}}function z(e,t,n,r){let i=Array(256),a;for(let r=0;r<256;r++){let o=M(n,r),s=L(e,o,t);if(i[o]=s,s.kind===`payload`&&s.payload.key===n)return o;if(s.kind===`reusable`&&a===void 0&&(a=o),s.kind===`empty`)return a??o}if(a!==void 0)return a;let o=Number.parseInt(n.slice(4,6),16)%256;for(let e=0;e<256;e++){let t=M(n,(o+e)%256);if(i[t]?.kind===`payload`&&!r.has(t))return t}}function B(e,t,n,r,i){if(typeof r.code!=`string`)return;let o=F(r.facts);if(o===void 0||h.byteLength(r.code)+o>b)return;let s={checksum:C(P(t,n,r.code,r.facts)),code:r.code,facts:r.facts,fingerprint:t,key:n,schema:v},c=JSON.stringify(s);if(h.byteLength(c)>b)return;let f=z(e,t,n,i);if(f===void 0)return;let m=N(e,f),g=p(e,`.${f.toString(16).padStart(2,`0`)}.tmp`),_=!1,y=!1;try{try{d(g,c,{encoding:`utf8`,flag:`wx`,mode:384}),_=!0}catch(e){if(e.code!==`EEXIST`)throw e;let t=!1;try{let e=a(g);e.isFile()&&O(e)&&Date.now()-e.mtimeMs>6e4&&(u(g),t=!0)}catch{}if(!t)return;d(g,c,{encoding:`utf8`,flag:`wx`,mode:384}),_=!0}try{l(g,m),_=!1,y=!0}catch(e){let t=e.code;if(t!==`EEXIST`&&t!==`EPERM`)throw e;u(m),l(g,m),_=!1,y=!0}}catch{}finally{if(_)try{u(g)}catch{}}return y?f:void 0}function V(e,t,n){if(D())return;let r=A(e);if(!r)return;let i=E(t);if(!i)return;let a=n?.protectedSlotsByDirectory.get(r);return a||(a=new Set,n?.protectedSlotsByDirectory.set(r,a)),{read(e){return R(r,i,j(i,e),a)},write(e,t){let n=B(r,i,j(i,e),t,a);n!==void 0&&a.add(n)}}}export{V as createPresetTransformDiskCache};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teacss/config",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "TeaCSS config loader — discovers the CSS entry and resolves its directives into a config (no teacss.config file).",
|
|
5
|
+
"homepage": "https://css.teasim.com",
|
|
6
|
+
"funding": "https://github.com/sponsors/billgo",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Billgo <hi@billgo.me>",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/index.js",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "bunx rimraf dist && bunx tsdown --config tsdown.config.mts",
|
|
22
|
+
"dev": "tsdown --watch"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@teacss/core": "0.3.0",
|
|
26
|
+
"consola": "^3.4.2",
|
|
27
|
+
"jiti": "^2.7.0"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22.12.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|