@salty-css/core 0.1.0-refactor-add-additional-paths-to-config-cache.1 → 0.1.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/README.md +355 -374
- package/bin/main.cjs +57 -58
- package/bin/main.js +1 -2
- package/{class-name-generator-CMWY5KTJ.js → class-name-generator-CUEoPowv.js} +18 -4
- package/{class-name-generator-DB5aQwC_.cjs → class-name-generator-MtPkBfM_.cjs} +19 -5
- package/compiler/helpers.cjs +10 -2
- package/compiler/helpers.d.ts +3 -2
- package/compiler/helpers.js +11 -3
- package/compiler/resolve-import.d.ts +17 -0
- package/compiler/salty-compiler.cjs +144 -33
- package/compiler/salty-compiler.d.ts +2 -5
- package/compiler/salty-compiler.js +149 -38
- package/config/index.cjs +4 -0
- package/config/index.js +5 -1
- package/css/index.cjs +0 -4
- package/css/index.d.ts +0 -1
- package/css/index.js +0 -4
- package/css/keyframes.cjs +2 -2
- package/css/keyframes.js +2 -2
- package/factories/define-font.d.ts +28 -0
- package/factories/define-import.d.ts +14 -0
- package/factories/index.cjs +140 -0
- package/factories/index.d.ts +2 -0
- package/factories/index.js +140 -0
- package/generators/index.cjs +3 -3
- package/generators/index.js +3 -3
- package/helpers/color.d.ts +6 -0
- package/instances/classname-instance.cjs +1 -1
- package/instances/classname-instance.js +1 -1
- package/package.json +1 -13
- package/{parse-styles-C54MOrPg.cjs → parse-styles-BbI-2wdn.cjs} +196 -11
- package/{parse-styles-CLMTHo2H.js → parse-styles-BgVqQAni.js} +196 -11
- package/parsers/index.cjs +93 -5
- package/parsers/index.js +97 -9
- package/parsers/parse-templates.d.ts +10 -0
- package/parsers/parser-regexes.d.ts +1 -0
- package/parsers/resolve-template-variants.d.ts +21 -0
- package/runtime/index.cjs +16 -3
- package/runtime/index.d.ts +7 -0
- package/runtime/index.js +16 -3
- package/{to-hash-DAN2LcHK.js → to-hash-DSoCPs8D.js} +8 -0
- package/{to-hash-C05Y906F.cjs → to-hash-DT2ImSPA.cjs} +8 -0
- package/types/config-types.d.ts +33 -2
- package/types/font-types.d.ts +53 -0
- package/util/index.cjs +3 -4
- package/util/index.js +1 -2
- package/util/module-type.d.ts +1 -1
- package/cache/resolve-dynamic-config-cache.cjs +0 -64
- package/cache/resolve-dynamic-config-cache.d.ts +0 -20
- package/cache/resolve-dynamic-config-cache.js +0 -64
- package/compiler/copy-config-cache.cjs +0 -39
- package/compiler/copy-config-cache.d.ts +0 -17
- package/compiler/copy-config-cache.js +0 -39
- package/css/dynamic-styles.cjs +0 -28
- package/css/dynamic-styles.d.ts +0 -49
- package/css/dynamic-styles.js +0 -28
- package/dash-case-DIwKaYgE.cjs +0 -9
- package/dash-case-DblXvymC.js +0 -10
- package/logger-7xz0pyAz.cjs +0 -12
- package/logger-hHmCwThj.js +0 -13
package/css/index.cjs
CHANGED
|
@@ -4,13 +4,9 @@ const css_keyframes = require("./keyframes.cjs");
|
|
|
4
4
|
const css_media = require("./media.cjs");
|
|
5
5
|
const css_token = require("./token.cjs");
|
|
6
6
|
const css_merge = require("./merge.cjs");
|
|
7
|
-
const css_dynamicStyles = require("./dynamic-styles.cjs");
|
|
8
7
|
exports.keyframes = css_keyframes.keyframes;
|
|
9
8
|
exports.MediaQueryFactory = css_media.MediaQueryFactory;
|
|
10
9
|
exports.media = css_media.media;
|
|
11
10
|
exports.token = css_token.token;
|
|
12
11
|
exports.mergeFactories = css_merge.mergeFactories;
|
|
13
12
|
exports.mergeObjects = css_merge.mergeObjects;
|
|
14
|
-
exports.getDynamicStylesClassName = css_dynamicStyles.getDynamicStylesClassName;
|
|
15
|
-
exports.getDynamicStylesCss = css_dynamicStyles.getDynamicStylesCss;
|
|
16
|
-
exports.initializeDynamicStyles = css_dynamicStyles.initializeDynamicStyles;
|
package/css/index.d.ts
CHANGED
package/css/index.js
CHANGED
|
@@ -2,12 +2,8 @@ import { keyframes } from "./keyframes.js";
|
|
|
2
2
|
import { MediaQueryFactory, media } from "./media.js";
|
|
3
3
|
import { token } from "./token.js";
|
|
4
4
|
import { mergeFactories, mergeObjects } from "./merge.js";
|
|
5
|
-
import { getDynamicStylesClassName, getDynamicStylesCss, initializeDynamicStyles } from "./dynamic-styles.js";
|
|
6
5
|
export {
|
|
7
6
|
MediaQueryFactory,
|
|
8
|
-
getDynamicStylesClassName,
|
|
9
|
-
getDynamicStylesCss,
|
|
10
|
-
initializeDynamicStyles,
|
|
11
7
|
keyframes,
|
|
12
8
|
media,
|
|
13
9
|
mergeFactories,
|
package/css/keyframes.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-
|
|
4
|
-
const toHash = require("../to-hash-
|
|
3
|
+
const parseStyles = require("../parse-styles-BbI-2wdn.cjs");
|
|
4
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
5
5
|
const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
|
|
6
6
|
const modifyKeyframes = async (params = {}) => {
|
|
7
7
|
const animationName = _name || toHash.toHash(keyframes2);
|
package/css/keyframes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as parseAndJoinStyles } from "../parse-styles-
|
|
2
|
-
import { t as toHash } from "../to-hash-
|
|
1
|
+
import { p as parseAndJoinStyles } from "../parse-styles-BgVqQAni.js";
|
|
2
|
+
import { t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
3
3
|
const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
|
|
4
4
|
const modifyKeyframes = async (params = {}) => {
|
|
5
5
|
const animationName = _name || toHash(keyframes2);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DefineFontOptions } from '../types/font-types';
|
|
2
|
+
export interface FontCss {
|
|
3
|
+
/** `@import url(...)` lines that must sit at the top of the stylesheet, before any `@layer`. */
|
|
4
|
+
imports: string[];
|
|
5
|
+
/** Body that goes inside the `@layer fonts { ... }` wrapper. */
|
|
6
|
+
body: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class FontFactory {
|
|
9
|
+
readonly _options: DefineFontOptions;
|
|
10
|
+
readonly variable: string;
|
|
11
|
+
readonly fontFamily: string;
|
|
12
|
+
readonly className: string;
|
|
13
|
+
constructor(_options: DefineFontOptions);
|
|
14
|
+
get isDefineFont(): true;
|
|
15
|
+
/** Acts as a string equal to the resolved font-family value. */
|
|
16
|
+
toString(): string;
|
|
17
|
+
/** Inline-style helper: spread onto a React `style` prop. */
|
|
18
|
+
get style(): Record<string, string>;
|
|
19
|
+
/** Build the CSS pieces written to `_fonts.css`. */
|
|
20
|
+
_toCss(): FontCss;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Define a custom font that is registered globally as `@font-face` and exposed
|
|
24
|
+
* as a CSS variable. The returned object stringifies to its `font-family`
|
|
25
|
+
* value, and exposes `.variable`, `.fontFamily`, `.className`, and `.style`
|
|
26
|
+
* for use in styles and components.
|
|
27
|
+
*/
|
|
28
|
+
export declare const defineFont: (options: DefineFontOptions) => FontFactory;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ImportSpecOptions {
|
|
2
|
+
url: string;
|
|
3
|
+
media?: string;
|
|
4
|
+
supports?: string;
|
|
5
|
+
}
|
|
6
|
+
export type ImportSpec = string | ImportSpecOptions;
|
|
7
|
+
export declare class ImportFactory {
|
|
8
|
+
_current: ImportSpec[];
|
|
9
|
+
_path?: string;
|
|
10
|
+
constructor(_current: ImportSpec[]);
|
|
11
|
+
get isDefineImport(): boolean;
|
|
12
|
+
_setPath(path: string): this;
|
|
13
|
+
}
|
|
14
|
+
export declare const defineImport: (...specs: ImportSpec[]) => ImportFactory;
|
package/factories/index.cjs
CHANGED
|
@@ -1,7 +1,129 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
3
7
|
const css_media = require("../css/media.cjs");
|
|
4
8
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
9
|
+
const FONT_FORMAT_BY_EXTENSION = {
|
|
10
|
+
woff2: "woff2",
|
|
11
|
+
woff: "woff",
|
|
12
|
+
ttf: "truetype",
|
|
13
|
+
otf: "opentype",
|
|
14
|
+
eot: "embedded-opentype",
|
|
15
|
+
svg: "svg",
|
|
16
|
+
ttc: "collection"
|
|
17
|
+
};
|
|
18
|
+
const detectFontFormat = (url) => {
|
|
19
|
+
const cleaned = url.split("?")[0].split("#")[0];
|
|
20
|
+
const dot = cleaned.lastIndexOf(".");
|
|
21
|
+
if (dot === -1) return void 0;
|
|
22
|
+
const ext = cleaned.slice(dot + 1).toLowerCase();
|
|
23
|
+
return FONT_FORMAT_BY_EXTENSION[ext];
|
|
24
|
+
};
|
|
25
|
+
const toFontSrc = (entry) => {
|
|
26
|
+
if (typeof entry === "string") return { url: entry, format: detectFontFormat(entry) };
|
|
27
|
+
return entry;
|
|
28
|
+
};
|
|
29
|
+
const normalizeSources = (src) => {
|
|
30
|
+
if (Array.isArray(src)) return src.map(toFontSrc);
|
|
31
|
+
return [toFontSrc(src)];
|
|
32
|
+
};
|
|
33
|
+
const normalizeVariable = (variable) => {
|
|
34
|
+
const trimmed = variable.trim();
|
|
35
|
+
const stripped = trimmed.replace(/^--/, "");
|
|
36
|
+
if (!stripped) throw new Error(`defineFont: invalid \`variable\` value "${variable}".`);
|
|
37
|
+
return `--${toHash.dashCase(stripped)}`;
|
|
38
|
+
};
|
|
39
|
+
const deriveVariable = (options) => {
|
|
40
|
+
const hashSource = [options.name, options.fallback, "variants" in options ? options.variants : void 0, "import" in options ? options.import : void 0];
|
|
41
|
+
return `--font-${toHash.dashCase(options.name)}-${toHash.toHash(hashSource, 6)}`;
|
|
42
|
+
};
|
|
43
|
+
const quoteFamily = (name) => {
|
|
44
|
+
if (/^["'].*["']$/.test(name)) return name;
|
|
45
|
+
if (/\s/.test(name)) return `"${name}"`;
|
|
46
|
+
return name;
|
|
47
|
+
};
|
|
48
|
+
const buildFontFamilyValue = (name, fallback) => {
|
|
49
|
+
const head = quoteFamily(name);
|
|
50
|
+
if (!fallback || fallback.length === 0) return head;
|
|
51
|
+
return [head, fallback].join(", ");
|
|
52
|
+
};
|
|
53
|
+
const formatSrc = (src) => {
|
|
54
|
+
const parts = [`url("${src.url}")`];
|
|
55
|
+
if (src.format) parts.push(`format("${src.format}")`);
|
|
56
|
+
if (src.tech) parts.push(`tech(${src.tech})`);
|
|
57
|
+
return parts.join(" ");
|
|
58
|
+
};
|
|
59
|
+
const variantToFontFace = (name, variant, defaultDisplay) => {
|
|
60
|
+
const sources = normalizeSources(variant.src);
|
|
61
|
+
if (sources.length === 0) {
|
|
62
|
+
throw new Error(`defineFont(${name}): variant must declare at least one \`src\`.`);
|
|
63
|
+
}
|
|
64
|
+
const lines = [`font-family: ${quoteFamily(name)};`, `src: ${sources.map(formatSrc).join(", ")};`, `font-display: ${variant.display ?? defaultDisplay};`];
|
|
65
|
+
if (variant.weight !== void 0) lines.push(`font-weight: ${variant.weight};`);
|
|
66
|
+
if (variant.style !== void 0) lines.push(`font-style: ${variant.style};`);
|
|
67
|
+
if (variant.stretch !== void 0) lines.push(`font-stretch: ${variant.stretch};`);
|
|
68
|
+
if (variant.unicodeRange !== void 0) lines.push(`unicode-range: ${variant.unicodeRange};`);
|
|
69
|
+
if (variant.ascentOverride !== void 0) lines.push(`ascent-override: ${variant.ascentOverride};`);
|
|
70
|
+
if (variant.descentOverride !== void 0) lines.push(`descent-override: ${variant.descentOverride};`);
|
|
71
|
+
if (variant.lineGapOverride !== void 0) lines.push(`line-gap-override: ${variant.lineGapOverride};`);
|
|
72
|
+
if (variant.sizeAdjust !== void 0) lines.push(`size-adjust: ${variant.sizeAdjust};`);
|
|
73
|
+
return `@font-face { ${lines.join(" ")} }`;
|
|
74
|
+
};
|
|
75
|
+
class FontFactory {
|
|
76
|
+
constructor(_options) {
|
|
77
|
+
__publicField(this, "variable");
|
|
78
|
+
__publicField(this, "fontFamily");
|
|
79
|
+
__publicField(this, "className");
|
|
80
|
+
this._options = _options;
|
|
81
|
+
if (!_options || !_options.name) {
|
|
82
|
+
throw new Error("defineFont: `name` is required.");
|
|
83
|
+
}
|
|
84
|
+
if ("variants" in _options && "import" in _options && _options.import !== void 0 && _options.variants !== void 0) {
|
|
85
|
+
throw new Error("defineFont: provide either `variants` or `import`, not both.");
|
|
86
|
+
}
|
|
87
|
+
if (!("variants" in _options && _options.variants) && !("import" in _options && _options.import)) {
|
|
88
|
+
throw new Error("defineFont: must provide either `variants` or `import`.");
|
|
89
|
+
}
|
|
90
|
+
this.variable = _options.variable ? normalizeVariable(_options.variable) : deriveVariable(_options);
|
|
91
|
+
this.fontFamily = buildFontFamilyValue(_options.name, _options.fallback);
|
|
92
|
+
this.className = `font-${toHash.dashCase(_options.name)}`;
|
|
93
|
+
}
|
|
94
|
+
get isDefineFont() {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
/** Acts as a string equal to the resolved font-family value. */
|
|
98
|
+
toString() {
|
|
99
|
+
return this.fontFamily;
|
|
100
|
+
}
|
|
101
|
+
/** Inline-style helper: spread onto a React `style` prop. */
|
|
102
|
+
get style() {
|
|
103
|
+
return {
|
|
104
|
+
fontFamily: this.fontFamily,
|
|
105
|
+
[this.variable]: this.fontFamily
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Build the CSS pieces written to `_fonts.css`. */
|
|
109
|
+
_toCss() {
|
|
110
|
+
const imports = [];
|
|
111
|
+
const blocks = [];
|
|
112
|
+
if ("import" in this._options && this._options.import) {
|
|
113
|
+
imports.push(`@import url("${this._options.import}");`);
|
|
114
|
+
} else if ("variants" in this._options && this._options.variants) {
|
|
115
|
+
const display = this._options.display ?? "swap";
|
|
116
|
+
for (const variant of this._options.variants) {
|
|
117
|
+
blocks.push(variantToFontFace(this._options.name, variant, display));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
blocks.push(`:root { ${this.variable}: ${this.fontFamily}; }`, `.${this.className} { font-family: var(${this.variable}); }`);
|
|
121
|
+
return { imports, body: blocks.join(" ") };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const defineFont = (options) => {
|
|
125
|
+
return new FontFactory(options);
|
|
126
|
+
};
|
|
5
127
|
class GlobalStylesFactory {
|
|
6
128
|
constructor(_current) {
|
|
7
129
|
this._current = _current;
|
|
@@ -13,6 +135,20 @@ class GlobalStylesFactory {
|
|
|
13
135
|
const defineGlobalStyles = (styles) => {
|
|
14
136
|
return new GlobalStylesFactory(styles);
|
|
15
137
|
};
|
|
138
|
+
class ImportFactory {
|
|
139
|
+
constructor(_current) {
|
|
140
|
+
__publicField(this, "_path");
|
|
141
|
+
this._current = _current;
|
|
142
|
+
}
|
|
143
|
+
get isDefineImport() {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
_setPath(path) {
|
|
147
|
+
this._path = path;
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const defineImport = (...specs) => new ImportFactory(specs);
|
|
16
152
|
const defineMediaQuery = (mediaFactory) => {
|
|
17
153
|
return mediaFactory(css_media.media);
|
|
18
154
|
};
|
|
@@ -30,8 +166,12 @@ const defineVariables = (variables) => {
|
|
|
30
166
|
exports.TemplateFactory = defineTemplates.TemplateFactory;
|
|
31
167
|
exports.TemplatesFactory = defineTemplates.TemplatesFactory;
|
|
32
168
|
exports.defineTemplates = defineTemplates.defineTemplates;
|
|
169
|
+
exports.FontFactory = FontFactory;
|
|
33
170
|
exports.GlobalStylesFactory = GlobalStylesFactory;
|
|
171
|
+
exports.ImportFactory = ImportFactory;
|
|
34
172
|
exports.VariablesFactory = VariablesFactory;
|
|
173
|
+
exports.defineFont = defineFont;
|
|
35
174
|
exports.defineGlobalStyles = defineGlobalStyles;
|
|
175
|
+
exports.defineImport = defineImport;
|
|
36
176
|
exports.defineMediaQuery = defineMediaQuery;
|
|
37
177
|
exports.defineVariables = defineVariables;
|
package/factories/index.d.ts
CHANGED
package/factories/index.js
CHANGED
|
@@ -1,5 +1,127 @@
|
|
|
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, t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
1
5
|
import { media } from "../css/media.js";
|
|
2
6
|
import { T, a, d } from "../define-templates-CVhhgPnd.js";
|
|
7
|
+
const FONT_FORMAT_BY_EXTENSION = {
|
|
8
|
+
woff2: "woff2",
|
|
9
|
+
woff: "woff",
|
|
10
|
+
ttf: "truetype",
|
|
11
|
+
otf: "opentype",
|
|
12
|
+
eot: "embedded-opentype",
|
|
13
|
+
svg: "svg",
|
|
14
|
+
ttc: "collection"
|
|
15
|
+
};
|
|
16
|
+
const detectFontFormat = (url) => {
|
|
17
|
+
const cleaned = url.split("?")[0].split("#")[0];
|
|
18
|
+
const dot = cleaned.lastIndexOf(".");
|
|
19
|
+
if (dot === -1) return void 0;
|
|
20
|
+
const ext = cleaned.slice(dot + 1).toLowerCase();
|
|
21
|
+
return FONT_FORMAT_BY_EXTENSION[ext];
|
|
22
|
+
};
|
|
23
|
+
const toFontSrc = (entry) => {
|
|
24
|
+
if (typeof entry === "string") return { url: entry, format: detectFontFormat(entry) };
|
|
25
|
+
return entry;
|
|
26
|
+
};
|
|
27
|
+
const normalizeSources = (src) => {
|
|
28
|
+
if (Array.isArray(src)) return src.map(toFontSrc);
|
|
29
|
+
return [toFontSrc(src)];
|
|
30
|
+
};
|
|
31
|
+
const normalizeVariable = (variable) => {
|
|
32
|
+
const trimmed = variable.trim();
|
|
33
|
+
const stripped = trimmed.replace(/^--/, "");
|
|
34
|
+
if (!stripped) throw new Error(`defineFont: invalid \`variable\` value "${variable}".`);
|
|
35
|
+
return `--${dashCase(stripped)}`;
|
|
36
|
+
};
|
|
37
|
+
const deriveVariable = (options) => {
|
|
38
|
+
const hashSource = [options.name, options.fallback, "variants" in options ? options.variants : void 0, "import" in options ? options.import : void 0];
|
|
39
|
+
return `--font-${dashCase(options.name)}-${toHash(hashSource, 6)}`;
|
|
40
|
+
};
|
|
41
|
+
const quoteFamily = (name) => {
|
|
42
|
+
if (/^["'].*["']$/.test(name)) return name;
|
|
43
|
+
if (/\s/.test(name)) return `"${name}"`;
|
|
44
|
+
return name;
|
|
45
|
+
};
|
|
46
|
+
const buildFontFamilyValue = (name, fallback) => {
|
|
47
|
+
const head = quoteFamily(name);
|
|
48
|
+
if (!fallback || fallback.length === 0) return head;
|
|
49
|
+
return [head, fallback].join(", ");
|
|
50
|
+
};
|
|
51
|
+
const formatSrc = (src) => {
|
|
52
|
+
const parts = [`url("${src.url}")`];
|
|
53
|
+
if (src.format) parts.push(`format("${src.format}")`);
|
|
54
|
+
if (src.tech) parts.push(`tech(${src.tech})`);
|
|
55
|
+
return parts.join(" ");
|
|
56
|
+
};
|
|
57
|
+
const variantToFontFace = (name, variant, defaultDisplay) => {
|
|
58
|
+
const sources = normalizeSources(variant.src);
|
|
59
|
+
if (sources.length === 0) {
|
|
60
|
+
throw new Error(`defineFont(${name}): variant must declare at least one \`src\`.`);
|
|
61
|
+
}
|
|
62
|
+
const lines = [`font-family: ${quoteFamily(name)};`, `src: ${sources.map(formatSrc).join(", ")};`, `font-display: ${variant.display ?? defaultDisplay};`];
|
|
63
|
+
if (variant.weight !== void 0) lines.push(`font-weight: ${variant.weight};`);
|
|
64
|
+
if (variant.style !== void 0) lines.push(`font-style: ${variant.style};`);
|
|
65
|
+
if (variant.stretch !== void 0) lines.push(`font-stretch: ${variant.stretch};`);
|
|
66
|
+
if (variant.unicodeRange !== void 0) lines.push(`unicode-range: ${variant.unicodeRange};`);
|
|
67
|
+
if (variant.ascentOverride !== void 0) lines.push(`ascent-override: ${variant.ascentOverride};`);
|
|
68
|
+
if (variant.descentOverride !== void 0) lines.push(`descent-override: ${variant.descentOverride};`);
|
|
69
|
+
if (variant.lineGapOverride !== void 0) lines.push(`line-gap-override: ${variant.lineGapOverride};`);
|
|
70
|
+
if (variant.sizeAdjust !== void 0) lines.push(`size-adjust: ${variant.sizeAdjust};`);
|
|
71
|
+
return `@font-face { ${lines.join(" ")} }`;
|
|
72
|
+
};
|
|
73
|
+
class FontFactory {
|
|
74
|
+
constructor(_options) {
|
|
75
|
+
__publicField(this, "variable");
|
|
76
|
+
__publicField(this, "fontFamily");
|
|
77
|
+
__publicField(this, "className");
|
|
78
|
+
this._options = _options;
|
|
79
|
+
if (!_options || !_options.name) {
|
|
80
|
+
throw new Error("defineFont: `name` is required.");
|
|
81
|
+
}
|
|
82
|
+
if ("variants" in _options && "import" in _options && _options.import !== void 0 && _options.variants !== void 0) {
|
|
83
|
+
throw new Error("defineFont: provide either `variants` or `import`, not both.");
|
|
84
|
+
}
|
|
85
|
+
if (!("variants" in _options && _options.variants) && !("import" in _options && _options.import)) {
|
|
86
|
+
throw new Error("defineFont: must provide either `variants` or `import`.");
|
|
87
|
+
}
|
|
88
|
+
this.variable = _options.variable ? normalizeVariable(_options.variable) : deriveVariable(_options);
|
|
89
|
+
this.fontFamily = buildFontFamilyValue(_options.name, _options.fallback);
|
|
90
|
+
this.className = `font-${dashCase(_options.name)}`;
|
|
91
|
+
}
|
|
92
|
+
get isDefineFont() {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/** Acts as a string equal to the resolved font-family value. */
|
|
96
|
+
toString() {
|
|
97
|
+
return this.fontFamily;
|
|
98
|
+
}
|
|
99
|
+
/** Inline-style helper: spread onto a React `style` prop. */
|
|
100
|
+
get style() {
|
|
101
|
+
return {
|
|
102
|
+
fontFamily: this.fontFamily,
|
|
103
|
+
[this.variable]: this.fontFamily
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Build the CSS pieces written to `_fonts.css`. */
|
|
107
|
+
_toCss() {
|
|
108
|
+
const imports = [];
|
|
109
|
+
const blocks = [];
|
|
110
|
+
if ("import" in this._options && this._options.import) {
|
|
111
|
+
imports.push(`@import url("${this._options.import}");`);
|
|
112
|
+
} else if ("variants" in this._options && this._options.variants) {
|
|
113
|
+
const display = this._options.display ?? "swap";
|
|
114
|
+
for (const variant of this._options.variants) {
|
|
115
|
+
blocks.push(variantToFontFace(this._options.name, variant, display));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
blocks.push(`:root { ${this.variable}: ${this.fontFamily}; }`, `.${this.className} { font-family: var(${this.variable}); }`);
|
|
119
|
+
return { imports, body: blocks.join(" ") };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const defineFont = (options) => {
|
|
123
|
+
return new FontFactory(options);
|
|
124
|
+
};
|
|
3
125
|
class GlobalStylesFactory {
|
|
4
126
|
constructor(_current) {
|
|
5
127
|
this._current = _current;
|
|
@@ -11,6 +133,20 @@ class GlobalStylesFactory {
|
|
|
11
133
|
const defineGlobalStyles = (styles) => {
|
|
12
134
|
return new GlobalStylesFactory(styles);
|
|
13
135
|
};
|
|
136
|
+
class ImportFactory {
|
|
137
|
+
constructor(_current) {
|
|
138
|
+
__publicField(this, "_path");
|
|
139
|
+
this._current = _current;
|
|
140
|
+
}
|
|
141
|
+
get isDefineImport() {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
_setPath(path) {
|
|
145
|
+
this._path = path;
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const defineImport = (...specs) => new ImportFactory(specs);
|
|
14
150
|
const defineMediaQuery = (mediaFactory) => {
|
|
15
151
|
return mediaFactory(media);
|
|
16
152
|
};
|
|
@@ -26,11 +162,15 @@ const defineVariables = (variables) => {
|
|
|
26
162
|
return new VariablesFactory(variables);
|
|
27
163
|
};
|
|
28
164
|
export {
|
|
165
|
+
FontFactory,
|
|
29
166
|
GlobalStylesFactory,
|
|
167
|
+
ImportFactory,
|
|
30
168
|
T as TemplateFactory,
|
|
31
169
|
a as TemplatesFactory,
|
|
32
170
|
VariablesFactory,
|
|
171
|
+
defineFont,
|
|
33
172
|
defineGlobalStyles,
|
|
173
|
+
defineImport,
|
|
34
174
|
defineMediaQuery,
|
|
35
175
|
d as defineTemplates,
|
|
36
176
|
defineVariables
|
package/generators/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const classNameGenerator = require("../class-name-generator-
|
|
4
|
-
const
|
|
3
|
+
const classNameGenerator = require("../class-name-generator-MtPkBfM_.cjs");
|
|
4
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
5
5
|
class StyledGenerator extends classNameGenerator.StylesGenerator {
|
|
6
6
|
constructor(tagName, _params) {
|
|
7
7
|
super(_params);
|
|
@@ -35,7 +35,7 @@ class StyledGenerator extends classNameGenerator.StylesGenerator {
|
|
|
35
35
|
if (matches) {
|
|
36
36
|
matches.forEach((match) => {
|
|
37
37
|
const value = match.replace(/\{(?:-)?props\.([^}]+)\}/gi, "$1");
|
|
38
|
-
const dashed =
|
|
38
|
+
const dashed = toHash.dashCase(value);
|
|
39
39
|
if (value) propValueKeys.add(dashed);
|
|
40
40
|
});
|
|
41
41
|
}
|
package/generators/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as StylesGenerator } from "../class-name-generator-
|
|
2
|
-
import { C } from "../class-name-generator-
|
|
3
|
-
import { d as dashCase } from "../
|
|
1
|
+
import { S as StylesGenerator } from "../class-name-generator-CUEoPowv.js";
|
|
2
|
+
import { C } from "../class-name-generator-CUEoPowv.js";
|
|
3
|
+
import { d as dashCase } from "../to-hash-DSoCPs8D.js";
|
|
4
4
|
class StyledGenerator extends StylesGenerator {
|
|
5
5
|
constructor(tagName, _params) {
|
|
6
6
|
super(_params);
|
package/helpers/color.d.ts
CHANGED
|
@@ -14,5 +14,11 @@ declare class Color {
|
|
|
14
14
|
_handleColorMethod(method: keyof ColorInstance): any;
|
|
15
15
|
toString(): string;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Token references must point to a **static** variable that resolves to a real
|
|
19
|
+
* CSS color value (e.g. a hex code or named color). Conditional tokens
|
|
20
|
+
* (`{theme.*}`) and responsive tokens are not in `staticVariables` and will
|
|
21
|
+
* resolve to `transparent`. `color()` cannot be used inside `defineVariables`.
|
|
22
|
+
*/
|
|
17
23
|
export declare const color: (value: BaseColor) => Color & ColorInstance;
|
|
18
24
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const classNameGenerator = require("../class-name-generator-
|
|
3
|
+
const classNameGenerator = require("../class-name-generator-MtPkBfM_.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-
|
|
1
|
+
import { C as ClassNameGenerator } from "../class-name-generator-CUEoPowv.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
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -63,10 +63,6 @@
|
|
|
63
63
|
"import": "./compiler/helpers.js",
|
|
64
64
|
"require": "./compiler/helpers.cjs"
|
|
65
65
|
},
|
|
66
|
-
"./compiler/copy-config-cache": {
|
|
67
|
-
"import": "./compiler/copy-config-cache.js",
|
|
68
|
-
"require": "./compiler/copy-config-cache.cjs"
|
|
69
|
-
},
|
|
70
66
|
"./factories": {
|
|
71
67
|
"import": "./factories/index.js",
|
|
72
68
|
"require": "./factories/index.cjs"
|
|
@@ -91,10 +87,6 @@
|
|
|
91
87
|
"import": "./css/merge.js",
|
|
92
88
|
"require": "./css/merge.cjs"
|
|
93
89
|
},
|
|
94
|
-
"./css/dynamic-styles": {
|
|
95
|
-
"import": "./css/dynamic-styles.js",
|
|
96
|
-
"require": "./css/dynamic-styles.cjs"
|
|
97
|
-
},
|
|
98
90
|
"./helpers": {
|
|
99
91
|
"import": "./helpers/index.js",
|
|
100
92
|
"require": "./helpers/index.cjs"
|
|
@@ -123,10 +115,6 @@
|
|
|
123
115
|
"import": "./server/index.js",
|
|
124
116
|
"require": "./server/index.cjs"
|
|
125
117
|
},
|
|
126
|
-
"./cache/resolve-dynamic-config-cache": {
|
|
127
|
-
"import": "./cache/resolve-dynamic-config-cache.js",
|
|
128
|
-
"require": "./cache/resolve-dynamic-config-cache.cjs"
|
|
129
|
-
},
|
|
130
118
|
"./instances/classname-instance": {
|
|
131
119
|
"import": "./instances/classname-instance.js",
|
|
132
120
|
"require": "./instances/classname-instance.cjs"
|