@stillwind/integration 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +67 -2
- package/dist/NPM-THIRD-PARTY-LICENSES +52 -0
- package/dist/astro/development.d.ts +15 -0
- package/dist/astro/development.js +34 -0
- package/dist/astro/development.js.map +1 -0
- package/dist/astro/index.d.ts +17 -0
- package/dist/astro/index.js +194 -0
- package/dist/astro/index.js.map +1 -0
- package/dist/astro/middleware.d.ts +2 -0
- package/dist/astro/middleware.js +64 -0
- package/dist/astro/middleware.js.map +1 -0
- package/dist/binding-files-Ds5NpyVV.js +45 -0
- package/dist/binding-files-Ds5NpyVV.js.map +1 -0
- package/dist/emission-BVi5aRbb.js +520 -0
- package/dist/emission-BVi5aRbb.js.map +1 -0
- package/dist/fresh/index.d.ts +10 -0
- package/dist/fresh/index.js +55 -0
- package/dist/fresh/index.js.map +1 -0
- package/dist/gen-mapping-D7jFzOEh.js +559 -0
- package/dist/gen-mapping-D7jFzOEh.js.map +1 -0
- package/dist/index-DFfbZxNT.d.ts +12 -0
- package/dist/next/css-loader.d.ts +14 -0
- package/dist/next/css-loader.js +58 -0
- package/dist/next/css-loader.js.map +1 -0
- package/dist/next/index.d.ts +15 -0
- package/dist/next/index.js +66 -0
- package/dist/next/index.js.map +1 -0
- package/dist/node-loader-D-3Ynpy1.d.ts +19 -0
- package/dist/nuxt/index.d.ts +13 -0
- package/dist/nuxt/index.js +64 -0
- package/dist/nuxt/index.js.map +1 -0
- package/dist/plugin-C_ZFfzo2.js +2572 -0
- package/dist/plugin-C_ZFfzo2.js.map +1 -0
- package/dist/plugin-aV0zIIAe.d.ts +278 -0
- package/dist/plugin-mPiBLdqa.js +79 -0
- package/dist/plugin-mPiBLdqa.js.map +1 -0
- package/dist/project-BNw0nZBE.d.ts +58 -0
- package/dist/project-C3IH7geC.js +182 -0
- package/dist/project-C3IH7geC.js.map +1 -0
- package/dist/project-DUGu8g_L.d.ts +15 -0
- package/dist/rsbuild/index.d.ts +28 -0
- package/dist/rsbuild/index.js +77 -0
- package/dist/rsbuild/index.js.map +1 -0
- package/dist/rspack/index.d.ts +3 -0
- package/dist/rspack/index.js +1 -0
- package/dist/rules-BvKsL2at.js +91 -0
- package/dist/rules-BvKsL2at.js.map +1 -0
- package/dist/session-B9_rp9TH.d.ts +72 -0
- package/dist/session-DHUCQMG5.js +117 -0
- package/dist/session-DHUCQMG5.js.map +1 -0
- package/dist/source-map-loader-CBLiYaBI.d.ts +128 -0
- package/dist/sveltekit/handle.d.ts +13 -0
- package/dist/sveltekit/handle.js +16 -0
- package/dist/sveltekit/handle.js.map +1 -0
- package/dist/trace-mapping-DV_eP3r7.d.ts +58 -0
- package/dist/turbopack/css-loader.d.ts +15 -0
- package/dist/turbopack/css-loader.js +44 -0
- package/dist/turbopack/css-loader.js.map +1 -0
- package/dist/turbopack/index.d.ts +54 -0
- package/dist/turbopack/index.js +1 -0
- package/dist/turbopack/loader.d.ts +13 -0
- package/dist/turbopack/loader.js +70 -0
- package/dist/turbopack/loader.js.map +1 -0
- package/dist/turbopack/node-loader.d.ts +2 -0
- package/dist/turbopack/node-loader.js +20 -0
- package/dist/turbopack/node-loader.js.map +1 -0
- package/dist/turbopack/stillwind-turbopack.css +0 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/vite/index.js +1 -0
- package/dist/vite/runtime-source-map.d.ts +19 -0
- package/dist/vite/runtime-source-map.js +106 -0
- package/dist/vite/runtime-source-map.js.map +1 -0
- package/dist/vite/runtime.d.ts +58 -0
- package/dist/vite/runtime.js +90 -0
- package/dist/vite/runtime.js.map +1 -0
- package/dist/webpack/css-loader.d.ts +17 -0
- package/dist/webpack/css-loader.js +36 -0
- package/dist/webpack/css-loader.js.map +1 -0
- package/dist/webpack/css-map-loader.d.ts +24 -0
- package/dist/webpack/css-map-loader.js +43 -0
- package/dist/webpack/css-map-loader.js.map +1 -0
- package/dist/webpack/document-loader.d.ts +12 -0
- package/dist/webpack/document-loader.js +19 -0
- package/dist/webpack/document-loader.js.map +1 -0
- package/dist/webpack/fragment-loader.d.ts +9 -0
- package/dist/webpack/fragment-loader.js +23 -0
- package/dist/webpack/fragment-loader.js.map +1 -0
- package/dist/webpack/index.d.ts +3 -0
- package/dist/webpack/index.js +1 -0
- package/dist/webpack/loader.d.ts +35 -0
- package/dist/webpack/loader.js +199 -0
- package/dist/webpack/loader.js.map +1 -0
- package/dist/webpack/source-loader.d.ts +11 -0
- package/dist/webpack/source-loader.js +17 -0
- package/dist/webpack/source-loader.js.map +1 -0
- package/dist/webpack/source-map-loader.d.ts +2 -0
- package/dist/webpack/source-map-loader.js +35 -0
- package/dist/webpack/source-map-loader.js.map +1 -0
- package/dist/webpack/stillwind-fragment.d.ts +1 -0
- package/dist/webpack/stillwind-fragment.js +1 -0
- package/dist/webpack/stillwind-webpack.css +1 -0
- package/package.json +133 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./session-B9_rp9TH.js";
|
|
2
|
+
import { CssUpstreamMap, PluginRuntime } from "@stillwind/host";
|
|
3
|
+
import { NativeDesignSystemLoader, NativeStylesheetPlan } from "@stillwind/native";
|
|
4
|
+
import { Plugin } from "vite";
|
|
5
|
+
import { InlineConfig } from "@stillwind/config";
|
|
6
|
+
/** File selection and compiler overrides for Vite, Astro, and Nuxt, with CSS emission placement. */
|
|
7
|
+
interface IntegrationConfig extends InlineConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Production CSS placement. `single` emits one document stylesheet. `split` emits ordered parts
|
|
10
|
+
* selected by chunks. Defaults to `single`.
|
|
11
|
+
*/
|
|
12
|
+
emission?: "single" | "split";
|
|
13
|
+
}
|
|
14
|
+
export { IntegrationConfig as t };
|
|
15
|
+
//# sourceMappingURL=project-DUGu8g_L.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InlineConfig, InlineConfig as IntegrationConfig } from "@stillwind/config";
|
|
2
|
+
import { RsbuildPlugin } from "@rsbuild/core";
|
|
3
|
+
import { RspackOptions } from "@rspack/core";
|
|
4
|
+
/** Rsbuild plugin that uses only the hook for updating the Rspack configuration. */
|
|
5
|
+
export interface StillwindRsbuildPlugin extends RsbuildPlugin {
|
|
6
|
+
/**
|
|
7
|
+
* Registers Stillwind's configuration changes through the host's Rspack hook.
|
|
8
|
+
*
|
|
9
|
+
* @param api - Host API that accepts a modifier for the mutable Rspack configuration.
|
|
10
|
+
*/
|
|
11
|
+
setup(api: {
|
|
12
|
+
/**
|
|
13
|
+
* Registers a modifier for each generated Rspack configuration.
|
|
14
|
+
* @param callback - Receives mutable host options and returns the configuration to use.
|
|
15
|
+
*/
|
|
16
|
+
modifyRspackConfig(callback: (options: RspackOptions) => RspackOptions): void;
|
|
17
|
+
}): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an Rsbuild plugin that installs Stillwind compilation and CSS rules.
|
|
21
|
+
*
|
|
22
|
+
* @param config - Configuration discovery and inline overrides shared by the generated rules.
|
|
23
|
+
* @returns A plugin whose setup hook adjusts Rspack rules and registers a `StillwindPlugin`
|
|
24
|
+
* instance.
|
|
25
|
+
*/
|
|
26
|
+
export declare function pluginStillwind(config?: InlineConfig): StillwindRsbuildPlugin;
|
|
27
|
+
export type { IntegrationConfig };
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { d as stillwindRules } from "../emission-BVi5aRbb.js";
|
|
2
|
+
import { t as StillwindPlugin } from "../plugin-mPiBLdqa.js";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
// src/rsbuild/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Adapts existing CSS rules for Stillwind document carriers and source-map composition.
|
|
7
|
+
*
|
|
8
|
+
* The function excludes document carriers from matching CSS rules and inserts the Stillwind map
|
|
9
|
+
* bridge before each Lightning CSS loader entry.
|
|
10
|
+
*
|
|
11
|
+
* @param rules - Mutable Rsbuild rule list, including any nested `oneOf` and `rules` lists.
|
|
12
|
+
*/
|
|
13
|
+
function configureCssRules(rules) {
|
|
14
|
+
for (const rule of rules) {
|
|
15
|
+
if (!rule || typeof rule !== "object") continue;
|
|
16
|
+
if (rule.test instanceof RegExp && rule.test.test("stillwind-webpack.css")) rule.exclude = [rule.exclude, /stillwind-webpack\.css$/].filter((condition) => Boolean(condition));
|
|
17
|
+
if (Array.isArray(rule.use)) rule.use = rule.use.flatMap((use) => {
|
|
18
|
+
return (typeof use === "string" ? use : typeof use === "object" && use !== null ? use.loader : void 0) === "builtin:lightningcss-loader" ? [{ loader: fileURLToPath(new URL("./css-map-loader.js", import.meta.resolve("@stillwind/integration/webpack"))) }, use] : [use];
|
|
19
|
+
});
|
|
20
|
+
configureCssRules(rule.oneOf ?? []);
|
|
21
|
+
configureCssRules(rule.rules ?? []);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates an Rsbuild plugin that installs Stillwind compilation and CSS rules.
|
|
26
|
+
*
|
|
27
|
+
* @param config - Configuration discovery and inline overrides shared by the generated rules.
|
|
28
|
+
* @returns A plugin whose setup hook adjusts Rspack rules and registers a `StillwindPlugin`
|
|
29
|
+
* instance.
|
|
30
|
+
*/
|
|
31
|
+
function pluginStillwind(config = {}) {
|
|
32
|
+
return {
|
|
33
|
+
name: "stillwind",
|
|
34
|
+
/**
|
|
35
|
+
* Registers CSS rule adaptation and the compiler plugin on Rsbuild's Rspack configuration hook.
|
|
36
|
+
* @param api - Host API that applies the registered modifier before compilation.
|
|
37
|
+
*/
|
|
38
|
+
setup(api) {
|
|
39
|
+
api.modifyRspackConfig((options) => {
|
|
40
|
+
options.module ??= {};
|
|
41
|
+
options.module.rules ??= [];
|
|
42
|
+
configureCssRules(options.module.rules);
|
|
43
|
+
options.plugins ??= [];
|
|
44
|
+
options.plugins.push(new RsbuildStillwindPlugin(config));
|
|
45
|
+
return options;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A Stillwind plugin that places producer compilation within the Rsbuild framework loader chain.
|
|
52
|
+
*/
|
|
53
|
+
var RsbuildStillwindPlugin = class extends StillwindPlugin {
|
|
54
|
+
/**
|
|
55
|
+
* Appends Stillwind rules after framework pre-loaders and before normal JSX lowering.
|
|
56
|
+
*
|
|
57
|
+
* Vue query blocks are excluded from the script rule. Document carriers use native CSS modules so
|
|
58
|
+
* rebuilding them does not rerun the extraction loader.
|
|
59
|
+
*
|
|
60
|
+
* @param rules - Mutable Rspack rule list already configured by Rsbuild.
|
|
61
|
+
*/
|
|
62
|
+
configureRules(rules) {
|
|
63
|
+
const [javascript, ...stylesheets] = stillwindRules(this.config);
|
|
64
|
+
delete javascript.enforce;
|
|
65
|
+
const script = {
|
|
66
|
+
...javascript,
|
|
67
|
+
resourceQuery: { not: [/[?&]vue(?:[=&]|$)/] }
|
|
68
|
+
};
|
|
69
|
+
rules.push(script, ...stylesheets.map((rule) => rule.test.test("stillwind-webpack.css") ? {
|
|
70
|
+
...rule,
|
|
71
|
+
type: "css"
|
|
72
|
+
} : rule));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export { pluginStillwind };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/rsbuild/index.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\n\nimport type { RsbuildPlugin } from \"@rsbuild/core\";\nimport type { RspackOptions } from \"@rspack/core\";\nimport type { InlineConfig } from \"@stillwind/config\";\n\nimport { StillwindPlugin } from \"../webpack/plugin.ts\";\nimport { stillwindRules } from \"../webpack/rules.ts\";\n\nexport type { InlineConfig as IntegrationConfig } from \"@stillwind/config\";\n\n/** Rsbuild plugin that uses only the hook for updating the Rspack configuration. */\nexport interface StillwindRsbuildPlugin extends RsbuildPlugin {\n /**\n * Registers Stillwind's configuration changes through the host's Rspack hook.\n *\n * @param api - Host API that accepts a modifier for the mutable Rspack configuration.\n */\n setup(api: {\n /**\n * Registers a modifier for each generated Rspack configuration.\n * @param callback - Receives mutable host options and returns the configuration to use.\n */\n modifyRspackConfig(callback: (options: RspackOptions) => RspackOptions): void;\n }): void;\n}\n\n/**\n * Adapts existing CSS rules for Stillwind document carriers and source-map composition.\n *\n * The function excludes document carriers from matching CSS rules and inserts the Stillwind map\n * bridge before each Lightning CSS loader entry.\n *\n * @param rules - Mutable Rsbuild rule list, including any nested `oneOf` and `rules` lists.\n */\nfunction configureCssRules(rules: NonNullable<NonNullable<RspackOptions[\"module\"]>[\"rules\"]>) {\n for (const rule of rules) {\n if (!rule || typeof rule !== \"object\") {\n continue;\n }\n if (rule.test instanceof RegExp && rule.test.test(\"stillwind-webpack.css\")) {\n rule.exclude = [rule.exclude, /stillwind-webpack\\.css$/].filter(\n (condition): condition is NonNullable<typeof condition> => Boolean(condition),\n );\n }\n if (Array.isArray(rule.use)) {\n rule.use = rule.use.flatMap((use) => {\n const name =\n typeof use === \"string\"\n ? use\n : typeof use === \"object\" && use !== null\n ? use.loader\n : undefined;\n return name === \"builtin:lightningcss-loader\"\n ? [\n {\n loader: fileURLToPath(\n new URL(\n \"./css-map-loader.js\",\n import.meta.resolve(\"@stillwind/integration/webpack\"),\n ),\n ),\n },\n use,\n ]\n : [use];\n });\n }\n configureCssRules(rule.oneOf ?? []);\n configureCssRules(rule.rules ?? []);\n }\n}\n\n/**\n * Creates an Rsbuild plugin that installs Stillwind compilation and CSS rules.\n *\n * @param config - Configuration discovery and inline overrides shared by the generated rules.\n * @returns A plugin whose setup hook adjusts Rspack rules and registers a `StillwindPlugin`\n * instance.\n */\nexport function pluginStillwind(config: InlineConfig = {}): StillwindRsbuildPlugin {\n return {\n name: \"stillwind\",\n /**\n * Registers CSS rule adaptation and the compiler plugin on Rsbuild's Rspack configuration hook.\n * @param api - Host API that applies the registered modifier before compilation.\n */\n setup(api) {\n api.modifyRspackConfig((options) => {\n options.module ??= {};\n options.module.rules ??= [];\n configureCssRules(options.module.rules);\n options.plugins ??= [];\n options.plugins.push(new RsbuildStillwindPlugin(config));\n return options;\n });\n },\n };\n}\n\n/**\n * A Stillwind plugin that places producer compilation within the Rsbuild framework loader chain.\n */\nclass RsbuildStillwindPlugin extends StillwindPlugin {\n /**\n * Appends Stillwind rules after framework pre-loaders and before normal JSX lowering.\n *\n * Vue query blocks are excluded from the script rule. Document carriers use native CSS modules so\n * rebuilding them does not rerun the extraction loader.\n *\n * @param rules - Mutable Rspack rule list already configured by Rsbuild.\n */\n protected override configureRules(rules: unknown[]): void {\n const [javascript, ...stylesheets] = stillwindRules(this.config);\n // Framework pre-loaders must split routes/server functions before CSS\n // ownership is determined. Appending a normal loader still runs before SWC.\n delete javascript.enforce;\n const script = {\n ...javascript,\n resourceQuery: {\n not: [/[?&]vue(?:[=&]|$)/],\n },\n };\n // Document carriers are rebuilt after graph linking. Native CSS modules avoid\n // running Rsbuild's extraction loader again during that rebuild.\n rules.push(\n script,\n ...stylesheets.map((rule) =>\n rule.test.test(\"stillwind-webpack.css\")\n ? {\n ...rule,\n type: \"css\",\n }\n : rule,\n ),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,kBAAkB,OAAmE;CAC5F,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,QAAQ,OAAO,SAAS,UAC3B;EAEF,IAAI,KAAK,gBAAgB,UAAU,KAAK,KAAK,KAAK,uBAAuB,GACvE,KAAK,UAAU,CAAC,KAAK,SAAS,yBAAyB,CAAC,CAAC,QACtD,cAA0D,QAAQ,SAAS,CAC9E;EAEF,IAAI,MAAM,QAAQ,KAAK,GAAG,GACxB,KAAK,MAAM,KAAK,IAAI,SAAS,QAAQ;GAOnC,QALE,OAAO,QAAQ,WACX,MACA,OAAO,QAAQ,YAAY,QAAQ,OACjC,IAAI,SACJ,KAAA,OACQ,gCACZ,CACE,EACE,QAAQ,cACN,IAAI,IACF,uBACA,YAAY,QAAQ,gCAAgC,CACtD,CACF,EACF,GACA,GACF,IACA,CAAC,GAAG;EACV,CAAC;EAEH,kBAAkB,KAAK,SAAS,CAAC,CAAC;EAClC,kBAAkB,KAAK,SAAS,CAAC,CAAC;CACpC;AACF;;;;;;;;AASA,SAAgB,gBAAgB,SAAuB,CAAC,GAA2B;CACjF,OAAO;EACL,MAAM;;;;;EAKN,MAAM,KAAK;GACT,IAAI,oBAAoB,YAAY;IAClC,QAAQ,WAAW,CAAC;IACpB,QAAQ,OAAO,UAAU,CAAC;IAC1B,kBAAkB,QAAQ,OAAO,KAAK;IACtC,QAAQ,YAAY,CAAC;IACrB,QAAQ,QAAQ,KAAK,IAAI,uBAAuB,MAAM,CAAC;IACvD,OAAO;GACT,CAAC;EACH;CACF;AACF;;;;AAKA,IAAM,yBAAN,cAAqC,gBAAgB;;;;;;;;;CASnD,eAAkC,OAAwB;EACxD,MAAM,CAAC,YAAY,GAAG,eAAe,eAAe,KAAK,MAAM;EAG/D,OAAO,WAAW;EAClB,MAAM,SAAS;GACb,GAAG;GACH,eAAe,EACb,KAAK,CAAC,mBAAmB,EAC3B;EACF;EAGA,MAAM,KACJ,QACA,GAAG,YAAY,KAAK,SAClB,KAAK,KAAK,KAAK,uBAAuB,IAClC;GACE,GAAG;GACH,MAAM;EACR,IACA,IACN,CACF;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as StillwindPlugin } from "../plugin-mPiBLdqa.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
// src/turbopack/rules.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates producer and shared stylesheet rules for a host's turbopack.rules
|
|
6
|
+
* configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Entry paths, optional mode, configuration file selection, and
|
|
9
|
+
* serializable compiler overrides. File evaluation occurs in loaders after the bundler
|
|
10
|
+
* starts.
|
|
11
|
+
* @returns Rules with independent Stillwind loaders. The host supplies its CSS output
|
|
12
|
+
* pipeline.
|
|
13
|
+
* @throws If entries is empty or contains blank paths, inline naming callbacks are
|
|
14
|
+
* supplied, or installed loader paths cannot be resolved.
|
|
15
|
+
*/
|
|
16
|
+
function stillwindRules(config) {
|
|
17
|
+
if (!Array.isArray(config.entries) || !config.entries.length || config.entries.some((entry) => typeof entry !== "string" || !entry.trim())) throw new Error("Stillwind Turbopack requires a non-empty list of application entry files");
|
|
18
|
+
const { entries, mode, ...compiler } = config;
|
|
19
|
+
return createRules(createLoaderOptions(compiler, entries, mode));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Prepares serializable settings for isolated loader workers.
|
|
23
|
+
*
|
|
24
|
+
* @param compiler - Discovery settings and inline overrides. Naming callbacks must be
|
|
25
|
+
* defined in the configuration file, since loader transport cannot serialize inline
|
|
26
|
+
* functions.
|
|
27
|
+
* @param entries - Entry paths copied into the loader options. Next can supply an empty
|
|
28
|
+
* list and discover routes later. Paths are resolved after the loader evaluates the
|
|
29
|
+
* project root.
|
|
30
|
+
* @param mode - Compilation mode. Omission uses development only when NODE_ENV is
|
|
31
|
+
* development.
|
|
32
|
+
* @returns Loader options with copied compiler settings and entries. The bundler root
|
|
33
|
+
* supplies the application directory for discovery.
|
|
34
|
+
* @throws If compiler supplies inline naming callbacks or values that cannot be cloned.
|
|
35
|
+
*/
|
|
36
|
+
function createLoaderOptions(compiler, entries, mode) {
|
|
37
|
+
if ("naming" in compiler && compiler.naming) throw new Error("Turbopack loader options must be serializable; naming callbacks are not supported");
|
|
38
|
+
return {
|
|
39
|
+
compiler: structuredClone(compiler),
|
|
40
|
+
root: ".",
|
|
41
|
+
entries: [...entries],
|
|
42
|
+
mode: mode ?? (process.env.NODE_ENV === "development" ? "development" : "release")
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Locates a built loader beside the installed Turbopack entrypoint.
|
|
47
|
+
*
|
|
48
|
+
* @param file - Filename relative to that entrypoint, such as loader.js or css-loader.js.
|
|
49
|
+
* @returns The absolute filesystem path. Existence of the selected file is not checked.
|
|
50
|
+
* @throws If the installed Turbopack entrypoint cannot be resolved.
|
|
51
|
+
*/
|
|
52
|
+
function loaderPath(file) {
|
|
53
|
+
return fileURLToPath(new URL(`./${file}`, import.meta.resolve("@stillwind/integration/turbopack")));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates source and stylesheet carrier rules from captured loader options.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Serializable settings retained by both rules without copying.
|
|
59
|
+
* @param cssLoader - Absolute stylesheet loader path. Next supplies its route-discovery
|
|
60
|
+
* wrapper. Omission selects the standalone Turbopack stylesheet loader.
|
|
61
|
+
* @returns Rules keyed by source and carrier filename patterns. Configuration is not
|
|
62
|
+
* evaluated here.
|
|
63
|
+
* @throws If an installed loader path cannot be resolved.
|
|
64
|
+
*/
|
|
65
|
+
function createRules(options, cssLoader = loaderPath("css-loader.js")) {
|
|
66
|
+
return {
|
|
67
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": {
|
|
68
|
+
condition: { not: "foreign" },
|
|
69
|
+
loaders: [{
|
|
70
|
+
loader: loaderPath("node-loader.js"),
|
|
71
|
+
options: {
|
|
72
|
+
...options,
|
|
73
|
+
implementation: loaderPath("loader.js")
|
|
74
|
+
}
|
|
75
|
+
}]
|
|
76
|
+
},
|
|
77
|
+
"stillwind-turbopack.css": {
|
|
78
|
+
loaders: [{
|
|
79
|
+
loader: loaderPath("node-loader.js"),
|
|
80
|
+
options: {
|
|
81
|
+
...options,
|
|
82
|
+
implementation: cssLoader
|
|
83
|
+
}
|
|
84
|
+
}],
|
|
85
|
+
as: "*.css"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export { stillwindRules as i, createRules as n, loaderPath as r, createLoaderOptions as t };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=rules-BvKsL2at.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-BvKsL2at.js","names":[],"sources":["../src/turbopack/rules.ts"],"sourcesContent":["import process from \"node:process\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { SerializableInlineConfig } from \"@stillwind/config\";\n\nimport type { NodeLoaderOptions } from \"./node-loader.ts\";\nimport type { TurbopackLoaderOptions } from \"./project.ts\";\n\n/**\n * Serializable inline settings and entry selection for standalone Turbopack rules.\n * Naming callbacks can be supplied by stillwind.config.*, which each loader evaluates.\n */\nexport interface IntegrationConfig extends SerializableInlineConfig {\n /**\n * Nonempty list of entry paths, absolute or relative to the resolved project root.\n * Globs are not expanded.\n */\n entries: string[];\n /** Defaults to development when NODE_ENV is development, otherwise release. */\n mode?: \"development\" | \"release\";\n}\n\n/**\n * Host rule that maps source files or the shared stylesheet carrier to Stillwind\n * loaders.\n */\nexport interface TurbopackRule {\n /**\n * Limits the producer rule to application modules rather than foreign package\n * modules.\n */\n condition?: {\n /** Turbopack condition excluding modules classified as foreign packages. */\n not: \"foreign\";\n };\n /** Loader chain in bundler rule order, using shared captured options. */\n loaders: {\n /** Absolute path to an installed Stillwind loader. */\n loader: string;\n /** Serializable settings forwarded to the isolated loader invocation. */\n options: NodeLoaderOptions;\n }[];\n /** Forces the stylesheet carrier's output to be processed as CSS. */\n as?: string;\n}\n\n/**\n * Creates producer and shared stylesheet rules for a host's turbopack.rules\n * configuration.\n *\n * @param config - Entry paths, optional mode, configuration file selection, and\n * serializable compiler overrides. File evaluation occurs in loaders after the bundler\n * starts.\n * @returns Rules with independent Stillwind loaders. The host supplies its CSS output\n * pipeline.\n * @throws If entries is empty or contains blank paths, inline naming callbacks are\n * supplied, or installed loader paths cannot be resolved.\n */\nexport function stillwindRules(config: IntegrationConfig): Record<string, TurbopackRule> {\n if (\n !Array.isArray(config.entries) ||\n !config.entries.length ||\n config.entries.some((entry) => typeof entry !== \"string\" || !entry.trim())\n ) {\n throw new Error(\"Stillwind Turbopack requires a non-empty list of application entry files\");\n }\n const { entries, mode, ...compiler } = config;\n return createRules(createLoaderOptions(compiler, entries, mode));\n}\n\n/**\n * Prepares serializable settings for isolated loader workers.\n *\n * @param compiler - Discovery settings and inline overrides. Naming callbacks must be\n * defined in the configuration file, since loader transport cannot serialize inline\n * functions.\n * @param entries - Entry paths copied into the loader options. Next can supply an empty\n * list and discover routes later. Paths are resolved after the loader evaluates the\n * project root.\n * @param mode - Compilation mode. Omission uses development only when NODE_ENV is\n * development.\n * @returns Loader options with copied compiler settings and entries. The bundler root\n * supplies the application directory for discovery.\n * @throws If compiler supplies inline naming callbacks or values that cannot be cloned.\n */\nexport function createLoaderOptions(\n compiler: SerializableInlineConfig,\n entries: string[],\n mode?: string,\n): TurbopackLoaderOptions {\n if (\"naming\" in compiler && compiler.naming) {\n throw new Error(\n \"Turbopack loader options must be serializable; naming callbacks are not supported\",\n );\n }\n\n return {\n compiler: structuredClone(compiler) as TurbopackLoaderOptions[\"compiler\"],\n root: \".\",\n entries: [...entries],\n mode: mode ?? (process.env.NODE_ENV === \"development\" ? \"development\" : \"release\"),\n };\n}\n\n/**\n * Locates a built loader beside the installed Turbopack entrypoint.\n *\n * @param file - Filename relative to that entrypoint, such as loader.js or css-loader.js.\n * @returns The absolute filesystem path. Existence of the selected file is not checked.\n * @throws If the installed Turbopack entrypoint cannot be resolved.\n */\nexport function loaderPath(file: string): string {\n return fileURLToPath(\n new URL(`./${file}`, import.meta.resolve(\"@stillwind/integration/turbopack\")),\n );\n}\n\n/**\n * Creates source and stylesheet carrier rules from captured loader options.\n *\n * @param options - Serializable settings retained by both rules without copying.\n * @param cssLoader - Absolute stylesheet loader path. Next supplies its route-discovery\n * wrapper. Omission selects the standalone Turbopack stylesheet loader.\n * @returns Rules keyed by source and carrier filename patterns. Configuration is not\n * evaluated here.\n * @throws If an installed loader path cannot be resolved.\n */\nexport function createRules(\n options: TurbopackLoaderOptions,\n cssLoader = loaderPath(\"css-loader.js\"),\n): Record<string, TurbopackRule> {\n return {\n \"*.{js,jsx,ts,tsx,mjs,cjs}\": {\n condition: {\n not: \"foreign\",\n },\n loaders: [\n {\n loader: loaderPath(\"node-loader.js\"),\n options: {\n ...options,\n implementation: loaderPath(\"loader.js\"),\n },\n },\n ],\n },\n \"stillwind-turbopack.css\": {\n loaders: [\n {\n loader: loaderPath(\"node-loader.js\"),\n options: {\n ...options,\n implementation: cssLoader,\n },\n },\n ],\n as: \"*.css\",\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0DA,SAAgB,eAAe,QAA0D;CACvF,IACE,CAAC,MAAM,QAAQ,OAAO,OAAO,KAC7B,CAAC,OAAO,QAAQ,UAChB,OAAO,QAAQ,MAAM,UAAU,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,CAAC,GAEzE,MAAM,IAAI,MAAM,0EAA0E;CAE5F,MAAM,EAAE,SAAS,MAAM,GAAG,aAAa;CACvC,OAAO,YAAY,oBAAoB,UAAU,SAAS,IAAI,CAAC;AACjE;;;;;;;;;;;;;;;;AAiBA,SAAgB,oBACd,UACA,SACA,MACwB;CACxB,IAAI,YAAY,YAAY,SAAS,QACnC,MAAM,IAAI,MACR,mFACF;CAGF,OAAO;EACL,UAAU,gBAAgB,QAAQ;EAClC,MAAM;EACN,SAAS,CAAC,GAAG,OAAO;EACpB,MAAM,SAAS,QAAQ,IAAI,aAAa,gBAAgB,gBAAgB;CAC1E;AACF;;;;;;;;AASA,SAAgB,WAAW,MAAsB;CAC/C,OAAO,cACL,IAAI,IAAI,KAAK,QAAQ,YAAY,QAAQ,kCAAkC,CAAC,CAC9E;AACF;;;;;;;;;;;AAYA,SAAgB,YACd,SACA,YAAY,WAAW,eAAe,GACP;CAC/B,OAAO;EACL,6BAA6B;GAC3B,WAAW,EACT,KAAK,UACP;GACA,SAAS,CACP;IACE,QAAQ,WAAW,gBAAgB;IACnC,SAAS;KACP,GAAG;KACH,gBAAgB,WAAW,WAAW;IACxC;GACF,CACF;EACF;EACA,2BAA2B;GACzB,SAAS,CACP;IACE,QAAQ,WAAW,gBAAgB;IACnC,SAAS;KACP,GAAG;KACH,gBAAgB;IAClB;GACF,CACF;GACA,IAAI;EACN;CACF;AACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,IAAI,MACR,mBAAmB,SAAS,kCAAkC,SAAS,MAAM,YAC/E;IAEF,MAAM,gBACJ,oBAAoB,IAAI,UAAU,KAAK,KAAK,uBAAuB,IAAI,UAAU;IACnF,IAAI,kBAAkB,KAAA,KAAa,kBAAkB,UACnD,MAAM,IAAI,MAAM,qBAAqB,WAAW,yBAAyB;IAE3E,QAAQ,IAAI,UAAU,UAAU;IAChC,oBAAoB,IAAI,YAAY,QAAQ;GAC9C;EACF,GACA,SACF;EACA,KAAK,MAAM,CAAC,UAAU,eAAe,SAAS;GAC5C,KAAK,uBAAuB,IAAI,UAAU,UAAU;GACpD,KAAK,uBAAuB,IAAI,YAAY,QAAQ;GACpD,KAAK,WAAW,UAAU,UAAU;EACtC;EACA,OAAO;CACT;;;;;;;;CASA,WAAW,UAA0B;EACnC,MAAM,KAAK,KAAK,uBAAuB,IAAI,QAAQ;EACnD,IAAI,OAAO,KAAA,GACT,MAAM,IAAI,MAAM,sCAAsC,UAAU;EAElE,OAAO;CACT;;;;;;;CAQA,QAAc;EACZ,KAAK,QAAQ,MAAM;EACnB,KAAK,SAAS,KAAA;CAChB;AACF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { n as EncodedSourceMap$1, r as SourceMapInput, t as DecodedSourceMap } from "./trace-mapping-DV_eP3r7.js";
|
|
2
|
+
import { UpstreamSourceMap } from "@stillwind/host";
|
|
3
|
+
import { NativeStylesheetPlan } from "@stillwind/native";
|
|
4
|
+
import { LoaderContext } from "webpack";
|
|
5
|
+
interface SourceMapV3 {
|
|
6
|
+
file?: string | null;
|
|
7
|
+
names: readonly string[];
|
|
8
|
+
sourceRoot?: string;
|
|
9
|
+
sources: readonly (string | null)[];
|
|
10
|
+
sourcesContent?: readonly (string | null)[];
|
|
11
|
+
version: 3;
|
|
12
|
+
ignoreList?: readonly number[];
|
|
13
|
+
}
|
|
14
|
+
interface EncodedSourceMap extends SourceMapV3 {
|
|
15
|
+
mappings: string;
|
|
16
|
+
}
|
|
17
|
+
type Options$1 = {
|
|
18
|
+
file?: string | null;
|
|
19
|
+
sourceRoot?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Provides the state to generate a sourcemap.
|
|
23
|
+
*/
|
|
24
|
+
declare class GenMapping {
|
|
25
|
+
private _names;
|
|
26
|
+
private _sources;
|
|
27
|
+
private _sourcesContent;
|
|
28
|
+
private _mappings;
|
|
29
|
+
private _ignoreList;
|
|
30
|
+
file: string | null | undefined;
|
|
31
|
+
sourceRoot: string | null | undefined;
|
|
32
|
+
constructor({ file, sourceRoot }?: Options$1);
|
|
33
|
+
}
|
|
34
|
+
type Options = {
|
|
35
|
+
excludeContent?: boolean;
|
|
36
|
+
decodedMappings?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
|
40
|
+
* provided to it.
|
|
41
|
+
*/
|
|
42
|
+
declare class SourceMap {
|
|
43
|
+
file?: string | null;
|
|
44
|
+
mappings: EncodedSourceMap$1['mappings'] | DecodedSourceMap['mappings'];
|
|
45
|
+
sourceRoot?: string;
|
|
46
|
+
names: string[];
|
|
47
|
+
sources: (string | null)[];
|
|
48
|
+
sourcesContent?: (string | null)[];
|
|
49
|
+
version: 3;
|
|
50
|
+
ignoreList: number[] | undefined;
|
|
51
|
+
constructor(map: GenMapping, options: Options);
|
|
52
|
+
toString(): string;
|
|
53
|
+
}
|
|
54
|
+
/** Stillwind metadata passed between loaders while preserving other plugins' additional fields. */
|
|
55
|
+
interface LoaderAdditionalData {
|
|
56
|
+
/** AST supplied by a preceding webpack loader, when available. */
|
|
57
|
+
webpackAST?: object;
|
|
58
|
+
/** Compiler output and identity of a source already transformed by Stillwind. */
|
|
59
|
+
stillwind?: Partial<Pick<NativeStylesheetPlan, "coverage" | "designSystem" | "producers">> & {
|
|
60
|
+
/** Resource identity and digest used to avoid compiling an identical transform twice. */
|
|
61
|
+
sourceTransform?: {
|
|
62
|
+
/** Resource path and query that selected the source. */
|
|
63
|
+
resource: string;
|
|
64
|
+
/** SHA-256 hex digest of the transformed source. */
|
|
65
|
+
fingerprint: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/** Data owned by other loaders, forwarded without interpretation. */
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
/** Transformed SFC text and its map shared through the pitch data of one loader. */
|
|
72
|
+
interface SourceTransform {
|
|
73
|
+
/** Source after Stillwind compilation and finalization. */
|
|
74
|
+
code: string;
|
|
75
|
+
/** Map from transformed code back to the original component. */
|
|
76
|
+
map: EncodedSourceMap | SourceMap;
|
|
77
|
+
/** Resource identity that must match the source-map bridge's resource path. */
|
|
78
|
+
resource: string;
|
|
79
|
+
}
|
|
80
|
+
/** Pitch data retained for source-map composition after framework loaders have run. */
|
|
81
|
+
interface SourceTransformData {
|
|
82
|
+
/** Stillwind transform for this loader invocation, when an SFC was compiled. */
|
|
83
|
+
stillwindSourceTransform?: SourceTransform;
|
|
84
|
+
}
|
|
85
|
+
/** Loader context with typed pitch data for both webpack and Rspack's loader runner. */
|
|
86
|
+
type SourceTransformContext<Options> = Omit<LoaderContext<Options>, "data" | "loaders"> & {
|
|
87
|
+
/** Data shared by this loader's pitch and normal phases. */
|
|
88
|
+
data: SourceTransformData;
|
|
89
|
+
/** Loader chain whose entries expose pitch data in either runner's representation. */
|
|
90
|
+
loaders: (Omit<LoaderContext<Options>["loaders"][number], "data"> & {
|
|
91
|
+
/** Pitch data exposed directly by webpack. */
|
|
92
|
+
data?: SourceTransformData;
|
|
93
|
+
/** Pitch data exposed through Rspack 2's loader item. */
|
|
94
|
+
loaderItem?: {
|
|
95
|
+
/** Optional per-loader pitch data containing the preceding Stillwind transform. */
|
|
96
|
+
data?: SourceTransformData;
|
|
97
|
+
};
|
|
98
|
+
})[];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Completes a loader invocation with maps and optional metadata accepted by the loader runners.
|
|
102
|
+
*
|
|
103
|
+
* @param error - Failure, or null or undefined for successful completion.
|
|
104
|
+
* @param source - Generated or unchanged source text.
|
|
105
|
+
* @param map - Upstream map or map chain supplied by loaders, when available.
|
|
106
|
+
* @param data - Additional data forwarded to the next loader, when available.
|
|
107
|
+
*/
|
|
108
|
+
type LoaderCompletion = (error?: unknown, source?: string | Buffer, map?: UpstreamSourceMap | EncodedSourceMap | SourceMap, data?: LoaderAdditionalData) => void;
|
|
109
|
+
/**
|
|
110
|
+
* Obtains an asynchronous completion callback for the shared loader protocol.
|
|
111
|
+
*
|
|
112
|
+
* @param context - webpack-compatible loader context for the current invocation.
|
|
113
|
+
* @returns The runner's callback. Stillwind metadata does not require a `webpackAST` field, and
|
|
114
|
+
* composed maps can contain nullable source content allowed by the source-map library.
|
|
115
|
+
*/
|
|
116
|
+
declare function loaderCompletion(context: Pick<LoaderContext<unknown>, "async">): LoaderCompletion;
|
|
117
|
+
/**
|
|
118
|
+
* Composes a framework's output map through the Stillwind transform stored in pitch data.
|
|
119
|
+
*
|
|
120
|
+
* @param this - Loader context whose chain exposes the preceding Stillwind transform.
|
|
121
|
+
* @param source - Framework output forwarded unchanged.
|
|
122
|
+
* @param inputMap - Framework map, when available.
|
|
123
|
+
* @param additionalData - Additional loader data forwarded unchanged.
|
|
124
|
+
* @returns Undefined after completing the loader callback.
|
|
125
|
+
*/
|
|
126
|
+
declare function webpackSourceMapLoader(this: SourceTransformContext<unknown>, source: string, inputMap: SourceMapInput | null | undefined, additionalData?: LoaderAdditionalData): void;
|
|
127
|
+
export { SourceTransformData as a, SourceTransformContext as i, LoaderCompletion as n, loaderCompletion as o, SourceTransform as r, webpackSourceMapLoader as s, LoaderAdditionalData as t };
|
|
128
|
+
//# sourceMappingURL=source-map-loader-CBLiYaBI.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { sequence } from "@sveltejs/kit/hooks";
|
|
2
|
+
/**
|
|
3
|
+
* Supplies development SSR CSS through SvelteKit's page transformation hook.
|
|
4
|
+
* Use this handle with the Vite adapter; production uses Vite's emitted stylesheets.
|
|
5
|
+
* SvelteKit's sequence helper can compose it with application handles.
|
|
6
|
+
*
|
|
7
|
+
* @param options - SvelteKit request event and the resolver that renders its response.
|
|
8
|
+
* @returns The resolver's response. Development HTML chunks receive a stylesheet link before
|
|
9
|
+
* their first closing head tag, and production chunks retain their original text.
|
|
10
|
+
* @throws If request resolution or page transformation fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare const handle: ReturnType<typeof sequence>;
|
|
13
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from "$app/paths";
|
|
2
|
+
// src/sveltekit/handle.ts
|
|
3
|
+
/**
|
|
4
|
+
* Supplies development SSR CSS through SvelteKit's page transformation hook.
|
|
5
|
+
* Use this handle with the Vite adapter; production uses Vite's emitted stylesheets.
|
|
6
|
+
* SvelteKit's sequence helper can compose it with application handles.
|
|
7
|
+
*
|
|
8
|
+
* @param options - SvelteKit request event and the resolver that renders its response.
|
|
9
|
+
* @returns The resolver's response. Development HTML chunks receive a stylesheet link before
|
|
10
|
+
* their first closing head tag, and production chunks retain their original text.
|
|
11
|
+
* @throws If request resolution or page transformation fails.
|
|
12
|
+
*/
|
|
13
|
+
const handle = ({ event, resolve: resolve$1 }) => resolve$1(event, { transformPageChunk: ({ html }) => import.meta.env.DEV ? html.replace("</head>", `<link rel="stylesheet" href="${resolve("/__stillwind/style.css?environment=ssr", {})}"></head>`) : html });
|
|
14
|
+
export { handle };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","names":["resolve","resolvePath"],"sources":["../../src/sveltekit/handle.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\n\nimport { resolve as resolvePath } from \"$app/paths\";\nimport type { sequence } from \"@sveltejs/kit/hooks\";\n\n/**\n * Supplies development SSR CSS through SvelteKit's page transformation hook.\n * Use this handle with the Vite adapter; production uses Vite's emitted stylesheets.\n * SvelteKit's sequence helper can compose it with application handles.\n *\n * @param options - SvelteKit request event and the resolver that renders its response.\n * @returns The resolver's response. Development HTML chunks receive a stylesheet link before\n * their first closing head tag, and production chunks retain their original text.\n * @throws If request resolution or page transformation fails.\n */\nexport const handle: ReturnType<typeof sequence> = ({ event, resolve }) =>\n resolve(event, {\n transformPageChunk: ({ html }) =>\n import.meta.env.DEV\n ? html.replace(\n \"</head>\",\n `<link rel=\"stylesheet\" href=\"${resolvePath(\"/__stillwind/style.css?environment=ssr\", {})}\"></head>`,\n )\n : html,\n });\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,UAAuC,EAAE,OAAO,SAAA,gBAC3DA,UAAQ,OAAO,EACb,qBAAqB,EAAE,WACrB,YAAY,IAAI,MACZ,KAAK,QACH,WACA,gCAAgCC,QAAY,0CAA0C,CAAC,CAAC,EAAE,UAC5F,IACA,KACR,CAAC"}
|