@homebound/truss 2.0.8 → 2.0.10
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/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/plugin/index.js +28 -1
- package/build/plugin/index.js.map +1 -1
- package/build/runtime.js +5 -0
- package/build/runtime.js.map +1 -1
- package/package.json +1 -1
package/build/runtime.js
CHANGED
|
@@ -23,6 +23,11 @@ function asStyleArray(styles) {
|
|
|
23
23
|
if (Array.isArray(styles)) {
|
|
24
24
|
return styles;
|
|
25
25
|
}
|
|
26
|
+
if (styles && typeof styles === "object" && Object.keys(styles).length > 0) {
|
|
27
|
+
console.error(
|
|
28
|
+
"[truss] asStyleArray received a non-empty object \u2014 this likely means a style value was not rewritten to an array. Use a style array (e.g. Css.df.$) or an empty array [] instead of {}."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
26
31
|
return styles ? [styles] : [];
|
|
27
32
|
}
|
|
28
33
|
function splitDebugInfo(styles) {
|
package/build/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type * as stylex from \"@stylexjs/stylex\";\n\nexport class TrussDebugInfo {\n /** A compact `FileName.tsx:line` source label for a Truss CSS expression. */\n readonly src: string;\n\n constructor(src: string) {\n this.src = src;\n }\n}\n\ntype StylexPropArg = Parameters<typeof stylex.props>[number];\n\n/** Call StyleX while stripping Truss debug sentinels from the style list. */\nexport function trussProps(stylexNs: typeof stylex, ...styles: unknown[]): Record<string, unknown> {\n const { debugSources, styleArgs } = splitDebugInfo(styles);\n const sx = stylexNs.props(...styleArgs);\n return applyDebugSources(sx, debugSources);\n}\n\nexport function mergeProps(\n stylexNs: typeof stylex,\n explicitClassName: string,\n ...styles: unknown[]\n): Record<string, unknown> {\n const { debugSources, styleArgs } = splitDebugInfo(styles);\n const sx = stylexNs.props(...styleArgs);\n return {\n ...applyDebugSources(sx, debugSources),\n className: `${explicitClassName} ${sx.className ?? \"\"}`.trim(),\n };\n}\n\n/**\n * Coerce maybe-array StyleX inputs into arrays, guarding against nullish/false and plain object values.\n *\n * I.e. `...asStyleArray(xss)` stays safe when destructured `xss` is `undefined`.\n */\nexport function asStyleArray(styles: unknown): ReadonlyArray<unknown> {\n if (Array.isArray(styles)) {\n return styles;\n }\n
|
|
1
|
+
{"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["import type * as stylex from \"@stylexjs/stylex\";\n\nexport class TrussDebugInfo {\n /** A compact `FileName.tsx:line` source label for a Truss CSS expression. */\n readonly src: string;\n\n constructor(src: string) {\n this.src = src;\n }\n}\n\ntype StylexPropArg = Parameters<typeof stylex.props>[number];\n\n/** Call StyleX while stripping Truss debug sentinels from the style list. */\nexport function trussProps(stylexNs: typeof stylex, ...styles: unknown[]): Record<string, unknown> {\n const { debugSources, styleArgs } = splitDebugInfo(styles);\n const sx = stylexNs.props(...styleArgs);\n return applyDebugSources(sx, debugSources);\n}\n\nexport function mergeProps(\n stylexNs: typeof stylex,\n explicitClassName: string,\n ...styles: unknown[]\n): Record<string, unknown> {\n const { debugSources, styleArgs } = splitDebugInfo(styles);\n const sx = stylexNs.props(...styleArgs);\n return {\n ...applyDebugSources(sx, debugSources),\n className: `${explicitClassName} ${sx.className ?? \"\"}`.trim(),\n };\n}\n\n/**\n * Coerce maybe-array StyleX inputs into arrays, guarding against nullish/false and plain object values.\n *\n * I.e. `...asStyleArray(xss)` stays safe when destructured `xss` is `undefined`.\n */\nexport function asStyleArray(styles: unknown): ReadonlyArray<unknown> {\n if (Array.isArray(styles)) {\n return styles;\n }\n if (styles && typeof styles === \"object\" && Object.keys(styles).length > 0) {\n console.error(\n \"[truss] asStyleArray received a non-empty object — this likely means a style value was not rewritten to an array. \" +\n \"Use a style array (e.g. Css.df.$) or an empty array [] instead of {}.\",\n );\n }\n return styles ? [styles] : [];\n}\n\n/** Collect Truss debug info while preserving the original StyleX argument order. */\nfunction splitDebugInfo(styles: ReadonlyArray<unknown>): {\n debugSources: string[];\n styleArgs: StylexPropArg[];\n} {\n const debugSources: string[] = [];\n const styleArgs: StylexPropArg[] = [];\n\n for (const style of styles) {\n if (style instanceof TrussDebugInfo) {\n debugSources.push(style.src);\n } else {\n styleArgs.push(style as StylexPropArg);\n }\n }\n\n return { debugSources, styleArgs };\n}\n\n/** Deduplicate and attach compact Truss source labels to emitted props. */\nfunction applyDebugSources(\n props: Record<string, unknown>,\n debugSources: ReadonlyArray<string>,\n): Record<string, unknown> {\n if (debugSources.length === 0) {\n return props;\n }\n\n const uniqueSources = Array.from(new Set(debugSources));\n return {\n ...props,\n \"data-truss-src\": uniqueSources.join(\"; \"),\n };\n}\n"],"mappings":";AAEO,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAEjB;AAAA,EAET,YAAY,KAAa;AACvB,SAAK,MAAM;AAAA,EACb;AACF;AAKO,SAAS,WAAW,aAA4B,QAA4C;AACjG,QAAM,EAAE,cAAc,UAAU,IAAI,eAAe,MAAM;AACzD,QAAM,KAAK,SAAS,MAAM,GAAG,SAAS;AACtC,SAAO,kBAAkB,IAAI,YAAY;AAC3C;AAEO,SAAS,WACd,UACA,sBACG,QACsB;AACzB,QAAM,EAAE,cAAc,UAAU,IAAI,eAAe,MAAM;AACzD,QAAM,KAAK,SAAS,MAAM,GAAG,SAAS;AACtC,SAAO;AAAA,IACL,GAAG,kBAAkB,IAAI,YAAY;AAAA,IACrC,WAAW,GAAG,iBAAiB,IAAI,GAAG,aAAa,EAAE,GAAG,KAAK;AAAA,EAC/D;AACF;AAOO,SAAS,aAAa,QAAyC;AACpE,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,WAAO;AAAA,EACT;AACA,MAAI,UAAU,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,EAAE,SAAS,GAAG;AAC1E,YAAQ;AAAA,MACN;AAAA,IAEF;AAAA,EACF;AACA,SAAO,SAAS,CAAC,MAAM,IAAI,CAAC;AAC9B;AAGA,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