@stillwind/integration 0.5.0 → 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-B2UvdR4C.js → plugin-BFSq3lEh.js} +48 -6
- package/dist/plugin-BFSq3lEh.js.map +1 -0
- package/dist/vite/index.js +1 -1
- package/package.json +30 -7
- package/dist/plugin-B2UvdR4C.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";
|
|
@@ -513,8 +513,9 @@ function developmentHooks(project) {
|
|
|
513
513
|
/**
|
|
514
514
|
* Registers routes that serve document CSS and revisioned stylesheet snapshots.
|
|
515
515
|
*
|
|
516
|
-
* The document route supports repeated `module` selections and defaults to `ssr`.
|
|
517
|
-
*
|
|
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
|
|
518
519
|
* 500.
|
|
519
520
|
*
|
|
520
521
|
* @param server - Active server with the project's initialized Vite environments.
|
|
@@ -526,6 +527,9 @@ function developmentHooks(project) {
|
|
|
526
527
|
const selection = params.getAll("module");
|
|
527
528
|
const environment = server.environments[name];
|
|
528
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);
|
|
529
533
|
documentPlan(name, {
|
|
530
534
|
resolve: (specifier, importer, options) => environment.pluginContainer.resolveId(specifier, importer, options),
|
|
531
535
|
addWatchFile: (id) => {
|
|
@@ -1788,6 +1792,10 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1788
1792
|
let configurationDependencies = [];
|
|
1789
1793
|
let missingConfigurations = [];
|
|
1790
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();
|
|
1791
1799
|
let bindings = /* @__PURE__ */ new WeakMap();
|
|
1792
1800
|
/**
|
|
1793
1801
|
* Gets or creates the compiler state owned by one Vite environment.
|
|
@@ -1896,6 +1904,8 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1896
1904
|
/** Detaches server listeners, closes discovery watchers, and closes every retained compiler environment. */
|
|
1897
1905
|
const close = () => {
|
|
1898
1906
|
stopCssWatching();
|
|
1907
|
+
documentStylesheets.clear();
|
|
1908
|
+
publishedDocumentCss.clear();
|
|
1899
1909
|
for (const state of environments.values()) state.close();
|
|
1900
1910
|
};
|
|
1901
1911
|
/**
|
|
@@ -1907,12 +1917,29 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1907
1917
|
*/
|
|
1908
1918
|
const publish = (name, context) => {
|
|
1909
1919
|
if (!settings.watching || !settings.devServerRef) return Promise.resolve();
|
|
1920
|
+
const environmentName = name ?? "client";
|
|
1910
1921
|
return environment(name).publish(context, (snapshot) => {
|
|
1911
|
-
settings.devServerRef?.environments
|
|
1922
|
+
const environments = settings.devServerRef?.environments;
|
|
1923
|
+
environments?.[environmentName]?.hot.send({
|
|
1912
1924
|
type: "custom",
|
|
1913
1925
|
event: "stillwind:css",
|
|
1914
1926
|
data: snapshot
|
|
1915
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
|
+
});
|
|
1916
1943
|
});
|
|
1917
1944
|
};
|
|
1918
1945
|
const project = {
|
|
@@ -1950,6 +1977,14 @@ function createViteProject(supplied = {}, applicationRoot = () => void 0) {
|
|
|
1950
1977
|
documentPlan: (name, context, complete = false, selection) => environment(name).documentPlan(context, complete, selection),
|
|
1951
1978
|
snapshot: (name, context) => environment(name).snapshot(context),
|
|
1952
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
|
+
},
|
|
1953
1988
|
publicSourceMap: (name, map) => publicCssSourceMap(environment(name).browserSources, map),
|
|
1954
1989
|
cssForBrowser: (name, output, replacements) => cssForBrowser(environment(name).browserSources, output, replacements),
|
|
1955
1990
|
buildOutput: (name) => environment(name).buildOutput ?? {},
|
|
@@ -2010,6 +2045,8 @@ async function projectionImports(code, id) {
|
|
|
2010
2045
|
return [...imports];
|
|
2011
2046
|
}
|
|
2012
2047
|
// src/vite/transform.ts
|
|
2048
|
+
/** Project settings whose configured CSS entrypoint has already produced an import warning. */
|
|
2049
|
+
const warnedEntrypointImports = /* @__PURE__ */ new WeakSet();
|
|
2013
2050
|
/**
|
|
2014
2051
|
* Creates source transform and watch hooks for the project compiler plugin.
|
|
2015
2052
|
*
|
|
@@ -2021,7 +2058,8 @@ async function projectionImports(code, id) {
|
|
|
2021
2058
|
* generated modules.
|
|
2022
2059
|
* @param options - Source selection and ordering required by the framework integration.
|
|
2023
2060
|
* @returns Hooks that recompile cached producers, register stylesheet projections, reserve authored
|
|
2024
|
-
* 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.
|
|
2025
2063
|
*/
|
|
2026
2064
|
function transformHooks(project, virtualModules, options = {}) {
|
|
2027
2065
|
const { settings, publish, compile } = project;
|
|
@@ -2074,6 +2112,10 @@ function transformHooks(project, virtualModules, options = {}) {
|
|
|
2074
2112
|
if (typeof load === "function") return load.call(this, id);
|
|
2075
2113
|
}
|
|
2076
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
|
+
}
|
|
2077
2119
|
await project.environment(name).reserveAuthoredCss(id, code, this);
|
|
2078
2120
|
return;
|
|
2079
2121
|
}
|
|
@@ -2571,4 +2613,4 @@ function compilerPlugin(project, transform, closed) {
|
|
|
2571
2613
|
}
|
|
2572
2614
|
export { renderChunkStyles as i, stillwind as n, createViteProject as r, createVitePlugins as t };
|
|
2573
2615
|
|
|
2574
|
-
//# sourceMappingURL=plugin-
|
|
2616
|
+
//# sourceMappingURL=plugin-BFSq3lEh.js.map
|