@homebound/truss 2.29.11 → 2.29.13

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.
@@ -592,6 +592,8 @@ import * as t5 from "@babel/types";
592
592
 
593
593
  // src/plugin/css-property-abbreviations.ts
594
594
  var cssPropertyAbbreviations = {
595
+ // Accent color
596
+ accentColor: "acc",
595
597
  // Alignment
596
598
  alignContent: "ac",
597
599
  alignItems: "ai",
@@ -1134,7 +1136,7 @@ function computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping) {
1134
1136
  return canonical ?? `${getPropertyAbbreviation(cssProp)}_${classNameFragmentForResolvedValue(cssValue)}`;
1135
1137
  }
1136
1138
  if (seg.argResolved !== void 0) {
1137
- return `${seg.abbr}_${classNameFragmentForResolvedValue(seg.argResolved)}`;
1139
+ return `${getPropertyAbbreviation(seg.abbr)}_${classNameFragmentForResolvedValue(seg.argResolved)}`;
1138
1140
  }
1139
1141
  return seg.abbr;
1140
1142
  }
@@ -3825,8 +3827,7 @@ function trussPlugin(opts) {
3825
3827
  let devSocket;
3826
3828
  const libraryPaths = opts.libraries ?? [];
3827
3829
  let emittedCssFileName = null;
3828
- let cssVersion = 0;
3829
- let lastSentVersion = 0;
3830
+ let cssUpdateTimer;
3830
3831
  function mappingPath() {
3831
3832
  return resolve4(projectRoot || process.cwd(), opts.mapping);
3832
3833
  }
@@ -3840,7 +3841,11 @@ function trussPlugin(opts) {
3840
3841
  projectRoot: () => projectRoot || process.cwd(),
3841
3842
  libraries: libraryPaths,
3842
3843
  onCssChanged() {
3843
- cssVersion++;
3844
+ if (!devSocket || cssUpdateTimer !== void 0) return;
3845
+ cssUpdateTimer = setTimeout(() => {
3846
+ cssUpdateTimer = void 0;
3847
+ devSocket?.send({ type: "custom", event: "truss:css-update" });
3848
+ }, 0);
3844
3849
  }
3845
3850
  });
3846
3851
  return {
@@ -3856,8 +3861,8 @@ function trussPlugin(opts) {
3856
3861
  buildStart() {
3857
3862
  session.ensureMapping();
3858
3863
  session.reset();
3859
- cssVersion = 0;
3860
- lastSentVersion = 0;
3864
+ clearTimeout(cssUpdateTimer);
3865
+ cssUpdateTimer = void 0;
3861
3866
  },
3862
3867
  // -- Dev mode HMR --
3863
3868
  configureServer(server) {
@@ -3870,14 +3875,10 @@ function trussPlugin(opts) {
3870
3875
  res.setHeader("Cache-Control", "no-store");
3871
3876
  res.end(css);
3872
3877
  });
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
3878
  server.httpServer?.on("close", () => {
3880
- clearInterval(interval);
3879
+ clearTimeout(cssUpdateTimer);
3880
+ cssUpdateTimer = void 0;
3881
+ devSocket = void 0;
3881
3882
  });
3882
3883
  },
3883
3884
  transformIndexHtml(html) {
@@ -3891,11 +3892,6 @@ function trussPlugin(opts) {
3891
3892
  return html.replace("</head>", ` ${tag}
3892
3893
  </head>`);
3893
3894
  },
3894
- handleHotUpdate(ctx) {
3895
- if (ctx.server?.ws) {
3896
- ctx.server.ws.send({ type: "custom", event: "truss:css-update" });
3897
- }
3898
- },
3899
3895
  // -- Virtual module resolution --
3900
3896
  resolveId(source, importer) {
3901
3897
  if (source === VIRTUAL_RUNTIME_ID || source === "/" + VIRTUAL_RUNTIME_ID) {
@@ -3933,9 +3929,6 @@ function trussPlugin(opts) {
3933
3929
 
3934
3930
  if (import.meta.hot) {
3935
3931
  import.meta.hot.on("truss:css-update", fetchCss);
3936
- import.meta.hot.on("vite:afterUpdate", () => {
3937
- setTimeout(fetchCss, 50);
3938
- });
3939
3932
  }
3940
3933
  })();
3941
3934
  `;