@homebound/truss 2.20.0 → 2.20.1

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.
@@ -3871,6 +3871,7 @@ function trussPlugin(opts) {
3871
3871
  const libraryPaths = opts.libraries ?? [];
3872
3872
  let emittedCssFileName = null;
3873
3873
  const cssRegistry = /* @__PURE__ */ new Map();
3874
+ const arbitraryCssRegistry = /* @__PURE__ */ new Map();
3874
3875
  let cssVersion = 0;
3875
3876
  let lastSentVersion = 0;
3876
3877
  function mappingPath() {
@@ -3892,8 +3893,21 @@ function trussPlugin(opts) {
3892
3893
  }
3893
3894
  return libraryCache;
3894
3895
  }
3896
+ function updateArbitraryCssRegistry(sourcePath, sourceCode) {
3897
+ const css = transformCssTs(sourceCode, sourcePath, ensureMapping()).trim();
3898
+ if (css.length > 0) {
3899
+ const prev = arbitraryCssRegistry.get(sourcePath);
3900
+ arbitraryCssRegistry.set(sourcePath, css);
3901
+ if (prev !== css) cssVersion++;
3902
+ } else {
3903
+ if (arbitraryCssRegistry.delete(sourcePath)) cssVersion++;
3904
+ }
3905
+ }
3895
3906
  function collectCss() {
3896
- const appCss = generateCssText(cssRegistry);
3907
+ const appCssParts = [generateCssText(cssRegistry)];
3908
+ const allArbitrary = Array.from(arbitraryCssRegistry.values()).join("\n\n");
3909
+ appCssParts.push(annotateArbitraryCssBlock(allArbitrary));
3910
+ const appCss = appCssParts.filter((p) => p.length > 0).join("\n");
3897
3911
  const libs = loadLibraries();
3898
3912
  if (libs.length === 0) return appCss;
3899
3913
  const appParsed = parseTrussCss(appCss);
@@ -3911,6 +3925,7 @@ function trussPlugin(opts) {
3911
3925
  buildStart() {
3912
3926
  ensureMapping();
3913
3927
  cssRegistry.clear();
3928
+ arbitraryCssRegistry.clear();
3914
3929
  libraryCache = null;
3915
3930
  cssVersion = 0;
3916
3931
  lastSentVersion = 0;
@@ -4005,7 +4020,8 @@ __injectTrussCSS(${JSON.stringify(css)});
4005
4020
  if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;
4006
4021
  const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + ".ts";
4007
4022
  const sourceCode = readFileSync3(sourcePath, "utf8");
4008
- return transformCssTs(sourceCode, sourcePath, ensureMapping());
4023
+ updateArbitraryCssRegistry(sourcePath, sourceCode);
4024
+ return `/* [truss] ${sourcePath} \u2014 included via truss.css */`;
4009
4025
  },
4010
4026
  transform(code, id) {
4011
4027
  if (!/\.[cm]?[jt]sx?(\?|$)/.test(id)) return null;
@@ -4021,6 +4037,7 @@ __injectTrussCSS(${JSON.stringify(css)});
4021
4037
  }
4022
4038
  if (!hasCssDsl && !rewrittenImports.changed && !testCssBootstrap.changed) return null;
4023
4039
  if (fileId.endsWith(".css.ts")) {
4040
+ updateArbitraryCssRegistry(fileId, code);
4024
4041
  return rewrittenImports.changed || testCssBootstrap.changed ? { code: transformedCode, map: null } : null;
4025
4042
  }
4026
4043
  if (!hasCssDsl) {