@stillwind/config 0.1.0 → 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/README.md +4 -6
- package/dist/browser.d.ts +28 -3
- package/dist/browser.js +54 -9
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/node.d.ts +35 -9
- package/dist/node.js +48 -9
- package/dist/node.js.map +1 -1
- package/dist/{resolution-BnR6LLM-.d.ts → resolution-D-_c0Q11.d.ts} +73 -15
- package/dist/{resolution-BK-NUhyh.js → resolution-DCwmb-pa.js} +142 -22
- package/dist/resolution-DCwmb-pa.js.map +1 -0
- package/package.json +8 -6
- package/dist/resolution-BK-NUhyh.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# @stillwind/config
|
|
2
2
|
|
|
3
|
-
Stillwind compiles Tailwind CSS v4 utilities into component props and static CSS.
|
|
4
|
-
It uses theme rules and compiler checks to keep styling code in order, even when
|
|
5
|
-
AI agents write much of it.
|
|
3
|
+
[Stillwind](https://stillwind.dev/) compiles Tailwind CSS v4 utilities into component props and static CSS.
|
|
4
|
+
It uses theme rules and compiler checks to keep styling code in order, even when AI agents write much of it.
|
|
6
5
|
|
|
7
|
-
`@stillwind/config` provides shared project configuration, lint presets, plugin
|
|
8
|
-
|
|
9
|
-
Applications use the helpers through `stillwind/config`.
|
|
6
|
+
`@stillwind/config` provides shared project configuration, lint presets, plugin contracts, and configuration
|
|
7
|
+
loading for Stillwind builds and analysis. Applications use the helpers through `stillwind/config`.
|
|
10
8
|
|
|
11
9
|
See [Configuration](https://stillwind.dev/docs/configuration)
|
|
12
10
|
for settings and resolution rules.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as AnalysisProjectConfig, i as documentConfiguration, t as InlineConfig } from "./resolution-D-_c0Q11.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reports the configuration file that failed to load, keeping the message of the original failure.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigurationLoadError extends Error {
|
|
6
|
+
/** Absolute virtual path of the file that failed. A referenced file names itself. */
|
|
7
|
+
readonly configFile: string;
|
|
8
|
+
/**
|
|
9
|
+
* @param configFile - Absolute virtual path of the file that failed.
|
|
10
|
+
* @param cause - Failure from evaluation, validation, or reference expansion.
|
|
11
|
+
*/
|
|
12
|
+
constructor(configFile: string, cause: unknown);
|
|
13
|
+
}
|
|
2
14
|
/** Configuration evaluation supplied by a browser module runtime. */
|
|
3
15
|
export interface BrowserConfigHost {
|
|
4
16
|
/**
|
|
5
17
|
* Tests whether a configuration candidate exists in the captured workspace.
|
|
18
|
+
*
|
|
6
19
|
* @param id - Absolute virtual path supplied by discovery or an explicit file selection.
|
|
7
20
|
* @returns Whether the evaluator can load this path from the captured inventory.
|
|
8
21
|
*/
|
|
9
22
|
exists(id: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Enumerates the captured workspace for glob references in configuration.
|
|
25
|
+
*
|
|
26
|
+
* @returns Absolute virtual paths of captured files.
|
|
27
|
+
*/
|
|
28
|
+
list(): Iterable<string>;
|
|
10
29
|
/**
|
|
11
30
|
* Evaluates a configuration module without invoking its exported factory.
|
|
31
|
+
*
|
|
12
32
|
* @param id - Existing absolute virtual path selected from the same captured inventory.
|
|
13
33
|
* @returns The module's default export, which resolveConfig subsequently evaluates and validates.
|
|
14
34
|
* @throws If loading or evaluating the module fails.
|
|
@@ -17,6 +37,7 @@ export interface BrowserConfigHost {
|
|
|
17
37
|
}
|
|
18
38
|
/**
|
|
19
39
|
* Discovers and evaluates browser configuration using the same export contract as Node.
|
|
40
|
+
*
|
|
20
41
|
* @param root - Absolute virtual application directory.
|
|
21
42
|
* @param host - Captured file inventory and browser module evaluator.
|
|
22
43
|
* @param inline - Explicit file, project selection, and compiler overrides.
|
|
@@ -34,12 +55,15 @@ export declare function resolveBrowserConfig(root: string, host: BrowserConfigHo
|
|
|
34
55
|
}>;
|
|
35
56
|
/**
|
|
36
57
|
* Loads every configured project for analysis across a workspace.
|
|
58
|
+
*
|
|
37
59
|
* @param root - Absolute virtual directory where discovery starts.
|
|
38
60
|
* @param host - Captured files and module evaluator.
|
|
39
61
|
* @param requested - Absolute path or nonempty path relative to root. False disables loading, and
|
|
40
62
|
* omission searches root and its ancestors in configurationFiles order within each directory.
|
|
41
|
-
* @returns Evaluated projects with absolute roots,
|
|
42
|
-
*
|
|
63
|
+
* @returns Evaluated projects with absolute roots, including the projects of referenced files, or
|
|
64
|
+
* undefined when loading is disabled or discovery finds no file.
|
|
65
|
+
* @throws If an explicit path is invalid or missing. A {@link ConfigurationLoadError} if evaluation,
|
|
66
|
+
* validation, or reference expansion fails.
|
|
43
67
|
*/
|
|
44
68
|
export declare function loadBrowserConfig(root: string, host: BrowserConfigHost, requested?: string | false): Promise<{
|
|
45
69
|
/** Absolute virtual path selected for evaluation. */
|
|
@@ -47,4 +71,5 @@ export declare function loadBrowserConfig(root: string, host: BrowserConfigHost,
|
|
|
47
71
|
/** Validated projects in authored order with root, CSS, and string tsconfig paths resolved. */
|
|
48
72
|
projects: AnalysisProjectConfig[];
|
|
49
73
|
} | undefined>;
|
|
74
|
+
export { documentConfiguration };
|
|
50
75
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as expandProjects, c as selectProject, i as documentConfiguration, l as validateInlineConfig, n as configurationCandidates, o as resolveCompilerSettings, p as resolveConfig, s as resolveProjectPaths, t as compilerConfig } from "./resolution-DCwmb-pa.js";
|
|
2
|
+
import { minimatch } from "minimatch";
|
|
2
3
|
import * as paths from "pathe";
|
|
3
|
-
import { dirname, resolve } from "pathe";
|
|
4
|
+
import { dirname, relative, resolve } from "pathe";
|
|
4
5
|
// src/browser.ts
|
|
5
6
|
/** Evaluates and selects configuration from virtual paths through an embedding's captured files and module runtime. */
|
|
6
7
|
/**
|
|
8
|
+
* Reports the configuration file that failed to load, keeping the message of the original failure.
|
|
9
|
+
*/
|
|
10
|
+
var ConfigurationLoadError = class extends Error {
|
|
11
|
+
/** Absolute virtual path of the file that failed. A referenced file names itself. */
|
|
12
|
+
configFile;
|
|
13
|
+
/**
|
|
14
|
+
* @param configFile - Absolute virtual path of the file that failed.
|
|
15
|
+
* @param cause - Failure from evaluation, validation, or reference expansion.
|
|
16
|
+
*/
|
|
17
|
+
constructor(configFile, cause) {
|
|
18
|
+
super(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
19
|
+
this.configFile = configFile;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
7
23
|
* Discovers and evaluates browser configuration using the same export contract as Node.
|
|
24
|
+
*
|
|
8
25
|
* @param root - Absolute virtual application directory.
|
|
9
26
|
* @param host - Captured file inventory and browser module evaluator.
|
|
10
27
|
* @param inline - Explicit file, project selection, and compiler overrides.
|
|
@@ -37,12 +54,15 @@ async function resolveBrowserConfig(root, host, inline = {}) {
|
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
39
56
|
* Loads every configured project for analysis across a workspace.
|
|
57
|
+
*
|
|
40
58
|
* @param root - Absolute virtual directory where discovery starts.
|
|
41
59
|
* @param host - Captured files and module evaluator.
|
|
42
60
|
* @param requested - Absolute path or nonempty path relative to root. False disables loading, and
|
|
43
61
|
* omission searches root and its ancestors in configurationFiles order within each directory.
|
|
44
|
-
* @returns Evaluated projects with absolute roots,
|
|
45
|
-
*
|
|
62
|
+
* @returns Evaluated projects with absolute roots, including the projects of referenced files, or
|
|
63
|
+
* undefined when loading is disabled or discovery finds no file.
|
|
64
|
+
* @throws If an explicit path is invalid or missing. A {@link ConfigurationLoadError} if evaluation,
|
|
65
|
+
* validation, or reference expansion fails.
|
|
46
66
|
*/
|
|
47
67
|
async function loadBrowserConfig(root, host, requested) {
|
|
48
68
|
if (requested === false) return;
|
|
@@ -54,12 +74,37 @@ async function loadBrowserConfig(root, host, requested) {
|
|
|
54
74
|
if (!host.exists(file)) throw new Error(`Cannot find Stillwind configuration: ${file}`);
|
|
55
75
|
} else file = configurationCandidates(root, paths).find((candidate) => host.exists(candidate));
|
|
56
76
|
if (!file) return;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Evaluates one captured configuration file.
|
|
79
|
+
*
|
|
80
|
+
* @param id - Existing absolute virtual path.
|
|
81
|
+
* @returns Validated settings.
|
|
82
|
+
* @throws If module evaluation or configuration validation fails.
|
|
83
|
+
*/
|
|
84
|
+
const load = async (id) => {
|
|
85
|
+
try {
|
|
86
|
+
return await resolveConfig(await host.evaluate(id));
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw new ConfigurationLoadError(id, error);
|
|
89
|
+
}
|
|
61
90
|
};
|
|
91
|
+
try {
|
|
92
|
+
const projects = await expandProjects(await load(file), file, {
|
|
93
|
+
isFile: (id) => host.exists(id),
|
|
94
|
+
glob: async (patterns, ignore, directory) => [...host.list()].filter((id) => {
|
|
95
|
+
const name = relative(directory, id);
|
|
96
|
+
return patterns.some((pattern) => minimatch(name, pattern)) && !ignore.some((pattern) => minimatch(name, pattern));
|
|
97
|
+
}),
|
|
98
|
+
load
|
|
99
|
+
}, paths);
|
|
100
|
+
return {
|
|
101
|
+
configFile: file,
|
|
102
|
+
projects: projects.map((project) => resolveProjectPaths(project, dirname(file), paths))
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw error instanceof ConfigurationLoadError ? error : new ConfigurationLoadError(file, error);
|
|
106
|
+
}
|
|
62
107
|
}
|
|
63
|
-
export { loadBrowserConfig, resolveBrowserConfig };
|
|
108
|
+
export { ConfigurationLoadError, documentConfiguration, loadBrowserConfig, resolveBrowserConfig };
|
|
64
109
|
|
|
65
110
|
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/** Evaluates and selects configuration from virtual paths through an embedding's captured files and module runtime. */\n\nimport * as paths from \"pathe\";\nimport { dirname, resolve } from \"pathe\";\n\nimport { resolveConfig, type AnalysisProjectConfig } from \"./configuration.ts\";\nimport {\n compilerConfig,\n configurationCandidates,\n resolveCompilerSettings,\n resolveProjectPaths,\n selectProject,\n validateInlineConfig,\n type InlineConfig,\n} from \"./resolution.ts\";\n\n/** Configuration evaluation supplied by a browser module runtime. */\nexport interface BrowserConfigHost {\n /**\n * Tests whether a configuration candidate exists in the captured workspace.\n * @param id - Absolute virtual path supplied by discovery or an explicit file selection.\n * @returns Whether the evaluator can load this path from the captured inventory.\n */\n exists(id: string): boolean;\n /**\n * Evaluates a configuration module without invoking its exported factory.\n * @param id - Existing absolute virtual path selected from the same captured inventory.\n * @returns The module's default export, which resolveConfig subsequently evaluates and validates.\n * @throws If loading or evaluating the module fails.\n */\n evaluate(id: string): Promise<unknown>;\n}\n\n/**\n * Discovers and evaluates browser configuration using the same export contract as Node.\n * @param root - Absolute virtual application directory.\n * @param host - Captured file inventory and browser module evaluator.\n * @param inline - Explicit file, project selection, and compiler overrides.\n * @returns The selected project, configuration identity, and every evaluated project.\n * @throws If an explicit file is missing, evaluation or validation fails, project selection is\n * unsuccessful or ambiguous, or the effective settings lack a nonempty CSS path.\n */\nexport async function resolveBrowserConfig(\n root: string,\n host: BrowserConfigHost,\n inline: InlineConfig = {},\n): Promise<{\n /** Selected project with merged overrides, compiler defaults, and absolute paths. */\n config: AnalysisProjectConfig;\n /** Absolute virtual configuration path, or undefined when no file was loaded. */\n configFile?: string;\n /** Projects in authored order, with the selected entry replaced by config. Inline-only settings return one project. */\n projects: AnalysisProjectConfig[];\n}> {\n root = resolve(root);\n\n validateInlineConfig(inline);\n\n const loaded = await loadBrowserConfig(root, host, inline.configFile);\n const file = loaded?.configFile;\n const projects = loaded?.projects ?? [];\n if (!file && inline.project !== undefined) {\n throw new Error(\"Cannot select a Stillwind project without a configuration file\");\n }\n\n const selected = file\n ? selectProject(\n projects as (AnalysisProjectConfig & {\n /** Absolute virtual root resolved from the configuration directory. */\n root: string;\n })[],\n root,\n inline,\n paths,\n )\n : undefined;\n const settings = resolveCompilerSettings(\n selected\n ? compilerConfig(selected)\n : {\n root,\n lint: inline.lint,\n },\n inline,\n root,\n paths,\n );\n const config: AnalysisProjectConfig = {\n ...selected,\n files: selected?.files ?? [\"**/*\"],\n ...settings,\n };\n\n return {\n config,\n configFile: file,\n projects: projects.length\n ? projects.map((project) => (project === selected ? config : project))\n : [config],\n };\n}\n\n/**\n * Loads every configured project for analysis across a workspace.\n * @param root - Absolute virtual directory where discovery starts.\n * @param host - Captured files and module evaluator.\n * @param requested - Absolute path or nonempty path relative to root. False disables loading, and\n * omission searches root and its ancestors in configurationFiles order within each directory.\n * @returns Evaluated projects with absolute roots, or undefined when loading is disabled or discovery finds no file.\n * @throws If an explicit path is invalid or missing
|
|
1
|
+
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/** Evaluates and selects configuration from virtual paths through an embedding's captured files and module runtime. */\n\nimport { minimatch } from \"minimatch\";\nimport * as paths from \"pathe\";\nimport { dirname, relative, resolve } from \"pathe\";\n\nimport { resolveConfig, type AnalysisProjectConfig } from \"./configuration.ts\";\nimport {\n compilerConfig,\n configurationCandidates,\n expandProjects,\n resolveCompilerSettings,\n resolveProjectPaths,\n selectProject,\n validateInlineConfig,\n type InlineConfig,\n} from \"./resolution.ts\";\n\nexport { documentConfiguration } from \"./resolution.ts\";\n\n/**\n * Reports the configuration file that failed to load, keeping the message of the original failure.\n */\nexport class ConfigurationLoadError extends Error {\n /** Absolute virtual path of the file that failed. A referenced file names itself. */\n readonly configFile: string;\n\n /**\n * @param configFile - Absolute virtual path of the file that failed.\n * @param cause - Failure from evaluation, validation, or reference expansion.\n */\n constructor(configFile: string, cause: unknown) {\n super(cause instanceof Error ? cause.message : String(cause), { cause });\n this.configFile = configFile;\n }\n}\n\n/** Configuration evaluation supplied by a browser module runtime. */\nexport interface BrowserConfigHost {\n /**\n * Tests whether a configuration candidate exists in the captured workspace.\n *\n * @param id - Absolute virtual path supplied by discovery or an explicit file selection.\n * @returns Whether the evaluator can load this path from the captured inventory.\n */\n exists(id: string): boolean;\n /**\n * Enumerates the captured workspace for glob references in configuration.\n *\n * @returns Absolute virtual paths of captured files.\n */\n list(): Iterable<string>;\n /**\n * Evaluates a configuration module without invoking its exported factory.\n *\n * @param id - Existing absolute virtual path selected from the same captured inventory.\n * @returns The module's default export, which resolveConfig subsequently evaluates and validates.\n * @throws If loading or evaluating the module fails.\n */\n evaluate(id: string): Promise<unknown>;\n}\n\n/**\n * Discovers and evaluates browser configuration using the same export contract as Node.\n *\n * @param root - Absolute virtual application directory.\n * @param host - Captured file inventory and browser module evaluator.\n * @param inline - Explicit file, project selection, and compiler overrides.\n * @returns The selected project, configuration identity, and every evaluated project.\n * @throws If an explicit file is missing, evaluation or validation fails, project selection is\n * unsuccessful or ambiguous, or the effective settings lack a nonempty CSS path.\n */\nexport async function resolveBrowserConfig(\n root: string,\n host: BrowserConfigHost,\n inline: InlineConfig = {},\n): Promise<{\n /** Selected project with merged overrides, compiler defaults, and absolute paths. */\n config: AnalysisProjectConfig;\n /** Absolute virtual configuration path, or undefined when no file was loaded. */\n configFile?: string;\n /** Projects in authored order, with the selected entry replaced by config. Inline-only settings return one project. */\n projects: AnalysisProjectConfig[];\n}> {\n root = resolve(root);\n\n validateInlineConfig(inline);\n\n const loaded = await loadBrowserConfig(root, host, inline.configFile);\n const file = loaded?.configFile;\n const projects = loaded?.projects ?? [];\n if (!file && inline.project !== undefined) {\n throw new Error(\"Cannot select a Stillwind project without a configuration file\");\n }\n\n const selected = file\n ? selectProject(\n projects as (AnalysisProjectConfig & {\n /** Absolute virtual root resolved from the configuration directory. */\n root: string;\n })[],\n root,\n inline,\n paths,\n )\n : undefined;\n const settings = resolveCompilerSettings(\n selected\n ? compilerConfig(selected)\n : {\n root,\n lint: inline.lint,\n },\n inline,\n root,\n paths,\n );\n const config: AnalysisProjectConfig = {\n ...selected,\n files: selected?.files ?? [\"**/*\"],\n ...settings,\n };\n\n return {\n config,\n configFile: file,\n projects: projects.length\n ? projects.map((project) => (project === selected ? config : project))\n : [config],\n };\n}\n\n/**\n * Loads every configured project for analysis across a workspace.\n *\n * @param root - Absolute virtual directory where discovery starts.\n * @param host - Captured files and module evaluator.\n * @param requested - Absolute path or nonempty path relative to root. False disables loading, and\n * omission searches root and its ancestors in configurationFiles order within each directory.\n * @returns Evaluated projects with absolute roots, including the projects of referenced files, or\n * undefined when loading is disabled or discovery finds no file.\n * @throws If an explicit path is invalid or missing. A {@link ConfigurationLoadError} if evaluation,\n * validation, or reference expansion fails.\n */\nexport async function loadBrowserConfig(\n root: string,\n host: BrowserConfigHost,\n requested?: string | false,\n): Promise<\n | {\n /** Absolute virtual path selected for evaluation. */\n configFile: string;\n /** Validated projects in authored order with root, CSS, and string tsconfig paths resolved. */\n projects: AnalysisProjectConfig[];\n }\n | undefined\n> {\n if (requested === false) {\n return undefined;\n }\n if (requested !== undefined && (typeof requested !== \"string\" || !requested.trim())) {\n throw new Error(\"Stillwind configFile must be a path or false\");\n }\n\n root = resolve(root);\n\n let file: string | undefined;\n if (requested) {\n file = resolve(root, requested);\n if (!host.exists(file)) {\n throw new Error(`Cannot find Stillwind configuration: ${file}`);\n }\n } else {\n file = configurationCandidates(root, paths).find((candidate) => host.exists(candidate));\n }\n if (!file) {\n return undefined;\n }\n\n /**\n * Evaluates one captured configuration file.\n *\n * @param id - Existing absolute virtual path.\n * @returns Validated settings.\n * @throws If module evaluation or configuration validation fails.\n */\n const load = async (id: string) => {\n try {\n return await resolveConfig(await host.evaluate(id));\n } catch (error) {\n throw new ConfigurationLoadError(id, error);\n }\n };\n try {\n const projects = await expandProjects(\n await load(file),\n file,\n {\n isFile: (id) => host.exists(id),\n glob: async (patterns, ignore, directory) =>\n [...host.list()].filter((id) => {\n const name = relative(directory, id);\n return (\n patterns.some((pattern) => minimatch(name, pattern)) &&\n !ignore.some((pattern) => minimatch(name, pattern))\n );\n }),\n load,\n },\n paths,\n );\n return {\n configFile: file,\n projects: projects.map((project) => resolveProjectPaths(project, dirname(file!), paths)),\n };\n } catch (error) {\n throw error instanceof ConfigurationLoadError ? error : new ConfigurationLoadError(file, error);\n }\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAa,yBAAb,cAA4C,MAAM;;CAEhD;;;;;CAMA,YAAY,YAAoB,OAAgB;EAC9C,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EAAE,MAAM,CAAC;EACvE,KAAK,aAAa;CACpB;AACF;;;;;;;;;;;AAqCA,eAAsB,qBACpB,MACA,MACA,SAAuB,CAAC,GAQvB;CACD,OAAO,QAAQ,IAAI;CAEnB,qBAAqB,MAAM;CAE3B,MAAM,SAAS,MAAM,kBAAkB,MAAM,MAAM,OAAO,UAAU;CACpE,MAAM,OAAO,QAAQ;CACrB,MAAM,WAAW,QAAQ,YAAY,CAAC;CACtC,IAAI,CAAC,QAAQ,OAAO,YAAY,KAAA,GAC9B,MAAM,IAAI,MAAM,gEAAgE;CAGlF,MAAM,WAAW,OACb,cACE,UAIA,MACA,QACA,KACF,IACA,KAAA;CACJ,MAAM,WAAW,wBACf,WACI,eAAe,QAAQ,IACvB;EACE;EACA,MAAM,OAAO;CACf,GACJ,QACA,MACA,KACF;CACA,MAAM,SAAgC;EACpC,GAAG;EACH,OAAO,UAAU,SAAS,CAAC,MAAM;EACjC,GAAG;CACL;CAEA,OAAO;EACL;EACA,YAAY;EACZ,UAAU,SAAS,SACf,SAAS,KAAK,YAAa,YAAY,WAAW,SAAS,OAAQ,IACnE,CAAC,MAAM;CACb;AACF;;;;;;;;;;;;;AAcA,eAAsB,kBACpB,MACA,MACA,WASA;CACA,IAAI,cAAc,OAChB;CAEF,IAAI,cAAc,KAAA,MAAc,OAAO,cAAc,YAAY,CAAC,UAAU,KAAK,IAC/E,MAAM,IAAI,MAAM,8CAA8C;CAGhE,OAAO,QAAQ,IAAI;CAEnB,IAAI;CACJ,IAAI,WAAW;EACb,OAAO,QAAQ,MAAM,SAAS;EAC9B,IAAI,CAAC,KAAK,OAAO,IAAI,GACnB,MAAM,IAAI,MAAM,wCAAwC,MAAM;CAElE,OACE,OAAO,wBAAwB,MAAM,KAAK,CAAC,CAAC,MAAM,cAAc,KAAK,OAAO,SAAS,CAAC;CAExF,IAAI,CAAC,MACH;;;;;;;;CAUF,MAAM,OAAO,OAAO,OAAe;EACjC,IAAI;GACF,OAAO,MAAM,cAAc,MAAM,KAAK,SAAS,EAAE,CAAC;EACpD,SAAS,OAAO;GACd,MAAM,IAAI,uBAAuB,IAAI,KAAK;EAC5C;CACF;CACA,IAAI;EACF,MAAM,WAAW,MAAM,eACrB,MAAM,KAAK,IAAI,GACf,MACA;GACE,SAAS,OAAO,KAAK,OAAO,EAAE;GAC9B,MAAM,OAAO,UAAU,QAAQ,cAC7B,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,OAAO;IAC9B,MAAM,OAAO,SAAS,WAAW,EAAE;IACnC,OACE,SAAS,MAAM,YAAY,UAAU,MAAM,OAAO,CAAC,KACnD,CAAC,OAAO,MAAM,YAAY,UAAU,MAAM,OAAO,CAAC;GAEtD,CAAC;GACH;EACF,GACA,KACF;EACA,OAAO;GACL,YAAY;GACZ,UAAU,SAAS,KAAK,YAAY,oBAAoB,SAAS,QAAQ,IAAK,GAAG,KAAK,CAAC;EACzF;CACF,SAAS,OAAO;EACd,MAAM,iBAAiB,yBAAyB,QAAQ,IAAI,uBAAuB,MAAM,KAAK;CAChG;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as lintRules, A as definePlugin, B as LintScope, C as UtilitySortOptions, D as PluginDirectoryEntry, E as PluginContext, F as ImportantOptions, G as RestrictedDeclarationsOptions, H as LogicalPropertiesOptions, I as LengthUnitsOptions, J as VariantDirectiveOptions, K as RestrictedThemeTokensOptions, L as LintConfig, M as CanonicalUtilitiesOptions, N as ConflictingUtilitiesOptions, O as PluginWatchKind, P as DefinitionScope, Q as LintRule, R as LintPreset, S as TailwindConfig, T as validateCompilerConfig, U as MarkerUseOptions, V as LintSeverity, W as ResolvedLintRules, X as resolveLintConfig, Y as mergeLintConfig, Z as LintCategory, _ as validateConfig, a as AnalysisProjectConfig, b as BuildOptions, c as ProjectionProvider, d as StillwindConfig, f as StillwindConfigExport, g as resolveConfig, h as defineConfig, j as ArbitrarySpacingOptions, k as StillwindPlugin, l as SourceProvider, m as captureProjectConfig, n as SerializableInlineConfig, o as CapturedProjectConfig, p as StillwindConfigFactory, q as RestrictedUtilitiesOptions, r as configurationFiles, s as PreviewOptions, t as InlineConfig, u as SourceProviderContext, v as BaseConfig, w as normalizeCompilerConfig, x as NormalizedCompilerConfig, y as BuildConfig, z as LintRules } from "./resolution-D-_c0Q11.js";
|
|
2
2
|
/**
|
|
3
3
|
* Built-in lint policies for ordered preset composition. Treat their shared objects as readonly.
|
|
4
4
|
* Recommended supplies the omitted-lint default. Strict denies every recommended rule and adds
|
|
@@ -43,10 +43,10 @@ export declare const lintPresets: {
|
|
|
43
43
|
readonly "interfering-imported-style-base": "warn";
|
|
44
44
|
readonly "incompatible-property-value": "deny";
|
|
45
45
|
readonly "invalid-utility": "deny";
|
|
46
|
-
readonly "unknown-utility": "
|
|
46
|
+
readonly "unknown-utility": "deny";
|
|
47
47
|
readonly "invalid-marker-use": "warn";
|
|
48
48
|
readonly "invalid-variant": "deny";
|
|
49
|
-
readonly "unknown-variant": "
|
|
49
|
+
readonly "unknown-variant": "deny";
|
|
50
50
|
readonly "missing-document-target": "deny";
|
|
51
51
|
readonly "prefer-canonical-utilities": "warn";
|
|
52
52
|
readonly "redundant-variant": "warn";
|
|
@@ -61,7 +61,7 @@ export declare const lintPresets: {
|
|
|
61
61
|
readonly "ignored-definition-condition": "deny";
|
|
62
62
|
readonly "incompatible-theme-value": "deny";
|
|
63
63
|
readonly "ignored-tailwind-feature": "warn";
|
|
64
|
-
readonly "
|
|
64
|
+
readonly "implicit-nesting-selector": "warn";
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
readonly strict: {
|
|
@@ -104,10 +104,10 @@ export declare const lintPresets: {
|
|
|
104
104
|
readonly "interfering-imported-style-base": "warn";
|
|
105
105
|
readonly "incompatible-property-value": "deny";
|
|
106
106
|
readonly "invalid-utility": "deny";
|
|
107
|
-
readonly "unknown-utility": "
|
|
107
|
+
readonly "unknown-utility": "deny";
|
|
108
108
|
readonly "invalid-marker-use": "warn";
|
|
109
109
|
readonly "invalid-variant": "deny";
|
|
110
|
-
readonly "unknown-variant": "
|
|
110
|
+
readonly "unknown-variant": "deny";
|
|
111
111
|
readonly "missing-document-target": "deny";
|
|
112
112
|
readonly "prefer-canonical-utilities": "warn";
|
|
113
113
|
readonly "redundant-variant": "warn";
|
|
@@ -122,7 +122,7 @@ export declare const lintPresets: {
|
|
|
122
122
|
readonly "ignored-definition-condition": "deny";
|
|
123
123
|
readonly "incompatible-theme-value": "deny";
|
|
124
124
|
readonly "ignored-tailwind-feature": "warn";
|
|
125
|
-
readonly "
|
|
125
|
+
readonly "implicit-nesting-selector": "warn";
|
|
126
126
|
};
|
|
127
127
|
}];
|
|
128
128
|
readonly rules: {
|
|
@@ -179,7 +179,7 @@ export declare const lintPresets: {
|
|
|
179
179
|
readonly "ignored-definition-condition": "deny";
|
|
180
180
|
readonly "incompatible-theme-value": "deny";
|
|
181
181
|
readonly "ignored-tailwind-feature": "deny";
|
|
182
|
-
readonly "
|
|
182
|
+
readonly "implicit-nesting-selector": "deny";
|
|
183
183
|
readonly "unused-lint-suppression": "deny";
|
|
184
184
|
};
|
|
185
185
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as mergeLintConfig, b as lintPresets, d as captureProjectConfig, f as defineConfig, g as validateCompilerConfig, h as normalizeCompilerConfig, m as validateConfig, p as resolveConfig, r as configurationFiles, u as mergeConfig, v as resolveLintConfig, y as lintRules } from "./resolution-DCwmb-pa.js";
|
|
2
2
|
// src/plugins.ts
|
|
3
3
|
/**
|
|
4
4
|
* Returns `plugin` unchanged with its type checked, for use in a configuration file.
|
package/dist/node.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
1
|
+
import { a as AnalysisProjectConfig, t as InlineConfig, v as BaseConfig, x as NormalizedCompilerConfig } from "./resolution-D-_c0Q11.js";
|
|
2
|
+
/**
|
|
3
|
+
* Evaluated settings and files that consumers must watch when retaining a compiler session.
|
|
4
|
+
*/
|
|
3
5
|
export interface LoadedConfiguration {
|
|
4
6
|
/** Validated settings after awaiting the module export and invoking its factory, if supplied. */
|
|
5
|
-
config:
|
|
7
|
+
config: {
|
|
8
|
+
/**
|
|
9
|
+
* Projects in authored order with references replaced. Referenced projects have an absolute
|
|
10
|
+
* root. Other projects keep their authored paths.
|
|
11
|
+
*/
|
|
12
|
+
projects: AnalysisProjectConfig[];
|
|
13
|
+
};
|
|
6
14
|
/** Absolute path of the evaluated configuration file. */
|
|
7
15
|
configFile: string;
|
|
8
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Distinct absolute paths of the configuration, referenced configurations, bundled local imports,
|
|
18
|
+
* and resolved external imports. A file that a glob reference would newly match is not included.
|
|
19
|
+
*/
|
|
9
20
|
dependencies: string[];
|
|
10
21
|
}
|
|
11
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Settings for one build integration after project selection and inline overrides.
|
|
24
|
+
*/
|
|
12
25
|
export interface ResolvedIntegrationConfig {
|
|
13
26
|
/** Selected compiler settings after inline overrides and defaults. Filesystem paths are absolute. */
|
|
14
27
|
config: NormalizedCompilerConfig & {
|
|
@@ -31,7 +44,18 @@ export interface ResolvedIntegrationConfig {
|
|
|
31
44
|
* @returns The first existing candidate's absolute path, or undefined if none exists.
|
|
32
45
|
*/
|
|
33
46
|
export declare function findConfiguration(directory: string): string | undefined;
|
|
34
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Finds the nearest configuration of a document in a workspace folder, without evaluating it.
|
|
49
|
+
*
|
|
50
|
+
* @param file - Absolute document path.
|
|
51
|
+
* @param folders - Absolute workspace folders.
|
|
52
|
+
* @returns The configuration path, or undefined when the document lies outside the folders or in
|
|
53
|
+
* `node_modules`, or the folder has no configuration at or above the document.
|
|
54
|
+
*/
|
|
55
|
+
export declare function findDocumentConfiguration(file: string, folders: readonly string[]): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* An evaluated module and the files that its evaluation read.
|
|
58
|
+
*/
|
|
35
59
|
export interface EvaluatedModule {
|
|
36
60
|
/** Default export, or the module value when it has no default export. */
|
|
37
61
|
exported: unknown;
|
|
@@ -59,13 +83,15 @@ export interface EvaluatedModule {
|
|
|
59
83
|
*/
|
|
60
84
|
export declare function evaluateModule(file: string): Promise<EvaluatedModule>;
|
|
61
85
|
/**
|
|
62
|
-
* Evaluates a configuration module with {@link evaluateModule}
|
|
63
|
-
* Configuration runs as trusted Node code
|
|
86
|
+
* Evaluates a configuration module with {@link evaluateModule}, validates its settings, and
|
|
87
|
+
* evaluates the configuration files that it references. Configuration runs as trusted Node code
|
|
88
|
+
* and can perform side effects.
|
|
64
89
|
*
|
|
65
90
|
* @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.
|
|
66
91
|
* @returns Evaluated settings and the file paths observed while resolving and bundling imports.
|
|
67
92
|
* Runtime file reads and imports that cannot be statically resolved are not added to dependencies.
|
|
68
|
-
* @throws If bundling, module evaluation, factory execution,
|
|
93
|
+
* @throws If bundling, module evaluation, factory execution, configuration validation, or reference
|
|
94
|
+
* expansion fails.
|
|
69
95
|
*/
|
|
70
96
|
export declare function loadConfiguration(file: string): Promise<LoadedConfiguration>;
|
|
71
97
|
/**
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as expandProjects, c as selectProject, i as documentConfiguration, l as validateInlineConfig, n as configurationCandidates$1, o as resolveCompilerSettings, p as resolveConfig, s as resolveProjectPaths, t as compilerConfig } from "./resolution-DCwmb-pa.js";
|
|
2
2
|
import { isBuiltin } from "node:module";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
3
|
+
import { existsSync, statSync } from "node:fs";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { createJiti } from "jiti";
|
|
8
8
|
import { rolldown } from "rolldown";
|
|
9
|
+
import { glob } from "tinyglobby";
|
|
9
10
|
// src/node.ts
|
|
10
11
|
/**
|
|
11
12
|
* Node configuration discovery, evaluation, and project selection. `loadConfiguration` opens an
|
|
@@ -23,6 +24,17 @@ function findConfiguration(directory) {
|
|
|
23
24
|
return configurationCandidates$1(directory, path).find((file) => existsSync(file));
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
27
|
+
* Finds the nearest configuration of a document in a workspace folder, without evaluating it.
|
|
28
|
+
*
|
|
29
|
+
* @param file - Absolute document path.
|
|
30
|
+
* @param folders - Absolute workspace folders.
|
|
31
|
+
* @returns The configuration path, or undefined when the document lies outside the folders or in
|
|
32
|
+
* `node_modules`, or the folder has no configuration at or above the document.
|
|
33
|
+
*/
|
|
34
|
+
function findDocumentConfiguration(file, folders) {
|
|
35
|
+
return documentConfiguration(file, folders, existsSync, path);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
26
38
|
* Bundles local imports of a module in memory and evaluates the bundle without module
|
|
27
39
|
* caches. Local sources are read again on each call, so a changed local import takes
|
|
28
40
|
* effect. External packages use runtime module loading, and Node keeps them cached. The
|
|
@@ -64,6 +76,7 @@ async function evaluateModule(file) {
|
|
|
64
76
|
name: "stillwind-module",
|
|
65
77
|
/**
|
|
66
78
|
* Resolves external packages from their importer and records their paths for watching.
|
|
79
|
+
*
|
|
67
80
|
* @param id - Import request before resolution.
|
|
68
81
|
* @param importer - Importing file, or undefined for the entry.
|
|
69
82
|
* @param options - Import kind used to select package export conditions.
|
|
@@ -89,6 +102,7 @@ async function evaluateModule(file) {
|
|
|
89
102
|
},
|
|
90
103
|
/**
|
|
91
104
|
* Reads a bundled local file and records its text.
|
|
105
|
+
*
|
|
92
106
|
* @param id - Absolute path of a local file, or a virtual module ID.
|
|
93
107
|
* @returns The file's text, or undefined for a virtual module.
|
|
94
108
|
*/
|
|
@@ -102,6 +116,7 @@ async function evaluateModule(file) {
|
|
|
102
116
|
filter: { id: /\.[cm]?[jt]sx?$/ },
|
|
103
117
|
/**
|
|
104
118
|
* Keeps file location expressions relative to each original source.
|
|
119
|
+
*
|
|
105
120
|
* @param code - Local module source.
|
|
106
121
|
* @param id - Absolute source path.
|
|
107
122
|
* @returns Source with its file location constants before ordinary syntax lowering.
|
|
@@ -142,21 +157,44 @@ ${code}`;
|
|
|
142
157
|
};
|
|
143
158
|
}
|
|
144
159
|
/**
|
|
145
|
-
* Evaluates a configuration module with {@link evaluateModule}
|
|
146
|
-
* Configuration runs as trusted Node code
|
|
160
|
+
* Evaluates a configuration module with {@link evaluateModule}, validates its settings, and
|
|
161
|
+
* evaluates the configuration files that it references. Configuration runs as trusted Node code
|
|
162
|
+
* and can perform side effects.
|
|
147
163
|
*
|
|
148
164
|
* @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.
|
|
149
165
|
* @returns Evaluated settings and the file paths observed while resolving and bundling imports.
|
|
150
166
|
* Runtime file reads and imports that cannot be statically resolved are not added to dependencies.
|
|
151
|
-
* @throws If bundling, module evaluation, factory execution,
|
|
167
|
+
* @throws If bundling, module evaluation, factory execution, configuration validation, or reference
|
|
168
|
+
* expansion fails.
|
|
152
169
|
*/
|
|
153
170
|
async function loadConfiguration(file) {
|
|
154
171
|
file = path.resolve(file);
|
|
155
|
-
const
|
|
172
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
173
|
+
/**
|
|
174
|
+
* Evaluates one configuration file and records the files that its evaluation read.
|
|
175
|
+
*
|
|
176
|
+
* @param id - Absolute configuration path.
|
|
177
|
+
* @returns Validated settings.
|
|
178
|
+
* @throws If module evaluation or configuration validation fails.
|
|
179
|
+
*/
|
|
180
|
+
const load = async (id) => {
|
|
181
|
+
const evaluated = await evaluateModule(id);
|
|
182
|
+
for (const dependency of evaluated.dependencies) dependencies.add(dependency);
|
|
183
|
+
return resolveConfig(evaluated.exported);
|
|
184
|
+
};
|
|
156
185
|
return {
|
|
157
|
-
config: await
|
|
186
|
+
config: { projects: await expandProjects(await load(file), file, {
|
|
187
|
+
isFile: (id) => statSync(id, { throwIfNoEntry: false })?.isFile() ?? false,
|
|
188
|
+
glob: async (patterns, ignore, directory) => (await glob(patterns, {
|
|
189
|
+
cwd: directory,
|
|
190
|
+
absolute: true,
|
|
191
|
+
expandDirectories: false,
|
|
192
|
+
ignore
|
|
193
|
+
})).map((match) => path.resolve(match)),
|
|
194
|
+
load
|
|
195
|
+
}, path) },
|
|
158
196
|
configFile: file,
|
|
159
|
-
dependencies
|
|
197
|
+
dependencies: [...dependencies]
|
|
160
198
|
};
|
|
161
199
|
}
|
|
162
200
|
/**
|
|
@@ -215,6 +253,7 @@ async function resolveIntegrationConfig(inline, applicationRoot, defaults = {})
|
|
|
215
253
|
}
|
|
216
254
|
/**
|
|
217
255
|
* Enumerates Node configuration candidates without checking existence.
|
|
256
|
+
*
|
|
218
257
|
* @param directory - Starting directory. Relative paths use the process working directory.
|
|
219
258
|
* @returns Absolute paths ordered from the nearest directory to the filesystem root, with
|
|
220
259
|
* configurationFiles precedence within each directory.
|
|
@@ -222,6 +261,6 @@ async function resolveIntegrationConfig(inline, applicationRoot, defaults = {})
|
|
|
222
261
|
function configurationCandidates(directory) {
|
|
223
262
|
return configurationCandidates$1(directory, path);
|
|
224
263
|
}
|
|
225
|
-
export { evaluateModule, findConfiguration, loadConfiguration, resolveIntegrationConfig, resolveProjectConfig };
|
|
264
|
+
export { evaluateModule, findConfiguration, findDocumentConfiguration, loadConfiguration, resolveIntegrationConfig, resolveProjectConfig };
|
|
226
265
|
|
|
227
266
|
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":["candidates"],"sources":["../src/node.ts"],"sourcesContent":["/**\n * Node configuration discovery, evaluation, and project selection. `loadConfiguration` opens an\n * explicit file. `resolveIntegrationConfig` also discovers files and applies build overrides.\n * `evaluateModule` bundles and evaluates other local modules, such as plugin files. Consumers\n * retaining compiler state use the returned dependency paths for change tracking.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport { createJiti } from \"jiti\";\nimport { rolldown } from \"rolldown\";\n\nimport type { BaseConfig, NormalizedCompilerConfig } from \"./compiler.ts\";\nimport {\n resolveConfig,\n type AnalysisProjectConfig,\n type StillwindConfig,\n} from \"./configuration.ts\";\nimport {\n configurationCandidates as candidates,\n compilerConfig,\n resolveCompilerSettings,\n resolveProjectPaths,\n selectProject,\n validateInlineConfig,\n type InlineConfig,\n} from \"./resolution.ts\";\n\n/** Evaluated settings and files that consumers must watch when retaining a compiler session. */\nexport interface LoadedConfiguration {\n /** Validated settings after awaiting the module export and invoking its factory, if supplied. */\n config: StillwindConfig;\n /** Absolute path of the evaluated configuration file. */\n configFile: string;\n /** Distinct absolute paths of the configuration, bundled local imports, and resolved external imports. */\n dependencies: string[];\n}\n\n/** Settings for one build integration after project selection and inline overrides. */\nexport interface ResolvedIntegrationConfig {\n /** Selected compiler settings after inline overrides and defaults. Filesystem paths are absolute. */\n config: NormalizedCompilerConfig & {\n /** Absolute selected project directory after applying inline overrides. */\n root: string;\n /** Absolute design-system stylesheet path, without an existence check. */\n css: string;\n };\n /** Absolute evaluated configuration path, or undefined when no file was loaded. */\n configFile?: string;\n /** Existing configuration dependency paths to watch. Empty when settings are entirely inline. */\n dependencies: string[];\n /** Absolute missing candidate paths before the selected file, nearest directory first. Watch their creation. */\n missing: string[];\n}\n\n/**\n * Finds the nearest supported stillwind.config.* file at or above an application directory.\n *\n * @param directory - Directory to start from. Relative paths use the process working directory.\n * @returns The first existing candidate's absolute path, or undefined if none exists.\n */\nexport function findConfiguration(directory: string): string | undefined {\n return candidates(directory, path).find((file) => existsSync(file));\n}\n\n/** An evaluated module and the files that its evaluation read. */\nexport interface EvaluatedModule {\n /** Default export, or the module value when it has no default export. */\n exported: unknown;\n /** Distinct absolute paths of the entry, bundled local imports, and resolved external imports. */\n dependencies: string[];\n /** Text of each bundled local file, keyed by absolute path, as the bundler read it. */\n sources: Map<string, string>;\n}\n\n/**\n * Bundles local imports of a module in memory and evaluates the bundle without module\n * caches. Local sources are read again on each call, so a changed local import takes\n * effect. External packages use runtime module loading, and Node keeps them cached. The\n * module runs as trusted Node code and can perform side effects. Evaluation is\n * available before a framework generates its TypeScript configuration.\n *\n * `import.meta.url`, `import.meta.filename`, `import.meta.dirname`, `__filename`, and\n * `__dirname` describe the original source file of each bundled module.\n *\n * @param file - JS, TS, or JSON module path. Relative paths use the process working\n * directory.\n * @returns The export and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to\n * dependencies.\n * @throws If a package cannot be resolved, or bundling or module evaluation fails.\n */\nexport async function evaluateModule(file: string): Promise<EvaluatedModule> {\n file = path.resolve(file);\n\n const dependencies = new Set([file]);\n const sources = new Map<string, string>();\n const bundle = await rolldown({\n input: file,\n cwd: path.dirname(file),\n logLevel: \"silent\",\n platform: \"node\",\n treeshake: false,\n tsconfig: false,\n transform: {\n target: \"node22\",\n define: {\n \"import.meta.url\": \"__stillwind_module_url\",\n \"import.meta.filename\": \"__stillwind_module_filename\",\n \"import.meta.dirname\": \"__stillwind_module_dirname\",\n __filename: \"__stillwind_module_filename\",\n __dirname: \"__stillwind_module_dirname\",\n },\n },\n plugins: [\n {\n name: \"stillwind-module\",\n /**\n * Resolves external packages from their importer and records their paths for watching.\n * @param id - Import request before resolution.\n * @param importer - Importing file, or undefined for the entry.\n * @param options - Import kind used to select package export conditions.\n * @returns An external module URL or require path, or undefined for bundled local sources.\n * @throws If a package cannot be resolved.\n */\n async resolveId(id, importer, options) {\n if (!importer || id.startsWith(\".\") || path.isAbsolute(id)) {\n return;\n }\n if (isBuiltin(id)) {\n return {\n id,\n external: true,\n };\n }\n const resolved = await this.resolve(id, importer, {\n skipSelf: true,\n kind: options.kind,\n });\n if (!resolved) {\n throw new Error(`Cannot resolve import ${id} from ${importer}`);\n }\n dependencies.add(resolved.id);\n return {\n id: options.kind === \"require-call\" ? resolved.id : pathToFileURL(resolved.id).href,\n external: \"absolute\",\n };\n },\n /**\n * Reads a bundled local file and records its text.\n * @param id - Absolute path of a local file, or a virtual module ID.\n * @returns The file's text, or undefined for a virtual module.\n */\n async load(id) {\n if (id.startsWith(\"\\0\")) {\n return;\n }\n const code = await readFile(id, \"utf8\");\n sources.set(id, code);\n return code;\n },\n transform: {\n filter: {\n id: /\\.[cm]?[jt]sx?$/,\n },\n /**\n * Keeps file location expressions relative to each original source.\n * @param code - Local module source.\n * @param id - Absolute source path.\n * @returns Source with its file location constants before ordinary syntax lowering.\n */\n handler(code, id) {\n return `const __stillwind_module_url = ${JSON.stringify(pathToFileURL(id).href)};\nconst __stillwind_module_filename = ${JSON.stringify(id)};\nconst __stillwind_module_dirname = ${JSON.stringify(path.dirname(id))};\n${code}`;\n },\n },\n },\n ],\n });\n\n let code: string;\n try {\n const result = await bundle.generate({\n format: \"esm\",\n codeSplitting: false,\n });\n const entry = result.output.find((output) => output.type === \"chunk\" && output.isEntry);\n if (entry?.type !== \"chunk\") {\n throw new Error(`Module bundle has no entry: ${file}`);\n }\n for (const id of entry.moduleIds) {\n if (!id.startsWith(\"\\0\")) {\n dependencies.add(id);\n }\n }\n code = entry.code;\n } finally {\n await bundle.close();\n }\n\n const jiti = createJiti(pathToFileURL(file).href, {\n fsCache: false,\n moduleCache: false,\n });\n const value = await jiti.evalModule(code, {\n filename: file.replaceAll(\"\\\\\", \"/\"),\n async: true,\n forceTranspile: true,\n });\n return {\n exported:\n value !== null && typeof value === \"object\" && \"default\" in value ? value.default : value,\n dependencies: [...dependencies],\n sources,\n };\n}\n\n/**\n * Evaluates a configuration module with {@link evaluateModule} and validates its settings.\n * Configuration runs as trusted Node code and can perform side effects.\n *\n * @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.\n * @returns Evaluated settings and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to dependencies.\n * @throws If bundling, module evaluation, factory execution, or configuration validation fails.\n */\nexport async function loadConfiguration(file: string): Promise<LoadedConfiguration> {\n file = path.resolve(file);\n const { exported, dependencies } = await evaluateModule(file);\n return {\n config: await resolveConfig(exported),\n configFile: file,\n dependencies,\n };\n}\n\n/**\n * Resolves project paths and removes analysis scope and provider settings.\n *\n * @param project - Evaluated project configuration with paths relative to its root.\n * @param directory - Base directory for a relative project root, normally the configuration directory.\n * @returns Compiler settings with absolute root, CSS, and tsconfig paths. The supplied project is not modified.\n * A false or omitted tsconfig setting is preserved.\n * @throws If compiler normalization fails or the project does not supply a valid CSS path.\n */\nexport function resolveProjectConfig(\n project: AnalysisProjectConfig,\n directory: string,\n): NormalizedCompilerConfig & {\n /** Absolute root resolved against directory. */\n root: string;\n /** Absolute CSS entrypoint resolved against the project's root. */\n css: string;\n} {\n const resolved = resolveProjectPaths(project, directory, path);\n return resolveCompilerSettings(compilerConfig(resolved), {}, resolved.root, path);\n}\n\n/**\n * Loads build settings and merges inline overrides into one selected project's compiler settings.\n * Without an explicit name, selection uses the sole project or the unique deepest root containing\n * the application directory after its inline root override. Arrays are replaced during merging.\n *\n * @param inline - File selection, optional project name, and compiler overrides. An inline root\n * uses applicationRoot. A configured root uses the configuration file's directory.\n * @param applicationRoot - Build directory used for discovery and relative inline paths.\n * Relative paths use the process working directory.\n * @param defaults - Browser targets used when the selected project and inline settings omit target.\n * @returns Validated compiler settings with an absolute root and paths to watch. When discovery\n * finds no file, inline settings must supply a CSS entrypoint.\n * @throws If an explicit file is missing, project selection is ambiguous or unsuccessful,\n * configuration evaluation fails, or merged compiler settings are invalid.\n */\nexport async function resolveIntegrationConfig(\n inline: InlineConfig,\n applicationRoot: string,\n defaults: Pick<BaseConfig, \"target\"> = {},\n): Promise<ResolvedIntegrationConfig> {\n applicationRoot = path.resolve(applicationRoot);\n\n validateInlineConfig(inline);\n const requested = inline.configFile;\n const candidates =\n requested === false\n ? []\n : requested\n ? [path.resolve(applicationRoot, requested)]\n : configurationCandidates(applicationRoot);\n const file = candidates.find((candidate) => existsSync(candidate));\n const missing = candidates.slice(0, file ? candidates.indexOf(file) : candidates.length);\n if (requested && !file) {\n throw new Error(`Cannot find Stillwind configuration: ${candidates[0]}`);\n }\n\n const loaded = file ? await loadConfiguration(file) : undefined;\n const projects = loaded?.config.projects.map((project) =>\n resolveProjectPaths(project, path.dirname(file!), path),\n );\n if (!projects && inline.project !== undefined) {\n throw new Error(\"Cannot select a Stillwind project without a configuration file\");\n }\n\n const selected = projects ? selectProject(projects, applicationRoot, inline, path) : undefined;\n const base = selected\n ? compilerConfig(selected)\n : {\n root: applicationRoot,\n lint: inline.lint,\n };\n const config = resolveCompilerSettings(\n { ...base, target: base.target ?? defaults.target },\n inline,\n applicationRoot,\n path,\n );\n\n return {\n config,\n configFile: file,\n dependencies: loaded?.dependencies ?? [],\n missing,\n };\n}\n\n/**\n * Enumerates Node configuration candidates without checking existence.\n * @param directory - Starting directory. Relative paths use the process working directory.\n * @returns Absolute paths ordered from the nearest directory to the filesystem root, with\n * configurationFiles precedence within each directory.\n */\nfunction configurationCandidates(directory: string): string[] {\n return candidates(directory, path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiEA,SA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;;;AAiBA,eAAsB,yBACpB,QACA,iBACA,WAAuC,CAAC,GACJ;CACpC,kBAAkB,KAAK,QAAQ,eAAe;CAE9C,qBAAqB,MAAM;CAC3B,MAAM,YAAY,OAAO;CACzB,MAAM,aACJ,cAAc,QACV,CAAC,IACD,YACE,CAAC,KAAK,QAAQ,iBAAiB,SAAS,CAAC,IACzC,wBAAwB,eAAe;CAC/C,MAAM,OAAO,WAAW,MAAM,cAAc,WAAW,SAAS,CAAC;CACjE,MAAM,UAAU,WAAW,MAAM,GAAG,OAAO,WAAW,QAAQ,IAAI,IAAI,WAAW,MAAM;CACvF,IAAI,aAAa,CAAC,MAChB,MAAM,IAAI,MAAM,wCAAwC,WAAW,IAAI;CAGzE,MAAM,SAAS,OAAO,MAAM,kBAAkB,IAAI,IAAI,KAAA;CACtD,MAAM,WAAW,QAAQ,OAAO,SAAS,KAAK,YAC5C,oBAAoB,SAAS,KAAK,QAAQ,IAAK,GAAG,IAAI,CACxD;CACA,IAAI,CAAC,YAAY,OAAO,YAAY,KAAA,GAClC,MAAM,IAAI,MAAM,gEAAgE;CAGlF,MAAM,WAAW,WAAW,cAAc,UAAU,iBAAiB,QAAQ,IAAI,IAAI,KAAA;CACrF,MAAM,OAAO,WACT,eAAe,QAAQ,IACvB;EACE,MAAM;EACN,MAAM,OAAO;CACf;CAQJ,OAAO;EACL,QARa,wBACb;GAAE,GAAG;GAAM,QAAQ,KAAK,UAAU,SAAS;EAAO,GAClD,QACA,iBACA,IAIK;EACL,YAAY;EACZ,cAAc,QAAQ,gBAAgB,CAAC;EACvC;CACF;AACF;;;;;;;AAQA,SAAS,wBAAwB,WAA6B;CAC5D,OAAOA,0BAAW,WAAW,IAAI;AACnC"}
|
|
1
|
+
{"version":3,"file":"node.js","names":["candidates"],"sources":["../src/node.ts"],"sourcesContent":["/**\n * Node configuration discovery, evaluation, and project selection. `loadConfiguration` opens an\n * explicit file. `resolveIntegrationConfig` also discovers files and applies build overrides.\n * `evaluateModule` bundles and evaluates other local modules, such as plugin files. Consumers\n * retaining compiler state use the returned dependency paths for change tracking.\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport { createJiti } from \"jiti\";\nimport { rolldown } from \"rolldown\";\nimport { glob } from \"tinyglobby\";\n\nimport type { BaseConfig, NormalizedCompilerConfig } from \"./compiler.ts\";\nimport { resolveConfig, type AnalysisProjectConfig } from \"./configuration.ts\";\nimport {\n configurationCandidates as candidates,\n compilerConfig,\n documentConfiguration,\n expandProjects,\n resolveCompilerSettings,\n resolveProjectPaths,\n selectProject,\n validateInlineConfig,\n type InlineConfig,\n} from \"./resolution.ts\";\n\n/**\n * Evaluated settings and files that consumers must watch when retaining a compiler session.\n */\nexport interface LoadedConfiguration {\n /** Validated settings after awaiting the module export and invoking its factory, if supplied. */\n config: {\n /**\n * Projects in authored order with references replaced. Referenced projects have an absolute\n * root. Other projects keep their authored paths.\n */\n projects: AnalysisProjectConfig[];\n };\n /** Absolute path of the evaluated configuration file. */\n configFile: string;\n /**\n * Distinct absolute paths of the configuration, referenced configurations, bundled local imports,\n * and resolved external imports. A file that a glob reference would newly match is not included.\n */\n dependencies: string[];\n}\n\n/**\n * Settings for one build integration after project selection and inline overrides.\n */\nexport interface ResolvedIntegrationConfig {\n /** Selected compiler settings after inline overrides and defaults. Filesystem paths are absolute. */\n config: NormalizedCompilerConfig & {\n /** Absolute selected project directory after applying inline overrides. */\n root: string;\n /** Absolute design-system stylesheet path, without an existence check. */\n css: string;\n };\n /** Absolute evaluated configuration path, or undefined when no file was loaded. */\n configFile?: string;\n /** Existing configuration dependency paths to watch. Empty when settings are entirely inline. */\n dependencies: string[];\n /** Absolute missing candidate paths before the selected file, nearest directory first. Watch their creation. */\n missing: string[];\n}\n\n/**\n * Finds the nearest supported stillwind.config.* file at or above an application directory.\n *\n * @param directory - Directory to start from. Relative paths use the process working directory.\n * @returns The first existing candidate's absolute path, or undefined if none exists.\n */\nexport function findConfiguration(directory: string): string | undefined {\n return candidates(directory, path).find((file) => existsSync(file));\n}\n\n/**\n * Finds the nearest configuration of a document in a workspace folder, without evaluating it.\n *\n * @param file - Absolute document path.\n * @param folders - Absolute workspace folders.\n * @returns The configuration path, or undefined when the document lies outside the folders or in\n * `node_modules`, or the folder has no configuration at or above the document.\n */\nexport function findDocumentConfiguration(\n file: string,\n folders: readonly string[],\n): string | undefined {\n return documentConfiguration(file, folders, existsSync, path);\n}\n\n/**\n * An evaluated module and the files that its evaluation read.\n */\nexport interface EvaluatedModule {\n /** Default export, or the module value when it has no default export. */\n exported: unknown;\n /** Distinct absolute paths of the entry, bundled local imports, and resolved external imports. */\n dependencies: string[];\n /** Text of each bundled local file, keyed by absolute path, as the bundler read it. */\n sources: Map<string, string>;\n}\n\n/**\n * Bundles local imports of a module in memory and evaluates the bundle without module\n * caches. Local sources are read again on each call, so a changed local import takes\n * effect. External packages use runtime module loading, and Node keeps them cached. The\n * module runs as trusted Node code and can perform side effects. Evaluation is\n * available before a framework generates its TypeScript configuration.\n *\n * `import.meta.url`, `import.meta.filename`, `import.meta.dirname`, `__filename`, and\n * `__dirname` describe the original source file of each bundled module.\n *\n * @param file - JS, TS, or JSON module path. Relative paths use the process working\n * directory.\n * @returns The export and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to\n * dependencies.\n * @throws If a package cannot be resolved, or bundling or module evaluation fails.\n */\nexport async function evaluateModule(file: string): Promise<EvaluatedModule> {\n file = path.resolve(file);\n\n const dependencies = new Set([file]);\n const sources = new Map<string, string>();\n const bundle = await rolldown({\n input: file,\n cwd: path.dirname(file),\n logLevel: \"silent\",\n platform: \"node\",\n treeshake: false,\n tsconfig: false,\n transform: {\n target: \"node22\",\n define: {\n \"import.meta.url\": \"__stillwind_module_url\",\n \"import.meta.filename\": \"__stillwind_module_filename\",\n \"import.meta.dirname\": \"__stillwind_module_dirname\",\n __filename: \"__stillwind_module_filename\",\n __dirname: \"__stillwind_module_dirname\",\n },\n },\n plugins: [\n {\n name: \"stillwind-module\",\n /**\n * Resolves external packages from their importer and records their paths for watching.\n *\n * @param id - Import request before resolution.\n * @param importer - Importing file, or undefined for the entry.\n * @param options - Import kind used to select package export conditions.\n * @returns An external module URL or require path, or undefined for bundled local sources.\n * @throws If a package cannot be resolved.\n */\n async resolveId(id, importer, options) {\n if (!importer || id.startsWith(\".\") || path.isAbsolute(id)) {\n return;\n }\n if (isBuiltin(id)) {\n return {\n id,\n external: true,\n };\n }\n const resolved = await this.resolve(id, importer, {\n skipSelf: true,\n kind: options.kind,\n });\n if (!resolved) {\n throw new Error(`Cannot resolve import ${id} from ${importer}`);\n }\n dependencies.add(resolved.id);\n return {\n id: options.kind === \"require-call\" ? resolved.id : pathToFileURL(resolved.id).href,\n external: \"absolute\",\n };\n },\n /**\n * Reads a bundled local file and records its text.\n *\n * @param id - Absolute path of a local file, or a virtual module ID.\n * @returns The file's text, or undefined for a virtual module.\n */\n async load(id) {\n if (id.startsWith(\"\\0\")) {\n return;\n }\n const code = await readFile(id, \"utf8\");\n sources.set(id, code);\n return code;\n },\n transform: {\n filter: {\n id: /\\.[cm]?[jt]sx?$/,\n },\n /**\n * Keeps file location expressions relative to each original source.\n *\n * @param code - Local module source.\n * @param id - Absolute source path.\n * @returns Source with its file location constants before ordinary syntax lowering.\n */\n handler(code, id) {\n return `const __stillwind_module_url = ${JSON.stringify(pathToFileURL(id).href)};\nconst __stillwind_module_filename = ${JSON.stringify(id)};\nconst __stillwind_module_dirname = ${JSON.stringify(path.dirname(id))};\n${code}`;\n },\n },\n },\n ],\n });\n\n let code: string;\n try {\n const result = await bundle.generate({\n format: \"esm\",\n codeSplitting: false,\n });\n const entry = result.output.find((output) => output.type === \"chunk\" && output.isEntry);\n if (entry?.type !== \"chunk\") {\n throw new Error(`Module bundle has no entry: ${file}`);\n }\n for (const id of entry.moduleIds) {\n if (!id.startsWith(\"\\0\")) {\n dependencies.add(id);\n }\n }\n code = entry.code;\n } finally {\n await bundle.close();\n }\n\n const jiti = createJiti(pathToFileURL(file).href, {\n fsCache: false,\n moduleCache: false,\n });\n const value = await jiti.evalModule(code, {\n filename: file.replaceAll(\"\\\\\", \"/\"),\n async: true,\n forceTranspile: true,\n });\n return {\n exported:\n value !== null && typeof value === \"object\" && \"default\" in value ? value.default : value,\n dependencies: [...dependencies],\n sources,\n };\n}\n\n/**\n * Evaluates a configuration module with {@link evaluateModule}, validates its settings, and\n * evaluates the configuration files that it references. Configuration runs as trusted Node code\n * and can perform side effects.\n *\n * @param file - JS, TS, or JSON configuration path. Relative paths use the process working directory.\n * @returns Evaluated settings and the file paths observed while resolving and bundling imports.\n * Runtime file reads and imports that cannot be statically resolved are not added to dependencies.\n * @throws If bundling, module evaluation, factory execution, configuration validation, or reference\n * expansion fails.\n */\nexport async function loadConfiguration(file: string): Promise<LoadedConfiguration> {\n file = path.resolve(file);\n\n const dependencies = new Set<string>();\n /**\n * Evaluates one configuration file and records the files that its evaluation read.\n *\n * @param id - Absolute configuration path.\n * @returns Validated settings.\n * @throws If module evaluation or configuration validation fails.\n */\n const load = async (id: string) => {\n const evaluated = await evaluateModule(id);\n for (const dependency of evaluated.dependencies) {\n dependencies.add(dependency);\n }\n return resolveConfig(evaluated.exported);\n };\n\n const projects = await expandProjects(\n await load(file),\n file,\n {\n isFile: (id) => statSync(id, { throwIfNoEntry: false })?.isFile() ?? false,\n glob: async (patterns, ignore, directory) =>\n (\n await glob(patterns, {\n cwd: directory,\n absolute: true,\n expandDirectories: false,\n ignore,\n })\n ).map((match) => path.resolve(match)),\n load,\n },\n path,\n );\n return {\n config: {\n projects,\n },\n configFile: file,\n dependencies: [...dependencies],\n };\n}\n\n/**\n * Resolves project paths and removes analysis scope and provider settings.\n *\n * @param project - Evaluated project configuration with paths relative to its root.\n * @param directory - Base directory for a relative project root, normally the configuration directory.\n * @returns Compiler settings with absolute root, CSS, and tsconfig paths. The supplied project is not modified.\n * A false or omitted tsconfig setting is preserved.\n * @throws If compiler normalization fails or the project does not supply a valid CSS path.\n */\nexport function resolveProjectConfig(\n project: AnalysisProjectConfig,\n directory: string,\n): NormalizedCompilerConfig & {\n /** Absolute root resolved against directory. */\n root: string;\n /** Absolute CSS entrypoint resolved against the project's root. */\n css: string;\n} {\n const resolved = resolveProjectPaths(project, directory, path);\n return resolveCompilerSettings(compilerConfig(resolved), {}, resolved.root, path);\n}\n\n/**\n * Loads build settings and merges inline overrides into one selected project's compiler settings.\n * Without an explicit name, selection uses the sole project or the unique deepest root containing\n * the application directory after its inline root override. Arrays are replaced during merging.\n *\n * @param inline - File selection, optional project name, and compiler overrides. An inline root\n * uses applicationRoot. A configured root uses the configuration file's directory.\n * @param applicationRoot - Build directory used for discovery and relative inline paths.\n * Relative paths use the process working directory.\n * @param defaults - Browser targets used when the selected project and inline settings omit target.\n * @returns Validated compiler settings with an absolute root and paths to watch. When discovery\n * finds no file, inline settings must supply a CSS entrypoint.\n * @throws If an explicit file is missing, project selection is ambiguous or unsuccessful,\n * configuration evaluation fails, or merged compiler settings are invalid.\n */\nexport async function resolveIntegrationConfig(\n inline: InlineConfig,\n applicationRoot: string,\n defaults: Pick<BaseConfig, \"target\"> = {},\n): Promise<ResolvedIntegrationConfig> {\n applicationRoot = path.resolve(applicationRoot);\n\n validateInlineConfig(inline);\n const requested = inline.configFile;\n const candidates =\n requested === false\n ? []\n : requested\n ? [path.resolve(applicationRoot, requested)]\n : configurationCandidates(applicationRoot);\n const file = candidates.find((candidate) => existsSync(candidate));\n const missing = candidates.slice(0, file ? candidates.indexOf(file) : candidates.length);\n if (requested && !file) {\n throw new Error(`Cannot find Stillwind configuration: ${candidates[0]}`);\n }\n\n const loaded = file ? await loadConfiguration(file) : undefined;\n const projects = loaded?.config.projects.map((project) =>\n resolveProjectPaths(project, path.dirname(file!), path),\n );\n if (!projects && inline.project !== undefined) {\n throw new Error(\"Cannot select a Stillwind project without a configuration file\");\n }\n\n const selected = projects ? selectProject(projects, applicationRoot, inline, path) : undefined;\n const base = selected\n ? compilerConfig(selected)\n : {\n root: applicationRoot,\n lint: inline.lint,\n };\n const config = resolveCompilerSettings(\n { ...base, target: base.target ?? defaults.target },\n inline,\n applicationRoot,\n path,\n );\n\n return {\n config,\n configFile: file,\n dependencies: loaded?.dependencies ?? [],\n missing,\n };\n}\n\n/**\n * Enumerates Node configuration candidates without checking existence.\n *\n * @param directory - Starting directory. Relative paths use the process working directory.\n * @returns Absolute paths ordered from the nearest directory to the filesystem root, with\n * configurationFiles precedence within each directory.\n */\nfunction configurationCandidates(directory: string): string[] {\n return candidates(directory, path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,kBAAkB,WAAuC;CACvE,OAAOA,0BAAW,WAAW,IAAI,CAAC,CAAC,MAAM,SAAS,WAAW,IAAI,CAAC;AACpE;;;;;;;;;AAUA,SAAgB,0BACd,MACA,SACoB;CACpB,OAAO,sBAAsB,MAAM,SAAS,YAAY,IAAI;AAC9D;;;;;;;;;;;;;;;;;;AA+BA,eAAsB,eAAe,MAAwC;CAC3E,OAAO,KAAK,QAAQ,IAAI;CAExB,MAAM,+BAAe,IAAI,IAAI,CAAC,IAAI,CAAC;CACnC,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,SAAS,MAAM,SAAS;EAC5B,OAAO;EACP,KAAK,KAAK,QAAQ,IAAI;EACtB,UAAU;EACV,UAAU;EACV,WAAW;EACX,UAAU;EACV,WAAW;GACT,QAAQ;GACR,QAAQ;IACN,mBAAmB;IACnB,wBAAwB;IACxB,uBAAuB;IACvB,YAAY;IACZ,WAAW;GACb;EACF;EACA,SAAS,CACP;GACE,MAAM;;;;;;;;;;GAUN,MAAM,UAAU,IAAI,UAAU,SAAS;IACrC,IAAI,CAAC,YAAY,GAAG,WAAW,GAAG,KAAK,KAAK,WAAW,EAAE,GACvD;IAEF,IAAI,UAAU,EAAE,GACd,OAAO;KACL;KACA,UAAU;I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