@homebound/truss 2.0.13 → 2.1.0-next.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.
- package/build/index.js +20 -24
- package/build/index.js.map +1 -1
- package/build/plugin/index.d.ts +11 -10
- package/build/plugin/index.js +987 -981
- package/build/plugin/index.js.map +1 -1
- package/build/runtime.d.ts +20 -10
- package/build/runtime.js +57 -41
- package/build/runtime.js.map +1 -1
- package/cli.js +5 -10
- package/package.json +7 -3
package/build/index.js
CHANGED
|
@@ -850,6 +850,7 @@ function makeBreakpoints(breakpoints) {
|
|
|
850
850
|
const r = {
|
|
851
851
|
print: "@media print"
|
|
852
852
|
};
|
|
853
|
+
const screenMedia = "@media screen and";
|
|
853
854
|
const bps = Object.keys(breakpoints);
|
|
854
855
|
Object.entries(breakpoints).forEach(([bp, px], i) => {
|
|
855
856
|
const isFirst = i === 0;
|
|
@@ -857,11 +858,11 @@ function makeBreakpoints(breakpoints) {
|
|
|
857
858
|
const min = !isFirst ? `${px}px` : "0";
|
|
858
859
|
const max = !isLast ? `${breakpoints[bps[i + 1]] - 1}px` : "0";
|
|
859
860
|
if (isFirst) {
|
|
860
|
-
r[bp] =
|
|
861
|
+
r[bp] = `${screenMedia} (max-width: ${max})`;
|
|
861
862
|
} else if (isLast) {
|
|
862
|
-
r[bp] =
|
|
863
|
+
r[bp] = `${screenMedia} (min-width: ${min})`;
|
|
863
864
|
} else {
|
|
864
|
-
r[bp] =
|
|
865
|
+
r[bp] = `${screenMedia} (min-width: ${min}) and (max-width: ${max})`;
|
|
865
866
|
}
|
|
866
867
|
if (!isFirst) {
|
|
867
868
|
const isSecond = i === 1;
|
|
@@ -875,11 +876,11 @@ function makeBreakpoints(breakpoints) {
|
|
|
875
876
|
if (!isLast) {
|
|
876
877
|
parts.push(`(max-width: ${max})`);
|
|
877
878
|
}
|
|
878
|
-
r[name] =
|
|
879
|
+
r[name] = `${screenMedia} ${parts.join(" and ")}`;
|
|
879
880
|
}
|
|
880
881
|
if (!isFirst && !isLast) {
|
|
881
|
-
r[`${bp}AndUp`] =
|
|
882
|
-
r[`${bp}AndDown`] =
|
|
882
|
+
r[`${bp}AndUp`] = `${screenMedia} (min-width: ${min})`;
|
|
883
|
+
r[`${bp}AndDown`] = `${screenMedia} (max-width: ${max})`;
|
|
883
884
|
}
|
|
884
885
|
});
|
|
885
886
|
return r;
|
|
@@ -1091,10 +1092,6 @@ class CssBuilder<T extends Properties> {
|
|
|
1091
1092
|
return this.newCss({ rules: rules as any });
|
|
1092
1093
|
}
|
|
1093
1094
|
|
|
1094
|
-
/** Marker helper for legacy object-spread composition. */
|
|
1095
|
-
spread<P extends object>(props: P): P {
|
|
1096
|
-
return props;
|
|
1097
|
-
}
|
|
1098
1095
|
}
|
|
1099
1096
|
|
|
1100
1097
|
/** Sort keys so equivalent rule objects have deterministic shape. */
|
|
@@ -1205,9 +1202,8 @@ function generateStylexCssBuilder(config, sections) {
|
|
|
1205
1202
|
return code`
|
|
1206
1203
|
// This file is auto-generated by truss: https://github.com/homebound-team/truss.
|
|
1207
1204
|
// See your project's \`truss-config.ts\` to make configuration changes (fonts, increments, etc).
|
|
1208
|
-
// Target:
|
|
1205
|
+
// Target: native (build-time plugin)
|
|
1209
1206
|
|
|
1210
|
-
import * as stylex from "@stylexjs/stylex";
|
|
1211
1207
|
import { trussProps } from "@homebound/truss/runtime";
|
|
1212
1208
|
|
|
1213
1209
|
/** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */
|
|
@@ -1215,8 +1211,8 @@ export type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;
|
|
|
1215
1211
|
|
|
1216
1212
|
export type ${def("Properties")} = ${CssProperties}<string | 0, string>;
|
|
1217
1213
|
|
|
1218
|
-
/** A marker
|
|
1219
|
-
export type Marker =
|
|
1214
|
+
/** A marker token used with \`when\`/\`markerOf\` etc. */
|
|
1215
|
+
export type Marker = symbol;
|
|
1220
1216
|
|
|
1221
1217
|
${typographyType}
|
|
1222
1218
|
|
|
@@ -1266,11 +1262,16 @@ class CssBuilder<T extends Properties> {
|
|
|
1266
1262
|
return this;
|
|
1267
1263
|
}
|
|
1268
1264
|
|
|
1269
|
-
/** Marks this element with a user-defined marker
|
|
1265
|
+
/** Marks this element with a user-defined marker. */
|
|
1270
1266
|
markerOf(_marker: Marker): CssBuilder<T> {
|
|
1271
1267
|
return this;
|
|
1272
1268
|
}
|
|
1273
1269
|
|
|
1270
|
+
/** Creates a marker token for use with markerOf() and when(). */
|
|
1271
|
+
newMarker(): Marker {
|
|
1272
|
+
return Symbol("truss-marker");
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1274
1275
|
typography(key: Typography): CssBuilder<T> {
|
|
1275
1276
|
return (this as any)[key];
|
|
1276
1277
|
}
|
|
@@ -1331,14 +1332,9 @@ class CssBuilder<T extends Properties> {
|
|
|
1331
1332
|
return this.newCss({ rules: rules as any });
|
|
1332
1333
|
}
|
|
1333
1334
|
|
|
1334
|
-
/**
|
|
1335
|
-
spread<P extends object>(props: P): P {
|
|
1336
|
-
return props;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
/** Convert a style array into \`{ className, style }\` props for manual spreading into non-\`css=\` contexts. */
|
|
1335
|
+
/** Convert a style hash into \`{ className, style }\` props for manual spreading into non-\`css=\` contexts. */
|
|
1340
1336
|
props(styles: Properties): Record<string, unknown> {
|
|
1341
|
-
return trussProps(
|
|
1337
|
+
return trussProps(styles as any);
|
|
1342
1338
|
}
|
|
1343
1339
|
|
|
1344
1340
|
private get rules(): T {
|
|
@@ -1400,7 +1396,7 @@ function generateTrussMapping(config, entries) {
|
|
|
1400
1396
|
break;
|
|
1401
1397
|
case "param":
|
|
1402
1398
|
abbreviations[entry.abbr] = {
|
|
1403
|
-
kind: "
|
|
1399
|
+
kind: "variable",
|
|
1404
1400
|
props: entry.props || [],
|
|
1405
1401
|
incremented: false,
|
|
1406
1402
|
extraDefs: entry.extraDefs
|
|
@@ -1408,7 +1404,7 @@ function generateTrussMapping(config, entries) {
|
|
|
1408
1404
|
break;
|
|
1409
1405
|
case "increment-param":
|
|
1410
1406
|
abbreviations[entry.abbr] = {
|
|
1411
|
-
kind: "
|
|
1407
|
+
kind: "variable",
|
|
1412
1408
|
props: entry.props || [],
|
|
1413
1409
|
incremented: true,
|
|
1414
1410
|
extraDefs: entry.extraDefs
|