@stillwind/integration 0.7.0 → 0.9.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/CHANGELOG.md +180 -0
- package/dist/astro/development.d.ts +2 -0
- package/dist/astro/development.js +2 -0
- package/dist/astro/development.js.map +1 -1
- package/dist/astro/index.d.ts +1 -1
- package/dist/astro/index.js +8 -2
- package/dist/astro/index.js.map +1 -1
- package/dist/{emission-BVi5aRbb.js → emission-BpaN4Z4m.js} +212 -69
- package/dist/emission-BpaN4Z4m.js.map +1 -0
- package/dist/fresh/index.d.ts +1 -1
- package/dist/fresh/index.js +1 -1
- package/dist/{index-DFfbZxNT.d.ts → index-B6EtrWus.d.ts} +2 -2
- package/dist/loader-cache-DfOGY8AJ.js +231 -0
- package/dist/loader-cache-DfOGY8AJ.js.map +1 -0
- package/dist/next/css-loader.d.ts +5 -2
- package/dist/next/css-loader.js +7 -2
- package/dist/next/css-loader.js.map +1 -1
- package/dist/next/index.js +2 -0
- package/dist/next/index.js.map +1 -1
- package/dist/{node-loader-D-3Ynpy1.d.ts → node-loader-Bqg7E5zq.d.ts} +6 -3
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/nuxt/index.js +2 -1
- package/dist/nuxt/index.js.map +1 -1
- package/dist/{plugin-aV0zIIAe.d.ts → plugin-BAG0ZI1X.d.ts} +58 -6
- package/dist/{plugin-mPiBLdqa.js → plugin-D-45o54j.js} +5 -2
- package/dist/plugin-D-45o54j.js.map +1 -0
- package/dist/{plugin-DOKl8qk3.js → plugin-DQH8QlYh.js} +379 -44
- package/dist/plugin-DQH8QlYh.js.map +1 -0
- package/dist/{project-DUGu8g_L.d.ts → project-B_KFQist.d.ts} +2 -2
- package/dist/project-egWF2vWJ.js +428 -0
- package/dist/project-egWF2vWJ.js.map +1 -0
- package/dist/{project-BNw0nZBE.d.ts → project-mB7CODIs.d.ts} +46 -7
- package/dist/rsbuild/index.d.ts +4 -1
- package/dist/rsbuild/index.js +2 -2
- package/dist/rsbuild/index.js.map +1 -1
- package/dist/rspack/index.d.ts +1 -1
- package/dist/rspack/index.js +1 -1
- package/dist/session-Cxf4D6oQ.d.ts +163 -0
- package/dist/source-entries-J5azZ_-z.js +350 -0
- package/dist/source-entries-J5azZ_-z.js.map +1 -0
- package/dist/turbopack/css-loader.d.ts +5 -2
- package/dist/turbopack/css-loader.js +53 -17
- package/dist/turbopack/css-loader.js.map +1 -1
- package/dist/turbopack/index.d.ts +2 -2
- package/dist/turbopack/loader.d.ts +3 -2
- package/dist/turbopack/loader.js +10 -4
- package/dist/turbopack/loader.js.map +1 -1
- package/dist/turbopack/node-loader.d.ts +1 -1
- package/dist/turbopack/node-loader.js +1 -0
- package/dist/turbopack/node-loader.js.map +1 -1
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/dist/vite/runtime.d.ts +10 -3
- package/dist/vite/runtime.js +8 -1
- package/dist/vite/runtime.js.map +1 -1
- package/dist/webpack/css-loader.js +1 -1
- package/dist/webpack/document-loader.d.ts +4 -1
- package/dist/webpack/document-loader.js +5 -2
- package/dist/webpack/document-loader.js.map +1 -1
- package/dist/webpack/fragment-loader.d.ts +1 -0
- package/dist/webpack/fragment-loader.js +1 -0
- package/dist/webpack/fragment-loader.js.map +1 -1
- package/dist/webpack/index.d.ts +1 -1
- package/dist/webpack/index.js +1 -1
- package/dist/webpack/loader.js +15 -21
- package/dist/webpack/loader.js.map +1 -1
- package/dist/webpack/source-loader.d.ts +1 -0
- package/dist/webpack/source-loader.js +1 -0
- package/dist/webpack/source-loader.js.map +1 -1
- package/package.json +19 -17
- package/dist/binding-files-Ds5NpyVV.js +0 -45
- package/dist/binding-files-Ds5NpyVV.js.map +0 -1
- package/dist/emission-BVi5aRbb.js.map +0 -1
- package/dist/plugin-DOKl8qk3.js.map +0 -1
- package/dist/plugin-mPiBLdqa.js.map +0 -1
- package/dist/project-C3IH7geC.js +0 -182
- package/dist/project-C3IH7geC.js.map +0 -1
- package/dist/session-B9_rp9TH.d.ts +0 -72
- package/dist/session-DHUCQMG5.js +0 -117
- package/dist/session-DHUCQMG5.js.map +0 -1
package/dist/project-C3IH7geC.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { n as buildCompilerOptions, r as warnSkippedCss, t as IntegrationSession } from "./session-DHUCQMG5.js";
|
|
2
|
-
import { t as nativeBindingFiles } from "./binding-files-Ds5NpyVV.js";
|
|
3
|
-
import { isBuiltin } from "node:module";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import { CompilationFailure, cleanModuleId, cssEntrypoint, fileModuleDescriptor, loadCssGraph, nodePluginHost, warnRejectedNames } from "@stillwind/host";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { scanSource } from "@stillwind/native";
|
|
9
|
-
import { resolveIntegrationConfig } from "@stillwind/config/node";
|
|
10
|
-
// src/turbopack/project.ts
|
|
11
|
-
/**
|
|
12
|
-
* Loads the design system and creates a compiler for a Turbopack or Next loader invocation.
|
|
13
|
-
*
|
|
14
|
-
* Configuration is evaluated independently in each loader invocation. Configuration dependencies,
|
|
15
|
-
* missing discovery candidates, compiler files, and CSS dependencies are registered with the host.
|
|
16
|
-
*
|
|
17
|
-
* @param context - Loader context containing serializable discovery settings, the bundler root,
|
|
18
|
-
* filesystem access, resolver operations, and dependency tracking.
|
|
19
|
-
* @returns A promise for the initialized project. The caller owns the compiler's lifetime.
|
|
20
|
-
* @throws If configuration evaluation or project selection fails, the CSS graph cannot be loaded,
|
|
21
|
-
* or compiler initialization fails.
|
|
22
|
-
*/
|
|
23
|
-
async function createProject(context) {
|
|
24
|
-
const supplied = context.getOptions();
|
|
25
|
-
const configuration = await resolveIntegrationConfig(supplied.compiler, path.resolve(context.rootContext, supplied.root));
|
|
26
|
-
const options = {
|
|
27
|
-
...supplied,
|
|
28
|
-
compiler: configuration.config,
|
|
29
|
-
root: configuration.config.root
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Registers a file whose changes invalidate this loader result.
|
|
33
|
-
* @param id - Filesystem path for configuration, compiler code, CSS, or a resolved dependency.
|
|
34
|
-
*/
|
|
35
|
-
const watch = (id) => {
|
|
36
|
-
context.addDependency(id);
|
|
37
|
-
};
|
|
38
|
-
for (const file of configuration.dependencies) watch(file);
|
|
39
|
-
for (const file of configuration.missing) context.addMissingDependency(file);
|
|
40
|
-
for (const file of nativeBindingFiles()) watch(file);
|
|
41
|
-
watch(fileURLToPath(import.meta.resolve("@stillwind/host")));
|
|
42
|
-
watch(import.meta.filename);
|
|
43
|
-
for (const file of ["loader.js", "css-loader.js"]) watch(fileURLToPath(new URL(`./${file}`, import.meta.resolve("@stillwind/integration/turbopack"))));
|
|
44
|
-
/**
|
|
45
|
-
* Reads text through Turbopack's loader filesystem.
|
|
46
|
-
* @param id - File path accepted by the loader filesystem.
|
|
47
|
-
* @returns File contents converted to a string.
|
|
48
|
-
* @throws If the filesystem reports a read error.
|
|
49
|
-
*/
|
|
50
|
-
const read = (id) => new Promise((done, reject) => {
|
|
51
|
-
context.fs.readFile(id, (error, contents) => error ? reject(error) : done(String(contents)));
|
|
52
|
-
});
|
|
53
|
-
/**
|
|
54
|
-
* Adapts a Turbopack resolver to imports relative to a source file.
|
|
55
|
-
* @param settings - Resolution policy passed to the loader's resolver factory.
|
|
56
|
-
* @returns An asynchronous resolver accepting a specifier and full importer identity. Its promise
|
|
57
|
-
* rejects on resolver errors or missing results, and otherwise returns the resolved identity.
|
|
58
|
-
*/
|
|
59
|
-
const resolver = (settings) => {
|
|
60
|
-
const resolve = context.getResolve(settings);
|
|
61
|
-
return (specifier, importer) => new Promise((done, reject) => {
|
|
62
|
-
resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) => error ? reject(error) : id ? done(id) : reject(/* @__PURE__ */ new Error(`Cannot resolve ${specifier} from ${importer}`)));
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
const resolveJs = resolver({
|
|
66
|
-
extensions: [
|
|
67
|
-
".tsx",
|
|
68
|
-
".ts",
|
|
69
|
-
".jsx",
|
|
70
|
-
".js",
|
|
71
|
-
".mjs",
|
|
72
|
-
".cjs",
|
|
73
|
-
".json"
|
|
74
|
-
],
|
|
75
|
-
dependencyType: "esm"
|
|
76
|
-
});
|
|
77
|
-
const resolveAsset = resolver({});
|
|
78
|
-
const loaded = await loadCssGraph(path.resolve(options.root, cssEntrypoint(options.compiler)), buildCompilerOptions(options.compiler), {
|
|
79
|
-
read,
|
|
80
|
-
documentUri: (id) => pathToFileURL(id).href,
|
|
81
|
-
sourceMapSource: (id) => pathToFileURL(id).href,
|
|
82
|
-
watch,
|
|
83
|
-
watchDirectory: (id) => {
|
|
84
|
-
context.addContextDependency(id);
|
|
85
|
-
},
|
|
86
|
-
resolve: resolver({
|
|
87
|
-
conditionNames: [
|
|
88
|
-
"style",
|
|
89
|
-
"import",
|
|
90
|
-
"default"
|
|
91
|
-
],
|
|
92
|
-
extensions: [".css"],
|
|
93
|
-
mainFields: ["style", "main"]
|
|
94
|
-
}),
|
|
95
|
-
plugins: nodePluginHost
|
|
96
|
-
}, void 0, void 0, {
|
|
97
|
-
plugins: options.compiler.plugins,
|
|
98
|
-
tailwind: options.compiler.tailwind,
|
|
99
|
-
important: options.compiler.important,
|
|
100
|
-
root: options.root
|
|
101
|
-
});
|
|
102
|
-
return {
|
|
103
|
-
options,
|
|
104
|
-
compiler: new IntegrationSession(options.root, loaded.loader, options.compiler, false, options.mode, loaded.plugins),
|
|
105
|
-
host: {
|
|
106
|
-
describe: (id) => fileModuleDescriptor(options.root, id),
|
|
107
|
-
read,
|
|
108
|
-
watch,
|
|
109
|
-
resolve: async (specifier, importer) => isBuiltin(specifier) || specifier === "server-only" || specifier === "client-only" ? {
|
|
110
|
-
id: specifier,
|
|
111
|
-
external: true
|
|
112
|
-
} : { id: await resolveJs(specifier, importer) },
|
|
113
|
-
warn: (message) => {
|
|
114
|
-
context.emitWarning(new Error(message));
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
loaded,
|
|
118
|
-
resolveAsset
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.
|
|
123
|
-
*
|
|
124
|
-
* @param entries - Entry paths, absolute or relative to the evaluated project root. Statically
|
|
125
|
-
* named imports, including lazy imports, are followed. Dynamic request expressions are not traversed.
|
|
126
|
-
* @param project - Initialized loader project. The caller closes its compiler after this operation.
|
|
127
|
-
* Its host receives warnings for the CSS statements that loading skipped and for rejected names.
|
|
128
|
-
* @returns A document plan selecting automatic producers, with a revision derived from visited
|
|
129
|
-
* source paths and contents. Explicit CSS values remain owned by their modules.
|
|
130
|
-
* @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.
|
|
131
|
-
*/
|
|
132
|
-
async function compileGraph(entries, project) {
|
|
133
|
-
const { options, compiler, host } = project;
|
|
134
|
-
const pending = entries.map((entry) => path.resolve(options.root, entry));
|
|
135
|
-
const visited = /* @__PURE__ */ new Set();
|
|
136
|
-
const selection = [];
|
|
137
|
-
const revision = createHash("sha256");
|
|
138
|
-
while (pending.length) {
|
|
139
|
-
const id = pending.shift();
|
|
140
|
-
if (visited.has(id)) continue;
|
|
141
|
-
visited.add(id);
|
|
142
|
-
host.watch(id);
|
|
143
|
-
const source = await host.read(id);
|
|
144
|
-
revision.update(id).update("\0").update(source).update("\0");
|
|
145
|
-
const descriptor = fileModuleDescriptor(options.root, id);
|
|
146
|
-
const scan = scanSource({
|
|
147
|
-
kind: "direct",
|
|
148
|
-
moduleId: descriptor.moduleId,
|
|
149
|
-
document: {
|
|
150
|
-
...descriptor.document,
|
|
151
|
-
code: source
|
|
152
|
-
},
|
|
153
|
-
syntax: descriptor.syntax
|
|
154
|
-
});
|
|
155
|
-
if (scan.kind === "failed") throw new CompilationFailure([scan.batch]);
|
|
156
|
-
const summary = scan.summary;
|
|
157
|
-
for (const { source: specifier } of summary.moduleSpecifiers) {
|
|
158
|
-
if (isBuiltin(specifier) || specifier === "stillwind" || specifier.startsWith("stillwind/")) continue;
|
|
159
|
-
const resolved = await host.resolve(specifier, id);
|
|
160
|
-
const file = cleanModuleId(resolved.id);
|
|
161
|
-
if (!resolved.external && !/[\\/]node_modules[\\/]/.test(file) && /\.[cm]?[jt]sx?$/.test(file)) pending.push(file);
|
|
162
|
-
}
|
|
163
|
-
if (!summary.macroImports && !summary.moduleCssImports) continue;
|
|
164
|
-
const output = await compiler.compile(source, id, host, { moduleCssImport: "stillwind/module-css" });
|
|
165
|
-
if (output && !output.hasModuleCssImport) selection.push(output.moduleId);
|
|
166
|
-
}
|
|
167
|
-
const plan = compiler.native.planStylesheet({
|
|
168
|
-
modules: selection,
|
|
169
|
-
coverage: {
|
|
170
|
-
kind: "complete",
|
|
171
|
-
target: "entry-graph",
|
|
172
|
-
revision: revision.digest("hex")
|
|
173
|
-
},
|
|
174
|
-
placement: "document"
|
|
175
|
-
});
|
|
176
|
-
warnSkippedCss(project.loaded.skipped, (message) => host.warn(message));
|
|
177
|
-
warnRejectedNames(plan.rejectedNames, (message) => host.warn(message));
|
|
178
|
-
return plan;
|
|
179
|
-
}
|
|
180
|
-
export { createProject as n, compileGraph as t };
|
|
181
|
-
|
|
182
|
-
//# sourceMappingURL=project-C3IH7geC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-C3IH7geC.js","names":[],"sources":["../src/turbopack/project.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isBuiltin } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nimport type { BuildConfig, SerializableInlineConfig } from \"@stillwind/config\";\nimport { resolveIntegrationConfig } from \"@stillwind/config/node\";\nimport {\n cleanModuleId,\n CompilationFailure,\n cssEntrypoint,\n fileModuleDescriptor,\n loadCssGraph,\n nodePluginHost,\n warnRejectedNames,\n type CompilerHost,\n type LoadedCssGraph,\n} from \"@stillwind/host\";\nimport { scanSource } from \"@stillwind/native\";\nimport type { LoaderContext } from \"webpack\";\n\nimport { nativeBindingFiles } from \"../binding-files.ts\";\nimport { buildCompilerOptions, IntegrationSession, warnSkippedCss } from \"../session.ts\";\n\n/** Removes readonly constraints recursively so cloned inline settings fit the bundler's loader transport. */\ntype MutableSettings<T> = T extends readonly (infer Item)[]\n ? MutableSettings<Item>[]\n : T extends object\n ? { -readonly [K in keyof T]: MutableSettings<T[K]> }\n : T;\n\n/** Serializable compiler settings and entry selection passed to Turbopack's isolated loaders. */\nexport type TurbopackLoaderOptions = {\n /** Configuration file selection and serializable inline settings. */\n compiler: MutableSettings<SerializableInlineConfig>;\n /** Application directory, absolute or relative to the loader context's root. */\n root: string;\n /** Entry files whose imports are traversed when reconstructing document CSS. */\n entries: string[];\n /** Compiler mode, normally `development` or `release`. */\n mode: string;\n};\n\n/** Compiler session and host operations owned by one Turbopack or Next loader invocation. */\nexport interface TurbopackProject {\n /** Evaluated compiler settings with an absolute project root, captured entry selection, and mode. */\n options: Omit<TurbopackLoaderOptions, \"compiler\"> & {\n /** Evaluated settings selected from configuration and inline overrides. */\n compiler: BuildConfig;\n };\n /** Initialized compiler. The caller must close it after compilation or stylesheet reconstruction. */\n compiler: IntegrationSession;\n /** Filesystem, source metadata, resolver, dependency watcher, and warning operations. */\n host: TurbopackHost;\n /** Completed CSS graph and authored resources used by the compiler. */\n loaded: LoadedCssGraph;\n /**\n * Resolves an asset with the loader context's default resolver.\n *\n * @param specifier - Resource request text from CSS or a producer.\n * @param importer - Absolute identity of the resource owner.\n * @returns A promise for the resolved asset identity. Unresolved requests reject the promise.\n */\n resolveAsset: (specifier: string, importer: string) => Promise<string>;\n}\n\n/** Compiler host whose resolver returns an identity or rejects instead of returning null. */\nexport interface TurbopackHost extends CompilerHost {\n /**\n * Resolves a script dependency or marks a Node builtin or Next boundary marker as external.\n *\n * @param specifier - Script request text, including any resource query.\n * @param importer - Absolute identity of the importing source.\n * @returns A promise for the resolved identity and optional external status. Resolution failures\n * reject the promise.\n */\n resolve: (\n specifier: string,\n importer: string,\n ) => Promise<{\n /** Resolved absolute source identity or external module name. */\n id: string;\n /** Whether the graph must skip loading this module as source. */\n external?: boolean;\n }>;\n}\n\n/**\n * Loads the design system and creates a compiler for a Turbopack or Next loader invocation.\n *\n * Configuration is evaluated independently in each loader invocation. Configuration dependencies,\n * missing discovery candidates, compiler files, and CSS dependencies are registered with the host.\n *\n * @param context - Loader context containing serializable discovery settings, the bundler root,\n * filesystem access, resolver operations, and dependency tracking.\n * @returns A promise for the initialized project. The caller owns the compiler's lifetime.\n * @throws If configuration evaluation or project selection fails, the CSS graph cannot be loaded,\n * or compiler initialization fails.\n */\nexport async function createProject(\n context: LoaderContext<TurbopackLoaderOptions>,\n): Promise<TurbopackProject> {\n const supplied = context.getOptions();\n const configuration = await resolveIntegrationConfig(\n supplied.compiler,\n path.resolve(context.rootContext, supplied.root),\n );\n const options = {\n ...supplied,\n compiler: configuration.config,\n root: configuration.config.root,\n };\n /**\n * Registers a file whose changes invalidate this loader result.\n * @param id - Filesystem path for configuration, compiler code, CSS, or a resolved dependency.\n */\n const watch = (id: string) => {\n context.addDependency(id);\n };\n for (const file of configuration.dependencies) {\n watch(file);\n }\n for (const file of configuration.missing) {\n context.addMissingDependency(file);\n }\n for (const file of nativeBindingFiles()) {\n watch(file);\n }\n watch(fileURLToPath(import.meta.resolve(\"@stillwind/host\")));\n watch(import.meta.filename);\n for (const file of [\"loader.js\", \"css-loader.js\"]) {\n watch(\n fileURLToPath(new URL(`./${file}`, import.meta.resolve(\"@stillwind/integration/turbopack\"))),\n );\n }\n /**\n * Reads text through Turbopack's loader filesystem.\n * @param id - File path accepted by the loader filesystem.\n * @returns File contents converted to a string.\n * @throws If the filesystem reports a read error.\n */\n const read = (id: string) =>\n new Promise<string>((done, reject) => {\n context.fs.readFile(id, (error, contents) =>\n error ? reject(error) : done(String(contents)),\n );\n });\n /**\n * Adapts a Turbopack resolver to imports relative to a source file.\n * @param settings - Resolution policy passed to the loader's resolver factory.\n * @returns An asynchronous resolver accepting a specifier and full importer identity. Its promise\n * rejects on resolver errors or missing results, and otherwise returns the resolved identity.\n */\n const resolver = (settings: Parameters<typeof context.getResolve>[0]) => {\n const resolve = context.getResolve(settings);\n return (specifier: string, importer: string) =>\n new Promise<string>((done, reject) => {\n resolve(path.dirname(cleanModuleId(importer)), specifier, (error, id) =>\n error\n ? reject(error)\n : id\n ? done(id)\n : reject(new Error(`Cannot resolve ${specifier} from ${importer}`)),\n );\n });\n };\n const resolveJs = resolver({\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".mjs\", \".cjs\", \".json\"],\n dependencyType: \"esm\",\n });\n const resolveAsset = resolver({});\n const loaded = await loadCssGraph(\n path.resolve(options.root, cssEntrypoint(options.compiler)),\n buildCompilerOptions(options.compiler),\n {\n read,\n documentUri: (id) => pathToFileURL(id).href,\n sourceMapSource: (id) => pathToFileURL(id).href,\n watch,\n watchDirectory: (id) => {\n context.addContextDependency(id);\n },\n resolve: resolver({\n conditionNames: [\"style\", \"import\", \"default\"],\n extensions: [\".css\"],\n mainFields: [\"style\", \"main\"],\n }),\n plugins: nodePluginHost,\n },\n undefined,\n undefined,\n {\n plugins: options.compiler.plugins,\n tailwind: options.compiler.tailwind,\n important: options.compiler.important,\n root: options.root,\n },\n );\n const compiler = new IntegrationSession(\n options.root,\n loaded.loader,\n options.compiler,\n false,\n options.mode,\n loaded.plugins,\n );\n const host = {\n describe: (id: string) => fileModuleDescriptor(options.root, id),\n read,\n watch,\n resolve: async (specifier: string, importer: string) =>\n // Next checks boundary markers when it builds server and client modules.\n // They provide no styles for this graph and do not use its loader resolver.\n isBuiltin(specifier) || specifier === \"server-only\" || specifier === \"client-only\"\n ? {\n id: specifier,\n external: true,\n }\n : {\n id: await resolveJs(specifier, importer),\n },\n warn: (message: string) => {\n context.emitWarning(new Error(message));\n },\n };\n return {\n options,\n compiler,\n host,\n loaded,\n resolveAsset,\n };\n}\n\n/**\n * Compiles entry-reachable local JS/TS producers and requests one document stylesheet plan.\n *\n * @param entries - Entry paths, absolute or relative to the evaluated project root. Statically\n * named imports, including lazy imports, are followed. Dynamic request expressions are not traversed.\n * @param project - Initialized loader project. The caller closes its compiler after this operation.\n * Its host receives warnings for the CSS statements that loading skipped and for rejected names.\n * @returns A document plan selecting automatic producers, with a revision derived from visited\n * source paths and contents. Explicit CSS values remain owned by their modules.\n * @throws If source resolution, reading, scanning, compilation, or stylesheet planning fails.\n */\nexport async function compileGraph(entries: readonly string[], project: TurbopackProject) {\n const { options, compiler, host } = project;\n const pending = entries.map((entry) => path.resolve(options.root, entry));\n const visited = new Set<string>();\n const selection: string[] = [];\n const revision = createHash(\"sha256\");\n while (pending.length) {\n const id = pending.shift()!;\n if (visited.has(id)) {\n continue;\n }\n visited.add(id);\n host.watch(id);\n const source = await host.read(id);\n revision.update(id).update(\"\\0\").update(source).update(\"\\0\");\n const descriptor = fileModuleDescriptor(options.root, id);\n const scan = scanSource({\n kind: \"direct\",\n moduleId: descriptor.moduleId,\n document: {\n ...descriptor.document,\n code: source,\n },\n syntax: descriptor.syntax,\n });\n if (scan.kind === \"failed\") {\n throw new CompilationFailure([scan.batch]);\n }\n const summary = scan.summary;\n for (const { source: specifier } of summary.moduleSpecifiers) {\n if (isBuiltin(specifier) || specifier === \"stillwind\" || specifier.startsWith(\"stillwind/\")) {\n continue;\n }\n const resolved = await host.resolve(specifier, id);\n const file = cleanModuleId(resolved.id);\n if (\n !resolved.external &&\n !/[\\\\/]node_modules[\\\\/]/.test(file) &&\n /\\.[cm]?[jt]sx?$/.test(file)\n ) {\n pending.push(file);\n }\n }\n if (!summary.macroImports && !summary.moduleCssImports) {\n continue;\n }\n const output = await compiler.compile(source, id, host, {\n moduleCssImport: \"stillwind/module-css\",\n });\n if (output && !output.hasModuleCssImport) {\n selection.push(output.moduleId);\n }\n }\n const plan = compiler.native.planStylesheet({\n modules: selection,\n coverage: {\n kind: \"complete\",\n target: \"entry-graph\",\n revision: revision.digest(\"hex\"),\n },\n placement: \"document\",\n });\n warnSkippedCss(project.loaded.skipped, (message) => host.warn(message));\n warnRejectedNames(plan.rejectedNames, (message) => host.warn(message));\n return plan;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmGA,eAAsB,cACpB,SAC2B;CAC3B,MAAM,WAAW,QAAQ,WAAW;CACpC,MAAM,gBAAgB,MAAM,yBAC1B,SAAS,UACT,KAAK,QAAQ,QAAQ,aAAa,SAAS,IAAI,CACjD;CACA,MAAM,UAAU;EACd,GAAG;EACH,UAAU,cAAc;EACxB,MAAM,cAAc,OAAO;CAC7B;;;;;CAKA,MAAM,SAAS,OAAe;EAC5B,QAAQ,cAAc,EAAE;CAC1B;CACA,KAAK,MAAM,QAAQ,cAAc,cAC/B,MAAM,IAAI;CAEZ,KAAK,MAAM,QAAQ,cAAc,SAC/B,QAAQ,qBAAqB,IAAI;CAEnC,KAAK,MAAM,QAAQ,mBAAmB,GACpC,MAAM,IAAI;CAEZ,MAAM,cAAc,YAAY,QAAQ,iBAAiB,CAAC,CAAC;CAC3D,MAAM,YAAY,QAAQ;CAC1B,KAAK,MAAM,QAAQ,CAAC,aAAa,eAAe,GAC9C,MACE,cAAc,IAAI,IAAI,KAAK,QAAQ,YAAY,QAAQ,kCAAkC,CAAC,CAAC,CAC7F;;;;;;;CAQF,MAAM,QAAQ,OACZ,IAAI,SAAiB,MAAM,WAAW;EACpC,QAAQ,GAAG,SAAS,KAAK,OAAO,aAC9B,QAAQ,OAAO,KAAK,IAAI,KAAK,OAAO,QAAQ,CAAC,CAC/C;CACF,CAAC;;;;;;;CAOH,MAAM,YAAY,aAAuD;EACvE,MAAM,UAAU,QAAQ,WAAW,QAAQ;EAC3C,QAAQ,WAAmB,aACzB,IAAI,SAAiB,MAAM,WAAW;GACpC,QAAQ,KAAK,QAAQ,cAAc,QAAQ,CAAC,GAAG,YAAY,OAAO,OAChE,QACI,OAAO,K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iB,uBACnB,CAAC;EACD,IAAI,UAAU,CAAC,OAAO,oBACpB,UAAU,KAAK,OAAO,QAAQ;CAElC;CACA,MAAM,OAAO,SAAS,OAAO,eAAe;EAC1C,SAAS;EACT,UAAU;GACR,MAAM;GACN,QAAQ;GACR,UAAU,SAAS,OAAO,KAAK;EACjC;EACA,WAAW;CACb,CAAC;CACD,eAAe,QAAQ,OAAO,UAAU,YAAY,KAAK,KAAK,OAAO,CAAC;CACtE,kBAAkB,KAAK,gBAAgB,YAAY,KAAK,KAAK,OAAO,CAAC;CACrE,OAAO;AACT"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { CompilerHost, ModuleCompileOptions, PluginRuntime } from "@stillwind/host";
|
|
2
|
-
import { NativeDesignSystemLoader, NativeProjectSession } from "@stillwind/native";
|
|
3
|
-
import { BuildConfig } from "@stillwind/config";
|
|
4
|
-
/**
|
|
5
|
-
* Owns a compiler session and a reusable checker for one adapter environment. TypeScript settings
|
|
6
|
-
* are selected at construction. Close the checker when the adapter releases or reloads the project.
|
|
7
|
-
*/
|
|
8
|
-
declare class IntegrationSession {
|
|
9
|
-
#private;
|
|
10
|
-
/** Native compiler state retained across module updates. Closing this wrapper only releases its checker. */
|
|
11
|
-
readonly native: NativeProjectSession;
|
|
12
|
-
/** Absolute project directory captured when TypeScript settings were selected. */
|
|
13
|
-
readonly root: string;
|
|
14
|
-
/**
|
|
15
|
-
* Creates compiler state without starting the TypeScript checker.
|
|
16
|
-
*
|
|
17
|
-
* @param root - Absolute adapter project root used for module identities and TypeScript settings.
|
|
18
|
-
* @param loader - Completed design-system loader retained by the native session.
|
|
19
|
-
* @param config - Compiler settings, including the root-relative or absolute tsconfig selection.
|
|
20
|
-
* @param watch - Whether failed native updates retain the last successful output.
|
|
21
|
-
* @param mode - Native compilation mode selected by the adapter.
|
|
22
|
-
* @param plugins - Plugin runtime of the loader's CSS graph, which resolves dynamic utilities.
|
|
23
|
-
* @throws If the selected TypeScript configuration does not exist or native session creation fails.
|
|
24
|
-
*/
|
|
25
|
-
constructor(root: string, loader: NativeDesignSystemLoader, config: BuildConfig, watch: boolean, mode: string, plugins?: PluginRuntime);
|
|
26
|
-
/**
|
|
27
|
-
* Compiles a module and records its resolver identities after compilation succeeds.
|
|
28
|
-
*
|
|
29
|
-
* @param code - Entry text before Stillwind transformation.
|
|
30
|
-
* @param id - Full adapter resolver identity, including any query suffix.
|
|
31
|
-
* @param host - Module descriptors, resolution, reads, and dependency tracking operations.
|
|
32
|
-
* @param transport - Diagnostics, checker inputs, and generated imports for this compilation.
|
|
33
|
-
* @returns The entry output, or undefined when compilation produces no entry code.
|
|
34
|
-
* @throws If module identities conflict or host, checker, or compiler operations fail.
|
|
35
|
-
*/
|
|
36
|
-
compile(code: string, id: string, host: CompilerHost, transport?: ModuleCompileOptions): Promise<{
|
|
37
|
-
hasModuleCssImport: boolean;
|
|
38
|
-
compositionModules: string[];
|
|
39
|
-
compositionTopology: string;
|
|
40
|
-
diagnostics: import("@stillwind/native").BindingDiagnostic[];
|
|
41
|
-
reports: import("@stillwind/native").BindingReport[];
|
|
42
|
-
composition: Array<import("@stillwind/native").NativeStyleDependency>;
|
|
43
|
-
moduleId: string;
|
|
44
|
-
resources: Array<import("@stillwind/native").NativeModuleResource>;
|
|
45
|
-
css: string;
|
|
46
|
-
code: string | null;
|
|
47
|
-
mappings: Array<import("@stillwind/native").NativeTransformMapping>;
|
|
48
|
-
classes: Array<import("@stillwind/native").NativeGeneratedClass>;
|
|
49
|
-
symbols: Array<import("@stillwind/native").NativeGeneratedSymbol>;
|
|
50
|
-
rejectedNames: Array<import("@stillwind/native").BindingRejectedIdentifier>;
|
|
51
|
-
dynamicCandidates: Array<string>;
|
|
52
|
-
lintFindings: Array<import("@stillwind/native").BindingLintFinding>;
|
|
53
|
-
lintSettings: Record<string, "warn" | "deny" | "off">;
|
|
54
|
-
} | undefined>;
|
|
55
|
-
/**
|
|
56
|
-
* Returns the host identity recorded after a compilation returned successfully.
|
|
57
|
-
*
|
|
58
|
-
* @param moduleId - Compiler identity previously observed during this session's compilation.
|
|
59
|
-
* @returns Full resolver identity, including any query suffix.
|
|
60
|
-
* @throws If this session has not recorded the module identity.
|
|
61
|
-
*/
|
|
62
|
-
resolverId(moduleId: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Closes the current checker while retaining native compiler state and selected TypeScript settings.
|
|
65
|
-
* Later compilation can start a new checker. Repeated calls have no effect until that happens.
|
|
66
|
-
*
|
|
67
|
-
* @throws If checker cleanup fails.
|
|
68
|
-
*/
|
|
69
|
-
close(): void;
|
|
70
|
-
}
|
|
71
|
-
export { IntegrationSession as t };
|
|
72
|
-
//# sourceMappingURL=session-B9_rp9TH.d.ts.map
|
package/dist/session-DHUCQMG5.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { TypeScriptFactsService, attachPlugins, compileModule, compilerOptions, resolveTypeFactsEnvironment } from "@stillwind/host";
|
|
2
|
-
import { NativeProjectSession } from "@stillwind/native";
|
|
3
|
-
// src/session.ts
|
|
4
|
-
/**
|
|
5
|
-
* Selects native settings for build and development sessions with lint disabled.
|
|
6
|
-
* @param config - Shared project settings. Analysis hosts retain its lint configuration.
|
|
7
|
-
* @returns Compiler settings for generating JavaScript and CSS.
|
|
8
|
-
*/
|
|
9
|
-
function buildCompilerOptions(config) {
|
|
10
|
-
return compilerOptions({
|
|
11
|
-
...config,
|
|
12
|
-
lint: false
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Reports each statement that loading skipped through a bundler warning channel. Build and
|
|
17
|
-
* development sessions run without stylesheet lint, so these warnings report the skipped statements.
|
|
18
|
-
* @param skipped - Skipped statements of a loaded graph.
|
|
19
|
-
* @param warn - Receives the lint rule, reason, and one-based authored location of each statement.
|
|
20
|
-
*/
|
|
21
|
-
function warnSkippedCss(skipped, warn) {
|
|
22
|
-
for (const statement of skipped) warn(`stillwind: ${statement.rule}: ${statement.message} (${statement.sourceName}:${statement.line + 1}:${statement.column + 1})`);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Owns a compiler session and a reusable checker for one adapter environment. TypeScript settings
|
|
26
|
-
* are selected at construction. Close the checker when the adapter releases or reloads the project.
|
|
27
|
-
*/
|
|
28
|
-
var IntegrationSession = class {
|
|
29
|
-
/** Native compiler state retained across module updates. Closing this wrapper only releases its checker. */
|
|
30
|
-
native;
|
|
31
|
-
/** Absolute project directory captured when TypeScript settings were selected. */
|
|
32
|
-
root;
|
|
33
|
-
/** Fixed TypeScript settings selected before any lazy checker startup. */
|
|
34
|
-
#typeFactsEnvironment;
|
|
35
|
-
/** Compiler-to-resolver correspondences recorded only after compilation returns successfully. */
|
|
36
|
-
#resolverIdsByModuleId = /* @__PURE__ */ new Map();
|
|
37
|
-
/** Reverse correspondences used to reject a host identity that changes compiler identity. */
|
|
38
|
-
#moduleIdsByResolverId = /* @__PURE__ */ new Map();
|
|
39
|
-
/** Lazily started Node checker, released and recreated independently of native compiler state. */
|
|
40
|
-
#facts;
|
|
41
|
-
/**
|
|
42
|
-
* Creates compiler state without starting the TypeScript checker.
|
|
43
|
-
*
|
|
44
|
-
* @param root - Absolute adapter project root used for module identities and TypeScript settings.
|
|
45
|
-
* @param loader - Completed design-system loader retained by the native session.
|
|
46
|
-
* @param config - Compiler settings, including the root-relative or absolute tsconfig selection.
|
|
47
|
-
* @param watch - Whether failed native updates retain the last successful output.
|
|
48
|
-
* @param mode - Native compilation mode selected by the adapter.
|
|
49
|
-
* @param plugins - Plugin runtime of the loader's CSS graph, which resolves dynamic utilities.
|
|
50
|
-
* @throws If the selected TypeScript configuration does not exist or native session creation fails.
|
|
51
|
-
*/
|
|
52
|
-
constructor(root, loader, config, watch, mode, plugins) {
|
|
53
|
-
this.root = root;
|
|
54
|
-
this.#typeFactsEnvironment = resolveTypeFactsEnvironment(root, config.tsconfig);
|
|
55
|
-
this.native = new NativeProjectSession(loader, watch, mode, config.naming, false);
|
|
56
|
-
attachPlugins(this.native, plugins);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Compiles a module and records its resolver identities after compilation succeeds.
|
|
60
|
-
*
|
|
61
|
-
* @param code - Entry text before Stillwind transformation.
|
|
62
|
-
* @param id - Full adapter resolver identity, including any query suffix.
|
|
63
|
-
* @param host - Module descriptors, resolution, reads, and dependency tracking operations.
|
|
64
|
-
* @param transport - Diagnostics, checker inputs, and generated imports for this compilation.
|
|
65
|
-
* @returns The entry output, or undefined when compilation produces no entry code.
|
|
66
|
-
* @throws If module identities conflict or host, checker, or compiler operations fail.
|
|
67
|
-
*/
|
|
68
|
-
async compile(code, id, host, transport = {}) {
|
|
69
|
-
const pending = /* @__PURE__ */ new Map();
|
|
70
|
-
const pendingByResolverId = /* @__PURE__ */ new Map();
|
|
71
|
-
const output = await compileModule(this.native, () => {
|
|
72
|
-
this.#facts ??= new TypeScriptFactsService(this.#typeFactsEnvironment);
|
|
73
|
-
return this.#facts;
|
|
74
|
-
}, code, id, {
|
|
75
|
-
...host,
|
|
76
|
-
onModule: (moduleId, resolverId) => {
|
|
77
|
-
const previous = this.#resolverIdsByModuleId.get(moduleId);
|
|
78
|
-
if (previous !== void 0 && previous !== resolverId) throw new Error(`Module identity ${moduleId} changed resolver identity from ${previous} to ${resolverId}`);
|
|
79
|
-
const priorModuleId = pendingByResolverId.get(resolverId) ?? this.#moduleIdsByResolverId.get(resolverId);
|
|
80
|
-
if (priorModuleId !== void 0 && priorModuleId !== moduleId) throw new Error(`Resolver identity ${resolverId} changed module identity`);
|
|
81
|
-
pending.set(moduleId, resolverId);
|
|
82
|
-
pendingByResolverId.set(resolverId, moduleId);
|
|
83
|
-
}
|
|
84
|
-
}, transport);
|
|
85
|
-
for (const [moduleId, resolverId] of pending) {
|
|
86
|
-
this.#resolverIdsByModuleId.set(moduleId, resolverId);
|
|
87
|
-
this.#moduleIdsByResolverId.set(resolverId, moduleId);
|
|
88
|
-
host.onModule?.(moduleId, resolverId);
|
|
89
|
-
}
|
|
90
|
-
return output;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Returns the host identity recorded after a compilation returned successfully.
|
|
94
|
-
*
|
|
95
|
-
* @param moduleId - Compiler identity previously observed during this session's compilation.
|
|
96
|
-
* @returns Full resolver identity, including any query suffix.
|
|
97
|
-
* @throws If this session has not recorded the module identity.
|
|
98
|
-
*/
|
|
99
|
-
resolverId(moduleId) {
|
|
100
|
-
const id = this.#resolverIdsByModuleId.get(moduleId);
|
|
101
|
-
if (id === void 0) throw new Error(`Unknown Stillwind module identity: ${moduleId}`);
|
|
102
|
-
return id;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Closes the current checker while retaining native compiler state and selected TypeScript settings.
|
|
106
|
-
* Later compilation can start a new checker. Repeated calls have no effect until that happens.
|
|
107
|
-
*
|
|
108
|
-
* @throws If checker cleanup fails.
|
|
109
|
-
*/
|
|
110
|
-
close() {
|
|
111
|
-
this.#facts?.close();
|
|
112
|
-
this.#facts = void 0;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
export { buildCompilerOptions as n, warnSkippedCss as r, IntegrationSession as t };
|
|
116
|
-
|
|
117
|
-
//# sourceMappingURL=session-DHUCQMG5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-DHUCQMG5.js","names":[],"sources":["../src/session.ts"],"sourcesContent":["import type { BuildConfig } from \"@stillwind/config\";\nimport {\n attachPlugins,\n compileModule,\n compilerOptions,\n resolveTypeFactsEnvironment,\n TypeScriptFactsService,\n type CompilerHost,\n type ModuleCompileOptions,\n type PluginRuntime,\n type TypeFactsEnvironment,\n} from \"@stillwind/host\";\nimport {\n NativeProjectSession,\n type NativeCompilerOptions,\n type NativeDesignSystemLoader,\n type NativeSkippedCss,\n} from \"@stillwind/native\";\n\n/**\n * Selects native settings for build and development sessions with lint disabled.\n * @param config - Shared project settings. Analysis hosts retain its lint configuration.\n * @returns Compiler settings for generating JavaScript and CSS.\n */\nexport function buildCompilerOptions(config: BuildConfig): NativeCompilerOptions {\n return compilerOptions({\n ...config,\n lint: false,\n });\n}\n\n/**\n * Reports each statement that loading skipped through a bundler warning channel. Build and\n * development sessions run without stylesheet lint, so these warnings report the skipped statements.\n * @param skipped - Skipped statements of a loaded graph.\n * @param warn - Receives the lint rule, reason, and one-based authored location of each statement.\n */\nexport function warnSkippedCss(\n skipped: readonly NativeSkippedCss[],\n warn: (message: string) => void,\n): void {\n for (const statement of skipped) {\n warn(\n `stillwind: ${statement.rule}: ${statement.message} (${statement.sourceName}:${statement.line + 1}:${statement.column + 1})`,\n );\n }\n}\n\n/**\n * Owns a compiler session and a reusable checker for one adapter environment. TypeScript settings\n * are selected at construction. Close the checker when the adapter releases or reloads the project.\n */\nexport class IntegrationSession {\n /** Native compiler state retained across module updates. Closing this wrapper only releases its checker. */\n readonly native: NativeProjectSession;\n /** Absolute project directory captured when TypeScript settings were selected. */\n readonly root: string;\n\n /** Fixed TypeScript settings selected before any lazy checker startup. */\n readonly #typeFactsEnvironment: TypeFactsEnvironment;\n /** Compiler-to-resolver correspondences recorded only after compilation returns successfully. */\n readonly #resolverIdsByModuleId = new Map<string, string>();\n /** Reverse correspondences used to reject a host identity that changes compiler identity. */\n readonly #moduleIdsByResolverId = new Map<string, string>();\n /** Lazily started Node checker, released and recreated independently of native compiler state. */\n #facts?: TypeScriptFactsService;\n\n /**\n * Creates compiler state without starting the TypeScript checker.\n *\n * @param root - Absolute adapter project root used for module identities and TypeScript settings.\n * @param loader - Completed design-system loader retained by the native session.\n * @param config - Compiler settings, including the root-relative or absolute tsconfig selection.\n * @param watch - Whether failed native updates retain the last successful output.\n * @param mode - Native compilation mode selected by the adapter.\n * @param plugins - Plugin runtime of the loader's CSS graph, which resolves dynamic utilities.\n * @throws If the selected TypeScript configuration does not exist or native session creation fails.\n */\n constructor(\n root: string,\n loader: NativeDesignSystemLoader,\n config: BuildConfig,\n watch: boolean,\n mode: string,\n plugins?: PluginRuntime,\n ) {\n this.root = root;\n this.#typeFactsEnvironment = resolveTypeFactsEnvironment(root, config.tsconfig);\n this.native = new NativeProjectSession(loader, watch, mode, config.naming, false);\n attachPlugins(this.native, plugins);\n }\n\n /**\n * Compiles a module and records its resolver identities after compilation succeeds.\n *\n * @param code - Entry text before Stillwind transformation.\n * @param id - Full adapter resolver identity, including any query suffix.\n * @param host - Module descriptors, resolution, reads, and dependency tracking operations.\n * @param transport - Diagnostics, checker inputs, and generated imports for this compilation.\n * @returns The entry output, or undefined when compilation produces no entry code.\n * @throws If module identities conflict or host, checker, or compiler operations fail.\n */\n async compile(\n code: string,\n id: string,\n host: CompilerHost,\n transport: ModuleCompileOptions = {},\n ) {\n const pending = new Map<string, string>();\n const pendingByResolverId = new Map<string, string>();\n const output = await compileModule(\n this.native,\n () => {\n this.#facts ??= new TypeScriptFactsService(this.#typeFactsEnvironment);\n return this.#facts;\n },\n code,\n id,\n {\n ...host,\n onModule: (moduleId, resolverId) => {\n const previous = this.#resolverIdsByModuleId.get(moduleId);\n if (previous !== undefined && previous !== resolverId) {\n throw new Error(\n `Module identity ${moduleId} changed resolver identity from ${previous} to ${resolverId}`,\n );\n }\n const priorModuleId =\n pendingByResolverId.get(resolverId) ?? this.#moduleIdsByResolverId.get(resolverId);\n if (priorModuleId !== undefined && priorModuleId !== moduleId) {\n throw new Error(`Resolver identity ${resolverId} changed module identity`);\n }\n pending.set(moduleId, resolverId);\n pendingByResolverId.set(resolverId, moduleId);\n },\n },\n transport,\n );\n for (const [moduleId, resolverId] of pending) {\n this.#resolverIdsByModuleId.set(moduleId, resolverId);\n this.#moduleIdsByResolverId.set(resolverId, moduleId);\n host.onModule?.(moduleId, resolverId);\n }\n return output;\n }\n\n /**\n * Returns the host identity recorded after a compilation returned successfully.\n *\n * @param moduleId - Compiler identity previously observed during this session's compilation.\n * @returns Full resolver identity, including any query suffix.\n * @throws If this session has not recorded the module identity.\n */\n resolverId(moduleId: string): string {\n const id = this.#resolverIdsByModuleId.get(moduleId);\n if (id === undefined) {\n throw new Error(`Unknown Stillwind module identity: ${moduleId}`);\n }\n return id;\n }\n\n /**\n * Closes the current checker while retaining native compiler state and selected TypeScript settings.\n * Later compilation can start a new checker. Repeated calls have no effect until that happens.\n *\n * @throws If checker cleanup fails.\n */\n close(): void {\n this.#facts?.close();\n this.#facts = undefined;\n }\n}\n"],"mappings":";;;;;;;;AAwBA,SAAgB,qBAAqB,QAA4C;CAC/E,OAAO,gBAAgB;EACrB,GAAG;EACH,MAAM;CACR,CAAC;AACH;;;;;;;AAQA,SAAgB,eACd,SACA,MACM;CACN,KAAK,MAAM,aAAa,SACtB,KACE,cAAc,UAAU,KAAK,IAAI,UAAU,QAAQ,IAAI,UAAU,WAAW,GAAG,UAAU,OAAO,EAAE,GAAG,UAAU,SAAS,EAAE,EAC5H;AAEJ;;;;;AAMA,IAAa,qBAAb,MAAgC;;CAE9B;;CAEA;;CAGA;;CAEA,yCAAkC,IAAI,IAAoB;;CAE1D,yCAAkC,IAAI,IAAoB;;CAE1D;;;;;;;;;;;;CAaA,YACE,MACA,QACA,QACA,OACA,MACA,SACA;EACA,KAAK,OAAO;EACZ,KAAK,wBAAwB,4BAA4B,MAAM,OAAO,QAAQ;EAC9E,KAAK,SAAS,IAAI,qBAAqB,QAAQ,OAAO,MAAM,OAAO,QAAQ,KAAK;EAChF,cAAc,KAAK,QAAQ,OAAO;CACpC;;;;;;;;;;;CAYA,MAAM,QACJ,MACA,IACA,MACA,YAAkC,CAAC,GACnC;EACA,MAAM,0BAAU,IAAI,IAAoB;EACxC,MAAM,sCAAsB,IAAI,IAAoB;EACpD,MAAM,SAAS,MAAM,cACnB,KAAK,cACC;GACJ,KAAK,WAAW,IAAI,uBAAuB,KAAK,qBAAqB;GACrE,OAAO,KAAK;EACd,GACA,MACA,IACA;GACE,GAAG;GACH,WAAW,UAAU,eAAe;IAClC,MAAM,WAAW,KAAK,uBAAuB,IAAI,QAAQ;IACzD,IAAI,aAAa,KAAA,KAAa,aAAa,YACzC,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