@salty-css/core 0.1.0-alpha.33 → 0.1.0-alpha.35
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 +2 -0
- package/{class-name-generator-B0WkxoIg.js → class-name-generator-CUEoPowv.js} +2 -3
- package/{class-name-generator-BEOEMEKX.cjs → class-name-generator-MtPkBfM_.cjs} +6 -7
- package/compiler/helpers.cjs +5 -1
- package/compiler/helpers.d.ts +1 -0
- package/compiler/helpers.js +6 -2
- package/compiler/salty-compiler.cjs +7 -11
- package/compiler/salty-compiler.js +4 -8
- package/css/index.cjs +0 -3
- package/css/index.d.ts +0 -1
- package/css/index.js +0 -3
- package/css/keyframes.cjs +2 -2
- package/css/keyframes.js +2 -2
- package/factories/index.cjs +4 -5
- package/factories/index.js +1 -2
- package/generators/index.cjs +3 -3
- package/generators/index.js +3 -3
- package/instances/classname-instance.cjs +1 -1
- package/instances/classname-instance.js +1 -1
- package/package.json +1 -9
- package/{parse-styles-lOMGe_c5.cjs → parse-styles-BbI-2wdn.cjs} +7 -5
- package/{parse-styles-BBJ3PWyV.js → parse-styles-BgVqQAni.js} +4 -2
- package/parsers/index.cjs +5 -6
- package/parsers/index.js +3 -4
- package/parsers/parser-regexes.d.ts +1 -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/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 -24
- package/cache/resolve-dynamic-config-cache.d.ts +0 -1
- package/cache/resolve-dynamic-config-cache.js +0 -24
- package/css/dynamic-styles.cjs +0 -15
- package/css/dynamic-styles.d.ts +0 -10
- package/css/dynamic-styles.js +0 -15
- package/dash-case-DIwKaYgE.cjs +0 -9
- package/dash-case-DblXvymC.js +0 -10
package/README.md
CHANGED
|
@@ -617,6 +617,8 @@ And note: steps 2 & 3 are just to show how get new components up and running, st
|
|
|
617
617
|
- **Next.js 15:** In `next.config.ts` add import for salty plugin `import { withSaltyCss } from '@salty-css/next';` and then add `withSaltyCss` to wrap your nextConfig export like so `export default withSaltyCss(nextConfig);`
|
|
618
618
|
- **Next.js 14 and older:** In `next.config.js` add import for salty plugin `const { withSaltyCss } = require('@salty-css/next');` and then add `withSaltyCss` to wrap your nextConfig export like so `module.exports = withSaltyCss(nextConfig);`
|
|
619
619
|
|
|
620
|
+
Both Webpack and Turbopack are supported. `withSaltyCss` auto-detects which bundler Next.js is using (`next dev --turbopack` sets `process.env.TURBOPACK=1`), so no extra config is required. To force a specific bundler, pass `{ bundler: 'webpack' | 'turbopack' }` as the second argument.
|
|
621
|
+
|
|
620
622
|
4. Make sure that `salty.config.ts` and `next.config.ts` are in the same folder!
|
|
621
623
|
5. Build `saltygen` directory by running your app once or with cli `npx salty-css build [directory]`
|
|
622
624
|
6. Import global styles from `saltygen/index.css` to some global css file with `@import 'insert_path_to_index_css';`.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { p as parseAndJoinStyles, b as parseTemplateCallSite } from "./parse-styles-
|
|
5
|
-
import { d as dashCase } from "./
|
|
6
|
-
import { t as toHash } from "./to-hash-DAN2LcHK.js";
|
|
4
|
+
import { p as parseAndJoinStyles, b as parseTemplateCallSite } from "./parse-styles-BgVqQAni.js";
|
|
5
|
+
import { t as toHash, d as dashCase } from "./to-hash-DSoCPs8D.js";
|
|
7
6
|
class StylesGenerator {
|
|
8
7
|
constructor(params) {
|
|
9
8
|
__publicField(this, "buildContext", {});
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
const parseStyles = require("./parse-styles-
|
|
6
|
-
const
|
|
7
|
-
const toHash = require("./to-hash-C05Y906F.cjs");
|
|
5
|
+
const parseStyles = require("./parse-styles-BbI-2wdn.cjs");
|
|
6
|
+
const toHash = require("./to-hash-DT2ImSPA.cjs");
|
|
8
7
|
class StylesGenerator {
|
|
9
8
|
constructor(params) {
|
|
10
9
|
__publicField(this, "buildContext", {});
|
|
@@ -35,7 +34,7 @@ class StylesGenerator {
|
|
|
35
34
|
get cssFileName() {
|
|
36
35
|
const { callerName } = this.buildContext;
|
|
37
36
|
if (callerName) {
|
|
38
|
-
const dasherized =
|
|
37
|
+
const dasherized = toHash.dashCase(callerName);
|
|
39
38
|
return `cl_${dasherized}-${this.hash}.css`;
|
|
40
39
|
}
|
|
41
40
|
return `${this.hash}.css`;
|
|
@@ -58,12 +57,12 @@ class StylesGenerator {
|
|
|
58
57
|
const cumulative = [];
|
|
59
58
|
for (const part of path) {
|
|
60
59
|
cumulative.push(part);
|
|
61
|
-
const baseClassName =
|
|
60
|
+
const baseClassName = toHash.dashCase(`${key}-${cumulative.join(".")}`);
|
|
62
61
|
acc.push("t_" + toHash.toHash(baseClassName, 4));
|
|
63
62
|
for (const [axis, axisValue] of Object.entries(variants)) {
|
|
64
63
|
if (axisValue === false || axisValue === void 0) continue;
|
|
65
|
-
const valueSuffix = axisValue === true ? "" : `-${
|
|
66
|
-
const variantClassName = `${baseClassName}-${
|
|
64
|
+
const valueSuffix = axisValue === true ? "" : `-${toHash.dashCase(String(axisValue))}`;
|
|
65
|
+
const variantClassName = `${baseClassName}-${toHash.dashCase(axis)}${valueSuffix}`;
|
|
67
66
|
acc.push("tv_" + toHash.toHash(variantClassName, 4));
|
|
68
67
|
}
|
|
69
68
|
}
|
package/compiler/helpers.cjs
CHANGED
|
@@ -16,11 +16,15 @@ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
|
16
16
|
return value;
|
|
17
17
|
};
|
|
18
18
|
const saltyFileExtensions = ["salty", "css", "styles", "styled"];
|
|
19
|
+
const tsFileExtensions = ["ts", "tsx", "js", "jsx", "mjs", "cjs"];
|
|
19
20
|
const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
20
|
-
const saltyFileRegExp = (additional = []) =>
|
|
21
|
+
const saltyFileRegExp = (additional = []) => {
|
|
22
|
+
return new RegExp(`\\.(${[...saltyFileExtensions, ...additional].map(escapeRegExp).join("|")})\\.(${tsFileExtensions.map(escapeRegExp).join("|")})$`);
|
|
23
|
+
};
|
|
21
24
|
const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
|
|
22
25
|
exports.getCorePackageRoot = getCorePackageRoot;
|
|
23
26
|
exports.isSaltyFile = isSaltyFile;
|
|
24
27
|
exports.resolveExportValue = resolveExportValue;
|
|
25
28
|
exports.saltyFileExtensions = saltyFileExtensions;
|
|
26
29
|
exports.saltyFileRegExp = saltyFileRegExp;
|
|
30
|
+
exports.tsFileExtensions = tsFileExtensions;
|
package/compiler/helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const getCorePackageRoot: () => string;
|
|
2
2
|
export declare const resolveExportValue: <T>(value: unknown, maxLevel?: number, _level?: number) => Promise<T>;
|
|
3
3
|
export declare const saltyFileExtensions: string[];
|
|
4
|
+
export declare const tsFileExtensions: string[];
|
|
4
5
|
export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
|
|
5
6
|
export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
|
package/compiler/helpers.js
CHANGED
|
@@ -13,13 +13,17 @@ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
|
13
13
|
return value;
|
|
14
14
|
};
|
|
15
15
|
const saltyFileExtensions = ["salty", "css", "styles", "styled"];
|
|
16
|
+
const tsFileExtensions = ["ts", "tsx", "js", "jsx", "mjs", "cjs"];
|
|
16
17
|
const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17
|
-
const saltyFileRegExp = (additional = []) =>
|
|
18
|
+
const saltyFileRegExp = (additional = []) => {
|
|
19
|
+
return new RegExp(`\\.(${[...saltyFileExtensions, ...additional].map(escapeRegExp).join("|")})\\.(${tsFileExtensions.map(escapeRegExp).join("|")})$`);
|
|
20
|
+
};
|
|
18
21
|
const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
|
|
19
22
|
export {
|
|
20
23
|
getCorePackageRoot,
|
|
21
24
|
isSaltyFile,
|
|
22
25
|
resolveExportValue,
|
|
23
26
|
saltyFileExtensions,
|
|
24
|
-
saltyFileRegExp
|
|
27
|
+
saltyFileRegExp,
|
|
28
|
+
tsFileExtensions
|
|
25
29
|
};
|
|
@@ -10,14 +10,13 @@ const promises = require("fs/promises");
|
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const child_process = require("child_process");
|
|
12
12
|
const compiler_helpers = require("./helpers.cjs");
|
|
13
|
-
const
|
|
14
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
13
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
15
14
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
16
15
|
const module$1 = require("module");
|
|
17
|
-
const parseStyles = require("../parse-styles-
|
|
16
|
+
const parseStyles = require("../parse-styles-BbI-2wdn.cjs");
|
|
18
17
|
const css_merge = require("../css/merge.cjs");
|
|
19
|
-
const parsers_index = require("../parsers/index.cjs");
|
|
20
18
|
const compiler_getFiles = require("./get-files.cjs");
|
|
19
|
+
const parsers_index = require("../parsers/index.cjs");
|
|
21
20
|
const console = require("console");
|
|
22
21
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
23
22
|
function _interopNamespaceDefault(e) {
|
|
@@ -392,7 +391,7 @@ ${currentFile}`;
|
|
|
392
391
|
const cssContent2 = localCssFile.map((file) => `@import url('./${file}');`).join("\n");
|
|
393
392
|
const hashName = toHash.toHash(src, 6);
|
|
394
393
|
const parsedPath = path.parse(src);
|
|
395
|
-
const dasherized =
|
|
394
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
396
395
|
const cssFile2 = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
397
396
|
fs.writeFileSync(cssFile2, cssContent2 || `/* Empty file */`);
|
|
398
397
|
});
|
|
@@ -490,10 +489,10 @@ ${css}
|
|
|
490
489
|
if (typeof value2 === "function") return await parseVariable(await value2());
|
|
491
490
|
if (typeof value2 === "object") return await parseVariables(value2, [...path2, key]);
|
|
492
491
|
const dottedKey = dotCase(key);
|
|
493
|
-
const dashedKey =
|
|
492
|
+
const dashedKey = toHash.dashCase(key);
|
|
494
493
|
const tsName = [...path2, dottedKey].join(".");
|
|
495
494
|
variableTokens.add(`"${tsName}"`);
|
|
496
|
-
const cssName = [...path2.map(
|
|
495
|
+
const cssName = [...path2.map(toHash.dashCase), dashedKey].join("-");
|
|
497
496
|
const result = parseStyles.parseVariableTokens(value2);
|
|
498
497
|
if (!result) return `--${cssName}: ${value2};`;
|
|
499
498
|
return `--${cssName}: ${result.transformed};`;
|
|
@@ -647,9 +646,6 @@ ${css}
|
|
|
647
646
|
fs.writeFileSync(tsTokensPath, tsTokensTypes);
|
|
648
647
|
const configCachePath = path.join(destDir, "cache/config-cache.json");
|
|
649
648
|
fs.writeFileSync(configCachePath, JSON.stringify(configCacheContent, null, 2));
|
|
650
|
-
const corePackageRoot = compiler_helpers.getCorePackageRoot();
|
|
651
|
-
const configCacheSecondaryPath = path.join(corePackageRoot, "cache/config-cache.json");
|
|
652
|
-
fs.writeFileSync(configCacheSecondaryPath, JSON.stringify(configCacheContent, null, 2));
|
|
653
649
|
});
|
|
654
650
|
__publicField(this, "compileSaltyFile", async (sourceFilePath, outputDirectory) => {
|
|
655
651
|
const hashedName = toHash.toHash(sourceFilePath);
|
|
@@ -778,7 +774,7 @@ ${newContent}
|
|
|
778
774
|
const cssContent = cssFiles.flat().map((file2) => `@import url('./${file2}');`).join("\n");
|
|
779
775
|
const hashName = toHash.toHash(file, 6);
|
|
780
776
|
const parsedPath = path.parse(file);
|
|
781
|
-
const dasherized =
|
|
777
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
782
778
|
const cssFile = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
783
779
|
fs.writeFileSync(cssFile, cssContent || `/* Empty file */`);
|
|
784
780
|
}
|
|
@@ -7,15 +7,14 @@ import { createLogger, transports, format } from "winston";
|
|
|
7
7
|
import { readFile } from "fs/promises";
|
|
8
8
|
import { existsSync, mkdirSync, copyFileSync, readFileSync, statSync, readdirSync, writeFileSync } from "fs";
|
|
9
9
|
import { execSync } from "child_process";
|
|
10
|
-
import { isSaltyFile, resolveExportValue,
|
|
11
|
-
import { d as dashCase } from "../
|
|
12
|
-
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
10
|
+
import { isSaltyFile, resolveExportValue, saltyFileExtensions } from "./helpers.js";
|
|
11
|
+
import { t as toHash, d as dashCase } from "../to-hash-DSoCPs8D.js";
|
|
13
12
|
import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
|
|
14
13
|
import { createRequire } from "module";
|
|
15
|
-
import { p as parseAndJoinStyles, c as parseVariableTokens } from "../parse-styles-
|
|
14
|
+
import { p as parseAndJoinStyles, c as parseVariableTokens } from "../parse-styles-BgVqQAni.js";
|
|
16
15
|
import { mergeObjects, mergeFactories } from "../css/merge.js";
|
|
17
|
-
import { parseTemplates, getTemplateTypes, getTemplateVariantMaps } from "../parsers/index.js";
|
|
18
16
|
import { getPackageJson } from "./get-files.js";
|
|
17
|
+
import { parseTemplates, getTemplateTypes, getTemplateVariantMaps } from "../parsers/index.js";
|
|
19
18
|
import console from "console";
|
|
20
19
|
const logger = createLogger({
|
|
21
20
|
level: "debug",
|
|
@@ -627,9 +626,6 @@ ${css}
|
|
|
627
626
|
writeFileSync(tsTokensPath, tsTokensTypes);
|
|
628
627
|
const configCachePath = join(destDir, "cache/config-cache.json");
|
|
629
628
|
writeFileSync(configCachePath, JSON.stringify(configCacheContent, null, 2));
|
|
630
|
-
const corePackageRoot = getCorePackageRoot();
|
|
631
|
-
const configCacheSecondaryPath = join(corePackageRoot, "cache/config-cache.json");
|
|
632
|
-
writeFileSync(configCacheSecondaryPath, JSON.stringify(configCacheContent, null, 2));
|
|
633
629
|
});
|
|
634
630
|
__publicField(this, "compileSaltyFile", async (sourceFilePath, outputDirectory) => {
|
|
635
631
|
const hashedName = toHash(sourceFilePath);
|
package/css/index.cjs
CHANGED
|
@@ -4,12 +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;
|
package/css/index.d.ts
CHANGED
package/css/index.js
CHANGED
|
@@ -2,11 +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 } from "./dynamic-styles.js";
|
|
6
5
|
export {
|
|
7
6
|
MediaQueryFactory,
|
|
8
|
-
getDynamicStylesClassName,
|
|
9
|
-
getDynamicStylesCss,
|
|
10
7
|
keyframes,
|
|
11
8
|
media,
|
|
12
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);
|
package/factories/index.cjs
CHANGED
|
@@ -3,8 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
const
|
|
7
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
6
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
8
7
|
const css_media = require("../css/media.cjs");
|
|
9
8
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
10
9
|
const FONT_FORMAT_BY_EXTENSION = {
|
|
@@ -35,11 +34,11 @@ const normalizeVariable = (variable) => {
|
|
|
35
34
|
const trimmed = variable.trim();
|
|
36
35
|
const stripped = trimmed.replace(/^--/, "");
|
|
37
36
|
if (!stripped) throw new Error(`defineFont: invalid \`variable\` value "${variable}".`);
|
|
38
|
-
return `--${
|
|
37
|
+
return `--${toHash.dashCase(stripped)}`;
|
|
39
38
|
};
|
|
40
39
|
const deriveVariable = (options) => {
|
|
41
40
|
const hashSource = [options.name, options.fallback, "variants" in options ? options.variants : void 0, "import" in options ? options.import : void 0];
|
|
42
|
-
return `--font-${
|
|
41
|
+
return `--font-${toHash.dashCase(options.name)}-${toHash.toHash(hashSource, 6)}`;
|
|
43
42
|
};
|
|
44
43
|
const quoteFamily = (name) => {
|
|
45
44
|
if (/^["'].*["']$/.test(name)) return name;
|
|
@@ -90,7 +89,7 @@ class FontFactory {
|
|
|
90
89
|
}
|
|
91
90
|
this.variable = _options.variable ? normalizeVariable(_options.variable) : deriveVariable(_options);
|
|
92
91
|
this.fontFamily = buildFontFamilyValue(_options.name, _options.fallback);
|
|
93
|
-
this.className = `font-${
|
|
92
|
+
this.className = `font-${toHash.dashCase(_options.name)}`;
|
|
94
93
|
}
|
|
95
94
|
get isDefineFont() {
|
|
96
95
|
return true;
|
package/factories/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { d as dashCase } from "../
|
|
5
|
-
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
4
|
+
import { d as dashCase, t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
6
5
|
import { media } from "../css/media.js";
|
|
7
6
|
import { T, a, d } from "../define-templates-CVhhgPnd.js";
|
|
8
7
|
const FONT_FORMAT_BY_EXTENSION = {
|
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);
|
|
@@ -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-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.35",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -87,10 +87,6 @@
|
|
|
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
|
-
},
|
|
94
90
|
"./helpers": {
|
|
95
91
|
"import": "./helpers/index.js",
|
|
96
92
|
"require": "./helpers/index.cjs"
|
|
@@ -119,10 +115,6 @@
|
|
|
119
115
|
"import": "./server/index.js",
|
|
120
116
|
"require": "./server/index.cjs"
|
|
121
117
|
},
|
|
122
|
-
"./cache/resolve-dynamic-config-cache": {
|
|
123
|
-
"import": "./cache/resolve-dynamic-config-cache.js",
|
|
124
|
-
"require": "./cache/resolve-dynamic-config-cache.cjs"
|
|
125
|
-
},
|
|
126
118
|
"./instances/classname-instance": {
|
|
127
119
|
"import": "./instances/classname-instance.js",
|
|
128
120
|
"require": "./instances/classname-instance.cjs"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const toHash = require("./to-hash-DT2ImSPA.cjs");
|
|
3
3
|
const viewportClamp = require("./viewport-clamp-CEmzmcSj.cjs");
|
|
4
4
|
const parseValueModifiers = (modifiers) => (value) => {
|
|
5
5
|
if (typeof value !== "string") return void 0;
|
|
@@ -21,7 +21,7 @@ const parseValueTokens = (tokenNames) => (value) => {
|
|
|
21
21
|
const hasToken = /\{[^{}]+\}/g.test(value);
|
|
22
22
|
if (!hasToken) return void 0;
|
|
23
23
|
const transformed = value.replace(/\{([^{}]+)\}/g, (...args) => {
|
|
24
|
-
const variable =
|
|
24
|
+
const variable = toHash.dashCase(args[1].trim().replaceAll(".", "-"));
|
|
25
25
|
if (tokenNames && !tokenNames.includes(variable)) console.warn(`Token ${variable} might not exist`);
|
|
26
26
|
if (variable.startsWith("-")) return `-${variable}`;
|
|
27
27
|
return `var(--${variable})`;
|
|
@@ -84,8 +84,8 @@ const isVendorPrefixed = (key) => {
|
|
|
84
84
|
};
|
|
85
85
|
const propertyNameCheck = (key) => {
|
|
86
86
|
if (key.startsWith("-")) return key;
|
|
87
|
-
if (isVendorPrefixed(key)) return `-${
|
|
88
|
-
return
|
|
87
|
+
if (isVendorPrefixed(key)) return `-${toHash.dashCase(key)}`;
|
|
88
|
+
return toHash.dashCase(key);
|
|
89
89
|
};
|
|
90
90
|
const reportParserIssue = (strict, message) => {
|
|
91
91
|
if (strict === true) throw new Error(`[salty-css] ${message}`);
|
|
@@ -94,6 +94,7 @@ const reportParserIssue = (strict, message) => {
|
|
|
94
94
|
const pseudoTypoRegex = /^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/;
|
|
95
95
|
const templateLiteralLeftoverRegex = /\$\{[^}]+\}/;
|
|
96
96
|
const bareAtRuleRegex = /^@(media|supports|container|layer)\s*$/;
|
|
97
|
+
const keyframesAtRuleRegex = /^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/;
|
|
97
98
|
const isRichTemplateNode = (node) => {
|
|
98
99
|
if (!node || typeof node !== "object") return false;
|
|
99
100
|
if (Array.isArray(node)) return false;
|
|
@@ -375,8 +376,9 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
|
|
|
375
376
|
}
|
|
376
377
|
if (_key.startsWith("@")) {
|
|
377
378
|
if (bareAtRuleRegex.test(_key)) reportParserIssue(strict, `At-rule "${_key}" is missing its condition (e.g. "@media (min-width: 600px)").`);
|
|
379
|
+
const innerScope = keyframesAtRuleRegex.test(_key) ? "" : currentScope;
|
|
378
380
|
const mediaQuery = ((_b = config == null ? void 0 : config.mediaQueries) == null ? void 0 : _b[_key]) || _key;
|
|
379
|
-
const results2 = await parseAndJoinStyles(value,
|
|
381
|
+
const results2 = await parseAndJoinStyles(value, innerScope, config);
|
|
380
382
|
const query = `${mediaQuery} { ${results2} }`;
|
|
381
383
|
cssStyles.add(query);
|
|
382
384
|
return void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as dashCase } from "./
|
|
1
|
+
import { d as dashCase } from "./to-hash-DSoCPs8D.js";
|
|
2
2
|
import { d as defineViewportClamp } from "./viewport-clamp-K553uXu3.js";
|
|
3
3
|
const parseValueModifiers = (modifiers) => (value) => {
|
|
4
4
|
if (typeof value !== "string") return void 0;
|
|
@@ -93,6 +93,7 @@ const reportParserIssue = (strict, message) => {
|
|
|
93
93
|
const pseudoTypoRegex = /^&(hover|focus(-(visible|within))?|active|visited|checked|disabled|enabled|empty|target|first-child|last-child|first-of-type|last-of-type|placeholder|placeholder-shown|root)\b/;
|
|
94
94
|
const templateLiteralLeftoverRegex = /\$\{[^}]+\}/;
|
|
95
95
|
const bareAtRuleRegex = /^@(media|supports|container|layer)\s*$/;
|
|
96
|
+
const keyframesAtRuleRegex = /^@(?:-(?:webkit|moz|o|ms)-)?keyframes\b/;
|
|
96
97
|
const isRichTemplateNode = (node) => {
|
|
97
98
|
if (!node || typeof node !== "object") return false;
|
|
98
99
|
if (Array.isArray(node)) return false;
|
|
@@ -374,8 +375,9 @@ const parseStyles = async (styles, currentScope = "", config, omitTemplates = fa
|
|
|
374
375
|
}
|
|
375
376
|
if (_key.startsWith("@")) {
|
|
376
377
|
if (bareAtRuleRegex.test(_key)) reportParserIssue(strict, `At-rule "${_key}" is missing its condition (e.g. "@media (min-width: 600px)").`);
|
|
378
|
+
const innerScope = keyframesAtRuleRegex.test(_key) ? "" : currentScope;
|
|
377
379
|
const mediaQuery = ((_b = config == null ? void 0 : config.mediaQueries) == null ? void 0 : _b[_key]) || _key;
|
|
378
|
-
const results2 = await parseAndJoinStyles(value,
|
|
380
|
+
const results2 = await parseAndJoinStyles(value, innerScope, config);
|
|
379
381
|
const query = `${mediaQuery} { ${results2} }`;
|
|
380
382
|
cssStyles.add(query);
|
|
381
383
|
return void 0;
|
package/parsers/index.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-
|
|
4
|
-
const
|
|
5
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
3
|
+
const parseStyles = require("../parse-styles-BbI-2wdn.cjs");
|
|
4
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
6
5
|
const RICH_META_KEYS = /* @__PURE__ */ new Set(["base", "variants", "defaultVariants", "compoundVariants", "anyOfVariants"]);
|
|
7
6
|
const isChildEntry = (key, value) => {
|
|
8
7
|
if (RICH_META_KEYS.has(key)) return false;
|
|
@@ -13,7 +12,7 @@ const parseTemplates = async (obj, path = []) => {
|
|
|
13
12
|
const classes = [];
|
|
14
13
|
if (parseStyles.isRichTemplateNode(obj)) {
|
|
15
14
|
const rich = obj;
|
|
16
|
-
const baseClassName = path.map((p) =>
|
|
15
|
+
const baseClassName = path.map((p) => toHash.dashCase(String(p))).join("-");
|
|
17
16
|
if (rich.base) {
|
|
18
17
|
const hashClass = "t_" + toHash.toHash(baseClassName, 4);
|
|
19
18
|
const result = await parseStyles.parseAndJoinStyles(rich.base, `.${baseClassName}, .${hashClass}`);
|
|
@@ -24,7 +23,7 @@ const parseTemplates = async (obj, path = []) => {
|
|
|
24
23
|
if (!valueMap || typeof valueMap !== "object") continue;
|
|
25
24
|
for (const [value, styles] of Object.entries(valueMap)) {
|
|
26
25
|
if (!styles || typeof styles !== "object") continue;
|
|
27
|
-
const variantClassName = `${baseClassName}-${
|
|
26
|
+
const variantClassName = `${baseClassName}-${toHash.dashCase(axis)}-${toHash.dashCase(value)}`;
|
|
28
27
|
const variantHashClass = "tv_" + toHash.toHash(variantClassName, 4);
|
|
29
28
|
const result = await parseStyles.parseAndJoinStyles(styles, `.${variantClassName}, .${variantHashClass}`);
|
|
30
29
|
classes.push(result);
|
|
@@ -50,7 +49,7 @@ const parseTemplates = async (obj, path = []) => {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
if (Object.keys(levelStyles).length) {
|
|
53
|
-
const className = path.map((p) =>
|
|
52
|
+
const className = path.map((p) => toHash.dashCase(String(p))).join("-");
|
|
54
53
|
const hashClass = "t_" + toHash.toHash(className, 4);
|
|
55
54
|
const result = await parseStyles.parseAndJoinStyles(levelStyles, `.${className}, .${hashClass}`);
|
|
56
55
|
classes.push(result);
|
package/parsers/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { i as isRichTemplateNode, p as parseAndJoinStyles } from "../parse-styles-
|
|
2
|
-
import { a, d, e, c, r } from "../parse-styles-
|
|
3
|
-
import { d as dashCase } from "../
|
|
4
|
-
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
1
|
+
import { i as isRichTemplateNode, p as parseAndJoinStyles } from "../parse-styles-BgVqQAni.js";
|
|
2
|
+
import { a, d, e, c, r } from "../parse-styles-BgVqQAni.js";
|
|
3
|
+
import { d as dashCase, t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
5
4
|
const RICH_META_KEYS = /* @__PURE__ */ new Set(["base", "variants", "defaultVariants", "compoundVariants", "anyOfVariants"]);
|
|
6
5
|
const isChildEntry = (key, value) => {
|
|
7
6
|
if (RICH_META_KEYS.has(key)) return false;
|
package/runtime/index.cjs
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-
|
|
3
|
+
const parseStyles = require("../parse-styles-BbI-2wdn.cjs");
|
|
4
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
4
5
|
const defineRuntime = (config) => {
|
|
5
|
-
const
|
|
6
|
+
const className = (styles) => toHash.toHash(styles);
|
|
7
|
+
const css = async (styles, scope) => {
|
|
6
8
|
const parsed = await parseStyles.parseStyles(styles, scope, config);
|
|
7
9
|
return parsed.join("\n");
|
|
8
10
|
};
|
|
9
|
-
|
|
11
|
+
const resolve = async (styles, scope) => {
|
|
12
|
+
const _className = className(styles);
|
|
13
|
+
const _css = await css(styles, scope || `.${_className}`);
|
|
14
|
+
return { className: _className, css: _css };
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
className,
|
|
18
|
+
css,
|
|
19
|
+
resolve,
|
|
20
|
+
/** @deprecated Use `css` instead. Kept as an alias for backward compatibility with the standalone `getDynamicStylesCss` helper. */
|
|
21
|
+
getDynamicStylesCss: css
|
|
22
|
+
};
|
|
10
23
|
};
|
|
11
24
|
exports.defineRuntime = defineRuntime;
|
package/runtime/index.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { CachedConfig, SaltyConfig } from '../config';
|
|
|
2
2
|
import { BaseStyles } from '../types';
|
|
3
3
|
type Config = Partial<SaltyConfig & CachedConfig>;
|
|
4
4
|
export declare const defineRuntime: (config: Config) => {
|
|
5
|
+
className: (styles: BaseStyles) => string;
|
|
6
|
+
css: (styles: BaseStyles, scope?: string) => Promise<string>;
|
|
7
|
+
resolve: (styles: BaseStyles, scope?: string) => Promise<{
|
|
8
|
+
className: string;
|
|
9
|
+
css: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** @deprecated Use `css` instead. Kept as an alias for backward compatibility with the standalone `getDynamicStylesCss` helper. */
|
|
5
12
|
getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
|
|
6
13
|
};
|
|
7
14
|
export {};
|
package/runtime/index.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import { a as parseStyles } from "../parse-styles-
|
|
1
|
+
import { a as parseStyles } from "../parse-styles-BgVqQAni.js";
|
|
2
|
+
import { t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
2
3
|
const defineRuntime = (config) => {
|
|
3
|
-
const
|
|
4
|
+
const className = (styles) => toHash(styles);
|
|
5
|
+
const css = async (styles, scope) => {
|
|
4
6
|
const parsed = await parseStyles(styles, scope, config);
|
|
5
7
|
return parsed.join("\n");
|
|
6
8
|
};
|
|
7
|
-
|
|
9
|
+
const resolve = async (styles, scope) => {
|
|
10
|
+
const _className = className(styles);
|
|
11
|
+
const _css = await css(styles, scope || `.${_className}`);
|
|
12
|
+
return { className: _className, css: _css };
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
className,
|
|
16
|
+
css,
|
|
17
|
+
resolve,
|
|
18
|
+
/** @deprecated Use `css` instead. Kept as an alias for backward compatibility with the standalone `getDynamicStylesCss` helper. */
|
|
19
|
+
getDynamicStylesCss: css
|
|
20
|
+
};
|
|
8
21
|
};
|
|
9
22
|
export {
|
|
10
23
|
defineRuntime
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
function dashCase(str) {
|
|
2
|
+
if (!str) return "";
|
|
3
|
+
if (typeof str !== "string") return dashCase(String(str));
|
|
4
|
+
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
5
|
+
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
6
|
+
});
|
|
7
|
+
}
|
|
1
8
|
const toAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
2
9
|
const toAlphabeticName = (code, length) => {
|
|
3
10
|
let name = "";
|
|
@@ -21,5 +28,6 @@ const toHash = (value, length = 5) => {
|
|
|
21
28
|
return toAlphabeticName(numericHash, length);
|
|
22
29
|
};
|
|
23
30
|
export {
|
|
31
|
+
dashCase as d,
|
|
24
32
|
toHash as t
|
|
25
33
|
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
function dashCase(str) {
|
|
3
|
+
if (!str) return "";
|
|
4
|
+
if (typeof str !== "string") return dashCase(String(str));
|
|
5
|
+
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
6
|
+
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
2
9
|
const toAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
3
10
|
const toAlphabeticName = (code, length) => {
|
|
4
11
|
let name = "";
|
|
@@ -21,4 +28,5 @@ const toHash = (value, length = 5) => {
|
|
|
21
28
|
const numericHash = toPhash(5381, JSON.stringify(value)) >>> 0;
|
|
22
29
|
return toAlphabeticName(numericHash, length);
|
|
23
30
|
};
|
|
31
|
+
exports.dashCase = dashCase;
|
|
24
32
|
exports.toHash = toHash;
|
package/util/index.cjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
4
4
|
const pascalCase = require("../pascal-case-By_l58S-.cjs");
|
|
5
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
6
5
|
function camelCase(str) {
|
|
7
6
|
if (!str) return "";
|
|
8
7
|
if (typeof str !== "string") return camelCase(String(str));
|
|
9
8
|
return str.replace(/\s/g, "-").replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
10
9
|
}
|
|
11
|
-
exports.dashCase =
|
|
12
|
-
exports.pascalCase = pascalCase.pascalCase;
|
|
10
|
+
exports.dashCase = toHash.dashCase;
|
|
13
11
|
exports.toHash = toHash.toHash;
|
|
12
|
+
exports.pascalCase = pascalCase.pascalCase;
|
|
14
13
|
exports.camelCase = camelCase;
|
package/util/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { d } from "../
|
|
1
|
+
import { d, t } from "../to-hash-DSoCPs8D.js";
|
|
2
2
|
import { p } from "../pascal-case-F3Usi5Wf.js";
|
|
3
|
-
import { t } from "../to-hash-DAN2LcHK.js";
|
|
4
3
|
function camelCase(str) {
|
|
5
4
|
if (!str) return "";
|
|
6
5
|
if (typeof str !== "string") return camelCase(String(str));
|
package/util/module-type.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const detectCurrentModuleType: (dirname: string) => Promise<"
|
|
1
|
+
export declare const detectCurrentModuleType: (dirname: string) => Promise<"cjs" | "esm">;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const promises = require("fs/promises");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const resolveDynamicConfigCache = async () => {
|
|
6
|
-
const currentDir = process.cwd();
|
|
7
|
-
const filename = "config-cache.json";
|
|
8
|
-
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "saltygen/cache", "src/saltygen/cache"];
|
|
9
|
-
let contents = "";
|
|
10
|
-
for (const pattern of patterns) {
|
|
11
|
-
const potentialPath = path.join(currentDir, pattern, filename);
|
|
12
|
-
try {
|
|
13
|
-
contents = await promises.readFile(potentialPath, "utf8");
|
|
14
|
-
break;
|
|
15
|
-
} catch {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (!contents) {
|
|
19
|
-
console.warn(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
return JSON.parse(contents);
|
|
23
|
-
};
|
|
24
|
-
exports.resolveDynamicConfigCache = resolveDynamicConfigCache;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveDynamicConfigCache: () => Promise<any>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
const resolveDynamicConfigCache = async () => {
|
|
4
|
-
const currentDir = process.cwd();
|
|
5
|
-
const filename = "config-cache.json";
|
|
6
|
-
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "saltygen/cache", "src/saltygen/cache"];
|
|
7
|
-
let contents = "";
|
|
8
|
-
for (const pattern of patterns) {
|
|
9
|
-
const potentialPath = join(currentDir, pattern, filename);
|
|
10
|
-
try {
|
|
11
|
-
contents = await readFile(potentialPath, "utf8");
|
|
12
|
-
break;
|
|
13
|
-
} catch {
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (!contents) {
|
|
17
|
-
console.warn(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
return JSON.parse(contents);
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
resolveDynamicConfigCache
|
|
24
|
-
};
|
package/css/dynamic-styles.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
|
|
4
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
5
|
-
const cache_resolveDynamicConfigCache = require("../cache/resolve-dynamic-config-cache.cjs");
|
|
6
|
-
const getDynamicStylesClassName = (styles) => {
|
|
7
|
-
return toHash.toHash(styles);
|
|
8
|
-
};
|
|
9
|
-
const getDynamicStylesCss = async (styles, scope) => {
|
|
10
|
-
const config = await cache_resolveDynamicConfigCache.resolveDynamicConfigCache();
|
|
11
|
-
const parsed = await parseStyles.parseStyles(styles, scope, config);
|
|
12
|
-
return parsed.join("\n");
|
|
13
|
-
};
|
|
14
|
-
exports.getDynamicStylesClassName = getDynamicStylesClassName;
|
|
15
|
-
exports.getDynamicStylesCss = getDynamicStylesCss;
|
package/css/dynamic-styles.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseStyles } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Create a hash of the dynamic styles that then can be used as scope.
|
|
4
|
-
*/
|
|
5
|
-
export declare const getDynamicStylesClassName: (styles: BaseStyles) => string;
|
|
6
|
-
/**
|
|
7
|
-
* Add any dynamic styles to your app with a custom scope.
|
|
8
|
-
* Note: this works only with server components.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
|
package/css/dynamic-styles.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { a as parseStyles } from "../parse-styles-BBJ3PWyV.js";
|
|
2
|
-
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
3
|
-
import { resolveDynamicConfigCache } from "../cache/resolve-dynamic-config-cache.js";
|
|
4
|
-
const getDynamicStylesClassName = (styles) => {
|
|
5
|
-
return toHash(styles);
|
|
6
|
-
};
|
|
7
|
-
const getDynamicStylesCss = async (styles, scope) => {
|
|
8
|
-
const config = await resolveDynamicConfigCache();
|
|
9
|
-
const parsed = await parseStyles(styles, scope, config);
|
|
10
|
-
return parsed.join("\n");
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
getDynamicStylesClassName,
|
|
14
|
-
getDynamicStylesCss
|
|
15
|
-
};
|
package/dash-case-DIwKaYgE.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function dashCase(str) {
|
|
3
|
-
if (!str) return "";
|
|
4
|
-
if (typeof str !== "string") return dashCase(String(str));
|
|
5
|
-
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
6
|
-
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
exports.dashCase = dashCase;
|
package/dash-case-DblXvymC.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function dashCase(str) {
|
|
2
|
-
if (!str) return "";
|
|
3
|
-
if (typeof str !== "string") return dashCase(String(str));
|
|
4
|
-
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
5
|
-
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
dashCase as d
|
|
10
|
-
};
|