@homebound/truss 2.21.5 → 2.22.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.
@@ -1,3 +1,6 @@
1
+ /** Return the complementary query used by `Css.*.else` media branches. */
2
+ declare function invertMediaQuery(query: string): string;
3
+
1
4
  /** A compact source label for a Truss CSS expression, used in debug mode. */
2
5
  declare class TrussDebugInfo {
3
6
  /** I.e. `"FileName.tsx:line"` */
@@ -92,4 +95,4 @@ declare function RuntimeStyle(props: RuntimeStyleProps): null;
92
95
  */
93
96
  declare function useRuntimeStyle(css: RuntimeStyleCss): void;
94
97
 
95
- export { RuntimeStyle, type RuntimeStyleCss, type RuntimeStyleDeclarationValue, type RuntimeStyleDeclarations, type RuntimeStyleProps, type TrussCustomClassNameValue, TrussDebugInfo, type TrussInlineStyleValue, type TrussStyleHash, type TrussStyleValue, __injectTrussCSS, mergeProps, trussProps, useRuntimeStyle };
98
+ export { RuntimeStyle, type RuntimeStyleCss, type RuntimeStyleDeclarationValue, type RuntimeStyleDeclarations, type RuntimeStyleProps, type TrussCustomClassNameValue, TrussDebugInfo, type TrussInlineStyleValue, type TrussStyleHash, type TrussStyleValue, __injectTrussCSS, invertMediaQuery as __invertTrussMediaQuery, mergeProps, trussProps, useRuntimeStyle };
package/build/runtime.js CHANGED
@@ -1,5 +1,36 @@
1
1
  // src/runtime.ts
2
2
  import { useInsertionEffect } from "react";
3
+
4
+ // src/style-metadata.ts
5
+ var TRUSS_MARKER_KEY = "__marker";
6
+ var TRUSS_CUSTOM_CLASS_PREFIX = "className_";
7
+ var TRUSS_INLINE_STYLE_PREFIX = "style_";
8
+ var TRUSS_CSS_MARKER_KEY = "$css";
9
+
10
+ // src/media-query.ts
11
+ function invertMediaQuery(query) {
12
+ const screenPrefix = "@media screen and ";
13
+ if (query.startsWith(screenPrefix)) {
14
+ const conditions = query.slice(screenPrefix.length).trim();
15
+ const rangeMatch = conditions.match(/^\(min-width: (\d+)px\) and \(max-width: (\d+)px\)$/);
16
+ if (rangeMatch) {
17
+ const min = Number(rangeMatch[1]);
18
+ const max = Number(rangeMatch[2]);
19
+ return `@media screen and (max-width: ${min - 1}px), screen and (min-width: ${max + 1}px)`;
20
+ }
21
+ const minMatch = conditions.match(/^\(min-width: (\d+)px\)$/);
22
+ if (minMatch) {
23
+ return `@media screen and (max-width: ${Number(minMatch[1]) - 1}px)`;
24
+ }
25
+ const maxMatch = conditions.match(/^\(max-width: (\d+)px\)$/);
26
+ if (maxMatch) {
27
+ return `@media screen and (min-width: ${Number(maxMatch[1]) + 1}px)`;
28
+ }
29
+ }
30
+ return query.replace("@media", "@media not");
31
+ }
32
+
33
+ // src/runtime.ts
3
34
  var TrussDebugInfo = class {
4
35
  /** I.e. `"FileName.tsx:line"` */
5
36
  src;
@@ -21,18 +52,18 @@ function trussProps(...hashes) {
21
52
  const inlineStyle = {};
22
53
  const debugSources = [];
23
54
  for (const [key, value] of Object.entries(merged)) {
24
- if (key === "$css") continue;
25
- if (key === "__marker") {
55
+ if (key === TRUSS_CSS_MARKER_KEY) continue;
56
+ if (key === TRUSS_MARKER_KEY) {
26
57
  if (typeof value === "string") {
27
58
  classNames.push(value);
28
59
  }
29
60
  continue;
30
61
  }
31
- if (key.startsWith("className_")) {
62
+ if (key.startsWith(TRUSS_CUSTOM_CLASS_PREFIX)) {
32
63
  appendCustomClassNames(classNames, value);
33
64
  continue;
34
65
  }
35
- if (key.startsWith("style_")) {
66
+ if (key.startsWith(TRUSS_INLINE_STYLE_PREFIX)) {
36
67
  appendInlineStyles(inlineStyle, value);
37
68
  continue;
38
69
  }
@@ -146,7 +177,7 @@ ${body}
146
177
  function formatRuntimeStyleRule(selector, declarations) {
147
178
  const lines = [];
148
179
  for (const [property, value] of Object.entries(declarations)) {
149
- if (property === "$css") continue;
180
+ if (property === TRUSS_CSS_MARKER_KEY) continue;
150
181
  if (value === void 0 || value === null) continue;
151
182
  if (typeof value !== "string" && typeof value !== "number") {
152
183
  throw new Error(runtimeStyleUnsupportedValueMessage(selector, property));
@@ -216,6 +247,7 @@ export {
216
247
  RuntimeStyle,
217
248
  TrussDebugInfo,
218
249
  __injectTrussCSS,
250
+ invertMediaQuery as __invertTrussMediaQuery,
219
251
  mergeProps,
220
252
  trussProps,
221
253
  useRuntimeStyle
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import { useInsertionEffect } from \"react\";\n\n/** A compact source label for a Truss CSS expression, used in debug mode. */\nexport class TrussDebugInfo {\n /** I.e. `\"FileName.tsx:line\"` */\n readonly src: string;\n\n constructor(src: string) {\n this.src = src;\n }\n}\n\n/**\n * Space-separated atomic class names, or a variable tuple with class names + CSS variable map.\n *\n * In debug mode, the transform appends a TrussDebugInfo as an extra tuple element:\n * - static with debug: `[classNames, debugInfo]`\n * - variable with debug: `[classNames, vars, debugInfo]`\n */\nexport type TrussStyleValue =\n | string\n | [classNames: string, vars: Record<string, string>]\n | [classNames: string, debugInfo: TrussDebugInfo]\n | [classNames: string, vars: Record<string, string>, debugInfo: TrussDebugInfo];\n\n/** A property-keyed style hash where each key owns one logical CSS property. */\nexport type TrussCustomClassNameValue = string | ReadonlyArray<string | false | null | undefined>;\nexport type RuntimeStyleDeclarationValue = string | number | null | undefined;\nexport type TrussInlineStyleValue = Record<string, RuntimeStyleDeclarationValue> | false | null | undefined;\nexport type TrussStyleHash = Record<string, TrussStyleValue | TrussCustomClassNameValue | TrussInlineStyleValue>;\nexport type RuntimeStyleDeclarations = Record<string, RuntimeStyleDeclarationValue | Record<string, unknown>>;\nexport type RuntimeStyleCss = Record<string, RuntimeStyleDeclarations | string>;\n\nconst shouldValidateTrussStyleValues = resolveShouldValidateTrussStyleValues();\nconst shouldEmitTrussSrcAttribute = resolveShouldEmitTrussSrcAttribute();\nconst TRUSS_CSS_CHUNKS = \"__trussCssChunks__\";\nlet trussStyleElement: TrussStyleElement | null = null;\n\n/** Merge one or more Truss style hashes into `{ className, style?, data-truss-src? }`. */\nexport function trussProps(\n ...hashes: ReadonlyArray<TrussStyleHash | false | null | undefined>\n): Record<string, unknown> {\n const merged: Record<string, unknown> = {};\n\n for (const hash of hashes) {\n if (!hash || typeof hash !== \"object\") continue;\n Object.assign(merged, hash);\n }\n\n const classNames: string[] = [];\n const inlineStyle: Record<string, unknown> = {};\n const debugSources: string[] = [];\n\n for (const [key, value] of Object.entries(merged)) {\n // $css is the Css expression marker — skip it\n if (key === \"$css\") continue;\n\n // __marker is a special key — its value is a marker class name, not a CSS property\n if (key === \"__marker\") {\n if (typeof value === \"string\") {\n classNames.push(value);\n }\n continue;\n }\n\n if (key.startsWith(\"className_\")) {\n // I.e. plugin-emitted raw class names that should flow straight into the final prop.\n appendCustomClassNames(classNames, value);\n continue;\n }\n\n if (key.startsWith(\"style_\")) {\n appendInlineStyles(inlineStyle, value);\n continue;\n }\n\n if (shouldValidateTrussStyleValues) assertValidTrussStyleValue(key, value);\n const trussValue = value as TrussStyleValue;\n\n if (typeof trussValue === \"string\") {\n // I.e. \"df\" or \"black blue_h\"\n classNames.push(trussValue);\n continue;\n }\n\n // Tuple: [classNames, varsOrDebug?, maybeDebug?]\n classNames.push(trussValue[0]);\n\n for (let i = 1; i < trussValue.length; i++) {\n const el = trussValue[i];\n if (el instanceof TrussDebugInfo) {\n debugSources.push(el.src);\n } else if (typeof el === \"object\" && el !== null) {\n Object.assign(inlineStyle, el);\n }\n }\n }\n\n const props: Record<string, unknown> = {\n className: classNames.join(\" \"),\n };\n\n if (Object.keys(inlineStyle).length > 0) {\n props.style = inlineStyle;\n }\n\n if (shouldEmitTrussSrcAttribute && debugSources.length > 0) {\n props[\"data-truss-src\"] = [...new Set(debugSources)].join(\"; \");\n }\n\n return props;\n}\n\nfunction appendCustomClassNames(classNames: string[], value: unknown): void {\n if (typeof value === \"string\") {\n // I.e. `className_button: \"button\"`\n classNames.push(value);\n return;\n }\n\n if (!Array.isArray(value)) return;\n for (const entry of value) {\n if (typeof entry === \"string\") {\n // I.e. `className_button: [\"button\", cond && \"selected\"]`\n classNames.push(entry);\n }\n }\n}\n\nfunction appendInlineStyles(inlineStyle: Record<string, unknown>, value: unknown): void {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return;\n }\n\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined || entry === null) {\n continue;\n }\n if (typeof entry === \"string\" || typeof entry === \"number\") {\n inlineStyle[key] = entry;\n }\n }\n}\n\n/** Merge explicit className/style with Truss style hashes. */\nexport function mergeProps(\n explicitClassName: string | undefined,\n explicitStyle: Record<string, unknown> | undefined,\n ...hashes: ReadonlyArray<TrussStyleHash | false | null | undefined>\n): Record<string, unknown> {\n const result = trussProps(...hashes);\n\n if (explicitClassName) {\n result.className = `${explicitClassName} ${result.className ?? \"\"}`.trim();\n }\n\n if (explicitStyle) {\n result.style = { ...explicitStyle, ...(result.style as Record<string, unknown> | undefined) };\n }\n\n return result;\n}\n\n/**\n * Inject CSS text into the document for jsdom/test environments.\n *\n * In browser dev mode, CSS is served via the Vite virtual endpoint instead.\n */\nexport function __injectTrussCSS(cssText: string): void {\n if (typeof document === \"undefined\" || cssText.length === 0) return;\n\n const style = getOrCreateTrussStyleElement();\n\n // Track exact injected chunks on the style node so repeated execution of the\n // test bootstrap or transformed modules does not append duplicate CSS text.\n const injectedChunks = (style[TRUSS_CSS_CHUNKS] ??= new Set<string>());\n if (injectedChunks.has(cssText) || style.textContent?.includes(cssText)) {\n injectedChunks.add(cssText);\n return;\n }\n\n injectedChunks.add(cssText);\n style.textContent = (style.textContent ?? \"\") + cssText;\n}\n\nexport interface RuntimeStyleProps {\n css: RuntimeStyleCss;\n}\n\n/**\n * Inject dynamic or selector-based CSS at runtime into a transient `<style>` tag.\n *\n * This is the runtime counterpart to `.css.ts` files:\n * - use `.css.ts` for static/global arbitrary selectors that should be baked into the build output\n * - use `RuntimeStyle` for selectors that depend on runtime values or should only exist while a component is mounted\n *\n * Example with a flat `Css` expression:\n * ```tsx\n * <RuntimeStyle\n * css={{\n * \".preview a\": Css.blue.$,\n * }}\n * />\n * ```\n *\n * Example with raw CSS via `Css.raw`:\n * ```tsx\n * <RuntimeStyle\n * css={{\n * \".preview code\": Css.raw`\n * font-variant-ligatures: none;\n * text-decoration: underline;\n * `,\n * }}\n * />\n * ```\n *\n * The injected `<style>` element is appended on mount and removed on unmount.\n *\n * Note: Only flat `Css.*.$` expressions are supported here; selector/marker helpers like\n * `onHover`, `when`, `ifSm`, `ifContainer`, `element`, `className()`, and `style()` are rejected\n * at runtime.\n */\nexport function RuntimeStyle(props: RuntimeStyleProps): null {\n useRuntimeStyle(props.css);\n return null;\n}\n\n/**\n * Hook that injects dynamic or selector-based CSS at runtime into a transient `<style>` tag.\n *\n * This is the hook counterpart to the `RuntimeStyle` component and `.css.ts` files:\n * - use `.css.ts` for static/global arbitrary selectors baked into the build output\n * - use `useRuntimeStyle` when you need the same thing from a hook instead of a component\n *\n * Example with a flat `Css` expression:\n * ```ts\n * useRuntimeStyle({ \"body\": Css.mbPx(dynamicValue).$ });\n * ```\n *\n * Example with raw CSS via `Css.raw`:\n * ```ts\n * useRuntimeStyle({ \".preview code\": Css.raw`font-variant-ligatures: none;` });\n * ```\n *\n * The injected `<style>` element is appended on mount and removed on unmount.\n *\n * Note: Only flat `Css.*.$` expressions are supported here; selector/marker helpers like\n * `onHover`, `when`, `ifSm`, `ifContainer`, `element`, `className()`, and `style()` are rejected\n * at runtime.\n */\nexport function useRuntimeStyle(css: RuntimeStyleCss): void {\n const cssText = buildRuntimeStyleCssText(css);\n useInsertionEffect(() => {\n if (typeof document === \"undefined\" || cssText.length === 0) return;\n const style = document.createElement(\"style\");\n style.setAttribute(\"data-truss-runtime-style\", \"\");\n style.textContent = cssText;\n document.head.appendChild(style);\n return () => style.remove();\n }, [cssText]);\n}\n\n/** Serialize RuntimeStyle rules into CSS text for a transient `<style>` tag. */\nfunction buildRuntimeStyleCssText(css: RuntimeStyleCss): string {\n const rules: string[] = [];\n for (const [selector, value] of Object.entries(css)) {\n if (typeof value === \"string\") {\n rules.push(formatRawRuntimeStyleRule(selector, value));\n } else {\n rules.push(formatRuntimeStyleRule(selector, value));\n }\n }\n return rules.join(\"\\n\\n\");\n}\n\nfunction formatRawRuntimeStyleRule(selector: string, raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) return `${selector} {}`;\n const body = trimmed\n .split(\"\\n\")\n .map((line) => ` ${line.trim()}`)\n .filter((line) => line.trim().length > 0)\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n\nfunction formatRuntimeStyleRule(selector: string, declarations: RuntimeStyleDeclarations): string {\n const lines: string[] = [];\n for (const [property, value] of Object.entries(declarations)) {\n if (property === \"$css\") continue;\n if (value === undefined || value === null) continue;\n if (typeof value !== \"string\" && typeof value !== \"number\") {\n throw new Error(runtimeStyleUnsupportedValueMessage(selector, property));\n }\n lines.push(` ${camelToKebabRuntime(property)}: ${String(value)};`);\n }\n if (lines.length === 0) return `${selector} {}`;\n return `${selector} {\\n${lines.join(\"\\n\")}\\n}`;\n}\n\nfunction runtimeStyleUnsupportedValueMessage(selector: string, property: string): string {\n return `RuntimeStyle selector \\`${selector}\\` has an unsupported nested value for \\`${property}\\`. Only flat Css expressions can be used here; selector/marker/className helpers like onHover, when, ifSm, ifContainer, element, className(), and style() are not supported.`;\n}\n\nfunction camelToKebabRuntime(property: string): string {\n return property\n .replace(/^(Webkit|Moz|Ms|O)/, function prefixToCss(prefix) {\n return `-${prefix.toLowerCase()}`;\n })\n .replace(/[A-Z]/g, function upperToCss(letter) {\n return `-${letter.toLowerCase()}`;\n });\n}\n\n/** Fail fast when `trussProps` receives a non-Truss style value. */\nfunction assertValidTrussStyleValue(key: string, value: unknown): asserts value is TrussStyleValue {\n if (typeof value === \"string\") return;\n if (Array.isArray(value) && typeof value[0] === \"string\") {\n for (let i = 1; i < value.length; i++) {\n const el = value[i];\n if (el instanceof TrussDebugInfo) continue;\n if (typeof el === \"object\" && el !== null && !Array.isArray(el)) continue;\n throw new TypeError(invalidTrussStyleValueMessage(key));\n }\n return;\n }\n throw new TypeError(invalidTrussStyleValueMessage(key));\n}\n\nfunction invalidTrussStyleValueMessage(key: string): string {\n return `Invalid Truss style value for \\`${key}\\`. trussProps only accepts generated Truss style hashes; use mergeProps for explicit className/style merging.`;\n}\n\n/** Enable validation in dev/test environments, but skip it in production. */\nfunction resolveShouldValidateTrussStyleValues(): boolean {\n if (typeof process !== \"undefined\" && typeof process.env.NODE_ENV === \"string\") {\n return process.env.NODE_ENV !== \"production\";\n }\n const viteEnv = (import.meta as ImportMeta & { env?: { DEV?: boolean; PROD?: boolean } }).env;\n if (typeof viteEnv?.DEV === \"boolean\") return viteEnv.DEV;\n if (typeof viteEnv?.PROD === \"boolean\") return !viteEnv.PROD;\n return false;\n}\n\n/** Omit unstable source labels from rendered props during Vitest runs. */\nfunction resolveShouldEmitTrussSrcAttribute(): boolean {\n if (typeof process !== \"undefined\" && typeof process.env.VITEST === \"string\") {\n return false;\n }\n return true;\n}\n\nfunction getOrCreateTrussStyleElement(): TrussStyleElement {\n const id = \"data-truss\";\n if (trussStyleElement?.ownerDocument === document && trussStyleElement.isConnected) {\n return trussStyleElement;\n }\n\n const style = (document.querySelector(`style[${id}]`) as TrussStyleElement | null) ?? document.createElement(\"style\");\n if (!style.isConnected) {\n style.setAttribute(id, \"\");\n document.head.appendChild(style);\n }\n trussStyleElement = style;\n return trussStyleElement;\n}\n\ntype TrussStyleElement = HTMLStyleElement & {\n [TRUSS_CSS_CHUNKS]?: Set<string>;\n};\n"],"mappings":";AAAA,SAAS,0BAA0B;AAG5B,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAEjB;AAAA,EAET,YAAY,KAAa;AACvB,SAAK,MAAM;AAAA,EACb;AACF;AAuBA,IAAM,iCAAiC,sCAAsC;AAC7E,IAAM,8BAA8B,mCAAmC;AACvE,IAAM,mBAAmB;AACzB,IAAI,oBAA8C;AAG3C,SAAS,cACX,QACsB;AACzB,QAAM,SAAkC,CAAC;AAEzC,a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,WAAO,QAAQ,IAAI,aAAa;AAAA,EAClC;AACA,QAAM,UAAW,YAAyE;AAC1F,MAAI,OAAO,SAAS,QAAQ,UAAW,QAAO,QAAQ;AACtD,MAAI,OAAO,SAAS,SAAS,UAAW,QAAO,CAAC,QAAQ;AACxD,SAAO;AACT;AAGA,SAAS,qCAA8C;AACrD,MAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,IAAI,WAAW,UAAU;AAC5E,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,+BAAkD;AACzD,QAAM,KAAK;AACX,MAAI,mBAAmB,kBAAkB,YAAY,kBAAkB,aAAa;AAClF,WAAO;AAAA,EACT;AAEA,QAAM,QAAS,SAAS,cAAc,SAAS,EAAE,GAAG,KAAkC,SAAS,cAAc,OAAO;AACpH,MAAI,CAAC,MAAM,aAAa;AACtB,UAAM,aAAa,IAAI,EAAE;AACzB,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AACA,sBAAoB;AACpB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/runtime.ts","../src/style-metadata.ts","../src/media-query.ts"],"sourcesContent":["import { useInsertionEffect } from \"react\";\nimport {\n TRUSS_CSS_MARKER_KEY,\n TRUSS_CUSTOM_CLASS_PREFIX,\n TRUSS_INLINE_STYLE_PREFIX,\n TRUSS_MARKER_KEY,\n} from \"./style-metadata\";\n\nexport { invertMediaQuery as __invertTrussMediaQuery } from \"./media-query\";\n\n/** A compact source label for a Truss CSS expression, used in debug mode. */\nexport class TrussDebugInfo {\n /** I.e. `\"FileName.tsx:line\"` */\n readonly src: string;\n\n constructor(src: string) {\n this.src = src;\n }\n}\n\n/**\n * Space-separated atomic class names, or a variable tuple with class names + CSS variable map.\n *\n * In debug mode, the transform appends a TrussDebugInfo as an extra tuple element:\n * - static with debug: `[classNames, debugInfo]`\n * - variable with debug: `[classNames, vars, debugInfo]`\n */\nexport type TrussStyleValue =\n | string\n | [classNames: string, vars: Record<string, string>]\n | [classNames: string, debugInfo: TrussDebugInfo]\n | [classNames: string, vars: Record<string, string>, debugInfo: TrussDebugInfo];\n\n/** A property-keyed style hash where each key owns one logical CSS property. */\nexport type TrussCustomClassNameValue = string | ReadonlyArray<string | false | null | undefined>;\nexport type RuntimeStyleDeclarationValue = string | number | null | undefined;\nexport type TrussInlineStyleValue = Record<string, RuntimeStyleDeclarationValue> | false | null | undefined;\nexport type TrussStyleHash = Record<string, TrussStyleValue | TrussCustomClassNameValue | TrussInlineStyleValue>;\nexport type RuntimeStyleDeclarations = Record<string, RuntimeStyleDeclarationValue | Record<string, unknown>>;\nexport type RuntimeStyleCss = Record<string, RuntimeStyleDeclarations | string>;\n\nconst shouldValidateTrussStyleValues = resolveShouldValidateTrussStyleValues();\nconst shouldEmitTrussSrcAttribute = resolveShouldEmitTrussSrcAttribute();\nconst TRUSS_CSS_CHUNKS = \"__trussCssChunks__\";\nlet trussStyleElement: TrussStyleElement | null = null;\n\n/** Merge one or more Truss style hashes into `{ className, style?, data-truss-src? }`. */\nexport function trussProps(\n ...hashes: ReadonlyArray<TrussStyleHash | false | null | undefined>\n): Record<string, unknown> {\n const merged: Record<string, unknown> = {};\n\n for (const hash of hashes) {\n if (!hash || typeof hash !== \"object\") continue;\n Object.assign(merged, hash);\n }\n\n const classNames: string[] = [];\n const inlineStyle: Record<string, unknown> = {};\n const debugSources: string[] = [];\n\n for (const [key, value] of Object.entries(merged)) {\n // $css is the Css expression marker — skip it\n if (key === TRUSS_CSS_MARKER_KEY) continue;\n\n // __marker is a special key — its value is a marker class name, not a CSS property\n if (key === TRUSS_MARKER_KEY) {\n if (typeof value === \"string\") {\n classNames.push(value);\n }\n continue;\n }\n\n if (key.startsWith(TRUSS_CUSTOM_CLASS_PREFIX)) {\n // I.e. plugin-emitted raw class names that should flow straight into the final prop.\n appendCustomClassNames(classNames, value);\n continue;\n }\n\n if (key.startsWith(TRUSS_INLINE_STYLE_PREFIX)) {\n appendInlineStyles(inlineStyle, value);\n continue;\n }\n\n if (shouldValidateTrussStyleValues) assertValidTrussStyleValue(key, value);\n const trussValue = value as TrussStyleValue;\n\n if (typeof trussValue === \"string\") {\n // I.e. \"df\" or \"black blue_h\"\n classNames.push(trussValue);\n continue;\n }\n\n // Tuple: [classNames, varsOrDebug?, maybeDebug?]\n classNames.push(trussValue[0]);\n\n for (let i = 1; i < trussValue.length; i++) {\n const el = trussValue[i];\n if (el instanceof TrussDebugInfo) {\n debugSources.push(el.src);\n } else if (typeof el === \"object\" && el !== null) {\n Object.assign(inlineStyle, el);\n }\n }\n }\n\n const props: Record<string, unknown> = {\n className: classNames.join(\" \"),\n };\n\n if (Object.keys(inlineStyle).length > 0) {\n props.style = inlineStyle;\n }\n\n if (shouldEmitTrussSrcAttribute && debugSources.length > 0) {\n props[\"data-truss-src\"] = [...new Set(debugSources)].join(\"; \");\n }\n\n return props;\n}\n\nfunction appendCustomClassNames(classNames: string[], value: unknown): void {\n if (typeof value === \"string\") {\n // I.e. `className_button: \"button\"`\n classNames.push(value);\n return;\n }\n\n if (!Array.isArray(value)) return;\n for (const entry of value) {\n if (typeof entry === \"string\") {\n // I.e. `className_button: [\"button\", cond && \"selected\"]`\n classNames.push(entry);\n }\n }\n}\n\nfunction appendInlineStyles(inlineStyle: Record<string, unknown>, value: unknown): void {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return;\n }\n\n for (const [key, entry] of Object.entries(value)) {\n if (entry === undefined || entry === null) {\n continue;\n }\n if (typeof entry === \"string\" || typeof entry === \"number\") {\n inlineStyle[key] = entry;\n }\n }\n}\n\n/** Merge explicit className/style with Truss style hashes. */\nexport function mergeProps(\n explicitClassName: string | undefined,\n explicitStyle: Record<string, unknown> | undefined,\n ...hashes: ReadonlyArray<TrussStyleHash | false | null | undefined>\n): Record<string, unknown> {\n const result = trussProps(...hashes);\n\n if (explicitClassName) {\n result.className = `${explicitClassName} ${result.className ?? \"\"}`.trim();\n }\n\n if (explicitStyle) {\n result.style = { ...explicitStyle, ...(result.style as Record<string, unknown> | undefined) };\n }\n\n return result;\n}\n\n/**\n * Inject CSS text into the document for jsdom/test environments.\n *\n * In browser dev mode, CSS is served via the Vite virtual endpoint instead.\n */\nexport function __injectTrussCSS(cssText: string): void {\n if (typeof document === \"undefined\" || cssText.length === 0) return;\n\n const style = getOrCreateTrussStyleElement();\n\n // Track exact injected chunks on the style node so repeated execution of the\n // test bootstrap or transformed modules does not append duplicate CSS text.\n const injectedChunks = (style[TRUSS_CSS_CHUNKS] ??= new Set<string>());\n if (injectedChunks.has(cssText) || style.textContent?.includes(cssText)) {\n injectedChunks.add(cssText);\n return;\n }\n\n injectedChunks.add(cssText);\n style.textContent = (style.textContent ?? \"\") + cssText;\n}\n\nexport interface RuntimeStyleProps {\n css: RuntimeStyleCss;\n}\n\n/**\n * Inject dynamic or selector-based CSS at runtime into a transient `<style>` tag.\n *\n * This is the runtime counterpart to `.css.ts` files:\n * - use `.css.ts` for static/global arbitrary selectors that should be baked into the build output\n * - use `RuntimeStyle` for selectors that depend on runtime values or should only exist while a component is mounted\n *\n * Example with a flat `Css` expression:\n * ```tsx\n * <RuntimeStyle\n * css={{\n * \".preview a\": Css.blue.$,\n * }}\n * />\n * ```\n *\n * Example with raw CSS via `Css.raw`:\n * ```tsx\n * <RuntimeStyle\n * css={{\n * \".preview code\": Css.raw`\n * font-variant-ligatures: none;\n * text-decoration: underline;\n * `,\n * }}\n * />\n * ```\n *\n * The injected `<style>` element is appended on mount and removed on unmount.\n *\n * Note: Only flat `Css.*.$` expressions are supported here; selector/marker helpers like\n * `onHover`, `when`, `ifSm`, `ifContainer`, `element`, `className()`, and `style()` are rejected\n * at runtime.\n */\nexport function RuntimeStyle(props: RuntimeStyleProps): null {\n useRuntimeStyle(props.css);\n return null;\n}\n\n/**\n * Hook that injects dynamic or selector-based CSS at runtime into a transient `<style>` tag.\n *\n * This is the hook counterpart to the `RuntimeStyle` component and `.css.ts` files:\n * - use `.css.ts` for static/global arbitrary selectors baked into the build output\n * - use `useRuntimeStyle` when you need the same thing from a hook instead of a component\n *\n * Example with a flat `Css` expression:\n * ```ts\n * useRuntimeStyle({ \"body\": Css.mbPx(dynamicValue).$ });\n * ```\n *\n * Example with raw CSS via `Css.raw`:\n * ```ts\n * useRuntimeStyle({ \".preview code\": Css.raw`font-variant-ligatures: none;` });\n * ```\n *\n * The injected `<style>` element is appended on mount and removed on unmount.\n *\n * Note: Only flat `Css.*.$` expressions are supported here; selector/marker helpers like\n * `onHover`, `when`, `ifSm`, `ifContainer`, `element`, `className()`, and `style()` are rejected\n * at runtime.\n */\nexport function useRuntimeStyle(css: RuntimeStyleCss): void {\n const cssText = buildRuntimeStyleCssText(css);\n useInsertionEffect(() => {\n if (typeof document === \"undefined\" || cssText.length === 0) return;\n const style = document.createElement(\"style\");\n style.setAttribute(\"data-truss-runtime-style\", \"\");\n style.textContent = cssText;\n document.head.appendChild(style);\n return () => style.remove();\n }, [cssText]);\n}\n\n/** Serialize RuntimeStyle rules into CSS text for a transient `<style>` tag. */\nfunction buildRuntimeStyleCssText(css: RuntimeStyleCss): string {\n const rules: string[] = [];\n for (const [selector, value] of Object.entries(css)) {\n if (typeof value === \"string\") {\n rules.push(formatRawRuntimeStyleRule(selector, value));\n } else {\n rules.push(formatRuntimeStyleRule(selector, value));\n }\n }\n return rules.join(\"\\n\\n\");\n}\n\nfunction formatRawRuntimeStyleRule(selector: string, raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) return `${selector} {}`;\n const body = trimmed\n .split(\"\\n\")\n .map((line) => ` ${line.trim()}`)\n .filter((line) => line.trim().length > 0)\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n\nfunction formatRuntimeStyleRule(selector: string, declarations: RuntimeStyleDeclarations): string {\n const lines: string[] = [];\n for (const [property, value] of Object.entries(declarations)) {\n if (property === TRUSS_CSS_MARKER_KEY) continue;\n if (value === undefined || value === null) continue;\n if (typeof value !== \"string\" && typeof value !== \"number\") {\n throw new Error(runtimeStyleUnsupportedValueMessage(selector, property));\n }\n lines.push(` ${camelToKebabRuntime(property)}: ${String(value)};`);\n }\n if (lines.length === 0) return `${selector} {}`;\n return `${selector} {\\n${lines.join(\"\\n\")}\\n}`;\n}\n\nfunction runtimeStyleUnsupportedValueMessage(selector: string, property: string): string {\n return `RuntimeStyle selector \\`${selector}\\` has an unsupported nested value for \\`${property}\\`. Only flat Css expressions can be used here; selector/marker/className helpers like onHover, when, ifSm, ifContainer, element, className(), and style() are not supported.`;\n}\n\nfunction camelToKebabRuntime(property: string): string {\n return property\n .replace(/^(Webkit|Moz|Ms|O)/, function prefixToCss(prefix) {\n return `-${prefix.toLowerCase()}`;\n })\n .replace(/[A-Z]/g, function upperToCss(letter) {\n return `-${letter.toLowerCase()}`;\n });\n}\n\n/** Fail fast when `trussProps` receives a non-Truss style value. */\nfunction assertValidTrussStyleValue(key: string, value: unknown): asserts value is TrussStyleValue {\n if (typeof value === \"string\") return;\n if (Array.isArray(value) && typeof value[0] === \"string\") {\n for (let i = 1; i < value.length; i++) {\n const el = value[i];\n if (el instanceof TrussDebugInfo) continue;\n if (typeof el === \"object\" && el !== null && !Array.isArray(el)) continue;\n throw new TypeError(invalidTrussStyleValueMessage(key));\n }\n return;\n }\n throw new TypeError(invalidTrussStyleValueMessage(key));\n}\n\nfunction invalidTrussStyleValueMessage(key: string): string {\n return `Invalid Truss style value for \\`${key}\\`. trussProps only accepts generated Truss style hashes; use mergeProps for explicit className/style merging.`;\n}\n\n/** Enable validation in dev/test environments, but skip it in production. */\nfunction resolveShouldValidateTrussStyleValues(): boolean {\n if (typeof process !== \"undefined\" && typeof process.env.NODE_ENV === \"string\") {\n return process.env.NODE_ENV !== \"production\";\n }\n const viteEnv = (import.meta as ImportMeta & { env?: { DEV?: boolean; PROD?: boolean } }).env;\n if (typeof viteEnv?.DEV === \"boolean\") return viteEnv.DEV;\n if (typeof viteEnv?.PROD === \"boolean\") return !viteEnv.PROD;\n return false;\n}\n\n/** Omit unstable source labels from rendered props during Vitest runs. */\nfunction resolveShouldEmitTrussSrcAttribute(): boolean {\n if (typeof process !== \"undefined\" && typeof process.env.VITEST === \"string\") {\n return false;\n }\n return true;\n}\n\nfunction getOrCreateTrussStyleElement(): TrussStyleElement {\n const id = \"data-truss\";\n if (trussStyleElement?.ownerDocument === document && trussStyleElement.isConnected) {\n return trussStyleElement;\n }\n\n const style = (document.querySelector(`style[${id}]`) as TrussStyleElement | null) ?? document.createElement(\"style\");\n if (!style.isConnected) {\n style.setAttribute(id, \"\");\n document.head.appendChild(style);\n }\n trussStyleElement = style;\n return trussStyleElement;\n}\n\ntype TrussStyleElement = HTMLStyleElement & {\n [TRUSS_CSS_CHUNKS]?: Set<string>;\n};\n","/** Metadata key that carries a marker class through Truss style hashes. */\nexport const TRUSS_MARKER_KEY = \"__marker\";\n\n/** Prefix for style-hash entries that append raw class names at runtime. */\nexport const TRUSS_CUSTOM_CLASS_PREFIX = \"className_\";\n\n/** Prefix for style-hash entries that append raw inline styles at runtime. */\nexport const TRUSS_INLINE_STYLE_PREFIX = \"style_\";\n\n/** Generated Css expressions include this brand marker in runtime-only paths. */\nexport const TRUSS_CSS_MARKER_KEY = \"$css\";\n","/** Return the complementary query used by `Css.*.else` media branches. */\nexport function invertMediaQuery(query: string): string {\n const screenPrefix = \"@media screen and \";\n if (query.startsWith(screenPrefix)) {\n const conditions = query.slice(screenPrefix.length).trim();\n const rangeMatch = conditions.match(/^\\(min-width: (\\d+)px\\) and \\(max-width: (\\d+)px\\)$/);\n if (rangeMatch) {\n const min = Number(rangeMatch[1]);\n const max = Number(rangeMatch[2]);\n return `@media screen and (max-width: ${min - 1}px), screen and (min-width: ${max + 1}px)`;\n }\n const minMatch = conditions.match(/^\\(min-width: (\\d+)px\\)$/);\n if (minMatch) {\n return `@media screen and (max-width: ${Number(minMatch[1]) - 1}px)`;\n }\n const maxMatch = conditions.match(/^\\(max-width: (\\d+)px\\)$/);\n if (maxMatch) {\n return `@media screen and (min-width: ${Number(maxMatch[1]) + 1}px)`;\n }\n }\n return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AAQ;AACxD,SAAO;AACT;AAGA,SAAS,qCAA8C;AACrD,MAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,IAAI,WAAW,UAAU;AAC5E,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,+BAAkD;AACzD,QAAM,KAAK;AACX,MAAI,mBAAmB,kBAAkB,YAAY,kBAAkB,aAAa;AAClF,WAAO;AAAA,EACT;AAEA,QAAM,QAAS,SAAS,cAAc,SAAS,EAAE,GAAG,KAAkC,SAAS,cAAc,OAAO;AACpH,MAAI,CAAC,MAAM,aAAa;AACtB,UAAM,aAAa,IAAI,EAAE;AACzB,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AACA,sBAAoB;AACpB,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/truss",
3
- "version": "2.21.5",
3
+ "version": "2.22.0",
4
4
  "type": "module",
5
5
  "main": "build/index.js",
6
6
  "bin": "cli.js",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
- "@babel/generator": "^7.29.0",
36
- "@babel/parser": "^7.29.0",
35
+ "@babel/generator": "^7.29.1",
36
+ "@babel/parser": "^7.29.2",
37
37
  "@babel/traverse": "^7.29.0",
38
38
  "@babel/types": "^7.29.0",
39
39
  "change-case": "^5.4.4",
@@ -48,11 +48,11 @@
48
48
  "@homebound/tsconfig": "^1.1.1",
49
49
  "@types/babel__generator": "^7.27.0",
50
50
  "@types/babel__traverse": "^7.28.0",
51
- "@types/node": "^25.5.0",
51
+ "@types/node": "^25.5.2",
52
52
  "@types/react": "^19.2.14",
53
- "react": "^19.2.4",
53
+ "react": "^19.2.5",
54
54
  "tsup": "^8.5.1",
55
- "typescript": "^5.9.3",
56
- "vitest": "^4.1.0"
55
+ "typescript": "^6.0.3",
56
+ "vitest": "^4.1.5"
57
57
  }
58
58
  }
@@ -0,0 +1 @@
1
+ {"root":["./src/breakpoints.test.ts","./src/breakpoints.ts","./src/config.ts","./src/generate.test.ts","./src/generate.ts","./src/index.ts","./src/media-query.ts","./src/methods.test.ts","./src/methods.ts","./src/pseudo-selectors.ts","./src/runtime.test.ts","./src/runtime.ts","./src/style-metadata.ts","./src/testUtils.ts","./src/toHaveStyle.test.ts","./src/toHaveStyle.ts","./src/utils.ts","./src/vitest.ts","./src/plugin/ast-utils.ts","./src/plugin/babel-utils.ts","./src/plugin/css-property-abbreviations.ts","./src/plugin/css-ts-utils.ts","./src/plugin/emit-truss.test.ts","./src/plugin/emit-truss.ts","./src/plugin/esbuild-plugin.test.ts","./src/plugin/esbuild-plugin.ts","./src/plugin/index.test.ts","./src/plugin/index.ts","./src/plugin/mapping-utils.ts","./src/plugin/merge-css.test.ts","./src/plugin/merge-css.ts","./src/plugin/priority.ts","./src/plugin/property-priorities.ts","./src/plugin/resolve-chain.ts","./src/plugin/rewrite-css-ts-imports.ts","./src/plugin/rewrite-sites.ts","./src/plugin/transform-css.test.ts","./src/plugin/transform-css.ts","./src/plugin/transform-session.ts","./src/plugin/transform.test.ts","./src/plugin/transform.ts","./src/plugin/types.ts","./src/sections/tachyons/border.ts","./src/sections/tachyons/borderColors.ts","./src/sections/tachyons/borderRadius.ts","./src/sections/tachyons/borderStyles.ts","./src/sections/tachyons/borderWidths.ts","./src/sections/tachyons/boxShadow.ts","./src/sections/tachyons/container.ts","./src/sections/tachyons/coordinates.ts","./src/sections/tachyons/cursor.ts","./src/sections/tachyons/display.ts","./src/sections/tachyons/flexbox.ts","./src/sections/tachyons/floats.ts","./src/sections/tachyons/fontWeight.ts","./src/sections/tachyons/grid.ts","./src/sections/tachyons/heights.ts","./src/sections/tachyons/index.ts","./src/sections/tachyons/lineClamp.ts","./src/sections/tachyons/objectFit.ts","./src/sections/tachyons/opacity.ts","./src/sections/tachyons/outlines.ts","./src/sections/tachyons/overflow.ts","./src/sections/tachyons/position.ts","./src/sections/tachyons/skins.ts","./src/sections/tachyons/spacing.ts","./src/sections/tachyons/textAlign.ts","./src/sections/tachyons/textDecoration.ts","./src/sections/tachyons/textTransform.ts","./src/sections/tachyons/typeScale.ts","./src/sections/tachyons/typography.ts","./src/sections/tachyons/userSelect.ts","./src/sections/tachyons/verticalAlign.ts","./src/sections/tachyons/visibility.ts","./src/sections/tachyons/whitespace.ts","./src/sections/tachyons/widths.ts","./src/sections/tachyons/wordBreak.ts","./src/sections/tachyons/zIndex.ts","./src/sections/tachyons-rn/index.ts","./src/sections/tachyons-rn/spacing.ts"],"version":"6.0.3"}
package/tsup.config.ts CHANGED
@@ -8,7 +8,11 @@ export default defineConfig({
8
8
  vitest: "src/vitest.ts",
9
9
  },
10
10
  format: ["esm"],
11
- dts: true,
11
+ dts: {
12
+ compilerOptions: {
13
+ ignoreDeprecations: "6.0",
14
+ },
15
+ },
12
16
  splitting: false,
13
17
  sourcemap: true,
14
18
  outDir: "build",