@homebound/truss 1.104.0 → 1.107.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.
package/build/config.d.ts CHANGED
@@ -45,7 +45,15 @@ export interface Config {
45
45
  /** Breakpoints, i.e. `{ sm: 0, md: 500 }`. */
46
46
  breakpoints?: Record<string, number>;
47
47
  /**
48
- * A map of "section" to list of rules to create utility methods.
48
+ * Which default methods to include.
49
+ *
50
+ * Currently, we support either `tachyons` or `none`. Could eventually support
51
+ * `tachyons-rn` or `tailwinds` / `tailwinds-rn` as additional options.
52
+ */
53
+ defaultMethods?: "tachyons" | "none";
54
+ /**
55
+ * A map of "section" to list of rules to create application-specific
56
+ * utility methods.
49
57
  *
50
58
  * I.e. "borderColors" -> () => [`get ml1() { ... }`].
51
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B;;;;GAIG;AACH,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACrB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;;;OAIG;IACH,KAAK,EAAE,UAAU,CAAC;IAElB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAElB,6EAA6E;IAC7E,kBAAkB,EAAE,MAAM,CAAC;IAE3B,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,kHAAkH;IAClH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,UAAU,C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G,OAAO,CAAC,IAAI,CAAC,CAI5D"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,OAAO,EAAE,MAAM,EAAwC,MAAM,UAAU,CAAC;AAKxE,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,UAAU,CAAC,CAStE,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI5D"}
package/build/generate.js CHANGED
@@ -77,6 +77,7 @@ var ts_poet_1 = require("ts-poet");
77
77
  var breakpoints_1 = require("./breakpoints");
78
78
  var methods_1 = require("./methods");
79
79
  var sections_1 = require("./sections");
80
+ var utils_1 = require("./utils");
80
81
  exports.defaultTypeAliases = {
81
82
  Margin: ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"],
82
83
  Padding: [
@@ -107,9 +108,11 @@ function generate(config) {
107
108
  }
108
109
  exports.generate = generate;
109
110
  function generateCssBuilder(config) {
110
- var aliases = config.aliases, increment = config.increment, extras = config.extras, typeAliases = config.typeAliases, breakpoints = config.breakpoints, palette = config.palette, customSections = config.sections;
111
+ var aliases = config.aliases, fonts = config.fonts, increment = config.increment, extras = config.extras, typeAliases = config.typeAliases, breakpoints = config.breakpoints, palette = config.palette, _a = config.defaultMethods, defaultMethods = _a === void 0 ? "tachyons" : _a, customSections = config.sections;
111
112
  // Combine our out-of-the-box utility methods with any custom ones
112
- var sections = __assign(__assign(__assign({}, generateMethods(config, sections_1.defaultSections)), (customSections ? generateMethods(config, customSections) : {})), (aliases && { aliases: methods_1.newAliasesMethods(aliases) }));
113
+ var sections = __assign(__assign(__assign({}, (defaultMethods === "tachyons"
114
+ ? generateMethods(config, sections_1.defaultSections)
115
+ : {})), (customSections ? generateMethods(config, customSections) : {})), (aliases && { aliases: methods_1.newAliasesMethods(aliases) }));
113
116
  var Properties = ts_poet_1.imp("Properties@csstype");
114
117
  var lines = Object.entries(sections)
115
118
  .map(function (_a) {
@@ -119,10 +122,12 @@ function generateCssBuilder(config) {
119
122
  .flat();
120
123
  var typeAliasCode = Object.entries(__assign(__assign({}, exports.defaultTypeAliases), typeAliases)).map(function (_a) {
121
124
  var _b = __read(_a, 2), name = _b[0], props = _b[1];
122
- return "export type " + name + " = " + props
123
- .map(function (p) { return "\"" + p + "\""; })
124
- .join(" | ") + ";\n\n";
125
+ return "export type " + name + " = " + props.map(utils_1.quote).join(" | ") + ";\n\n";
125
126
  });
127
+ var typographyType = ts_poet_1.code(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n export type ", " = ", ";\n "], ["\n export type ", " = ",
128
+ ";\n "])), ts_poet_1.def("Typography"), Object.keys(fonts)
129
+ .map(utils_1.quote)
130
+ .join(" | "));
126
131
  var breakpointCode = breakpoints === undefined
127
132
  ? []
128
133
  : __spread([
@@ -132,8 +137,8 @@ function generateCssBuilder(config) {
132
137
  var _b = __read(_a, 2), name = _b[0], query = _b[1];
133
138
  return "export const " + name + " = \"" + query + "\" as Breakpoint;";
134
139
  }));
135
- return ts_poet_1.code(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n// This file is auto-generated by truss: https://github.com/homebound-team/truss.\n\n/** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */\nexport type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;\n\nexport type ", " = ", ";\n\ntype Opts<T> = {\n rules: T,\n enabled: boolean,\n important: boolean,\n selector: string | undefined\n};\n\n// prettier-ignore\nclass CssBuilder<T extends ", "> {\n constructor(private opts: Opts<T>) {}\n\n private get rules(): T { return this.opts.rules };\n private get enabled(): boolean { return this.opts.enabled };\n private get selector(): string | undefined { return this.opts.selector };\n private newCss(opts: Partial<Opts<T>>): CssBuilder<T> {\n return new CssBuilder({ ...this.opts, ...opts });\n }\n\n ", "\n get $(): T { return maybeImportant(sortObject(this.rules), this.opts.important); }\n\n if(t: boolean | Breakpoint) {\n if (typeof t === \"boolean\") {\n return this.newCss({ enabled: t });\n } else {\n return this.newCss({ selector: t as string });\n }\n }\n\n get else() {\n if (this.selector !== undefined) {\n throw new Error(\"else is not supported with if(selector)\");\n }\n return this.newCss({ enabled: !this.enabled });\n }\n\n get important() { return this.newCss({ important: true }); }\n\n /** Adds new properties, either a specific key/value or a Properties object, to the current css. */\n add<P extends Properties>(props: P): CssBuilder<T & P>;\n add<K extends keyof Properties>(prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n add<K extends keyof Properties>(propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n const rules = this.selector\n ? { ...this.rules, [this.selector]: { ...(this.rules as any)[this.selector], ...newRules } }\n : this.enabled ? { ...this.rules, ...newRules } : this.rules;\n return this.newCss({ rules: rules as any });\n }\n\n /** Adds new properties, either a specific key/value or a Properties object, to a nested selector. */\n addIn<P extends Properties>(selector: string, props: P | undefined): CssBuilder<T & P>;\n addIn<K extends keyof Properties>(selector: string, prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n addIn<K extends keyof Properties>(selector: string, propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n if (newRules === undefined) {\n return this;\n }\n const rules = { ...this.rules, [selector]: { ...(this.rules as any)[selector], ...newRules } };\n return this.newCss({ rules: rules as any });\n }\n}\n\n/** Emotion treats the same rules, ordered differently as different classes, but naively they can be the same. */\nfunction sortObject<T extends object>(obj: T): T {\n return Object.keys(obj)\n .sort()\n .reduce((acc, key) => {\n acc[key as keyof T] = obj[key as keyof T];\n return acc;\n }, ({} as any) as T) as T;\n}\n\n/** Conditionally adds `important!` to everything. */\nfunction maybeImportant<T extends object>(obj: T, important: boolean): T {\n if (important) {\n Object.keys(obj).forEach(key => {\n (obj as any)[key] = `${(obj as any)[key]} !important`;\n });\n }\n return obj;\n}\n\n/** Converts `inc` into pixels value with a `px` suffix. */\nexport function maybeInc(inc: number | string): string {\n return typeof inc === \"string\" ? inc : `${increment(inc)}px`;\n}\n\n/** Converts `inc` into pixels. */\nexport function increment(inc: number): number {\n return inc * ", ";\n}\n\n/** Convert `pixels` to a `px` units string so it's not ambiguous. */\nexport function px(pixels: number): string {\n return `${pixels}px`;\n}\n\nexport enum Palette {\n ", "\n}\n\n/** A shortcut for defining Xss types. */\nexport type Xss<P extends keyof Properties> = Pick<Properties, P>;\n\n/** An entry point for Css expressions. CssBuilder is immutable so this is safe to share. */\nexport const Css = new CssBuilder({ rules: {}, enabled: true, important: false, selector: undefined });\n\n", "\n\n", "\n\n", "\n "], ["\n// This file is auto-generated by truss: https://github.com/homebound-team/truss.\n\n/** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */\nexport type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;\n\nexport type ", " = ", ";\n\ntype Opts<T> = {\n rules: T,\n enabled: boolean,\n important: boolean,\n selector: string | undefined\n};\n\n// prettier-ignore\nclass CssBuilder<T extends ", "> {\n constructor(private opts: Opts<T>) {}\n\n private get rules(): T { return this.opts.rules };\n private get enabled(): boolean { return this.opts.enabled };\n private get selector(): string | undefined { return this.opts.selector };\n private newCss(opts: Partial<Opts<T>>): CssBuilder<T> {\n return new CssBuilder({ ...this.opts, ...opts });\n }\n\n ", "\n get $(): T { return maybeImportant(sortObject(this.rules), this.opts.important); }\n\n if(t: boolean | Breakpoint) {\n if (typeof t === \"boolean\") {\n return this.newCss({ enabled: t });\n } else {\n return this.newCss({ selector: t as string });\n }\n }\n\n get else() {\n if (this.selector !== undefined) {\n throw new Error(\"else is not supported with if(selector)\");\n }\n return this.newCss({ enabled: !this.enabled });\n }\n\n get important() { return this.newCss({ important: true }); }\n\n /** Adds new properties, either a specific key/value or a Properties object, to the current css. */\n add<P extends Properties>(props: P): CssBuilder<T & P>;\n add<K extends keyof Properties>(prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n add<K extends keyof Properties>(propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n const rules = this.selector\n ? { ...this.rules, [this.selector]: { ...(this.rules as any)[this.selector], ...newRules } }\n : this.enabled ? { ...this.rules, ...newRules } : this.rules;\n return this.newCss({ rules: rules as any });\n }\n\n /** Adds new properties, either a specific key/value or a Properties object, to a nested selector. */\n addIn<P extends Properties>(selector: string, props: P | undefined): CssBuilder<T & P>;\n addIn<K extends keyof Properties>(selector: string, prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n addIn<K extends keyof Properties>(selector: string, propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n if (newRules === undefined) {\n return this;\n }\n const rules = { ...this.rules, [selector]: { ...(this.rules as any)[selector], ...newRules } };\n return this.newCss({ rules: rules as any });\n }\n}\n\n/** Emotion treats the same rules, ordered differently as different classes, but naively they can be the same. */\nfunction sortObject<T extends object>(obj: T): T {\n return Object.keys(obj)\n .sort()\n .reduce((acc, key) => {\n acc[key as keyof T] = obj[key as keyof T];\n return acc;\n }, ({} as any) as T) as T;\n}\n\n/** Conditionally adds \\`important!\\` to everything. */\nfunction maybeImportant<T extends object>(obj: T, important: boolean): T {\n if (important) {\n Object.keys(obj).forEach(key => {\n (obj as any)[key] = \\`\\${(obj as any)[key]} !important\\`;\n });\n }\n return obj;\n}\n\n/** Converts \\`inc\\` into pixels value with a \\`px\\` suffix. */\nexport function maybeInc(inc: number | string): string {\n return typeof inc === \"string\" ? inc : \\`\\${increment(inc)}px\\`;\n}\n\n/** Converts \\`inc\\` into pixels. */\nexport function increment(inc: number): number {\n return inc * ", ";\n}\n\n/** Convert \\`pixels\\` to a \\`px\\` units string so it's not ambiguous. */\nexport function px(pixels: number): string {\n return \\`\\${pixels}px\\`;\n}\n\nexport enum Palette {\n ",
136
- "\n}\n\n/** A shortcut for defining Xss types. */\nexport type Xss<P extends keyof Properties> = Pick<Properties, P>;\n\n/** An entry point for Css expressions. CssBuilder is immutable so this is safe to share. */\nexport const Css = new CssBuilder({ rules: {}, enabled: true, important: false, selector: undefined });\n\n", "\n\n", "\n\n", "\n "])), ts_poet_1.def("Properties"), Properties, Properties, lines.join("\n ").replace(/ +\n/g, "\n"), increment, Object.entries(palette).map(function (_a) {
140
+ return ts_poet_1.code(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n// This file is auto-generated by truss: https://github.com/homebound-team/truss.\n\n/** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */\nexport type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;\n\nexport type ", " = ", ";\n\n", "\n\ntype Opts<T> = {\n rules: T,\n enabled: boolean,\n important: boolean,\n selector: string | undefined\n};\n\n// prettier-ignore\nclass CssBuilder<T extends ", "> {\n constructor(private opts: Opts<T>) {}\n\n private get rules(): T { return this.opts.rules };\n private get enabled(): boolean { return this.opts.enabled };\n private get selector(): string | undefined { return this.opts.selector };\n private newCss(opts: Partial<Opts<T>>): CssBuilder<T> {\n return new CssBuilder({ ...this.opts, ...opts });\n }\n\n ", "\n get $(): T { return maybeImportant(sortObject(this.rules), this.opts.important); }\n\n if(t: boolean | Breakpoint) {\n if (typeof t === \"boolean\") {\n return this.newCss({ enabled: t });\n } else {\n return this.newCss({ selector: t as string });\n }\n }\n\n get else() {\n if (this.selector !== undefined) {\n throw new Error(\"else is not supported with if(selector)\");\n }\n return this.newCss({ enabled: !this.enabled });\n }\n\n get important() { return this.newCss({ important: true }); }\n\n /** Adds new properties, either a specific key/value or a Properties object, to the current css. */\n add<P extends Properties>(props: P): CssBuilder<T & P>;\n add<K extends keyof Properties>(prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n add<K extends keyof Properties>(propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n const rules = this.selector\n ? { ...this.rules, [this.selector]: { ...(this.rules as any)[this.selector], ...newRules } }\n : this.enabled ? { ...this.rules, ...newRules } : this.rules;\n return this.newCss({ rules: rules as any });\n }\n\n /** Adds new properties, either a specific key/value or a Properties object, to a nested selector. */\n addIn<P extends Properties>(selector: string, props: P | undefined): CssBuilder<T & P>;\n addIn<K extends keyof Properties>(selector: string, prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n addIn<K extends keyof Properties>(selector: string, propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n if (newRules === undefined) {\n return this;\n }\n const rules = { ...this.rules, [selector]: { ...(this.rules as any)[selector], ...newRules } };\n return this.newCss({ rules: rules as any });\n }\n}\n\n/** Emotion treats the same rules, ordered differently as different classes, but naively they can be the same. */\nfunction sortObject<T extends object>(obj: T): T {\n return Object.keys(obj)\n .sort()\n .reduce((acc, key) => {\n acc[key as keyof T] = obj[key as keyof T];\n return acc;\n }, ({} as any) as T) as T;\n}\n\n/** Conditionally adds `important!` to everything. */\nfunction maybeImportant<T extends object>(obj: T, important: boolean): T {\n if (important) {\n Object.keys(obj).forEach(key => {\n (obj as any)[key] = `${(obj as any)[key]} !important`;\n });\n }\n return obj;\n}\n\n/** Converts `inc` into pixels value with a `px` suffix. */\nexport function maybeInc(inc: number | string): string {\n return typeof inc === \"string\" ? inc : `${increment(inc)}px`;\n}\n\n/** Converts `inc` into pixels. */\nexport function increment(inc: number): number {\n return inc * ", ";\n}\n\n/** Convert `pixels` to a `px` units string so it's not ambiguous. */\nexport function px(pixels: number): string {\n return `${pixels}px`;\n}\n\nexport enum Palette {\n ", "\n}\n\n/** A shortcut for defining Xss types. */\nexport type Xss<P extends keyof Properties> = Pick<Properties, P>;\n\n/** An entry point for Css expressions. CssBuilder is immutable so this is safe to share. */\nexport const Css = new CssBuilder({ rules: {}, enabled: true, important: false, selector: undefined });\n\n", "\n\n", "\n\n", "\n "], ["\n// This file is auto-generated by truss: https://github.com/homebound-team/truss.\n\n/** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */\nexport type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;\n\nexport type ", " = ", ";\n\n", "\n\ntype Opts<T> = {\n rules: T,\n enabled: boolean,\n important: boolean,\n selector: string | undefined\n};\n\n// prettier-ignore\nclass CssBuilder<T extends ", "> {\n constructor(private opts: Opts<T>) {}\n\n private get rules(): T { return this.opts.rules };\n private get enabled(): boolean { return this.opts.enabled };\n private get selector(): string | undefined { return this.opts.selector };\n private newCss(opts: Partial<Opts<T>>): CssBuilder<T> {\n return new CssBuilder({ ...this.opts, ...opts });\n }\n\n ", "\n get $(): T { return maybeImportant(sortObject(this.rules), this.opts.important); }\n\n if(t: boolean | Breakpoint) {\n if (typeof t === \"boolean\") {\n return this.newCss({ enabled: t });\n } else {\n return this.newCss({ selector: t as string });\n }\n }\n\n get else() {\n if (this.selector !== undefined) {\n throw new Error(\"else is not supported with if(selector)\");\n }\n return this.newCss({ enabled: !this.enabled });\n }\n\n get important() { return this.newCss({ important: true }); }\n\n /** Adds new properties, either a specific key/value or a Properties object, to the current css. */\n add<P extends Properties>(props: P): CssBuilder<T & P>;\n add<K extends keyof Properties>(prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n add<K extends keyof Properties>(propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n const rules = this.selector\n ? { ...this.rules, [this.selector]: { ...(this.rules as any)[this.selector], ...newRules } }\n : this.enabled ? { ...this.rules, ...newRules } : this.rules;\n return this.newCss({ rules: rules as any });\n }\n\n /** Adds new properties, either a specific key/value or a Properties object, to a nested selector. */\n addIn<P extends Properties>(selector: string, props: P | undefined): CssBuilder<T & P>;\n addIn<K extends keyof Properties>(selector: string, prop: K, value: Properties[K]): CssBuilder<T & { [U in K]: Properties[K] }>;\n addIn<K extends keyof Properties>(selector: string, propOrProperties: K | Properties, value?: Properties[K]): CssBuilder<any> {\n const newRules = typeof propOrProperties === \"string\" ? { [propOrProperties]: value } : propOrProperties;\n if (newRules === undefined) {\n return this;\n }\n const rules = { ...this.rules, [selector]: { ...(this.rules as any)[selector], ...newRules } };\n return this.newCss({ rules: rules as any });\n }\n}\n\n/** Emotion treats the same rules, ordered differently as different classes, but naively they can be the same. */\nfunction sortObject<T extends object>(obj: T): T {\n return Object.keys(obj)\n .sort()\n .reduce((acc, key) => {\n acc[key as keyof T] = obj[key as keyof T];\n return acc;\n }, ({} as any) as T) as T;\n}\n\n/** Conditionally adds \\`important!\\` to everything. */\nfunction maybeImportant<T extends object>(obj: T, important: boolean): T {\n if (important) {\n Object.keys(obj).forEach(key => {\n (obj as any)[key] = \\`\\${(obj as any)[key]} !important\\`;\n });\n }\n return obj;\n}\n\n/** Converts \\`inc\\` into pixels value with a \\`px\\` suffix. */\nexport function maybeInc(inc: number | string): string {\n return typeof inc === \"string\" ? inc : \\`\\${increment(inc)}px\\`;\n}\n\n/** Converts \\`inc\\` into pixels. */\nexport function increment(inc: number): number {\n return inc * ", ";\n}\n\n/** Convert \\`pixels\\` to a \\`px\\` units string so it's not ambiguous. */\nexport function px(pixels: number): string {\n return \\`\\${pixels}px\\`;\n}\n\nexport enum Palette {\n ",
141
+ "\n}\n\n/** A shortcut for defining Xss types. */\nexport type Xss<P extends keyof Properties> = Pick<Properties, P>;\n\n/** An entry point for Css expressions. CssBuilder is immutable so this is safe to share. */\nexport const Css = new CssBuilder({ rules: {}, enabled: true, important: false, selector: undefined });\n\n", "\n\n", "\n\n", "\n "])), ts_poet_1.def("Properties"), Properties, typographyType, Properties, lines.join("\n ").replace(/ +\n/g, "\n"), increment, Object.entries(palette).map(function (_a) {
137
142
  var _b = __read(_a, 2), name = _b[0], value = _b[1];
138
143
  return name + " = \"" + value + "\",";
139
144
  }), typeAliasCode, breakpointCode, extras || "");
@@ -145,5 +150,5 @@ function generateMethods(config, methodFns) {
145
150
  return [name, fn(config)];
146
151
  }));
147
152
  }
148
- var templateObject_1;
153
+ var templateObject_1, templateObject_2;
149
154
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yBAAoC;AACpC,mCAA+C;AAC/C,6CAAgD;AAEhD,qCAA8C;AAC9C,uCAA6C;AAEhC,QAAA,kBAAkB,GAA4C;IACzE,MAAM,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,CAAC;IAC5E,OAAO,EAAE;QACP,SAAS;QACT,YAAY;QACZ,cAAc;QACd,eAAe;QACf,aAAa;KACd;CACF,CAAC;AAEF,SAAsB,QAAQ,CAAC,MAAc;;;;;;oBACnC,UAAU,GAAK,MAAM,WAAX,CAAY;oBACf,qBAAM,kBAAkB,CAAC,MAAM,CAAC,CAAC,mBAAmB,EAAE,EAAA;;oBAA/D,MAAM,GAAG,SAAsD;oBACrE,qBAAM,aAAE,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA;;oBAAtC,SAAsC,CAAC;;;;;CACxC;AAJD,4BAIC;AAED,SAAS,kBAAkB,CAAC,MAAc;IAEtC,IAAA,OAAO,GAOL,MAAM,QAPD,EACP,SAAS,GAMP,MAAM,UANC,EACT,MAAM,GAKJ,MAAM,OALF,EACN,WAAW,GAIT,MAAM,YAJG,EACX,WAAW,GAGT,MAAM,YAHG,EACX,OAAO,GAEL,MAAM,QAFD,EACG,cAAc,GACtB,MAAM,SADgB,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AAU,EAUnC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAuE5B,SAAS,EAStB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAC,EAAa;YAAb,KAAA,aAAa,EAAZ,IAAI,QAAA,EAAE,KAAK,QAAA;QACzC,OAAU,IAAI,aAAO,KAAK,QAAI,CAAC;IACjC,CAAC,CAAC,EASF,aAAa,EAEb,cAAc,EAEd,MAAM,IAAI,EAAE,EACV;AACJ,CAAC;AAED,wEAAwE;AACxE,SAAS,eAAe,CACtB,MAAc,EACd,SAAmB;IAEnB,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,UAAC,EAAU;YAAV,KAAA,aAAU,EAAT,IAAI,QAAA,EAAE,EAAE,QAAA;QAAM,OAAA,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAAlB,CAAkB,CAAC,CAClE,CAAC;AACJ,CAAC"}
package/build/utils.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare function lowerCaseFirst(s: string): string;
2
+ export declare function quote(s: string): string;
2
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,UAEvC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvC"}
package/build/utils.js CHANGED
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lowerCaseFirst = void 0;
3
+ exports.quote = exports.lowerCaseFirst = void 0;
4
4
  function lowerCaseFirst(s) {
5
5
  return s.charAt(0).toLowerCase() + s.substr(1);
6
6
  }
7
7
  exports.lowerCaseFirst = lowerCaseFirst;
8
+ function quote(s) {
9
+ return "\"" + s + "\"";
10
+ }
11
+ exports.quote = quote;
8
12
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,CAAS;IACtC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,CAAS;IACtC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC;AAED,SAAgB,KAAK,CAAC,CAAS;IAC7B,OAAO,OAAI,CAAC,OAAG,CAAC;AAClB,CAAC;AAFD,sBAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/truss",
3
- "version": "1.104.0",
3
+ "version": "1.107.0",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",