@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.
Files changed (60) hide show
  1. package/README.md +355 -374
  2. package/bin/main.cjs +57 -58
  3. package/bin/main.js +1 -2
  4. package/{class-name-generator-CMWY5KTJ.js → class-name-generator-CUEoPowv.js} +18 -4
  5. package/{class-name-generator-DB5aQwC_.cjs → class-name-generator-MtPkBfM_.cjs} +19 -5
  6. package/compiler/helpers.cjs +10 -2
  7. package/compiler/helpers.d.ts +3 -2
  8. package/compiler/helpers.js +11 -3
  9. package/compiler/resolve-import.d.ts +17 -0
  10. package/compiler/salty-compiler.cjs +144 -33
  11. package/compiler/salty-compiler.d.ts +2 -5
  12. package/compiler/salty-compiler.js +149 -38
  13. package/config/index.cjs +4 -0
  14. package/config/index.js +5 -1
  15. package/css/index.cjs +0 -4
  16. package/css/index.d.ts +0 -1
  17. package/css/index.js +0 -4
  18. package/css/keyframes.cjs +2 -2
  19. package/css/keyframes.js +2 -2
  20. package/factories/define-font.d.ts +28 -0
  21. package/factories/define-import.d.ts +14 -0
  22. package/factories/index.cjs +140 -0
  23. package/factories/index.d.ts +2 -0
  24. package/factories/index.js +140 -0
  25. package/generators/index.cjs +3 -3
  26. package/generators/index.js +3 -3
  27. package/helpers/color.d.ts +6 -0
  28. package/instances/classname-instance.cjs +1 -1
  29. package/instances/classname-instance.js +1 -1
  30. package/package.json +1 -13
  31. package/{parse-styles-C54MOrPg.cjs → parse-styles-BbI-2wdn.cjs} +196 -11
  32. package/{parse-styles-CLMTHo2H.js → parse-styles-BgVqQAni.js} +196 -11
  33. package/parsers/index.cjs +93 -5
  34. package/parsers/index.js +97 -9
  35. package/parsers/parse-templates.d.ts +10 -0
  36. package/parsers/parser-regexes.d.ts +1 -0
  37. package/parsers/resolve-template-variants.d.ts +21 -0
  38. package/runtime/index.cjs +16 -3
  39. package/runtime/index.d.ts +7 -0
  40. package/runtime/index.js +16 -3
  41. package/{to-hash-DAN2LcHK.js → to-hash-DSoCPs8D.js} +8 -0
  42. package/{to-hash-C05Y906F.cjs → to-hash-DT2ImSPA.cjs} +8 -0
  43. package/types/config-types.d.ts +33 -2
  44. package/types/font-types.d.ts +53 -0
  45. package/util/index.cjs +3 -4
  46. package/util/index.js +1 -2
  47. package/util/module-type.d.ts +1 -1
  48. package/cache/resolve-dynamic-config-cache.cjs +0 -64
  49. package/cache/resolve-dynamic-config-cache.d.ts +0 -20
  50. package/cache/resolve-dynamic-config-cache.js +0 -64
  51. package/compiler/copy-config-cache.cjs +0 -39
  52. package/compiler/copy-config-cache.d.ts +0 -17
  53. package/compiler/copy-config-cache.js +0 -39
  54. package/css/dynamic-styles.cjs +0 -28
  55. package/css/dynamic-styles.d.ts +0 -49
  56. package/css/dynamic-styles.js +0 -28
  57. package/dash-case-DIwKaYgE.cjs +0 -9
  58. package/dash-case-DblXvymC.js +0 -10
  59. package/logger-7xz0pyAz.cjs +0 -12
  60. 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
- };
@@ -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;
@@ -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>;
@@ -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
- };
@@ -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;
@@ -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
- };
@@ -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;
@@ -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
- };