@homebound/truss 2.21.2 → 2.21.4

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.d.ts CHANGED
@@ -55,15 +55,15 @@ interface Config {
55
55
  /**
56
56
  * The target CSS runtime to generate for.
57
57
  *
58
- * - `"stylex"` (default): Generates a StyleX-friendly CssBuilder (for IDE autocomplete + types) plus a
59
- * `Css.json` mapping file consumed by the truss Vite plugin, which transforms
60
- * `Css.*.$` expressions into file-local `stylex.create()` + `stylex.props()` calls at build time.
58
+ * - `"web"` (default): Generates a web CssBuilder (for IDE autocomplete + types) plus a
59
+ * `Css.json` mapping file consumed by the truss Vite plugin, which compiles
60
+ * `Css.*.$` expressions into atomic CSS output at build time.
61
61
  * - `"react-native"`: Generates a runtime CssBuilder that accumulates plain style objects,
62
62
  * intended for React Native usage.
63
63
  */
64
- target?: "react-native" | "stylex";
64
+ target?: "react-native" | "web";
65
65
  /**
66
- * The output path for the truss mapping file (only used when target is "stylex").
66
+ * The output path for the truss mapping file (only used when target is "web").
67
67
  * Defaults to a `.json` sibling of `outputPath` (e.g. `./src/Css.json`).
68
68
  */
69
69
  mappingOutputPath?: string;
@@ -165,7 +165,7 @@ declare const defaultSections: {
165
165
  declare function generate(config: Config): Promise<void>;
166
166
 
167
167
  type Prop = keyof Properties;
168
- interface StylexEntry {
168
+ interface WebEntry {
169
169
  kind: "static" | "param" | "increment-param" | "px-delegate" | "alias" | "cssvar";
170
170
  abbr: string;
171
171
  /** For static: the CSS properties object, e.g. { display: "flex" } */
@@ -179,10 +179,10 @@ interface StylexEntry {
179
179
  /** For aliases: the list of chained abbreviations */
180
180
  aliasTargets?: string[];
181
181
  }
182
- /** Start collecting StylexEntry metadata from method helpers. */
183
- declare function startStylexCollection(): void;
182
+ /** Start collecting WebEntry metadata from method helpers. */
183
+ declare function startWebCollection(): void;
184
184
  /** Stop collecting and return all accumulated entries. */
185
- declare function stopStylexCollection(): StylexEntry[];
185
+ declare function stopWebCollection(): WebEntry[];
186
186
  /**
187
187
  * Given a single abbreviation (i.e. `mt0`) and multiple `{ prop: value }` CSS values, returns
188
188
  * the TypeScript code for a `mt0` utility method that sets those values.
@@ -261,4 +261,4 @@ declare function newIncrementMethods(config: Config, abbr: UtilityName, prop: Pr
261
261
  declare function newCoreIncrementMethods(config: Config, abbr: UtilityName, props: Prop[]): UtilityMethod[];
262
262
  declare function newPxMethod(abbr: UtilityName, prop: Prop): UtilityMethod;
263
263
 
264
- export { type Aliases, type Config, type CreateMethodsFn, type FontConfig, type IncConfig, type SectionName, type Sections, type StylexEntry, type UtilityMethod, type UtilityName, defaultSections, defineConfig, generate, newAliasesMethods, newCoreIncrementMethods, newIncrementMethods, newMethod, newMethodsForProp, newParamMethod, newPxMethod, newSetCssVariablesMethod, startStylexCollection, stopStylexCollection };
264
+ export { type Aliases, type Config, type CreateMethodsFn, type FontConfig, type IncConfig, type SectionName, type Sections, type UtilityMethod, type UtilityName, type WebEntry, defaultSections, defineConfig, generate, newAliasesMethods, newCoreIncrementMethods, newIncrementMethods, newMethod, newMethodsForProp, newParamMethod, newPxMethod, newSetCssVariablesMethod, startWebCollection, stopWebCollection };
package/build/index.js CHANGED
@@ -4,17 +4,17 @@ function defineConfig(config) {
4
4
  }
5
5
 
6
6
  // src/methods.ts
7
- var _stylexCollector = null;
8
- function startStylexCollection() {
9
- _stylexCollector = [];
7
+ var _webCollector = null;
8
+ function startWebCollection() {
9
+ _webCollector = [];
10
10
  }
11
- function stopStylexCollection() {
12
- const result = _stylexCollector;
13
- _stylexCollector = null;
11
+ function stopWebCollection() {
12
+ const result = _webCollector;
13
+ _webCollector = null;
14
14
  return result;
15
15
  }
16
16
  function collect(entry) {
17
- if (_stylexCollector) _stylexCollector.push(entry);
17
+ if (_webCollector) _webCollector.push(entry);
18
18
  }
19
19
  function newMethod(abbr, defs) {
20
20
  collect({ kind: "static", abbr, defs: { ...defs } });
@@ -930,10 +930,10 @@ var defaultTypeAliases = {
930
930
  };
931
931
  async function generate(config) {
932
932
  const { outputPath } = config;
933
- const target = config.target ?? "stylex";
934
- if (target === "stylex") {
935
- const { sections, entries } = collectStylexGenerationData(config);
936
- const cssOutput = generateStylexCssBuilder(config, sections).toString();
933
+ const target = config.target ?? "web";
934
+ if (target === "web") {
935
+ const { sections, entries } = collectWebGenerationData(config);
936
+ const cssOutput = generateWebCssBuilder(config, sections).toString();
937
937
  await fs.writeFile(outputPath, cssOutput);
938
938
  const mappingPath = config.mappingOutputPath || outputPath.replace(/\.ts$/, ".json");
939
939
  const mapping = generateTrussMapping(config, entries);
@@ -945,7 +945,7 @@ async function generate(config) {
945
945
  await fs.writeFile(outputPath, output);
946
946
  return;
947
947
  }
948
- throw new Error(`Unsupported truss target "${target}". Use "stylex" (default) or "react-native".`);
948
+ throw new Error(`Unsupported truss target "${target}". Use "web" (default) or "react-native".`);
949
949
  }
950
950
  function generateCssBuilder(config) {
951
951
  const { fonts, increment, extras, typeAliases, breakpoints = {}, palette } = config;
@@ -1246,18 +1246,18 @@ function generateSections(config) {
1246
1246
  ...aliases && { aliases: newAliasesMethods(aliases) }
1247
1247
  };
1248
1248
  }
1249
- function collectStylexGenerationData(config) {
1250
- startStylexCollection();
1249
+ function collectWebGenerationData(config) {
1250
+ startWebCollection();
1251
1251
  try {
1252
1252
  const sections = generateSections(config);
1253
- const entries = stopStylexCollection();
1253
+ const entries = stopWebCollection();
1254
1254
  return { sections, entries };
1255
1255
  } catch (error) {
1256
- stopStylexCollection();
1256
+ stopWebCollection();
1257
1257
  throw error;
1258
1258
  }
1259
1259
  }
1260
- function generateStylexCssBuilder(config, sections) {
1260
+ function generateWebCssBuilder(config, sections) {
1261
1261
  const { fonts, increment, extras, typeAliases, palette, breakpoints = {} } = config;
1262
1262
  const lines = Object.entries(sections).map(([name, value]) => [`// ${name}`, ...value, ""]).flat();
1263
1263
  const typeAliasCode = Object.entries({
@@ -1287,7 +1287,7 @@ function generateStylexCssBuilder(config, sections) {
1287
1287
  return code`
1288
1288
  // This file is auto-generated by truss: https://github.com/homebound-team/truss.
1289
1289
  // See your project's \`truss-config.ts\` to make configuration changes (fonts, increments, etc).
1290
- // Target: native (build-time plugin)
1290
+ // Target: web (build-time plugin)
1291
1291
 
1292
1292
  import { trussProps, useRuntimeStyle as _useRuntimeStyle } from "@homebound/truss/runtime";
1293
1293
 
@@ -1718,7 +1718,7 @@ export {
1718
1718
  newParamMethod,
1719
1719
  newPxMethod,
1720
1720
  newSetCssVariablesMethod,
1721
- startStylexCollection,
1722
- stopStylexCollection
1721
+ startWebCollection,
1722
+ stopWebCollection
1723
1723
  };
1724
1724
  //# sourceMappingURL=index.js.map