@xessa/cli 0.0.0-stage → 0.1.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +443 -2
  3. package/dist/args.d.ts +43 -0
  4. package/dist/args.d.ts.map +1 -0
  5. package/dist/args.js +202 -0
  6. package/dist/args.js.map +1 -0
  7. package/dist/commands/build.d.ts +44 -0
  8. package/dist/commands/build.d.ts.map +1 -0
  9. package/dist/commands/build.js +533 -0
  10. package/dist/commands/build.js.map +1 -0
  11. package/dist/commands/check.d.ts +11 -0
  12. package/dist/commands/check.d.ts.map +1 -0
  13. package/dist/commands/check.js +35 -0
  14. package/dist/commands/check.js.map +1 -0
  15. package/dist/commands/clean.d.ts +12 -0
  16. package/dist/commands/clean.d.ts.map +1 -0
  17. package/dist/commands/clean.js +140 -0
  18. package/dist/commands/clean.js.map +1 -0
  19. package/dist/commands/format.d.ts +41 -0
  20. package/dist/commands/format.d.ts.map +1 -0
  21. package/dist/commands/format.js +127 -0
  22. package/dist/commands/format.js.map +1 -0
  23. package/dist/commands/watch.d.ts +38 -0
  24. package/dist/commands/watch.d.ts.map +1 -0
  25. package/dist/commands/watch.js +338 -0
  26. package/dist/commands/watch.js.map +1 -0
  27. package/dist/compiler.d.ts +20 -0
  28. package/dist/compiler.d.ts.map +1 -0
  29. package/dist/compiler.js +57 -0
  30. package/dist/compiler.js.map +1 -0
  31. package/dist/config.d.ts +93 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +331 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/formatter.d.ts +21 -0
  36. package/dist/formatter.d.ts.map +1 -0
  37. package/dist/formatter.js +38 -0
  38. package/dist/formatter.js.map +1 -0
  39. package/dist/glob.d.ts +52 -0
  40. package/dist/glob.d.ts.map +1 -0
  41. package/dist/glob.js +214 -0
  42. package/dist/glob.js.map +1 -0
  43. package/dist/index.d.ts +34 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +114 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/manifest.d.ts +56 -0
  48. package/dist/manifest.d.ts.map +1 -0
  49. package/dist/manifest.js +138 -0
  50. package/dist/manifest.js.map +1 -0
  51. package/dist/paths.d.ts +24 -0
  52. package/dist/paths.d.ts.map +1 -0
  53. package/dist/paths.js +42 -0
  54. package/dist/paths.js.map +1 -0
  55. package/dist/project.d.ts +44 -0
  56. package/dist/project.d.ts.map +1 -0
  57. package/dist/project.js +92 -0
  58. package/dist/project.js.map +1 -0
  59. package/dist/report.d.ts +128 -0
  60. package/dist/report.d.ts.map +1 -0
  61. package/dist/report.js +128 -0
  62. package/dist/report.js.map +1 -0
  63. package/dist/setup.d.ts +58 -0
  64. package/dist/setup.d.ts.map +1 -0
  65. package/dist/setup.js +181 -0
  66. package/dist/setup.js.map +1 -0
  67. package/dist/writer.d.ts +32 -0
  68. package/dist/writer.d.ts.map +1 -0
  69. package/dist/writer.js +93 -0
  70. package/dist/writer.js.map +1 -0
  71. package/package.json +40 -4
  72. package/src/args.ts +246 -0
  73. package/src/commands/build.ts +682 -0
  74. package/src/commands/check.ts +45 -0
  75. package/src/commands/clean.ts +168 -0
  76. package/src/commands/format.ts +169 -0
  77. package/src/commands/watch.ts +366 -0
  78. package/src/compiler-api.d.ts +261 -0
  79. package/src/compiler.ts +65 -0
  80. package/src/config.ts +443 -0
  81. package/src/formatter.ts +56 -0
  82. package/src/glob.ts +230 -0
  83. package/src/index.ts +137 -0
  84. package/src/manifest.ts +176 -0
  85. package/src/paths.ts +50 -0
  86. package/src/project.ts +122 -0
  87. package/src/report.ts +230 -0
  88. package/src/setup.ts +218 -0
  89. package/src/writer.ts +102 -0
@@ -0,0 +1,338 @@
1
+ /**
2
+ * `xessa watch` — incremental rebuilds until interrupted.
3
+ *
4
+ * The watcher performs an initial full build, then watches the directories that
5
+ * hold entry sources and their import dependencies. Events are debounced, mapped
6
+ * through a reverse import graph (built from `CompileResult.dependencies`) to the
7
+ * affected entries, and serialized: one build runs at a time and any event that
8
+ * arrives mid-build invalidates it through a generation counter, so a stale
9
+ * result never lands on disk.
10
+ *
11
+ * Sources (`.cssx`), the configuration file and directory events trigger work.
12
+ * Generated CSS, JS, declarations, maps, writer temporaries and the manifest are
13
+ * matched against the known artifact set and ignored, so the watcher cannot feed
14
+ * back on its own outputs. Deletions and unhandled paths trigger a full
15
+ * rediscovery through the include globs.
16
+ */
17
+ import { watch } from "node:fs";
18
+ import { stat } from "node:fs/promises";
19
+ import { staticDirectoryPrefix } from "../glob.js";
20
+ import { MANIFEST_FILENAME } from "../manifest.js";
21
+ import { dirnamePosix, joinPosix, relativePosix } from "../paths.js";
22
+ import { prepareProject } from "../project.js";
23
+ import { invocationFailure, writeErrorLine, writeLine } from "../report.js";
24
+ import { emitReport, executeBuild, toJsonReport } from "./build.js";
25
+ /**
26
+ * Debounce window for filesystem events in milliseconds.
27
+ *
28
+ * Exported so integration tests can reason about event coalescing instead of
29
+ * guessing at a sleep, and reported in the JSON `watch` ready event. Changing it
30
+ * only affects latency, never correctness: every build is still awaited through
31
+ * its emitted build event.
32
+ */
33
+ export const WATCH_DEBOUNCE_MS = 40;
34
+ /** Run `xessa watch [file]` until aborted. */
35
+ export async function runWatch(options) {
36
+ const { invocation, cwd } = options;
37
+ const controller = options.signal === undefined ? new AbortController() : undefined;
38
+ const signal = options.signal ?? controller?.signal;
39
+ if (controller !== undefined) {
40
+ process.once("SIGINT", () => controller.abort());
41
+ process.once("SIGTERM", () => controller.abort());
42
+ }
43
+ if (signal === undefined)
44
+ return 2;
45
+ const prepared = await prepareProject(invocation, cwd);
46
+ if (!prepared.ok)
47
+ return invocationFailure(invocation.command, prepared.message, invocation.json);
48
+ if (!prepared.context.singleEntry && prepared.context.entries.length === 0) {
49
+ return invocationFailure(invocation.command, "No .cssx sources matched the project include globs.", invocation.json);
50
+ }
51
+ const state = {
52
+ context: prepared.context,
53
+ config: prepared.context.config,
54
+ reverse: new Map(),
55
+ sources: new Set(),
56
+ artifacts: new Set(),
57
+ generation: 0,
58
+ };
59
+ const watchers = new Map();
60
+ const pending = new Set();
61
+ let pendingUnknown = false;
62
+ let pendingConfig = false;
63
+ let timer;
64
+ let wake;
65
+ /**
66
+ * Latched wakeup. `notify()` runs while no waiter exists (the build cycle is
67
+ * in flight), so the request is remembered here and the next `waitForWork()`
68
+ * returns immediately instead of sleeping until an unrelated event arrives.
69
+ */
70
+ let pendingWake = false;
71
+ const notify = () => {
72
+ const resolve = wake;
73
+ wake = undefined;
74
+ if (resolve === undefined)
75
+ pendingWake = true;
76
+ else
77
+ resolve();
78
+ };
79
+ const waitForWork = () => {
80
+ if (signal.aborted)
81
+ return Promise.resolve();
82
+ if (pendingWake) {
83
+ pendingWake = false;
84
+ return Promise.resolve();
85
+ }
86
+ return new Promise((resolve) => {
87
+ wake = resolve;
88
+ });
89
+ };
90
+ const clearTimer = () => {
91
+ if (timer !== undefined) {
92
+ clearTimeout(timer);
93
+ timer = undefined;
94
+ }
95
+ };
96
+ const schedule = (absolute) => {
97
+ if (absolute === null) {
98
+ pendingUnknown = true;
99
+ }
100
+ else {
101
+ const relative = relativePosix(state.context.root, absolute);
102
+ if (relative === "" || relative.startsWith("../"))
103
+ pendingUnknown = true;
104
+ else
105
+ pending.add(relative);
106
+ }
107
+ // Any event invalidates an in-flight build generation.
108
+ state.generation += 1;
109
+ clearTimer();
110
+ timer = setTimeout(() => {
111
+ timer = undefined;
112
+ notify();
113
+ }, WATCH_DEBOUNCE_MS);
114
+ };
115
+ const closeAll = () => {
116
+ clearTimer();
117
+ for (const watcher of watchers.values())
118
+ watcher.close();
119
+ watchers.clear();
120
+ };
121
+ const onAbort = () => {
122
+ closeAll();
123
+ notify();
124
+ };
125
+ signal.addEventListener("abort", onAbort, { once: true });
126
+ const watchDirectory = (directory) => {
127
+ if (watchers.has(directory))
128
+ return;
129
+ try {
130
+ const watcher = watch(directory, { persistent: true }, (_event, filename) => {
131
+ if (typeof filename === "string") {
132
+ if (filename === "")
133
+ return;
134
+ const absolute = joinPosix(directory, filename);
135
+ if (state.config !== null && absolute === state.config.file) {
136
+ pendingConfig = true;
137
+ schedule(absolute);
138
+ return;
139
+ }
140
+ const relative = relativePosix(state.context.root, absolute);
141
+ if (relative === "" || relative.startsWith("../")) {
142
+ schedule(null);
143
+ return;
144
+ }
145
+ // Generated artifacts, the manifest and the writer's temporaries are
146
+ // our own output: never rebuild because we wrote them.
147
+ if (relative === MANIFEST_FILENAME)
148
+ return;
149
+ if (relative.endsWith(".cssx-tmp"))
150
+ return;
151
+ if (state.artifacts.has(relative))
152
+ return;
153
+ if (relative.endsWith(".cssx")) {
154
+ schedule(absolute);
155
+ return;
156
+ }
157
+ // A directory creation/removal or an unknown entry: rediscover the
158
+ // include globs so a brand-new source tree becomes visible without a
159
+ // restart. This replaces the old "only `.cssx` filenames matter" rule.
160
+ schedule(null);
161
+ return;
162
+ }
163
+ schedule(null);
164
+ });
165
+ watcher.on("error", () => {
166
+ watchers.delete(directory);
167
+ });
168
+ watchers.set(directory, watcher);
169
+ }
170
+ catch {
171
+ // Missing or unwatchable directories are skipped; rediscovery retries.
172
+ }
173
+ };
174
+ const syncWatchers = () => {
175
+ const desired = new Set();
176
+ desired.add(state.context.root);
177
+ if (state.config !== null)
178
+ desired.add(dirnamePosix(state.config.file));
179
+ for (const source of state.sources) {
180
+ desired.add(dirnamePosix(joinPosix(state.context.root, source)));
181
+ }
182
+ for (const pattern of state.config?.include ?? []) {
183
+ const prefix = staticDirectoryPrefix(pattern);
184
+ desired.add(prefix === "" ? state.context.root : joinPosix(state.context.root, prefix));
185
+ }
186
+ for (const directory of desired)
187
+ watchDirectory(directory);
188
+ for (const [directory, watcher] of watchers) {
189
+ if (desired.has(directory))
190
+ continue;
191
+ watcher.close();
192
+ watchers.delete(directory);
193
+ }
194
+ };
195
+ const updateGraph = (report) => {
196
+ const reverse = new Map();
197
+ const sources = new Set();
198
+ for (const entry of report.entries) {
199
+ sources.add(entry.file);
200
+ const self = reverse.get(entry.file) ?? new Set();
201
+ self.add(entry.file);
202
+ reverse.set(entry.file, self);
203
+ for (const dependency of entry.dependencies) {
204
+ sources.add(dependency);
205
+ const affected = reverse.get(dependency) ?? new Set();
206
+ affected.add(entry.file);
207
+ reverse.set(dependency, affected);
208
+ }
209
+ for (const output of entry.outputs)
210
+ state.artifacts.add(output.path);
211
+ }
212
+ state.reverse = reverse;
213
+ state.sources = sources;
214
+ };
215
+ const runCycle = async (entries, prune) => {
216
+ const generation = state.generation;
217
+ let outcome;
218
+ try {
219
+ outcome = await executeBuild({
220
+ context: { ...state.context, entries },
221
+ write: true,
222
+ dryRun: false,
223
+ prune,
224
+ ...(invocation.minify === undefined ? {} : { minify: invocation.minify }),
225
+ isCurrent: () => state.generation === generation,
226
+ });
227
+ }
228
+ catch (error) {
229
+ writeErrorLine(`xessa watch: build failed: ${describeError(error)}`);
230
+ }
231
+ if (outcome !== undefined && !outcome.stale) {
232
+ updateGraph(outcome.report);
233
+ }
234
+ // Watchers must be attached (or refreshed) before the build event is
235
+ // reported, so consumers that react to the event cannot race attachment.
236
+ syncWatchers();
237
+ if (outcome === undefined)
238
+ return;
239
+ if (outcome.stale) {
240
+ writeLine("xessa watch: discarded a stale build generation");
241
+ return;
242
+ }
243
+ if (invocation.json) {
244
+ // True NDJSON: one compact JSON object per line, so consumers can parse
245
+ // the stream incrementally.
246
+ writeLine(JSON.stringify({ type: "build", ...toJsonReport(outcome.report) }));
247
+ }
248
+ else {
249
+ emitReport(outcome.report, false);
250
+ }
251
+ };
252
+ // Initial full build.
253
+ await runCycle(state.context.entries, !state.context.singleEntry);
254
+ if (invocation.json) {
255
+ // Readiness handshake: emitted only after the initial build and watcher
256
+ // attachment, so tests never guess when it is safe to touch files.
257
+ writeLine(JSON.stringify({
258
+ type: "watch",
259
+ ready: true,
260
+ sources: state.sources.size,
261
+ debounceMs: WATCH_DEBOUNCE_MS,
262
+ }));
263
+ }
264
+ else {
265
+ writeLine(`xessa watch: watching ${state.sources.size} source${state.sources.size === 1 ? "" : "s"} (Ctrl+C to stop)`);
266
+ }
267
+ while (!signal.aborted) {
268
+ await waitForWork();
269
+ if (signal.aborted)
270
+ break;
271
+ const changes = [...pending];
272
+ pending.clear();
273
+ const configChanged = pendingConfig;
274
+ pendingConfig = false;
275
+ const unknown = pendingUnknown;
276
+ pendingUnknown = false;
277
+ if (changes.length === 0 && !configChanged && !unknown)
278
+ continue;
279
+ let full = configChanged || unknown;
280
+ if (!full) {
281
+ for (const change of changes) {
282
+ if (!(await isFile(joinPosix(state.context.root, change)))) {
283
+ full = true;
284
+ break;
285
+ }
286
+ }
287
+ }
288
+ if (full) {
289
+ const refreshed = await prepareProject(invocation, cwd);
290
+ if (!refreshed.ok) {
291
+ writeErrorLine(`xessa watch: configuration error: ${refreshed.message}`);
292
+ continue;
293
+ }
294
+ state.context = refreshed.context;
295
+ state.config = refreshed.context.config;
296
+ await runCycle(state.context.entries, !state.context.singleEntry);
297
+ continue;
298
+ }
299
+ const affected = new Set();
300
+ for (const change of changes) {
301
+ const dependents = state.reverse.get(change);
302
+ if (dependents === undefined) {
303
+ full = true;
304
+ break;
305
+ }
306
+ for (const entry of dependents)
307
+ affected.add(entry);
308
+ }
309
+ if (full) {
310
+ const refreshed = await prepareProject(invocation, cwd);
311
+ if (!refreshed.ok)
312
+ continue;
313
+ state.context = refreshed.context;
314
+ state.config = refreshed.context.config;
315
+ await runCycle(state.context.entries, !state.context.singleEntry);
316
+ continue;
317
+ }
318
+ const entries = [...affected].filter((entry) => state.sources.has(entry)).sort();
319
+ if (entries.length === 0)
320
+ continue;
321
+ await runCycle(entries, false);
322
+ }
323
+ signal.removeEventListener("abort", onAbort);
324
+ closeAll();
325
+ return 0;
326
+ }
327
+ async function isFile(path) {
328
+ try {
329
+ return (await stat(path)).isFile();
330
+ }
331
+ catch {
332
+ return false;
333
+ }
334
+ }
335
+ function describeError(error) {
336
+ return error instanceof Error ? error.message : String(error);
337
+ }
338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AAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Compiler boundary for the CLI.
3
+ *
4
+ * The CLI consumes only the compiler's public barrel. Because the monorepo does
5
+ * not link workspace packages into `node_modules`, the loader tries, in order:
6
+ *
7
+ * 1. the bare `@xessa/compiler` specifier (published installs, or a linked
8
+ * workspace with a built `dist`);
9
+ * 2. `packages/compiler/dist/index.js` relative to this module (Bun and Node
10
+ * runs from the repository);
11
+ * 3. `packages/compiler/src/index.ts` under Bun only (development and tests
12
+ * without a build step).
13
+ *
14
+ * The module is cached after the first successful load.
15
+ */
16
+ /** Public compiler module surface used by the CLI. */
17
+ export type CompilerApi = typeof import("@xessa/compiler");
18
+ /** Load (and cache) the compiler public API. */
19
+ export declare function loadCompiler(): Promise<CompilerApi>;
20
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,sDAAsD;AACtD,MAAM,MAAM,WAAW,GAAG,cAAc,iBAAiB,CAAC,CAAC;AAI3D,gDAAgD;AAChD,wBAAgB,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC,CAGnD"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Compiler boundary for the CLI.
3
+ *
4
+ * The CLI consumes only the compiler's public barrel. Because the monorepo does
5
+ * not link workspace packages into `node_modules`, the loader tries, in order:
6
+ *
7
+ * 1. the bare `@xessa/compiler` specifier (published installs, or a linked
8
+ * workspace with a built `dist`);
9
+ * 2. `packages/compiler/dist/index.js` relative to this module (Bun and Node
10
+ * runs from the repository);
11
+ * 3. `packages/compiler/src/index.ts` under Bun only (development and tests
12
+ * without a build step).
13
+ *
14
+ * The module is cached after the first successful load.
15
+ */
16
+ let cached;
17
+ /** Load (and cache) the compiler public API. */
18
+ export function loadCompiler() {
19
+ cached ??= resolveCompiler();
20
+ return cached;
21
+ }
22
+ function isBun() {
23
+ return typeof globalThis.Bun !== "undefined";
24
+ }
25
+ function candidates() {
26
+ const list = [
27
+ () => import("@xessa/compiler"),
28
+ () => import(new URL("../../compiler/dist/index.js", import.meta.url).href),
29
+ ];
30
+ if (isBun()) {
31
+ list.push(() => import(new URL("../../compiler/src/index.ts", import.meta.url).href));
32
+ }
33
+ return list;
34
+ }
35
+ async function resolveCompiler() {
36
+ const errors = [];
37
+ for (const candidate of candidates()) {
38
+ try {
39
+ const loaded = (await candidate());
40
+ if (typeof loaded.compileProject !== "function" || typeof loaded.planOutputs !== "function") {
41
+ errors.push("module loaded without compileProject/planOutputs exports");
42
+ continue;
43
+ }
44
+ return loaded;
45
+ }
46
+ catch (error) {
47
+ errors.push(describeError(error));
48
+ }
49
+ }
50
+ throw new Error(`Unable to load @xessa/compiler. Build it first with "bun run build" in packages/compiler. Tried: ${errors.join(" | ")}`);
51
+ }
52
+ function describeError(error) {
53
+ if (error instanceof Error)
54
+ return error.message;
55
+ return String(error);
56
+ }
57
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,IAAI,MAAwC,CAAC;AAE7C,gDAAgD;AAChD,MAAM,UAAU,YAAY;IAC1B,MAAM,KAAK,eAAe,EAAE,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,C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K,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * `xessa.config.json` discovery, loading and schema validation.
3
+ *
4
+ * The document format is frozen by SPECIFICATION.md §10. Keys are camelCase in
5
+ * JSON while source `@setup` keys stay kebab-case:
6
+ *
7
+ * | `@setup` key | JSON key | Where |
8
+ * |---|---|---|
9
+ * | `prefix` | `classes.prefix` | `classes` |
10
+ * | `css-dir` | `output.cssDir` | `output` |
11
+ * | `css-name` | `output.cssName` | `output` |
12
+ * | `map-dir` | `output.mapDir` | `output` |
13
+ * | `map-name` | `output.mapName` | `output` |
14
+ * | `emit-css` | `output.emitCss` | `output` |
15
+ * | `emit-map` | `output.emitMap` | `output` |
16
+ * | `map-types` | `output.mapTypes` | `output` |
17
+ * | `emit-types` | `output.emitTypes` | `output` |
18
+ * | `source-map` | `output.sourceMap` | `output` |
19
+ * | `minify` | `output.minify` | `output` |
20
+ * | `map-inherit` | `output.mapInherit` | `output` |
21
+ * | `import-css` | `output.importCss` | `output` |
22
+ * | `media-grouping` | `compiler.mediaGrouping` | `compiler` |
23
+ *
24
+ * `output.prefix` is deliberately rejected: class naming lives under `classes`
25
+ * so strategy and prefix stay together.
26
+ *
27
+ * Unknown keys are rejected (exit 2) by default; an explicit
28
+ * `compiler.strict: false` downgrades them to warnings. Known keys are always
29
+ * type-checked.
30
+ *
31
+ * `include` defaults to {@link DEFAULT_INCLUDE} (`**\/*.cssx`), so a configuration
32
+ * file is only needed to change a default or scope discovery. `exclude` stays
33
+ * empty by default: imported modules declare themselves with
34
+ * `@setup { module: true; }` rather than appearing in a project-wide list.
35
+ */
36
+ import type { CompilerConfig, NamingOptions, OutputOptions } from "@xessa/compiler";
37
+ /** Entry globs used when a project does not configure `include`. */
38
+ export declare const DEFAULT_INCLUDE: readonly string[];
39
+ /** Validated project configuration with its resolved location. */
40
+ export interface CliConfig {
41
+ /** Absolute POSIX path of the configuration file. */
42
+ readonly file: string;
43
+ /** Absolute POSIX workspace root: the directory containing the configuration file. */
44
+ readonly root: string;
45
+ /** Include globs used for project entry discovery; defaults to {@link DEFAULT_INCLUDE}. */
46
+ readonly include: readonly string[];
47
+ /** Exclude globs and directory names removed from discovery. Default `[]`. */
48
+ readonly exclude: readonly string[];
49
+ /** Project-level output settings, resolved against the workspace root. */
50
+ readonly output?: OutputOptions;
51
+ /** Project-level class naming strategy and prefix. */
52
+ readonly classes?: NamingOptions;
53
+ /** Project-level media alias overrides merged after built-in defaults. */
54
+ readonly media?: Readonly<Record<string, string>>;
55
+ /** Compiler behaviour settings such as strict mode and media grouping. */
56
+ readonly compiler?: CompilerConfig;
57
+ }
58
+ /** Request for {@link loadConfig}. */
59
+ export interface LoadConfigRequest {
60
+ /** Working directory used to resolve an explicit relative `--config` path. */
61
+ readonly cwd: string;
62
+ /** Directory to start the nearest-config walk from. */
63
+ readonly startDir: string;
64
+ /** Explicit `--config` path, absolute or relative to `cwd`. */
65
+ readonly explicitPath?: string;
66
+ }
67
+ /** Outcome of loading a configuration file. */
68
+ export type ConfigLoadOutcome = {
69
+ readonly ok: true;
70
+ /** Parsed configuration, or `null` when no configuration file was found. */
71
+ readonly config: CliConfig | null;
72
+ /** Non-fatal validation notes (ignored unknown keys outside strict mode). */
73
+ readonly warnings: readonly string[];
74
+ } | {
75
+ readonly ok: false;
76
+ /** User-facing explanation; callers report it and exit 2. */
77
+ readonly message: string;
78
+ };
79
+ interface ConfigDocument {
80
+ readonly config?: CliConfig;
81
+ readonly errors: readonly string[];
82
+ readonly warnings: readonly string[];
83
+ }
84
+ /** Walk up from `startDir` to the filesystem root for the nearest config file. */
85
+ export declare function findConfigPath(startDir: string): Promise<string | null>;
86
+ /** Walk up for the nearest `xessa.config.json`, else `package.json`, else `startDir`. */
87
+ export declare function findWorkspaceRoot(startDir: string): Promise<string>;
88
+ /** Load and validate `xessa.config.json`, resolving the nearest file when not explicit. */
89
+ export declare function loadConfig(request: LoadConfigRequest): Promise<ConfigLoadOutcome>;
90
+ /** Parse and validate one configuration document. */
91
+ export declare function parseConfigDocument(text: string, file: string): ConfigDocument;
92
+ export {};
93
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,EAEb,aAAa,EACd,MAAM,iBAAiB,CAAC;AAGzB,oEAAoE;AACpE,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAiC,CAAC;AAE/E,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC;AAED,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+DAA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