@stillwind/integration 0.4.1 → 0.6.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/dist/astro/index.js +1 -1
- package/dist/fresh/index.js +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/{plugin-C_ZFfzo2.js → plugin-BFSq3lEh.js} +54 -10
- package/dist/plugin-BFSq3lEh.js.map +1 -0
- package/dist/vite/index.js +1 -1
- package/package.json +30 -7
- package/dist/plugin-C_ZFfzo2.js.map +0 -1
package/dist/astro/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as renderChunkStyles, r as createViteProject, t as createVitePlugins } from "../plugin-
|
|
1
|
+
import { i as renderChunkStyles, r as createViteProject, t as createVitePlugins } from "../plugin-BFSq3lEh.js";
|
|
2
2
|
import { registerDevelopmentCss } from "./development.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
package/dist/fresh/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as createViteProject, t as createVitePlugins } from "../plugin-
|
|
1
|
+
import { r as createViteProject, t as createVitePlugins } from "../plugin-BFSq3lEh.js";
|
|
2
2
|
// src/fresh/manifest.ts
|
|
3
3
|
/** Filters repeated static files for Fresh's move operation without changing the emitted manifest. */
|
|
4
4
|
function registrationManifest(source) {
|
package/dist/nuxt/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as createViteProject, t as createVitePlugins } from "../plugin-
|
|
1
|
+
import { r as createViteProject, t as createVitePlugins } from "../plugin-BFSq3lEh.js";
|
|
2
2
|
import { addPluginTemplate, defineNuxtModule } from "nuxt/kit";
|
|
3
3
|
// src/nuxt/index.ts
|
|
4
4
|
/**
|
|
@@ -3,7 +3,7 @@ import { n as buildCompilerOptions, r as warnSkippedCss, t as IntegrationSession
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import { attachPlugins, cleanModuleId, compilerModuleId, composeFrameworkSourceMap, createStylesheetResolver, cssEntrypoint, cssWithSourceMap, decodeCssSourceMap, fileSourceKind, finalizeCss, finalizeModuleWithMap, isStylesheet, loadCssGraph, moduleSourceMap, nodePluginHost, warnRejectedNames } from "@stillwind/host";
|
|
6
|
-
import { dirname, isAbsolute, posix, resolve } from "node:path";
|
|
6
|
+
import { dirname, isAbsolute, posix, relative, resolve } from "node:path";
|
|
7
7
|
import { readFile, readdir, realpath } from "node:fs/promises";
|
|
8
8
|
import { minifyCss } from "@stillwind/native";
|
|
9
9
|
import { isFileServingAllowed } from "vite";
|
|
@@ -462,8 +462,9 @@ function developmentHooks(project) {
|
|
|
462
462
|
*
|
|
463
463
|
* @param context - Vite hot-update event with the current server, changed file, and source
|
|
464
464
|
* reader.
|
|
465
|
-
* @returns Modules affected by a design-system update, an empty list
|
|
466
|
-
*
|
|
465
|
+
* @returns Modules affected by a design-system update, an empty list when a producer edit
|
|
466
|
+
* changes only CSS and no request has compiled the edited source yet, or `undefined` to retain
|
|
467
|
+
* normal Vite handling.
|
|
467
468
|
*/
|
|
468
469
|
async hotUpdate(context) {
|
|
469
470
|
const name = this.environment.name;
|
|
@@ -489,7 +490,8 @@ function developmentHooks(project) {
|
|
|
489
490
|
}
|
|
490
491
|
const previous = inputs(name).get(id);
|
|
491
492
|
if (previous && context.type !== "delete") {
|
|
492
|
-
const
|
|
493
|
+
const source = await context.read();
|
|
494
|
+
const result = await compile(name, source, id, host);
|
|
493
495
|
await publish(name, host);
|
|
494
496
|
const values = [];
|
|
495
497
|
for (const input of inputs(name).values()) {
|
|
@@ -502,7 +504,7 @@ function developmentHooks(project) {
|
|
|
502
504
|
}
|
|
503
505
|
}
|
|
504
506
|
if (values.length) return [.../* @__PURE__ */ new Set([...context.modules, ...values])];
|
|
505
|
-
if (!previous.manual && result?.code === previous.javascript) return [];
|
|
507
|
+
if (!previous.manual && previous.code !== source && result?.code === previous.javascript) return [];
|
|
506
508
|
}
|
|
507
509
|
} catch (error) {
|
|
508
510
|
this.warn(`Stillwind update failed; retaining published styles: ${String(error)}`);
|
|
@@ -511,8 +513,9 @@ function developmentHooks(project) {
|
|
|
511
513
|
/**
|
|
512
514
|
* Registers routes that serve document CSS and revisioned stylesheet snapshots.
|
|
513
515
|
*
|
|
514
|
-
* The document route supports repeated `module` selections and defaults to `ssr`.
|
|
515
|
-
*
|
|
516
|
+
* The document route supports repeated `module` selections and defaults to `ssr`. It records each
|
|
517
|
+
* served URL so that later CSS changes in that environment reload the document's link. The
|
|
518
|
+
* snapshot route defaults to `client`. Unknown environments return 404 and stylesheet failures return
|
|
516
519
|
* 500.
|
|
517
520
|
*
|
|
518
521
|
* @param server - Active server with the project's initialized Vite environments.
|
|
@@ -524,6 +527,9 @@ function developmentHooks(project) {
|
|
|
524
527
|
const selection = params.getAll("module");
|
|
525
528
|
const environment = server.environments[name];
|
|
526
529
|
if (!environment) return sendJson(response, { error: "Unknown environment" }, 404);
|
|
530
|
+
const link = new URL(request.originalUrl ?? request.url ?? "", "http://stillwind.local");
|
|
531
|
+
link.searchParams.delete("t");
|
|
532
|
+
project.observeDocumentStylesheet(name, link.pathname + link.search);
|
|
527
533
|
documentPlan(name, {
|
|
528
534
|
resolve: (specifier, importer, options) => environment.pluginContainer.resolveId(specifier, importer, options),
|
|
529
535
|
addWatchFile: (id) => {
|
|
@@ -1786,6 +1792,10 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1786
1792
|
let configurationDependencies = [];
|
|
1787
1793
|
let missingConfigurations = [];
|
|
1788
1794
|
const environments = /* @__PURE__ */ new Map();
|
|
1795
|
+
/** Document stylesheet URLs served in development, keyed by environment name. */
|
|
1796
|
+
const documentStylesheets = /* @__PURE__ */ new Map();
|
|
1797
|
+
/** CSS of the latest publication that refreshed document stylesheets, keyed by environment name. */
|
|
1798
|
+
const publishedDocumentCss = /* @__PURE__ */ new Map();
|
|
1789
1799
|
let bindings = /* @__PURE__ */ new WeakMap();
|
|
1790
1800
|
/**
|
|
1791
1801
|
* Gets or creates the compiler state owned by one Vite environment.
|
|
@@ -1894,6 +1904,8 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1894
1904
|
/** Detaches server listeners, closes discovery watchers, and closes every retained compiler environment. */
|
|
1895
1905
|
const close = () => {
|
|
1896
1906
|
stopCssWatching();
|
|
1907
|
+
documentStylesheets.clear();
|
|
1908
|
+
publishedDocumentCss.clear();
|
|
1897
1909
|
for (const state of environments.values()) state.close();
|
|
1898
1910
|
};
|
|
1899
1911
|
/**
|
|
@@ -1905,12 +1917,29 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1905
1917
|
*/
|
|
1906
1918
|
const publish = (name, context) => {
|
|
1907
1919
|
if (!settings.watching || !settings.devServerRef) return Promise.resolve();
|
|
1920
|
+
const environmentName = name ?? "client";
|
|
1908
1921
|
return environment(name).publish(context, (snapshot) => {
|
|
1909
|
-
settings.devServerRef?.environments
|
|
1922
|
+
const environments = settings.devServerRef?.environments;
|
|
1923
|
+
environments?.[environmentName]?.hot.send({
|
|
1910
1924
|
type: "custom",
|
|
1911
1925
|
event: "stillwind:css",
|
|
1912
1926
|
data: snapshot
|
|
1913
1927
|
});
|
|
1928
|
+
const urls = documentStylesheets.get(environmentName);
|
|
1929
|
+
if (!urls) return;
|
|
1930
|
+
const css = snapshot.parts.map((part) => part.css).join("\n");
|
|
1931
|
+
if (publishedDocumentCss.get(environmentName) === css) return;
|
|
1932
|
+
publishedDocumentCss.set(environmentName, css);
|
|
1933
|
+
const timestamp = Date.now();
|
|
1934
|
+
environments?.client?.hot.send({
|
|
1935
|
+
type: "update",
|
|
1936
|
+
updates: [...urls].sort((left, right) => right.length - left.length).map((path) => ({
|
|
1937
|
+
type: "css-update",
|
|
1938
|
+
path,
|
|
1939
|
+
acceptedPath: path,
|
|
1940
|
+
timestamp
|
|
1941
|
+
}))
|
|
1942
|
+
});
|
|
1914
1943
|
});
|
|
1915
1944
|
};
|
|
1916
1945
|
const project = {
|
|
@@ -1948,6 +1977,14 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1948
1977
|
documentPlan: (name, context, complete = false, selection) => environment(name).documentPlan(context, complete, selection),
|
|
1949
1978
|
snapshot: (name, context) => environment(name).snapshot(context),
|
|
1950
1979
|
publish,
|
|
1980
|
+
observeDocumentStylesheet: (name, url) => {
|
|
1981
|
+
let urls = documentStylesheets.get(name);
|
|
1982
|
+
if (!urls) {
|
|
1983
|
+
urls = /* @__PURE__ */ new Set();
|
|
1984
|
+
documentStylesheets.set(name, urls);
|
|
1985
|
+
}
|
|
1986
|
+
urls.add(url);
|
|
1987
|
+
},
|
|
1951
1988
|
publicSourceMap: (name, map) => publicCssSourceMap(environment(name).browserSources, map),
|
|
1952
1989
|
cssForBrowser: (name, output, replacements) => cssForBrowser(environment(name).browserSources, output, replacements),
|
|
1953
1990
|
buildOutput: (name) => environment(name).buildOutput ?? {},
|
|
@@ -2008,6 +2045,8 @@ async function projectionImports(code, id) {
|
|
|
2008
2045
|
return [...imports];
|
|
2009
2046
|
}
|
|
2010
2047
|
// src/vite/transform.ts
|
|
2048
|
+
/** Project settings whose configured CSS entrypoint has already produced an import warning. */
|
|
2049
|
+
const warnedEntrypointImports = /* @__PURE__ */ new WeakSet();
|
|
2011
2050
|
/**
|
|
2012
2051
|
* Creates source transform and watch hooks for the project compiler plugin.
|
|
2013
2052
|
*
|
|
@@ -2019,7 +2058,8 @@ async function projectionImports(code, id) {
|
|
|
2019
2058
|
* generated modules.
|
|
2020
2059
|
* @param options - Source selection and ordering required by the framework integration.
|
|
2021
2060
|
* @returns Hooks that recompile cached producers, register stylesheet projections, reserve authored
|
|
2022
|
-
* CSS identifiers, and remove deleted inputs.
|
|
2061
|
+
* CSS identifiers, and remove deleted inputs. The transform warns once per project when the
|
|
2062
|
+
* configured CSS entrypoint is imported as an ordinary stylesheet.
|
|
2023
2063
|
*/
|
|
2024
2064
|
function transformHooks(project, virtualModules, options = {}) {
|
|
2025
2065
|
const { settings, publish, compile } = project;
|
|
@@ -2072,6 +2112,10 @@ function transformHooks(project, virtualModules, options = {}) {
|
|
|
2072
2112
|
if (typeof load === "function") return load.call(this, id);
|
|
2073
2113
|
}
|
|
2074
2114
|
if (isAuthoredStylesheet(id)) {
|
|
2115
|
+
if (project.config.css && !warnedEntrypointImports.has(settings) && relative(resolve(settings.projectRoot, project.config.css), cleanModuleId(id)) === "") {
|
|
2116
|
+
warnedEntrypointImports.add(settings);
|
|
2117
|
+
this.warn(`The Stillwind CSS entrypoint ${project.config.css} is imported as an ordinary stylesheet. The integration already delivers its compiled CSS. Remove the import so that Vite does not also emit the uncompiled Stillwind rules.`);
|
|
2118
|
+
}
|
|
2075
2119
|
await project.environment(name).reserveAuthoredCss(id, code, this);
|
|
2076
2120
|
return;
|
|
2077
2121
|
}
|
|
@@ -2569,4 +2613,4 @@ function compilerPlugin(project, transform, closed) {
|
|
|
2569
2613
|
}
|
|
2570
2614
|
export { renderChunkStyles as i, stillwind as n, createViteProject as r, createVitePlugins as t };
|
|
2571
2615
|
|
|
2572
|
-
//# sourceMappingURL=plugin-
|
|
2616
|
+
//# sourceMappingURL=plugin-BFSq3lEh.js.map
|