@salty-css/core 0.1.0-alpha.9 → 0.1.0-refactor-add-additional-paths-to-config-cache.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/bin/confirm-install.d.ts +34 -0
- package/bin/context.d.ts +3 -0
- package/bin/integrations/index.d.ts +11 -3
- package/bin/integrations/types.d.ts +14 -2
- package/bin/main.cjs +197 -95
- package/bin/main.js +151 -49
- package/cache/resolve-dynamic-config-cache.cjs +64 -16
- package/cache/resolve-dynamic-config-cache.d.ts +20 -1
- package/cache/resolve-dynamic-config-cache.js +65 -17
- package/{class-name-generator-YeSQe_Ik.js → class-name-generator-CMWY5KTJ.js} +1 -1
- package/{class-name-generator-B2Pb2obX.cjs → class-name-generator-DB5aQwC_.cjs} +1 -1
- package/compiler/copy-config-cache.cjs +39 -0
- package/compiler/copy-config-cache.d.ts +17 -0
- package/compiler/copy-config-cache.js +39 -0
- package/compiler/salty-compiler.cjs +22 -21
- package/compiler/salty-compiler.d.ts +11 -1
- package/compiler/salty-compiler.js +20 -19
- package/css/dynamic-styles.cjs +21 -8
- package/css/dynamic-styles.d.ts +39 -0
- package/css/dynamic-styles.js +22 -9
- package/css/index.cjs +1 -0
- package/css/index.js +2 -1
- package/css/keyframes.cjs +1 -1
- package/css/keyframes.js +1 -1
- package/generators/index.cjs +1 -1
- package/generators/index.js +2 -2
- package/instances/classname-instance.cjs +1 -1
- package/instances/classname-instance.js +1 -1
- package/logger-7xz0pyAz.cjs +12 -0
- package/logger-hHmCwThj.js +13 -0
- package/package.json +5 -1
- package/{parse-styles-CA3TP5n1.cjs → parse-styles-C54MOrPg.cjs} +106 -7
- package/{parse-styles-BTIoYnBr.js → parse-styles-CLMTHo2H.js} +107 -8
- package/parsers/index.cjs +2 -1
- package/parsers/index.d.ts +1 -0
- package/parsers/index.js +4 -3
- package/parsers/parser-regexes.d.ts +3 -0
- package/parsers/strict.d.ts +2 -0
- package/runtime/index.cjs +1 -1
- package/runtime/index.js +1 -1
- package/{salty.config-cqavVm2t.cjs → salty.config-DogY_sSQ.cjs} +1 -1
- package/salty.config-GV37Q-D2.js +4 -0
- package/types/config-types.d.ts +9 -0
- package/salty.config-DjosWdPw.js +0 -4
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
6
|
const esbuild = require("esbuild");
|
|
7
7
|
const path = require("path");
|
|
8
|
-
const
|
|
8
|
+
const logger = require("../logger-7xz0pyAz.cjs");
|
|
9
9
|
const promises = require("fs/promises");
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const child_process = require("child_process");
|
|
@@ -13,10 +13,11 @@ const compiler_helpers = require("./helpers.cjs");
|
|
|
13
13
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
14
14
|
const dashCase = require("../dash-case-DIwKaYgE.cjs");
|
|
15
15
|
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
16
|
-
const parseStyles = require("../parse-styles-
|
|
16
|
+
const parseStyles = require("../parse-styles-C54MOrPg.cjs");
|
|
17
17
|
const css_merge = require("../css/merge.cjs");
|
|
18
|
-
|
|
18
|
+
require("../css/dynamic-styles.cjs");
|
|
19
19
|
const compiler_getFiles = require("./get-files.cjs");
|
|
20
|
+
const parsers_index = require("../parsers/index.cjs");
|
|
20
21
|
const console = require("console");
|
|
21
22
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
22
23
|
function _interopNamespaceDefault(e) {
|
|
@@ -36,14 +37,6 @@ function _interopNamespaceDefault(e) {
|
|
|
36
37
|
return Object.freeze(n);
|
|
37
38
|
}
|
|
38
39
|
const esbuild__namespace = /* @__PURE__ */ _interopNamespaceDefault(esbuild);
|
|
39
|
-
const logger = winston.createLogger({
|
|
40
|
-
level: "debug",
|
|
41
|
-
format: winston.format.combine(winston.format.colorize(), winston.format.cli()),
|
|
42
|
-
transports: [new winston.transports.Console({})]
|
|
43
|
-
});
|
|
44
|
-
const logError = (message) => {
|
|
45
|
-
logger.error(message);
|
|
46
|
-
};
|
|
47
40
|
const readPackageJsonModule = async (dirname) => {
|
|
48
41
|
const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
|
|
49
42
|
if (!packageJsonContent) return void 0;
|
|
@@ -111,7 +104,7 @@ const saltyReset = {
|
|
|
111
104
|
}
|
|
112
105
|
};
|
|
113
106
|
class SaltyCompiler {
|
|
114
|
-
constructor(projectRootDir) {
|
|
107
|
+
constructor(projectRootDir, options = {}) {
|
|
115
108
|
__publicField(this, "importFile", (path2) => {
|
|
116
109
|
const now = Date.now();
|
|
117
110
|
return import(
|
|
@@ -168,6 +161,14 @@ class SaltyCompiler {
|
|
|
168
161
|
this.cache.destDir = destDir;
|
|
169
162
|
return destDir;
|
|
170
163
|
});
|
|
164
|
+
/**
|
|
165
|
+
* Absolute path to the `config-cache.json` written during `generateCss()`.
|
|
166
|
+
* Plugins read this to copy the file into the production bundle output.
|
|
167
|
+
*/
|
|
168
|
+
__publicField(this, "getConfigCachePath", async () => {
|
|
169
|
+
const destDir = await this.getDestDir();
|
|
170
|
+
return path.join(destDir, "cache/config-cache.json");
|
|
171
|
+
});
|
|
171
172
|
__publicField(this, "generateConfig", async () => {
|
|
172
173
|
const rcProject = await this.getRCProjectConfig(this.projectRootDir);
|
|
173
174
|
const destDir = await this.getDestDir();
|
|
@@ -201,8 +202,7 @@ ${currentFile}`;
|
|
|
201
202
|
}
|
|
202
203
|
});
|
|
203
204
|
__publicField(this, "getConfigCache", async () => {
|
|
204
|
-
const
|
|
205
|
-
const coreConfigDest = path.join(destDir, "cache/config-cache.json");
|
|
205
|
+
const coreConfigDest = await this.getConfigCachePath();
|
|
206
206
|
const contents = fs.readFileSync(coreConfigDest, "utf8");
|
|
207
207
|
if (!contents) throw new Error("Could not find config cache file");
|
|
208
208
|
return JSON.parse(contents);
|
|
@@ -220,8 +220,8 @@ ${currentFile}`;
|
|
|
220
220
|
__publicField(this, "generateCss", async (clean = true) => {
|
|
221
221
|
try {
|
|
222
222
|
const start = Date.now();
|
|
223
|
-
if (this.isProduction) logger.info("Generating CSS in production mode! 🔥");
|
|
224
|
-
else logger.info("Generating CSS in development mode! 🚀");
|
|
223
|
+
if (this.isProduction) logger.logger.info("Generating CSS in production mode! 🔥");
|
|
224
|
+
else logger.logger.info("Generating CSS in development mode! 🚀");
|
|
225
225
|
const globalCssFiles = [];
|
|
226
226
|
const cssFiles = [];
|
|
227
227
|
const destDir = await this.getDestDir();
|
|
@@ -393,7 +393,7 @@ ${css}
|
|
|
393
393
|
const end = Date.now();
|
|
394
394
|
const time = end - start;
|
|
395
395
|
const emoji = time < 200 ? "🔥" : time < 500 ? "🚀" : time < 1e3 ? "🎉" : time < 2e3 ? "🚗" : time < 5e3 ? "🤔" : "🥴";
|
|
396
|
-
logger.info(`Generated CSS in ${time}ms! ${emoji}`);
|
|
396
|
+
logger.logger.info(`Generated CSS in ${time}ms! ${emoji}`);
|
|
397
397
|
} catch (e) {
|
|
398
398
|
console.error(e);
|
|
399
399
|
}
|
|
@@ -532,7 +532,7 @@ ${css}
|
|
|
532
532
|
type MediaQueryKeys = ${mediaQueryKeys || `''`};
|
|
533
533
|
`;
|
|
534
534
|
fs.writeFileSync(tsTokensPath, tsTokensTypes);
|
|
535
|
-
const configCachePath =
|
|
535
|
+
const configCachePath = await this.getConfigCachePath();
|
|
536
536
|
fs.writeFileSync(configCachePath, JSON.stringify(configCacheContent, null, 2));
|
|
537
537
|
const corePackageRoot = compiler_helpers.getCorePackageRoot();
|
|
538
538
|
const configCacheSecondaryPath = path.join(corePackageRoot, "cache/config-cache.json");
|
|
@@ -546,7 +546,8 @@ ${css}
|
|
|
546
546
|
let currentFile = fs.readFileSync(sourceFilePath, "utf8");
|
|
547
547
|
currentFile = this.replaceStyledTag(currentFile);
|
|
548
548
|
currentFile = this.addConfigCache(currentFile);
|
|
549
|
-
const
|
|
549
|
+
const currentFileHash = toHash.toHash(currentFile);
|
|
550
|
+
const outputFilePath = path.join(outputDirectory, "js", `${hashedName}-${currentFileHash}.js`);
|
|
550
551
|
const rcProject = await this.getRCProjectConfig(this.projectRootDir);
|
|
551
552
|
const coreConfigPath = path.join(this.projectRootDir, (rcProject == null ? void 0 : rcProject.configDir) || "", "salty.config.ts");
|
|
552
553
|
const externalModules = this.getExternalModules(coreConfigPath);
|
|
@@ -690,11 +691,13 @@ ${newContent}
|
|
|
690
691
|
});
|
|
691
692
|
});
|
|
692
693
|
this.projectRootDir = projectRootDir;
|
|
694
|
+
this.options = options;
|
|
693
695
|
if (typeof process === "undefined") {
|
|
694
696
|
throw new Error("SaltyServer can only be used in a Node.js environment.");
|
|
695
697
|
}
|
|
696
698
|
}
|
|
697
699
|
get isProduction() {
|
|
700
|
+
if (this.options.mode) return this.options.mode === "production";
|
|
698
701
|
try {
|
|
699
702
|
return process.env["NODE_ENV"] !== "development";
|
|
700
703
|
} catch {
|
|
@@ -703,5 +706,3 @@ ${newContent}
|
|
|
703
706
|
}
|
|
704
707
|
}
|
|
705
708
|
exports.SaltyCompiler = SaltyCompiler;
|
|
706
|
-
exports.logError = logError;
|
|
707
|
-
exports.logger = logger;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { CachedConfig, SaltyConfig } from '../config';
|
|
2
|
+
export type SaltyCompilerMode = 'production' | 'development';
|
|
3
|
+
export interface SaltyCompilerOptions {
|
|
4
|
+
mode?: SaltyCompilerMode;
|
|
5
|
+
}
|
|
2
6
|
export declare class SaltyCompiler {
|
|
3
7
|
projectRootDir: string;
|
|
8
|
+
private options;
|
|
4
9
|
importFile: (path: string) => Promise<any>;
|
|
5
10
|
private cache;
|
|
6
|
-
constructor(projectRootDir: string);
|
|
11
|
+
constructor(projectRootDir: string, options?: SaltyCompilerOptions);
|
|
7
12
|
get isProduction(): boolean;
|
|
8
13
|
/**
|
|
9
14
|
* Locate and read the .saltyrc.json file starting from the current directory and moving up the directory tree.
|
|
@@ -21,6 +26,11 @@ export declare class SaltyCompiler {
|
|
|
21
26
|
* Caches the result to avoid redundant computations.
|
|
22
27
|
*/
|
|
23
28
|
getDestDir: () => Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Absolute path to the `config-cache.json` written during `generateCss()`.
|
|
31
|
+
* Plugins read this to copy the file into the production bundle output.
|
|
32
|
+
*/
|
|
33
|
+
getConfigCachePath: () => Promise<string>;
|
|
24
34
|
private generateConfig;
|
|
25
35
|
private addConfigCache;
|
|
26
36
|
private getConfigCache;
|
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import * as esbuild from "esbuild";
|
|
5
5
|
import { join, parse } from "path";
|
|
6
|
-
import {
|
|
6
|
+
import { l as logger } from "../logger-hHmCwThj.js";
|
|
7
7
|
import { readFile } from "fs/promises";
|
|
8
8
|
import { readFileSync, existsSync, mkdirSync, statSync, readdirSync, writeFileSync } from "fs";
|
|
9
9
|
import { execSync } from "child_process";
|
|
@@ -11,19 +11,12 @@ import { isSaltyFile, resolveExportValue, getCorePackageRoot, saltyFileExtension
|
|
|
11
11
|
import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
|
|
12
12
|
import { d as dashCase } from "../dash-case-DblXvymC.js";
|
|
13
13
|
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
14
|
-
import { p as parseAndJoinStyles, b as parseVariableTokens } from "../parse-styles-
|
|
14
|
+
import { p as parseAndJoinStyles, b as parseVariableTokens } from "../parse-styles-CLMTHo2H.js";
|
|
15
15
|
import { mergeObjects, mergeFactories } from "../css/merge.js";
|
|
16
|
-
import
|
|
16
|
+
import "../css/dynamic-styles.js";
|
|
17
17
|
import { getPackageJson } from "./get-files.js";
|
|
18
|
+
import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
|
|
18
19
|
import console from "console";
|
|
19
|
-
const logger = createLogger({
|
|
20
|
-
level: "debug",
|
|
21
|
-
format: format.combine(format.colorize(), format.cli()),
|
|
22
|
-
transports: [new transports.Console({})]
|
|
23
|
-
});
|
|
24
|
-
const logError = (message) => {
|
|
25
|
-
logger.error(message);
|
|
26
|
-
};
|
|
27
20
|
const readPackageJsonModule = async (dirname) => {
|
|
28
21
|
const packageJsonContent = await getPackageJson(dirname);
|
|
29
22
|
if (!packageJsonContent) return void 0;
|
|
@@ -91,7 +84,7 @@ const saltyReset = {
|
|
|
91
84
|
}
|
|
92
85
|
};
|
|
93
86
|
class SaltyCompiler {
|
|
94
|
-
constructor(projectRootDir) {
|
|
87
|
+
constructor(projectRootDir, options = {}) {
|
|
95
88
|
__publicField(this, "importFile", (path) => {
|
|
96
89
|
const now = Date.now();
|
|
97
90
|
return import(
|
|
@@ -148,6 +141,14 @@ class SaltyCompiler {
|
|
|
148
141
|
this.cache.destDir = destDir;
|
|
149
142
|
return destDir;
|
|
150
143
|
});
|
|
144
|
+
/**
|
|
145
|
+
* Absolute path to the `config-cache.json` written during `generateCss()`.
|
|
146
|
+
* Plugins read this to copy the file into the production bundle output.
|
|
147
|
+
*/
|
|
148
|
+
__publicField(this, "getConfigCachePath", async () => {
|
|
149
|
+
const destDir = await this.getDestDir();
|
|
150
|
+
return join(destDir, "cache/config-cache.json");
|
|
151
|
+
});
|
|
151
152
|
__publicField(this, "generateConfig", async () => {
|
|
152
153
|
const rcProject = await this.getRCProjectConfig(this.projectRootDir);
|
|
153
154
|
const destDir = await this.getDestDir();
|
|
@@ -181,8 +182,7 @@ ${currentFile}`;
|
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
__publicField(this, "getConfigCache", async () => {
|
|
184
|
-
const
|
|
185
|
-
const coreConfigDest = join(destDir, "cache/config-cache.json");
|
|
185
|
+
const coreConfigDest = await this.getConfigCachePath();
|
|
186
186
|
const contents = readFileSync(coreConfigDest, "utf8");
|
|
187
187
|
if (!contents) throw new Error("Could not find config cache file");
|
|
188
188
|
return JSON.parse(contents);
|
|
@@ -512,7 +512,7 @@ ${css}
|
|
|
512
512
|
type MediaQueryKeys = ${mediaQueryKeys || `''`};
|
|
513
513
|
`;
|
|
514
514
|
writeFileSync(tsTokensPath, tsTokensTypes);
|
|
515
|
-
const configCachePath =
|
|
515
|
+
const configCachePath = await this.getConfigCachePath();
|
|
516
516
|
writeFileSync(configCachePath, JSON.stringify(configCacheContent, null, 2));
|
|
517
517
|
const corePackageRoot = getCorePackageRoot();
|
|
518
518
|
const configCacheSecondaryPath = join(corePackageRoot, "cache/config-cache.json");
|
|
@@ -526,7 +526,8 @@ ${css}
|
|
|
526
526
|
let currentFile = readFileSync(sourceFilePath, "utf8");
|
|
527
527
|
currentFile = this.replaceStyledTag(currentFile);
|
|
528
528
|
currentFile = this.addConfigCache(currentFile);
|
|
529
|
-
const
|
|
529
|
+
const currentFileHash = toHash(currentFile);
|
|
530
|
+
const outputFilePath = join(outputDirectory, "js", `${hashedName}-${currentFileHash}.js`);
|
|
530
531
|
const rcProject = await this.getRCProjectConfig(this.projectRootDir);
|
|
531
532
|
const coreConfigPath = join(this.projectRootDir, (rcProject == null ? void 0 : rcProject.configDir) || "", "salty.config.ts");
|
|
532
533
|
const externalModules = this.getExternalModules(coreConfigPath);
|
|
@@ -670,11 +671,13 @@ ${newContent}
|
|
|
670
671
|
});
|
|
671
672
|
});
|
|
672
673
|
this.projectRootDir = projectRootDir;
|
|
674
|
+
this.options = options;
|
|
673
675
|
if (typeof process === "undefined") {
|
|
674
676
|
throw new Error("SaltyServer can only be used in a Node.js environment.");
|
|
675
677
|
}
|
|
676
678
|
}
|
|
677
679
|
get isProduction() {
|
|
680
|
+
if (this.options.mode) return this.options.mode === "production";
|
|
678
681
|
try {
|
|
679
682
|
return process.env["NODE_ENV"] !== "development";
|
|
680
683
|
} catch {
|
|
@@ -683,7 +686,5 @@ ${newContent}
|
|
|
683
686
|
}
|
|
684
687
|
}
|
|
685
688
|
export {
|
|
686
|
-
SaltyCompiler
|
|
687
|
-
logError as a,
|
|
688
|
-
logger as l
|
|
689
|
+
SaltyCompiler
|
|
689
690
|
};
|
package/css/dynamic-styles.cjs
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
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-C54MOrPg.cjs");
|
|
4
4
|
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
5
5
|
const cache_resolveDynamicConfigCache = require("../cache/resolve-dynamic-config-cache.cjs");
|
|
6
|
-
const getDynamicStylesClassName = (styles) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
|
13
23
|
};
|
|
24
|
+
const defaultHelpers = initializeDynamicStyles();
|
|
25
|
+
const getDynamicStylesCss = defaultHelpers.getDynamicStylesCss;
|
|
14
26
|
exports.getDynamicStylesClassName = getDynamicStylesClassName;
|
|
15
27
|
exports.getDynamicStylesCss = getDynamicStylesCss;
|
|
28
|
+
exports.initializeDynamicStyles = initializeDynamicStyles;
|
package/css/dynamic-styles.d.ts
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
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
|
+
}
|
|
2
25
|
/**
|
|
3
26
|
* Create a hash of the dynamic styles that then can be used as scope.
|
|
4
27
|
*/
|
|
5
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;
|
|
6
42
|
/**
|
|
7
43
|
* Add any dynamic styles to your app with a custom scope.
|
|
8
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.
|
|
9
48
|
*/
|
|
10
49
|
export declare const getDynamicStylesCss: (styles: BaseStyles, scope?: string) => Promise<string>;
|
package/css/dynamic-styles.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import { a as parseStyles } from "../parse-styles-
|
|
1
|
+
import { a as parseStyles } from "../parse-styles-CLMTHo2H.js";
|
|
2
2
|
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
3
3
|
import { resolveDynamicConfigCache } from "../cache/resolve-dynamic-config-cache.js";
|
|
4
|
-
const getDynamicStylesClassName = (styles) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
};
|
|
11
21
|
};
|
|
22
|
+
const defaultHelpers = initializeDynamicStyles();
|
|
23
|
+
const getDynamicStylesCss = defaultHelpers.getDynamicStylesCss;
|
|
12
24
|
export {
|
|
13
25
|
getDynamicStylesClassName,
|
|
14
|
-
getDynamicStylesCss
|
|
26
|
+
getDynamicStylesCss,
|
|
27
|
+
initializeDynamicStyles
|
|
15
28
|
};
|
package/css/index.cjs
CHANGED
|
@@ -13,3 +13,4 @@ exports.mergeFactories = css_merge.mergeFactories;
|
|
|
13
13
|
exports.mergeObjects = css_merge.mergeObjects;
|
|
14
14
|
exports.getDynamicStylesClassName = css_dynamicStyles.getDynamicStylesClassName;
|
|
15
15
|
exports.getDynamicStylesCss = css_dynamicStyles.getDynamicStylesCss;
|
|
16
|
+
exports.initializeDynamicStyles = css_dynamicStyles.initializeDynamicStyles;
|
package/css/index.js
CHANGED
|
@@ -2,11 +2,12 @@ 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";
|
|
5
|
+
import { getDynamicStylesClassName, getDynamicStylesCss, initializeDynamicStyles } from "./dynamic-styles.js";
|
|
6
6
|
export {
|
|
7
7
|
MediaQueryFactory,
|
|
8
8
|
getDynamicStylesClassName,
|
|
9
9
|
getDynamicStylesCss,
|
|
10
|
+
initializeDynamicStyles,
|
|
10
11
|
keyframes,
|
|
11
12
|
media,
|
|
12
13
|
mergeFactories,
|
package/css/keyframes.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-C54MOrPg.cjs");
|
|
4
4
|
const toHash = require("../to-hash-C05Y906F.cjs");
|
|
5
5
|
const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
|
|
6
6
|
const modifyKeyframes = async (params = {}) => {
|
package/css/keyframes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as parseAndJoinStyles } from "../parse-styles-
|
|
1
|
+
import { p as parseAndJoinStyles } from "../parse-styles-CLMTHo2H.js";
|
|
2
2
|
import { t as toHash } from "../to-hash-DAN2LcHK.js";
|
|
3
3
|
const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
|
|
4
4
|
const modifyKeyframes = async (params = {}) => {
|
package/generators/index.cjs
CHANGED
|
@@ -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-DB5aQwC_.cjs");
|
|
4
4
|
const dashCase = require("../dash-case-DIwKaYgE.cjs");
|
|
5
5
|
class StyledGenerator extends classNameGenerator.StylesGenerator {
|
|
6
6
|
constructor(tagName, _params) {
|
package/generators/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StylesGenerator } from "../class-name-generator-
|
|
2
|
-
import { C } from "../class-name-generator-
|
|
1
|
+
import { S as StylesGenerator } from "../class-name-generator-CMWY5KTJ.js";
|
|
2
|
+
import { C } from "../class-name-generator-CMWY5KTJ.js";
|
|
3
3
|
import { d as dashCase } from "../dash-case-DblXvymC.js";
|
|
4
4
|
class StyledGenerator extends StylesGenerator {
|
|
5
5
|
constructor(tagName, _params) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const classNameGenerator = require("../class-name-generator-
|
|
3
|
+
const classNameGenerator = require("../class-name-generator-DB5aQwC_.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-CMWY5KTJ.js";
|
|
2
2
|
const classNameInstance = (params) => {
|
|
3
3
|
const generator = new ClassNameGenerator(params);
|
|
4
4
|
const createClass = (classNameStr) => {
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
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-refactor-add-additional-paths-to-config-cache.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -63,6 +63,10 @@
|
|
|
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
|
+
},
|
|
66
70
|
"./factories": {
|
|
67
71
|
"import": "./factories/index.js",
|
|
68
72
|
"require": "./factories/index.cjs"
|