@homebound/truss 2.29.11 → 2.29.12
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/build/plugin/index.js +11 -20
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -3825,8 +3825,7 @@ function trussPlugin(opts) {
|
|
|
3825
3825
|
let devSocket;
|
|
3826
3826
|
const libraryPaths = opts.libraries ?? [];
|
|
3827
3827
|
let emittedCssFileName = null;
|
|
3828
|
-
let
|
|
3829
|
-
let lastSentVersion = 0;
|
|
3828
|
+
let cssUpdateTimer;
|
|
3830
3829
|
function mappingPath() {
|
|
3831
3830
|
return resolve4(projectRoot || process.cwd(), opts.mapping);
|
|
3832
3831
|
}
|
|
@@ -3840,7 +3839,11 @@ function trussPlugin(opts) {
|
|
|
3840
3839
|
projectRoot: () => projectRoot || process.cwd(),
|
|
3841
3840
|
libraries: libraryPaths,
|
|
3842
3841
|
onCssChanged() {
|
|
3843
|
-
|
|
3842
|
+
if (!devSocket || cssUpdateTimer !== void 0) return;
|
|
3843
|
+
cssUpdateTimer = setTimeout(() => {
|
|
3844
|
+
cssUpdateTimer = void 0;
|
|
3845
|
+
devSocket?.send({ type: "custom", event: "truss:css-update" });
|
|
3846
|
+
}, 0);
|
|
3844
3847
|
}
|
|
3845
3848
|
});
|
|
3846
3849
|
return {
|
|
@@ -3856,8 +3859,8 @@ function trussPlugin(opts) {
|
|
|
3856
3859
|
buildStart() {
|
|
3857
3860
|
session.ensureMapping();
|
|
3858
3861
|
session.reset();
|
|
3859
|
-
|
|
3860
|
-
|
|
3862
|
+
clearTimeout(cssUpdateTimer);
|
|
3863
|
+
cssUpdateTimer = void 0;
|
|
3861
3864
|
},
|
|
3862
3865
|
// -- Dev mode HMR --
|
|
3863
3866
|
configureServer(server) {
|
|
@@ -3870,14 +3873,10 @@ function trussPlugin(opts) {
|
|
|
3870
3873
|
res.setHeader("Cache-Control", "no-store");
|
|
3871
3874
|
res.end(css);
|
|
3872
3875
|
});
|
|
3873
|
-
const interval = setInterval(() => {
|
|
3874
|
-
if (cssVersion !== lastSentVersion && server.ws) {
|
|
3875
|
-
lastSentVersion = cssVersion;
|
|
3876
|
-
server.ws.send({ type: "custom", event: "truss:css-update" });
|
|
3877
|
-
}
|
|
3878
|
-
}, 150);
|
|
3879
3876
|
server.httpServer?.on("close", () => {
|
|
3880
|
-
|
|
3877
|
+
clearTimeout(cssUpdateTimer);
|
|
3878
|
+
cssUpdateTimer = void 0;
|
|
3879
|
+
devSocket = void 0;
|
|
3881
3880
|
});
|
|
3882
3881
|
},
|
|
3883
3882
|
transformIndexHtml(html) {
|
|
@@ -3891,11 +3890,6 @@ function trussPlugin(opts) {
|
|
|
3891
3890
|
return html.replace("</head>", ` ${tag}
|
|
3892
3891
|
</head>`);
|
|
3893
3892
|
},
|
|
3894
|
-
handleHotUpdate(ctx) {
|
|
3895
|
-
if (ctx.server?.ws) {
|
|
3896
|
-
ctx.server.ws.send({ type: "custom", event: "truss:css-update" });
|
|
3897
|
-
}
|
|
3898
|
-
},
|
|
3899
3893
|
// -- Virtual module resolution --
|
|
3900
3894
|
resolveId(source, importer) {
|
|
3901
3895
|
if (source === VIRTUAL_RUNTIME_ID || source === "/" + VIRTUAL_RUNTIME_ID) {
|
|
@@ -3933,9 +3927,6 @@ function trussPlugin(opts) {
|
|
|
3933
3927
|
|
|
3934
3928
|
if (import.meta.hot) {
|
|
3935
3929
|
import.meta.hot.on("truss:css-update", fetchCss);
|
|
3936
|
-
import.meta.hot.on("vite:afterUpdate", () => {
|
|
3937
|
-
setTimeout(fetchCss, 50);
|
|
3938
|
-
});
|
|
3939
3930
|
}
|
|
3940
3931
|
})();
|
|
3941
3932
|
`;
|