@salty-css/core 0.1.0-alpha.3 → 0.1.0-alpha.30

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.
Files changed (77) hide show
  1. package/README.md +209 -0
  2. package/astro-component-5hrNTCJ5.js +4 -0
  3. package/astro-component-Dj3enX6K.cjs +4 -0
  4. package/bin/commands/build.d.ts +2 -0
  5. package/bin/commands/generate.d.ts +2 -0
  6. package/bin/commands/init.d.ts +2 -0
  7. package/bin/commands/update.d.ts +2 -0
  8. package/bin/commands/version.d.ts +2 -0
  9. package/bin/confirm-install.d.ts +34 -0
  10. package/bin/context.d.ts +22 -0
  11. package/bin/detection/css-file.d.ts +5 -0
  12. package/bin/frameworks/astro.d.ts +4 -0
  13. package/bin/frameworks/index.d.ts +13 -0
  14. package/bin/frameworks/react.d.ts +2 -0
  15. package/bin/frameworks/types.d.ts +27 -0
  16. package/bin/integrations/astro.d.ts +11 -0
  17. package/bin/integrations/eslint.d.ts +6 -0
  18. package/bin/integrations/index.d.ts +21 -0
  19. package/bin/integrations/next.d.ts +9 -0
  20. package/bin/integrations/types.d.ts +29 -0
  21. package/bin/integrations/vite.d.ts +8 -0
  22. package/bin/main.cjs +653 -336
  23. package/bin/main.d.ts +8 -0
  24. package/bin/main.js +653 -336
  25. package/bin/package-json.d.ts +21 -0
  26. package/bin/saltyrc.d.ts +31 -0
  27. package/bin/templates.d.ts +14 -0
  28. package/{class-name-generator-YeSQe_Ik.js → class-name-generator-B0WkxoIg.js} +17 -2
  29. package/{class-name-generator-B2Pb2obX.cjs → class-name-generator-BEOEMEKX.cjs} +17 -2
  30. package/compiler/resolve-import.d.ts +17 -0
  31. package/compiler/salty-compiler.cjs +131 -30
  32. package/compiler/salty-compiler.d.ts +8 -1
  33. package/compiler/salty-compiler.js +133 -31
  34. package/config/index.cjs +4 -0
  35. package/config/index.js +5 -1
  36. package/css/dynamic-styles.cjs +15 -0
  37. package/css/dynamic-styles.d.ts +10 -0
  38. package/css/dynamic-styles.js +15 -0
  39. package/css/index.cjs +3 -0
  40. package/css/index.d.ts +1 -0
  41. package/css/index.js +3 -0
  42. package/css/keyframes.cjs +1 -1
  43. package/css/keyframes.js +1 -1
  44. package/factories/define-font.d.ts +28 -0
  45. package/factories/define-import.d.ts +14 -0
  46. package/factories/index.cjs +141 -0
  47. package/factories/index.d.ts +2 -0
  48. package/factories/index.js +141 -0
  49. package/generators/index.cjs +1 -1
  50. package/generators/index.js +2 -2
  51. package/instances/classname-instance.cjs +1 -1
  52. package/instances/classname-instance.js +1 -1
  53. package/package.json +5 -1
  54. package/parse-styles-BBJ3PWyV.js +514 -0
  55. package/parse-styles-lOMGe_c5.cjs +513 -0
  56. package/parsers/index.cjs +93 -3
  57. package/parsers/index.d.ts +1 -0
  58. package/parsers/index.js +97 -7
  59. package/parsers/parse-templates.d.ts +10 -0
  60. package/parsers/parser-regexes.d.ts +3 -0
  61. package/parsers/resolve-template-variants.d.ts +21 -0
  62. package/parsers/strict.d.ts +2 -0
  63. package/runtime/index.cjs +1 -1
  64. package/runtime/index.js +1 -1
  65. package/{salty.config-cqavVm2t.cjs → salty.config-DogY_sSQ.cjs} +1 -1
  66. package/salty.config-GV37Q-D2.js +4 -0
  67. package/styled-file-BzmB9_Ez.cjs +12 -0
  68. package/{react-styled-file-U02jek-B.cjs → styled-file-CPd_rTW2.cjs} +2 -2
  69. package/{react-styled-file-B99mwk0w.js → styled-file-Cda3EeR6.js} +2 -2
  70. package/styled-file-DLcgYmGN.js +12 -0
  71. package/types/config-types.d.ts +42 -2
  72. package/types/font-types.d.ts +53 -0
  73. package/{react-vanilla-file-D9px70iK.js → vanilla-file-1kOqbCIM.js} +2 -2
  74. package/{react-vanilla-file-Bj6XC8GS.cjs → vanilla-file-r0fp2q_m.cjs} +2 -2
  75. package/parse-styles-BTIoYnBr.js +0 -232
  76. package/parse-styles-CA3TP5n1.cjs +0 -231
  77. package/salty.config-DjosWdPw.js +0 -4
@@ -1,5 +1,128 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { d as dashCase } from "../dash-case-DblXvymC.js";
5
+ import { t as toHash } from "../to-hash-DAN2LcHK.js";
1
6
  import { media } from "../css/media.js";
2
7
  import { T, a, d } from "../define-templates-CVhhgPnd.js";
8
+ const FONT_FORMAT_BY_EXTENSION = {
9
+ woff2: "woff2",
10
+ woff: "woff",
11
+ ttf: "truetype",
12
+ otf: "opentype",
13
+ eot: "embedded-opentype",
14
+ svg: "svg",
15
+ ttc: "collection"
16
+ };
17
+ const detectFontFormat = (url) => {
18
+ const cleaned = url.split("?")[0].split("#")[0];
19
+ const dot = cleaned.lastIndexOf(".");
20
+ if (dot === -1) return void 0;
21
+ const ext = cleaned.slice(dot + 1).toLowerCase();
22
+ return FONT_FORMAT_BY_EXTENSION[ext];
23
+ };
24
+ const toFontSrc = (entry) => {
25
+ if (typeof entry === "string") return { url: entry, format: detectFontFormat(entry) };
26
+ return entry;
27
+ };
28
+ const normalizeSources = (src) => {
29
+ if (Array.isArray(src)) return src.map(toFontSrc);
30
+ return [toFontSrc(src)];
31
+ };
32
+ const normalizeVariable = (variable) => {
33
+ const trimmed = variable.trim();
34
+ const stripped = trimmed.replace(/^--/, "");
35
+ if (!stripped) throw new Error(`defineFont: invalid \`variable\` value "${variable}".`);
36
+ return `--${dashCase(stripped)}`;
37
+ };
38
+ const deriveVariable = (options) => {
39
+ const hashSource = [options.name, options.fallback, "variants" in options ? options.variants : void 0, "import" in options ? options.import : void 0];
40
+ return `--font-${dashCase(options.name)}-${toHash(hashSource, 6)}`;
41
+ };
42
+ const quoteFamily = (name) => {
43
+ if (/^["'].*["']$/.test(name)) return name;
44
+ if (/\s/.test(name)) return `"${name}"`;
45
+ return name;
46
+ };
47
+ const buildFontFamilyValue = (name, fallback) => {
48
+ const head = quoteFamily(name);
49
+ if (!fallback || fallback.length === 0) return head;
50
+ return [head, fallback].join(", ");
51
+ };
52
+ const formatSrc = (src) => {
53
+ const parts = [`url("${src.url}")`];
54
+ if (src.format) parts.push(`format("${src.format}")`);
55
+ if (src.tech) parts.push(`tech(${src.tech})`);
56
+ return parts.join(" ");
57
+ };
58
+ const variantToFontFace = (name, variant, defaultDisplay) => {
59
+ const sources = normalizeSources(variant.src);
60
+ if (sources.length === 0) {
61
+ throw new Error(`defineFont(${name}): variant must declare at least one \`src\`.`);
62
+ }
63
+ const lines = [`font-family: ${quoteFamily(name)};`, `src: ${sources.map(formatSrc).join(", ")};`, `font-display: ${variant.display ?? defaultDisplay};`];
64
+ if (variant.weight !== void 0) lines.push(`font-weight: ${variant.weight};`);
65
+ if (variant.style !== void 0) lines.push(`font-style: ${variant.style};`);
66
+ if (variant.stretch !== void 0) lines.push(`font-stretch: ${variant.stretch};`);
67
+ if (variant.unicodeRange !== void 0) lines.push(`unicode-range: ${variant.unicodeRange};`);
68
+ if (variant.ascentOverride !== void 0) lines.push(`ascent-override: ${variant.ascentOverride};`);
69
+ if (variant.descentOverride !== void 0) lines.push(`descent-override: ${variant.descentOverride};`);
70
+ if (variant.lineGapOverride !== void 0) lines.push(`line-gap-override: ${variant.lineGapOverride};`);
71
+ if (variant.sizeAdjust !== void 0) lines.push(`size-adjust: ${variant.sizeAdjust};`);
72
+ return `@font-face { ${lines.join(" ")} }`;
73
+ };
74
+ class FontFactory {
75
+ constructor(_options) {
76
+ __publicField(this, "variable");
77
+ __publicField(this, "fontFamily");
78
+ __publicField(this, "className");
79
+ this._options = _options;
80
+ if (!_options || !_options.name) {
81
+ throw new Error("defineFont: `name` is required.");
82
+ }
83
+ if ("variants" in _options && "import" in _options && _options.import !== void 0 && _options.variants !== void 0) {
84
+ throw new Error("defineFont: provide either `variants` or `import`, not both.");
85
+ }
86
+ if (!("variants" in _options && _options.variants) && !("import" in _options && _options.import)) {
87
+ throw new Error("defineFont: must provide either `variants` or `import`.");
88
+ }
89
+ this.variable = _options.variable ? normalizeVariable(_options.variable) : deriveVariable(_options);
90
+ this.fontFamily = buildFontFamilyValue(_options.name, _options.fallback);
91
+ this.className = `font-${dashCase(_options.name)}`;
92
+ }
93
+ get isDefineFont() {
94
+ return true;
95
+ }
96
+ /** Acts as a string equal to the resolved font-family value. */
97
+ toString() {
98
+ return this.fontFamily;
99
+ }
100
+ /** Inline-style helper: spread onto a React `style` prop. */
101
+ get style() {
102
+ return {
103
+ fontFamily: this.fontFamily,
104
+ [this.variable]: this.fontFamily
105
+ };
106
+ }
107
+ /** Build the CSS pieces written to `_fonts.css`. */
108
+ _toCss() {
109
+ const imports = [];
110
+ const blocks = [];
111
+ if ("import" in this._options && this._options.import) {
112
+ imports.push(`@import url("${this._options.import}");`);
113
+ } else if ("variants" in this._options && this._options.variants) {
114
+ const display = this._options.display ?? "swap";
115
+ for (const variant of this._options.variants) {
116
+ blocks.push(variantToFontFace(this._options.name, variant, display));
117
+ }
118
+ }
119
+ blocks.push(`:root { ${this.variable}: ${this.fontFamily}; }`, `.${this.className} { font-family: var(${this.variable}); }`);
120
+ return { imports, body: blocks.join(" ") };
121
+ }
122
+ }
123
+ const defineFont = (options) => {
124
+ return new FontFactory(options);
125
+ };
3
126
  class GlobalStylesFactory {
4
127
  constructor(_current) {
5
128
  this._current = _current;
@@ -11,6 +134,20 @@ class GlobalStylesFactory {
11
134
  const defineGlobalStyles = (styles) => {
12
135
  return new GlobalStylesFactory(styles);
13
136
  };
137
+ class ImportFactory {
138
+ constructor(_current) {
139
+ __publicField(this, "_path");
140
+ this._current = _current;
141
+ }
142
+ get isDefineImport() {
143
+ return true;
144
+ }
145
+ _setPath(path) {
146
+ this._path = path;
147
+ return this;
148
+ }
149
+ }
150
+ const defineImport = (...specs) => new ImportFactory(specs);
14
151
  const defineMediaQuery = (mediaFactory) => {
15
152
  return mediaFactory(media);
16
153
  };
@@ -26,11 +163,15 @@ const defineVariables = (variables) => {
26
163
  return new VariablesFactory(variables);
27
164
  };
28
165
  export {
166
+ FontFactory,
29
167
  GlobalStylesFactory,
168
+ ImportFactory,
30
169
  T as TemplateFactory,
31
170
  a as TemplatesFactory,
32
171
  VariablesFactory,
172
+ defineFont,
33
173
  defineGlobalStyles,
174
+ defineImport,
34
175
  defineMediaQuery,
35
176
  d as defineTemplates,
36
177
  defineVariables
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-B2Pb2obX.cjs");
3
+ const classNameGenerator = require("../class-name-generator-BEOEMEKX.cjs");
4
4
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
5
5
  class StyledGenerator extends classNameGenerator.StylesGenerator {
6
6
  constructor(tagName, _params) {
@@ -1,5 +1,5 @@
1
- import { S as StylesGenerator } from "../class-name-generator-YeSQe_Ik.js";
2
- import { C } from "../class-name-generator-YeSQe_Ik.js";
1
+ import { S as StylesGenerator } from "../class-name-generator-B0WkxoIg.js";
2
+ import { C } from "../class-name-generator-B0WkxoIg.js";
3
3
  import { d as dashCase } from "../dash-case-DblXvymC.js";
4
4
  class StyledGenerator extends StylesGenerator {
5
5
  constructor(tagName, _params) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-B2Pb2obX.cjs");
3
+ const classNameGenerator = require("../class-name-generator-BEOEMEKX.cjs");
4
4
  const classNameInstance = (params) => {
5
5
  const generator = new classNameGenerator.ClassNameGenerator(params);
6
6
  const createClass = (classNameStr) => {
@@ -1,4 +1,4 @@
1
- import { C as ClassNameGenerator } from "../class-name-generator-YeSQe_Ik.js";
1
+ import { C as ClassNameGenerator } from "../class-name-generator-B0WkxoIg.js";
2
2
  const classNameInstance = (params) => {
3
3
  const generator = new ClassNameGenerator(params);
4
4
  const createClass = (classNameStr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.30",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -87,6 +87,10 @@
87
87
  "import": "./css/merge.js",
88
88
  "require": "./css/merge.cjs"
89
89
  },
90
+ "./css/dynamic-styles": {
91
+ "import": "./css/dynamic-styles.js",
92
+ "require": "./css/dynamic-styles.cjs"
93
+ },
90
94
  "./helpers": {
91
95
  "import": "./helpers/index.js",
92
96
  "require": "./helpers/index.cjs"