@salty-css/core 0.0.1-alpha.309 → 0.0.1-alpha.310
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/main.cjs +10 -7
- package/bin/main.js +9 -6
- package/compiler/as-class.cjs +14 -14
- package/compiler/as-class.js +3 -3
- package/compiler/index.cjs +14 -14
- package/compiler/index.js +5 -5
- package/css/keyframes.cjs +3 -3
- package/css/keyframes.js +2 -2
- package/generators/index.cjs +6 -6
- package/generators/index.js +2 -2
- package/package.json +1 -1
- package/{parse-styles-CqBQc3eQ.js → parse-styles-CS97_e4S.js} +1 -1
- package/{parse-styles-D-p_guRO.cjs → parse-styles-gRr_iCy7.cjs} +4 -4
- package/parsers/index.cjs +4 -4
- package/parsers/index.js +3 -3
- package/{salty-reset-wJhVT2ys.cjs → salty-reset-zWMaTt2Q.cjs} +10 -10
- package/util/index.cjs +3 -3
- package/util/index.js +1 -1
- package/{salty-reset-StBt2yzJ.js → salty-reset-D1VR51zL.js} +9 -9
- package/{dash-case-NMk0mXyT.js → to-hash-DSoCPs8D.js} +7 -7
- package/{dash-case-Cz8wwE9a.cjs → to-hash-DT2ImSPA.cjs} +7 -7
package/bin/main.cjs
CHANGED
|
@@ -5,12 +5,13 @@ const fs = require("fs");
|
|
|
5
5
|
const promises = require("fs/promises");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const ejs = require("ejs");
|
|
8
|
-
const compiler_index = require("../compiler/index.cjs");
|
|
9
8
|
const pascalCase = require("../pascal-case-By_l58S-.cjs");
|
|
10
|
-
const saltyReset = require("../salty-reset-
|
|
9
|
+
const saltyReset = require("../salty-reset-zWMaTt2Q.cjs");
|
|
11
10
|
const child_process = require("child_process");
|
|
12
11
|
const ora = require("ora");
|
|
13
12
|
const shouldRestart = require("../should-restart-DoaGoD5T.cjs");
|
|
13
|
+
const compiler_asClass = require("../compiler/as-class.cjs");
|
|
14
|
+
const compiler_helpers = require("../compiler/helpers.cjs");
|
|
14
15
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
15
16
|
const execAsync = (command) => {
|
|
16
17
|
return new Promise((resolve, reject) => {
|
|
@@ -104,6 +105,7 @@ async function main() {
|
|
|
104
105
|
const rootDir = process.cwd();
|
|
105
106
|
const projectDir = resolveProjectDir(dir);
|
|
106
107
|
const projectFiles = await Promise.all([readTemplate("salty.config.ts"), readTemplate("saltygen/index.css")]);
|
|
108
|
+
const saltyCompiler = new compiler_asClass.SaltyCompiler(projectDir);
|
|
107
109
|
await promises.mkdir(projectDir, { recursive: true });
|
|
108
110
|
const writeFiles = projectFiles.map(async ({ fileName, content }) => {
|
|
109
111
|
const filePath = path.join(projectDir, fileName);
|
|
@@ -309,7 +311,7 @@ ${eslintConfigContent}`;
|
|
|
309
311
|
});
|
|
310
312
|
await updatePackageJson(packageJsonContent);
|
|
311
313
|
saltyReset.logger.info("Running the build to generate initial CSS...");
|
|
312
|
-
await
|
|
314
|
+
await saltyCompiler.generateCss();
|
|
313
315
|
saltyReset.logger.info("🎉 Salty CSS project initialized successfully!");
|
|
314
316
|
saltyReset.logger.info("Next steps:");
|
|
315
317
|
saltyReset.logger.info("1. Configure variables and templates in `salty.config.ts`");
|
|
@@ -323,16 +325,17 @@ ${eslintConfigContent}`;
|
|
|
323
325
|
const { dir = _dir, watch } = this.opts();
|
|
324
326
|
if (!dir) return saltyReset.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
|
325
327
|
const projectDir = resolveProjectDir(dir);
|
|
326
|
-
|
|
328
|
+
const saltyCompiler = new compiler_asClass.SaltyCompiler(projectDir);
|
|
329
|
+
await saltyCompiler.generateCss();
|
|
327
330
|
if (watch) {
|
|
328
331
|
saltyReset.logger.info("Watching for changes in the project directory...");
|
|
329
332
|
fs.watch(projectDir, { recursive: true }, async (event, filePath) => {
|
|
330
333
|
const shouldRestart$1 = await shouldRestart.checkShouldRestart(filePath);
|
|
331
334
|
if (shouldRestart$1) {
|
|
332
|
-
await
|
|
335
|
+
await saltyCompiler.generateCss(false);
|
|
333
336
|
} else {
|
|
334
|
-
const saltyFile =
|
|
335
|
-
if (saltyFile) await
|
|
337
|
+
const saltyFile = compiler_helpers.isSaltyFile(filePath);
|
|
338
|
+
if (saltyFile) await saltyCompiler.generateFile(filePath);
|
|
336
339
|
}
|
|
337
340
|
});
|
|
338
341
|
}
|
package/bin/main.js
CHANGED
|
@@ -3,12 +3,13 @@ import { existsSync, watch } from "fs";
|
|
|
3
3
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import { join, relative, parse, format } from "path";
|
|
5
5
|
import { render } from "ejs";
|
|
6
|
-
import { generateCss, isSaltyFile, generateFile } from "../compiler/index.js";
|
|
7
6
|
import { p as pascalCase } from "../pascal-case-F3Usi5Wf.js";
|
|
8
|
-
import { l as logger, b as logError } from "../salty-reset-
|
|
7
|
+
import { l as logger, b as logError } from "../salty-reset-D1VR51zL.js";
|
|
9
8
|
import { exec } from "child_process";
|
|
10
9
|
import ora from "ora";
|
|
11
10
|
import { c as checkShouldRestart } from "../should-restart-5jI-bzz0.js";
|
|
11
|
+
import { SaltyCompiler } from "../compiler/as-class.js";
|
|
12
|
+
import { isSaltyFile } from "../compiler/helpers.js";
|
|
12
13
|
const execAsync = (command) => {
|
|
13
14
|
return new Promise((resolve, reject) => {
|
|
14
15
|
exec(command, (error) => {
|
|
@@ -101,6 +102,7 @@ async function main() {
|
|
|
101
102
|
const rootDir = process.cwd();
|
|
102
103
|
const projectDir = resolveProjectDir(dir);
|
|
103
104
|
const projectFiles = await Promise.all([readTemplate("salty.config.ts"), readTemplate("saltygen/index.css")]);
|
|
105
|
+
const saltyCompiler = new SaltyCompiler(projectDir);
|
|
104
106
|
await mkdir(projectDir, { recursive: true });
|
|
105
107
|
const writeFiles = projectFiles.map(async ({ fileName, content }) => {
|
|
106
108
|
const filePath = join(projectDir, fileName);
|
|
@@ -306,7 +308,7 @@ ${eslintConfigContent}`;
|
|
|
306
308
|
});
|
|
307
309
|
await updatePackageJson(packageJsonContent);
|
|
308
310
|
logger.info("Running the build to generate initial CSS...");
|
|
309
|
-
await generateCss(
|
|
311
|
+
await saltyCompiler.generateCss();
|
|
310
312
|
logger.info("🎉 Salty CSS project initialized successfully!");
|
|
311
313
|
logger.info("Next steps:");
|
|
312
314
|
logger.info("1. Configure variables and templates in `salty.config.ts`");
|
|
@@ -320,16 +322,17 @@ ${eslintConfigContent}`;
|
|
|
320
322
|
const { dir = _dir, watch: watch$1 } = this.opts();
|
|
321
323
|
if (!dir) return logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
|
322
324
|
const projectDir = resolveProjectDir(dir);
|
|
323
|
-
|
|
325
|
+
const saltyCompiler = new SaltyCompiler(projectDir);
|
|
326
|
+
await saltyCompiler.generateCss();
|
|
324
327
|
if (watch$1) {
|
|
325
328
|
logger.info("Watching for changes in the project directory...");
|
|
326
329
|
watch(projectDir, { recursive: true }, async (event, filePath) => {
|
|
327
330
|
const shouldRestart = await checkShouldRestart(filePath);
|
|
328
331
|
if (shouldRestart) {
|
|
329
|
-
await generateCss(
|
|
332
|
+
await saltyCompiler.generateCss(false);
|
|
330
333
|
} else {
|
|
331
334
|
const saltyFile = isSaltyFile(filePath);
|
|
332
|
-
if (saltyFile) await generateFile(
|
|
335
|
+
if (saltyFile) await saltyCompiler.generateFile(filePath);
|
|
333
336
|
}
|
|
334
337
|
});
|
|
335
338
|
}
|
package/compiler/as-class.cjs
CHANGED
|
@@ -5,14 +5,14 @@ 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 saltyReset = require("../salty-reset-
|
|
8
|
+
const saltyReset = require("../salty-reset-zWMaTt2Q.cjs");
|
|
9
9
|
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
13
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
14
|
-
const
|
|
15
|
-
const parseStyles = require("../parse-styles-
|
|
14
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
15
|
+
const parseStyles = require("../parse-styles-gRr_iCy7.cjs");
|
|
16
16
|
const css_merge = require("../css/merge.cjs");
|
|
17
17
|
const parsers_index = require("../parsers/index.cjs");
|
|
18
18
|
const console = require("console");
|
|
@@ -264,9 +264,9 @@ ${currentFile}`;
|
|
|
264
264
|
if (config.importStrategy === "component") {
|
|
265
265
|
Object.entries(localCssFiles).forEach(([src, localCssFile]) => {
|
|
266
266
|
const cssContent2 = localCssFile.map((file) => `@import url('./${file}');`).join("\n");
|
|
267
|
-
const hashName =
|
|
267
|
+
const hashName = toHash.toHash(src, 6);
|
|
268
268
|
const parsedPath = path.parse(src);
|
|
269
|
-
const dasherized =
|
|
269
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
270
270
|
const cssFile2 = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
271
271
|
fs.writeFileSync(cssFile2, cssContent2 || `/* Empty file */`);
|
|
272
272
|
});
|
|
@@ -295,7 +295,7 @@ ${otherGlobalCssFiles}`;
|
|
|
295
295
|
var _a;
|
|
296
296
|
const filepath = path.join(destDir, "css", file);
|
|
297
297
|
const css = fs.readFileSync(filepath, "utf8");
|
|
298
|
-
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file)) == null ? void 0 : _a.at(1)) ||
|
|
298
|
+
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file)) == null ? void 0 : _a.at(1)) || toHash.toHash(filepath, 6);
|
|
299
299
|
if (layerAcc.includes(filepathHash)) return layerAcc;
|
|
300
300
|
return `${layerAcc}
|
|
301
301
|
/*start:${filepathHash}-${file}*/
|
|
@@ -357,10 +357,10 @@ ${css}
|
|
|
357
357
|
if (typeof value2 === "function") return await parseVariable(await value2());
|
|
358
358
|
if (typeof value2 === "object") return await parseVariables(value2, [...path2, key]);
|
|
359
359
|
const dottedKey = saltyReset.dotCase(key);
|
|
360
|
-
const dashedKey =
|
|
360
|
+
const dashedKey = toHash.dashCase(key);
|
|
361
361
|
const tsName = [...path2, dottedKey].join(".");
|
|
362
362
|
variableTokens.add(`"${tsName}"`);
|
|
363
|
-
const cssName = [...path2.map(
|
|
363
|
+
const cssName = [...path2.map(toHash.dashCase), dashedKey].join("-");
|
|
364
364
|
const result = parseStyles.parseVariableTokens(value2);
|
|
365
365
|
if (!result) return `--${cssName}: ${value2};`;
|
|
366
366
|
return `--${cssName}: ${result.transformed};`;
|
|
@@ -463,7 +463,7 @@ ${css}
|
|
|
463
463
|
fs.writeFileSync(configCacheSecondaryPath, JSON.stringify(configCacheContent, null, 2));
|
|
464
464
|
});
|
|
465
465
|
__publicField(this, "compileSaltyFile", async (sourceFilePath, outputDirectory) => {
|
|
466
|
-
const hashedName =
|
|
466
|
+
const hashedName = toHash.toHash(sourceFilePath);
|
|
467
467
|
const tempDir = path.join(outputDirectory, "./temp");
|
|
468
468
|
if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir);
|
|
469
469
|
const parsed = path.parse(sourceFilePath);
|
|
@@ -543,9 +543,9 @@ ${css}
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
if (config.importStrategy === "component") {
|
|
546
|
-
const fileHash =
|
|
546
|
+
const fileHash = toHash.toHash(file, 6);
|
|
547
547
|
const parsed = path.parse(file);
|
|
548
|
-
const dasherized =
|
|
548
|
+
const dasherized = toHash.dashCase(parsed.name);
|
|
549
549
|
const cssFileName = `f_${dasherized}-${fileHash}.css`;
|
|
550
550
|
current = `import '../../saltygen/css/${cssFileName}';
|
|
551
551
|
${current}`;
|
|
@@ -614,7 +614,7 @@ ${current}`;
|
|
|
614
614
|
val.forEach((file2) => {
|
|
615
615
|
var _a;
|
|
616
616
|
const filepath = path.join(destDir, "css", file2);
|
|
617
|
-
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file2)) == null ? void 0 : _a.at(1)) ||
|
|
617
|
+
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file2)) == null ? void 0 : _a.at(1)) || toHash.toHash(filepath, 6);
|
|
618
618
|
const found = currentLayerFileContent.includes(filepathHash);
|
|
619
619
|
if (!found) {
|
|
620
620
|
const css = fs.readFileSync(filepath, "utf8");
|
|
@@ -631,9 +631,9 @@ ${newContent}
|
|
|
631
631
|
});
|
|
632
632
|
} else {
|
|
633
633
|
const cssContent = cssFiles.flat().map((file2) => `@import url('./${file2}');`).join("\n");
|
|
634
|
-
const hashName =
|
|
634
|
+
const hashName = toHash.toHash(file, 6);
|
|
635
635
|
const parsedPath = path.parse(file);
|
|
636
|
-
const dasherized =
|
|
636
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
637
637
|
const cssFile = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
638
638
|
fs.writeFileSync(cssFile, cssContent || `/* Empty file */`);
|
|
639
639
|
}
|
package/compiler/as-class.js
CHANGED
|
@@ -3,14 +3,14 @@ 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 { d as detectCurrentModuleType, l as logger, s as saltyReset, a as dotCase } from "../salty-reset-
|
|
6
|
+
import { d as detectCurrentModuleType, l as logger, s as saltyReset, a as dotCase } from "../salty-reset-D1VR51zL.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";
|
|
10
10
|
import { isSaltyFile, resolveExportValue, getCorePackageRoot, saltyFileExtensions } from "./helpers.js";
|
|
11
11
|
import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
|
|
12
|
-
import { t as toHash, d as dashCase } from "../
|
|
13
|
-
import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-
|
|
12
|
+
import { t as toHash, d as dashCase } from "../to-hash-DSoCPs8D.js";
|
|
13
|
+
import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-CS97_e4S.js";
|
|
14
14
|
import { mergeObjects, mergeFactories } from "../css/merge.js";
|
|
15
15
|
import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
|
|
16
16
|
import console from "console";
|
package/compiler/index.cjs
CHANGED
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const esbuild = require("esbuild");
|
|
4
4
|
const child_process = require("child_process");
|
|
5
5
|
const vm = require("vm");
|
|
6
|
-
const
|
|
6
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const fs = require("fs");
|
|
9
9
|
const promises = require("fs/promises");
|
|
10
|
-
const parseStyles = require("../parse-styles-
|
|
10
|
+
const parseStyles = require("../parse-styles-gRr_iCy7.cjs");
|
|
11
11
|
const parsers_index = require("../parsers/index.cjs");
|
|
12
|
-
const saltyReset = require("../salty-reset-
|
|
12
|
+
const saltyReset = require("../salty-reset-zWMaTt2Q.cjs");
|
|
13
13
|
const css_merge = require("../css/merge.cjs");
|
|
14
14
|
const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
|
|
15
15
|
const compiler_getFunctionRange = require("./get-function-range.cjs");
|
|
@@ -132,10 +132,10 @@ const generateConfigStyles = async (dirname, configFiles) => {
|
|
|
132
132
|
if (typeof value2 === "function") return await parseVariable(await value2());
|
|
133
133
|
if (typeof value2 === "object") return await parseVariables(value2, [...path2, key]);
|
|
134
134
|
const dottedKey = saltyReset.dotCase(key);
|
|
135
|
-
const dashedKey =
|
|
135
|
+
const dashedKey = toHash.dashCase(key);
|
|
136
136
|
const tsName = [...path2, dottedKey].join(".");
|
|
137
137
|
variableTokens.add(`"${tsName}"`);
|
|
138
|
-
const cssName = [...path2.map(
|
|
138
|
+
const cssName = [...path2.map(toHash.dashCase), dashedKey].join("-");
|
|
139
139
|
const result = parseStyles.parseVariableTokens(value2);
|
|
140
140
|
if (!result) return `--${cssName}: ${value2};`;
|
|
141
141
|
return `--${cssName}: ${result.transformed};`;
|
|
@@ -267,7 +267,7 @@ ${currentFile}`;
|
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
const compileSaltyFile = async (dirname, sourceFilePath, outputDirectory) => {
|
|
270
|
-
const hashedName =
|
|
270
|
+
const hashedName = toHash.toHash(sourceFilePath);
|
|
271
271
|
const tempDir = path.join(outputDirectory, "./temp");
|
|
272
272
|
if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir);
|
|
273
273
|
const parsed = path.parse(sourceFilePath);
|
|
@@ -463,9 +463,9 @@ const generateCss = async (dirname, prod = isProduction(), clean = true) => {
|
|
|
463
463
|
if (config.importStrategy === "component") {
|
|
464
464
|
Object.entries(localCssFiles).forEach(([src, localCssFile]) => {
|
|
465
465
|
const cssContent2 = localCssFile.map((file) => `@import url('./${file}');`).join("\n");
|
|
466
|
-
const hashName =
|
|
466
|
+
const hashName = toHash.toHash(src, 6);
|
|
467
467
|
const parsedPath = path.parse(src);
|
|
468
|
-
const dasherized =
|
|
468
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
469
469
|
const cssFile2 = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
470
470
|
fs.writeFileSync(cssFile2, cssContent2 || `/* Empty file */`);
|
|
471
471
|
});
|
|
@@ -494,7 +494,7 @@ ${otherGlobalCssFiles}`;
|
|
|
494
494
|
var _a;
|
|
495
495
|
const filepath = path.join(destDir, "css", file);
|
|
496
496
|
const css = fs.readFileSync(filepath, "utf8");
|
|
497
|
-
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file)) == null ? void 0 : _a.at(1)) ||
|
|
497
|
+
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file)) == null ? void 0 : _a.at(1)) || toHash.toHash(filepath, 6);
|
|
498
498
|
if (layerAcc.includes(filepathHash)) return layerAcc;
|
|
499
499
|
return `${layerAcc}
|
|
500
500
|
/*start:${filepathHash}-${file}*/
|
|
@@ -575,7 +575,7 @@ const generateFile = async (dirname, file, prod = isProduction()) => {
|
|
|
575
575
|
val.forEach((file2) => {
|
|
576
576
|
var _a;
|
|
577
577
|
const filepath = path.join(destDir, "css", file2);
|
|
578
|
-
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file2)) == null ? void 0 : _a.at(1)) ||
|
|
578
|
+
const filepathHash = ((_a = /.*-([^-]+)-\d+.css/.exec(file2)) == null ? void 0 : _a.at(1)) || toHash.toHash(filepath, 6);
|
|
579
579
|
const found = currentLayerFileContent.includes(filepathHash);
|
|
580
580
|
if (!found) {
|
|
581
581
|
const css = fs.readFileSync(filepath, "utf8");
|
|
@@ -592,9 +592,9 @@ ${newContent}
|
|
|
592
592
|
});
|
|
593
593
|
} else {
|
|
594
594
|
const cssContent = cssFiles.flat().map((file2) => `@import url('./${file2}');`).join("\n");
|
|
595
|
-
const hashName =
|
|
595
|
+
const hashName = toHash.toHash(file, 6);
|
|
596
596
|
const parsedPath = path.parse(file);
|
|
597
|
-
const dasherized =
|
|
597
|
+
const dasherized = toHash.dashCase(parsedPath.name);
|
|
598
598
|
const cssFile = path.join(destDir, `css/f_${dasherized}-${hashName}.css`);
|
|
599
599
|
fs.writeFileSync(cssFile, cssContent || `/* Empty file */`);
|
|
600
600
|
}
|
|
@@ -639,9 +639,9 @@ const minimizeFile = async (dirname, file, prod = isProduction()) => {
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
if (config.importStrategy === "component") {
|
|
642
|
-
const fileHash =
|
|
642
|
+
const fileHash = toHash.toHash(file, 6);
|
|
643
643
|
const parsed = path.parse(file);
|
|
644
|
-
const dasherized =
|
|
644
|
+
const dasherized = toHash.dashCase(parsed.name);
|
|
645
645
|
const cssFileName = `f_${dasherized}-${fileHash}.css`;
|
|
646
646
|
current = `import '../../saltygen/css/${cssFileName}';
|
|
647
647
|
${current}`;
|
package/compiler/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as esbuild from "esbuild";
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
3
|
import { Script } from "vm";
|
|
4
|
-
import { t as toHash, d as dashCase } from "../
|
|
4
|
+
import { t as toHash, d as dashCase } from "../to-hash-DSoCPs8D.js";
|
|
5
5
|
import { join, parse } from "path";
|
|
6
|
-
import { existsSync, mkdirSync, statSync, readdirSync
|
|
6
|
+
import { writeFileSync, existsSync, mkdirSync, readFileSync, statSync, readdirSync } from "fs";
|
|
7
7
|
import { readFile } from "fs/promises";
|
|
8
|
-
import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-
|
|
8
|
+
import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-CS97_e4S.js";
|
|
9
9
|
import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
|
|
10
|
-
import {
|
|
10
|
+
import { d as detectCurrentModuleType, l as logger, s as saltyReset, a as dotCase } from "../salty-reset-D1VR51zL.js";
|
|
11
11
|
import { mergeObjects, mergeFactories } from "../css/merge.js";
|
|
12
12
|
import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
|
|
13
13
|
import { getFunctionRange } from "./get-function-range.js";
|
|
14
|
-
import {
|
|
14
|
+
import { getCorePackageRoot, resolveExportValue } from "./helpers.js";
|
|
15
15
|
const cache = {
|
|
16
16
|
externalModules: [],
|
|
17
17
|
rcFile: void 0,
|
package/css/keyframes.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const parseStyles = require("../parse-styles-
|
|
4
|
-
const
|
|
3
|
+
const parseStyles = require("../parse-styles-gRr_iCy7.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
|
-
const animationName = _name ||
|
|
7
|
+
const animationName = _name || toHash.toHash(keyframes2);
|
|
8
8
|
const fn = async () => {
|
|
9
9
|
const {
|
|
10
10
|
duration = "500ms",
|
package/css/keyframes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as parseAndJoinStyles } from "../parse-styles-
|
|
2
|
-
import { t as toHash } from "../
|
|
1
|
+
import { p as parseAndJoinStyles } from "../parse-styles-CS97_e4S.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/generators/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@ 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 parseStyles = require("../parse-styles-
|
|
7
|
-
const
|
|
6
|
+
const parseStyles = require("../parse-styles-gRr_iCy7.cjs");
|
|
7
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
8
8
|
class StylesGenerator {
|
|
9
9
|
constructor(params) {
|
|
10
10
|
__publicField(this, "buildContext", {});
|
|
@@ -18,7 +18,7 @@ class StylesGenerator {
|
|
|
18
18
|
}
|
|
19
19
|
get hash() {
|
|
20
20
|
const { base, variants, compoundVariants, anyOfVariants } = this.params;
|
|
21
|
-
return
|
|
21
|
+
return toHash.toHash({ base, variants, compoundVariants, anyOfVariants });
|
|
22
22
|
}
|
|
23
23
|
get cssClassName() {
|
|
24
24
|
return this.hash;
|
|
@@ -35,7 +35,7 @@ class StylesGenerator {
|
|
|
35
35
|
get cssFileName() {
|
|
36
36
|
const { callerName } = this.buildContext;
|
|
37
37
|
if (callerName) {
|
|
38
|
-
const dasherized =
|
|
38
|
+
const dasherized = toHash.dashCase(callerName);
|
|
39
39
|
return `cl_${dasherized}-${this.hash}.css`;
|
|
40
40
|
}
|
|
41
41
|
return `${this.hash}.css`;
|
|
@@ -51,7 +51,7 @@ class StylesGenerator {
|
|
|
51
51
|
if (!(config == null ? void 0 : config.templates) || !this.params.base || this.priority > 0) return [];
|
|
52
52
|
const templateKeys = Object.keys(config.templates);
|
|
53
53
|
return Object.entries(this.params.base).reduce((acc, [key, value]) => {
|
|
54
|
-
if (templateKeys.includes(key)) acc.push("t_" +
|
|
54
|
+
if (templateKeys.includes(key)) acc.push("t_" + toHash.toHash(toHash.dashCase(`${key}-${value}`), 4));
|
|
55
55
|
return acc;
|
|
56
56
|
}, []);
|
|
57
57
|
}
|
|
@@ -103,7 +103,7 @@ class StyledGenerator extends StylesGenerator {
|
|
|
103
103
|
if (matches) {
|
|
104
104
|
matches.forEach((match) => {
|
|
105
105
|
const value = match.replace(/\{(?:-)?props\.([^}]+)\}/gi, "$1");
|
|
106
|
-
const dashed =
|
|
106
|
+
const dashed = toHash.dashCase(value);
|
|
107
107
|
if (value) propValueKeys.add(dashed);
|
|
108
108
|
});
|
|
109
109
|
}
|
package/generators/index.js
CHANGED
|
@@ -1,8 +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 } from "../parse-styles-
|
|
5
|
-
import { t as toHash, d as dashCase } from "../
|
|
4
|
+
import { p as parseAndJoinStyles } from "../parse-styles-CS97_e4S.js";
|
|
5
|
+
import { t as toHash, d as dashCase } from "../to-hash-DSoCPs8D.js";
|
|
6
6
|
class StylesGenerator {
|
|
7
7
|
constructor(params) {
|
|
8
8
|
__publicField(this, "buildContext", {});
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -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].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})`;
|
|
@@ -77,8 +77,8 @@ const addUnit = (key, value, config) => {
|
|
|
77
77
|
const vendorPrefixes = ["Webkit", "Moz", "ms", "O"];
|
|
78
78
|
const propertyNameCheck = (key) => {
|
|
79
79
|
if (key.startsWith("-")) return key;
|
|
80
|
-
if (vendorPrefixes.some((prefix) => key.startsWith(prefix))) return `-${
|
|
81
|
-
return
|
|
80
|
+
if (vendorPrefixes.some((prefix) => key.startsWith(prefix))) return `-${toHash.dashCase(key)}`;
|
|
81
|
+
return toHash.dashCase(key);
|
|
82
82
|
};
|
|
83
83
|
const parseStyles = async (styles, currentScope = "", config, omitTemplates = false) => {
|
|
84
84
|
if (!styles) throw new Error("No styles provided to parseStyles function!");
|
package/parsers/index.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
|
|
3
|
+
const parseStyles = require("../parse-styles-gRr_iCy7.cjs");
|
|
4
|
+
const toHash = require("../to-hash-DT2ImSPA.cjs");
|
|
5
5
|
const parseTemplates = async (obj, path = []) => {
|
|
6
6
|
if (!obj) return "";
|
|
7
7
|
const classes = [];
|
|
@@ -17,8 +17,8 @@ const parseTemplates = async (obj, path = []) => {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
if (Object.keys(levelStyles).length) {
|
|
20
|
-
const className = path.map(
|
|
21
|
-
const hashClass = "t_" +
|
|
20
|
+
const className = path.map(toHash.dashCase).join("-");
|
|
21
|
+
const hashClass = "t_" + toHash.toHash(className, 4);
|
|
22
22
|
const result = await parseStyles.parseAndJoinStyles(levelStyles, `.${className}, .${hashClass}`);
|
|
23
23
|
classes.push(result);
|
|
24
24
|
}
|
package/parsers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as parseAndJoinStyles } from "../parse-styles-
|
|
2
|
-
import { c, b, d, a } from "../parse-styles-
|
|
3
|
-
import { d as dashCase, t as toHash } from "../
|
|
1
|
+
import { p as parseAndJoinStyles } from "../parse-styles-CS97_e4S.js";
|
|
2
|
+
import { c, b, d, a } from "../parse-styles-CS97_e4S.js";
|
|
3
|
+
import { d as dashCase, t as toHash } from "../to-hash-DSoCPs8D.js";
|
|
4
4
|
const parseTemplates = async (obj, path = []) => {
|
|
5
5
|
if (!obj) return "";
|
|
6
6
|
const classes = [];
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const compiler_getFiles = require("./compiler/get-files.cjs");
|
|
3
2
|
const winston = require("winston");
|
|
3
|
+
const compiler_getFiles = require("./compiler/get-files.cjs");
|
|
4
4
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
5
|
+
const logger = winston.createLogger({
|
|
6
|
+
level: "debug",
|
|
7
|
+
format: winston.format.combine(winston.format.colorize(), winston.format.cli()),
|
|
8
|
+
transports: [new winston.transports.Console({})]
|
|
9
|
+
});
|
|
10
|
+
const logError = (message) => {
|
|
11
|
+
logger.error(message);
|
|
12
|
+
};
|
|
5
13
|
const readPackageJsonModule = async (dirname) => {
|
|
6
14
|
const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
|
|
7
15
|
if (!packageJsonContent) return void 0;
|
|
@@ -13,17 +21,9 @@ const detectCurrentModuleType = async (dirname) => {
|
|
|
13
21
|
const packageJsonModule = await readPackageJsonModule(dirname);
|
|
14
22
|
if (packageJsonModule === "module") cachedModuleType = "esm";
|
|
15
23
|
else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
|
|
16
|
-
else if ((typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("salty-reset-
|
|
24
|
+
else if ((typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("salty-reset-zWMaTt2Q.cjs", document.baseURI).href).endsWith(".cjs")) cachedModuleType = "cjs";
|
|
17
25
|
return cachedModuleType || "esm";
|
|
18
26
|
};
|
|
19
|
-
const logger = winston.createLogger({
|
|
20
|
-
level: "debug",
|
|
21
|
-
format: winston.format.combine(winston.format.colorize(), winston.format.cli()),
|
|
22
|
-
transports: [new winston.transports.Console({})]
|
|
23
|
-
});
|
|
24
|
-
const logError = (message) => {
|
|
25
|
-
logger.error(message);
|
|
26
|
-
};
|
|
27
27
|
function dotCase(str) {
|
|
28
28
|
if (!str) return "";
|
|
29
29
|
if (typeof str !== "string") return dotCase(String(str));
|
package/util/index.cjs
CHANGED
|
@@ -1,13 +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
5
|
function camelCase(str) {
|
|
6
6
|
if (!str) return "";
|
|
7
7
|
if (typeof str !== "string") return camelCase(String(str));
|
|
8
8
|
return str.replace(/\s/g, "-").replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
9
9
|
}
|
|
10
|
-
exports.dashCase =
|
|
11
|
-
exports.toHash =
|
|
10
|
+
exports.dashCase = toHash.dashCase;
|
|
11
|
+
exports.toHash = toHash.toHash;
|
|
12
12
|
exports.pascalCase = pascalCase.pascalCase;
|
|
13
13
|
exports.camelCase = camelCase;
|
package/util/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { getPackageJson } from "./compiler/get-files.js";
|
|
2
1
|
import { createLogger, transports, format } from "winston";
|
|
2
|
+
import { getPackageJson } from "./compiler/get-files.js";
|
|
3
|
+
const logger = createLogger({
|
|
4
|
+
level: "debug",
|
|
5
|
+
format: format.combine(format.colorize(), format.cli()),
|
|
6
|
+
transports: [new transports.Console({})]
|
|
7
|
+
});
|
|
8
|
+
const logError = (message) => {
|
|
9
|
+
logger.error(message);
|
|
10
|
+
};
|
|
3
11
|
const readPackageJsonModule = async (dirname) => {
|
|
4
12
|
const packageJsonContent = await getPackageJson(dirname);
|
|
5
13
|
if (!packageJsonContent) return void 0;
|
|
@@ -14,14 +22,6 @@ const detectCurrentModuleType = async (dirname) => {
|
|
|
14
22
|
else if (import.meta.url.endsWith(".cjs")) cachedModuleType = "cjs";
|
|
15
23
|
return cachedModuleType || "esm";
|
|
16
24
|
};
|
|
17
|
-
const logger = createLogger({
|
|
18
|
-
level: "debug",
|
|
19
|
-
format: format.combine(format.colorize(), format.cli()),
|
|
20
|
-
transports: [new transports.Console({})]
|
|
21
|
-
});
|
|
22
|
-
const logError = (message) => {
|
|
23
|
-
logger.error(message);
|
|
24
|
-
};
|
|
25
25
|
function dotCase(str) {
|
|
26
26
|
if (!str) return "";
|
|
27
27
|
if (typeof str !== "string") return dotCase(String(str));
|
|
@@ -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 = "";
|
|
@@ -20,13 +27,6 @@ const toHash = (value, length = 5) => {
|
|
|
20
27
|
const numericHash = toPhash(5381, JSON.stringify(value)) >>> 0;
|
|
21
28
|
return toAlphabeticName(numericHash, length);
|
|
22
29
|
};
|
|
23
|
-
function dashCase(str) {
|
|
24
|
-
if (!str) return "";
|
|
25
|
-
if (typeof str !== "string") return dashCase(String(str));
|
|
26
|
-
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
27
|
-
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
30
|
export {
|
|
31
31
|
dashCase as d,
|
|
32
32
|
toHash as t
|
|
@@ -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,12 +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
|
};
|
|
24
|
-
function dashCase(str) {
|
|
25
|
-
if (!str) return "";
|
|
26
|
-
if (typeof str !== "string") return dashCase(String(str));
|
|
27
|
-
return str.replace(/[\s.]/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (s, i) => {
|
|
28
|
-
return (i > 0 ? "-" : "") + s.toLowerCase();
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
31
|
exports.dashCase = dashCase;
|
|
32
32
|
exports.toHash = toHash;
|