@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
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { mkdir, copyFile } from "fs/promises";
|
|
2
|
-
import { join, dirname, isAbsolute, resolve } from "path";
|
|
3
|
-
import { l as logger } from "../logger-hHmCwThj.js";
|
|
4
|
-
const DEFAULT_SUBPATH = join("saltygen", "cache", "config-cache.json");
|
|
5
|
-
const resolveCopyConfigCacheDestinations = (option, defaultOutDir, cwd = process.cwd()) => {
|
|
6
|
-
if (option === false) return [];
|
|
7
|
-
const userPaths = [];
|
|
8
|
-
if (typeof option === "string") userPaths.push(option);
|
|
9
|
-
else if (Array.isArray(option)) userPaths.push(...option);
|
|
10
|
-
const destinations = [];
|
|
11
|
-
const useDefault = option === void 0 || option === true;
|
|
12
|
-
if (useDefault && defaultOutDir) destinations.push(defaultOutDir);
|
|
13
|
-
destinations.push(...userPaths);
|
|
14
|
-
return destinations.map((entry) => {
|
|
15
|
-
const abs = isAbsolute(entry) ? entry : resolve(cwd, entry);
|
|
16
|
-
if (abs.endsWith(".json")) return abs;
|
|
17
|
-
return join(abs, DEFAULT_SUBPATH);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const copyConfigCacheTo = async (compiler, destinations) => {
|
|
21
|
-
if (destinations.length === 0) return;
|
|
22
|
-
const source = await compiler.getConfigCachePath();
|
|
23
|
-
await Promise.all(
|
|
24
|
-
destinations.map(async (destination) => {
|
|
25
|
-
if (destination === source) return;
|
|
26
|
-
try {
|
|
27
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
28
|
-
await copyFile(source, destination);
|
|
29
|
-
logger.info(`Copied Salty config cache → ${destination}`);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
logger.warn(`Failed to copy Salty config cache to ${destination}: ${error.message}`);
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
copyConfigCacheTo,
|
|
38
|
-
resolveCopyConfigCacheDestinations
|
|
39
|
-
};
|
package/css/dynamic-styles.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-C54MOrPg.cjs");
|
|
4
|
-
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
5
|
-
const cache_resolveDynamicConfigCache = require("../cache/resolve-dynamic-config-cache.cjs");
|
|
6
|
-
const getDynamicStylesClassName = (styles) => toHash.toHash(styles);
|
|
7
|
-
const initializeDynamicStyles = (options = {}) => {
|
|
8
|
-
const resolveConfig = async () => {
|
|
9
|
-
if (options.config) return options.config;
|
|
10
|
-
return cache_resolveDynamicConfigCache.resolveDynamicConfigCache({
|
|
11
|
-
primaryPath: options.configCachePath,
|
|
12
|
-
extraPaths: options.configCachePaths
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
getDynamicStylesClassName,
|
|
17
|
-
getDynamicStylesCss: async (styles, scope) => {
|
|
18
|
-
const config = await resolveConfig();
|
|
19
|
-
const parsed = await parseStyles.parseStyles(styles, scope, config);
|
|
20
|
-
return parsed.join("\n");
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
const defaultHelpers = initializeDynamicStyles();
|
|
25
|
-
const getDynamicStylesCss = defaultHelpers.getDynamicStylesCss;
|
|
26
|
-
exports.getDynamicStylesClassName = getDynamicStylesClassName;
|
|
27
|
-
exports.getDynamicStylesCss = getDynamicStylesCss;
|
|
28
|
-
exports.initializeDynamicStyles = initializeDynamicStyles;
|
package/css/dynamic-styles.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BaseStyles } from '../types';
|
|
2
|
-
import { CachedConfig, SaltyConfig } from '../types/config-types';
|
|
3
|
-
export interface InitializeDynamicStylesOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Absolute path (or path relative to `process.cwd()`) to a `config-cache.json` file.
|
|
6
|
-
* Wins over `configCachePaths` and the built-in search patterns when readable.
|
|
7
|
-
*/
|
|
8
|
-
configCachePath?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Extra paths searched before the built-in patterns. Each entry can be a directory
|
|
11
|
-
* (the resolver will look for `config-cache.json`, `cache/config-cache.json`, and
|
|
12
|
-
* `saltygen/cache/config-cache.json` inside) or a direct path to a `.json` file.
|
|
13
|
-
*/
|
|
14
|
-
configCachePaths?: string[];
|
|
15
|
-
/**
|
|
16
|
-
* Pre-loaded config object. When provided, the filesystem is not touched — required
|
|
17
|
-
* for edge runtimes (e.g. Cloudflare Workers) where `fs/promises` is unavailable.
|
|
18
|
-
*/
|
|
19
|
-
config?: Partial<SaltyConfig & CachedConfig>;
|
|
20
|
-
}
|
|
21
|
-
export interface DynamicStylesHelpers {
|
|
22
|
-
getDynamicStylesClassName: (styles: BaseStyles) => string;
|
|
23
|
-
getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Create a hash of the dynamic styles that then can be used as scope.
|
|
27
|
-
*/
|
|
28
|
-
export declare const getDynamicStylesClassName: (styles: BaseStyles) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Bind dynamic-styles helpers to a specific config / cache location.
|
|
31
|
-
*
|
|
32
|
-
* Useful when deploying to environments where the build-time `saltygen/` directory is
|
|
33
|
-
* not available at runtime — e.g. an Astro site shipped to Cloudflare. Configure once
|
|
34
|
-
* at app startup and reuse the returned helpers.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const { getDynamicStylesCss } = initializeDynamicStyles({
|
|
38
|
-
* configCachePath: 'dist/saltygen/cache/config-cache.json',
|
|
39
|
-
* });
|
|
40
|
-
*/
|
|
41
|
-
export declare const initializeDynamicStyles: (options?: InitializeDynamicStylesOptions) => DynamicStylesHelpers;
|
|
42
|
-
/**
|
|
43
|
-
* Add any dynamic styles to your app with a custom scope.
|
|
44
|
-
* Note: this works only with server components.
|
|
45
|
-
*
|
|
46
|
-
* For production deployments that strip the source tree (e.g. Cloudflare),
|
|
47
|
-
* use {@link initializeDynamicStyles} to bind to a known cache location.
|
|
48
|
-
*/
|
|
49
|
-
export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
|
package/css/dynamic-styles.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { a as parseStyles } from "../parse-styles-CLMTHo2H.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) => toHash(styles);
|
|
5
|
-
const initializeDynamicStyles = (options = {}) => {
|
|
6
|
-
const resolveConfig = async () => {
|
|
7
|
-
if (options.config) return options.config;
|
|
8
|
-
return resolveDynamicConfigCache({
|
|
9
|
-
primaryPath: options.configCachePath,
|
|
10
|
-
extraPaths: options.configCachePaths
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
return {
|
|
14
|
-
getDynamicStylesClassName,
|
|
15
|
-
getDynamicStylesCss: async (styles, scope) => {
|
|
16
|
-
const config = await resolveConfig();
|
|
17
|
-
const parsed = await parseStyles(styles, scope, config);
|
|
18
|
-
return parsed.join("\n");
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const defaultHelpers = initializeDynamicStyles();
|
|
23
|
-
const getDynamicStylesCss = defaultHelpers.getDynamicStylesCss;
|
|
24
|
-
export {
|
|
25
|
-
getDynamicStylesClassName,
|
|
26
|
-
getDynamicStylesCss,
|
|
27
|
-
initializeDynamicStyles
|
|
28
|
-
};
|
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
|
-
};
|
package/logger-7xz0pyAz.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const winston = require("winston");
|
|
3
|
-
const logger = winston.createLogger({
|
|
4
|
-
level: "debug",
|
|
5
|
-
format: winston.format.combine(winston.format.colorize(), winston.format.cli()),
|
|
6
|
-
transports: [new winston.transports.Console({})]
|
|
7
|
-
});
|
|
8
|
-
const logError = (message) => {
|
|
9
|
-
logger.error(message);
|
|
10
|
-
};
|
|
11
|
-
exports.logError = logError;
|
|
12
|
-
exports.logger = logger;
|
package/logger-hHmCwThj.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createLogger, transports, format } from "winston";
|
|
2
|
-
const logger = createLogger({
|
|
3
|
-
level: "debug",
|
|
4
|
-
format: format.combine(format.colorize(), format.cli()),
|
|
5
|
-
transports: [new transports.Console({})]
|
|
6
|
-
});
|
|
7
|
-
const logError = (message) => {
|
|
8
|
-
logger.error(message);
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
logError as a,
|
|
12
|
-
logger as l
|
|
13
|
-
};
|