@salty-css/core 0.0.1-alpha.303 → 0.0.1-alpha.304

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.
@@ -9,13 +9,11 @@ const fs = require("fs");
9
9
  const promises = require("fs/promises");
10
10
  const parseStyles = require("../parse-styles-D-p_guRO.cjs");
11
11
  const parsers_index = require("../parsers/index.cjs");
12
- const compiler_getFiles = require("./get-files.cjs");
13
- const winston = require("winston");
12
+ const saltyReset = require("../salty-reset-wJhVT2ys.cjs");
14
13
  const css_merge = require("../css/merge.cjs");
15
14
  const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
16
15
  const compiler_getFunctionRange = require("./get-function-range.cjs");
17
16
  const compiler_helpers = require("./helpers.cjs");
18
- var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
19
17
  function _interopNamespaceDefault(e) {
20
18
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
21
19
  if (e) {
@@ -33,80 +31,6 @@ function _interopNamespaceDefault(e) {
33
31
  return Object.freeze(n);
34
32
  }
35
33
  const esbuild__namespace = /* @__PURE__ */ _interopNamespaceDefault(esbuild);
36
- const readPackageJsonModule = async (dirname) => {
37
- const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
38
- if (!packageJsonContent) return void 0;
39
- return packageJsonContent.type;
40
- };
41
- let cachedModuleType;
42
- const detectCurrentModuleType = async (dirname) => {
43
- if (cachedModuleType) return cachedModuleType;
44
- const packageJsonModule = await readPackageJsonModule(dirname);
45
- if (packageJsonModule === "module") cachedModuleType = "esm";
46
- else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
47
- else if ((typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/index.cjs", document.baseURI).href).endsWith(".cjs")) cachedModuleType = "cjs";
48
- return cachedModuleType || "esm";
49
- };
50
- const logger = winston.createLogger({
51
- level: "debug",
52
- format: winston.format.combine(winston.format.colorize(), winston.format.cli()),
53
- transports: [new winston.transports.Console({})]
54
- });
55
- const logError = (message) => {
56
- logger.error(message);
57
- };
58
- function dotCase(str) {
59
- if (!str) return "";
60
- if (typeof str !== "string") return dotCase(String(str));
61
- return str.replace(/[^\d\w]/g, ".");
62
- }
63
- const saltyReset = {
64
- /** Set box model to border-box */
65
- "*, *::before, *::after": {
66
- boxSizing: "border-box"
67
- },
68
- /** Remove default margin and padding */
69
- "*": {
70
- margin: 0
71
- },
72
- /** Remove adjust font properties */
73
- html: {
74
- lineHeight: 1.15,
75
- textSizeAdjust: "100%",
76
- WebkitFontSmoothing: "antialiased"
77
- },
78
- /** Make media elements responsive */
79
- "img, picture, video, canvas, svg": {
80
- display: "block",
81
- maxWidth: "100%"
82
- },
83
- /** Avoid overflow of text */
84
- "p, h1, h2, h3, h4, h5, h6": {
85
- overflowWrap: "break-word"
86
- },
87
- /** Improve text wrapping */
88
- p: {
89
- textWrap: "pretty"
90
- },
91
- "h1, h2, h3, h4, h5, h6": {
92
- textWrap: "balance"
93
- },
94
- /** Improve link color */
95
- a: {
96
- color: "currentColor"
97
- },
98
- /** Improve button line height */
99
- button: {
100
- lineHeight: "1em",
101
- color: "currentColor"
102
- },
103
- /** Improve form elements */
104
- "input, optgroup, select, textarea": {
105
- fontFamily: "inherit",
106
- fontSize: "100%",
107
- lineHeight: "1.15em"
108
- }
109
- };
110
34
  const cache = {
111
35
  externalModules: [],
112
36
  rcFile: void 0,
@@ -152,7 +76,7 @@ const generateConfig = async (dirname) => {
152
76
  const destDir = await getDestDir(dirname);
153
77
  const coreConfigPath = path.join(dirname, (rcProject == null ? void 0 : rcProject.configDir) || "", "salty.config.ts");
154
78
  const coreConfigDest = path.join(destDir, "salty.config.js");
155
- await detectCurrentModuleType(dirname);
79
+ await saltyReset.detectCurrentModuleType(dirname);
156
80
  const externalModules = getExternalModules(coreConfigPath);
157
81
  await esbuild__namespace.build({
158
82
  entryPoints: [coreConfigPath],
@@ -207,7 +131,7 @@ const generateConfigStyles = async (dirname, configFiles) => {
207
131
  if (value2 instanceof Promise) return await parseVariable(await value2);
208
132
  if (typeof value2 === "function") return await parseVariable(await value2());
209
133
  if (typeof value2 === "object") return await parseVariables(value2, [...path2, key]);
210
- const dottedKey = dotCase(key);
134
+ const dottedKey = saltyReset.dotCase(key);
211
135
  const dashedKey = dashCase.dashCase(key);
212
136
  const tsName = [...path2, dottedKey].join(".");
213
137
  variableTokens.add(`"${tsName}"`);
@@ -277,7 +201,7 @@ const generateConfigStyles = async (dirname, configFiles) => {
277
201
  const getResetStyles = () => {
278
202
  if (config.reset === "none") return {};
279
203
  if (typeof config.reset === "object") return config.reset;
280
- return saltyReset;
204
+ return saltyReset.saltyReset;
281
205
  };
282
206
  const resetStyles = getResetStyles();
283
207
  const resetStylesString = await parseStyles.parseAndJoinStyles(resetStyles, "");
@@ -354,7 +278,7 @@ const compileSaltyFile = async (dirname, sourceFilePath, outputDirectory) => {
354
278
  const rcProject = await getRCProjectConfig(dirname);
355
279
  const coreConfigPath = path.join(dirname, (rcProject == null ? void 0 : rcProject.configDir) || "", "salty.config.ts");
356
280
  const externalModules = getExternalModules(coreConfigPath);
357
- await detectCurrentModuleType(dirname);
281
+ await saltyReset.detectCurrentModuleType(dirname);
358
282
  await esbuild__namespace.build({
359
283
  stdin: {
360
284
  contents: currentFile,
@@ -419,8 +343,8 @@ const isProduction = () => {
419
343
  const generateCss = async (dirname, prod = isProduction(), clean = true) => {
420
344
  try {
421
345
  const start = Date.now();
422
- if (prod) logger.info("Generating CSS in production mode! 🔥");
423
- else logger.info("Generating CSS in development mode! 🚀");
346
+ if (prod) saltyReset.logger.info("Generating CSS in production mode! 🔥");
347
+ else saltyReset.logger.info("Generating CSS in development mode! 🚀");
424
348
  const globalCssFiles = [];
425
349
  const cssFiles = [];
426
350
  const destDir = await getDestDir(dirname);
@@ -592,7 +516,7 @@ ${css}
592
516
  const end = Date.now();
593
517
  const time = end - start;
594
518
  const emoji = time < 200 ? "🔥" : time < 500 ? "🚀" : time < 1e3 ? "🎉" : time < 2e3 ? "🚗" : time < 5e3 ? "🤔" : "🥴";
595
- logger.info(`Generated CSS in ${time}ms! ${emoji}`);
519
+ saltyReset.logger.info(`Generated CSS in ${time}ms! ${emoji}`);
596
520
  } catch (e) {
597
521
  console.error(e);
598
522
  }
@@ -739,8 +663,6 @@ exports.generateFile = generateFile;
739
663
  exports.getConfig = getConfig;
740
664
  exports.getDestDir = getDestDir;
741
665
  exports.isSaltyFile = isSaltyFile;
742
- exports.logError = logError;
743
- exports.logger = logger;
744
666
  exports.minimizeFile = minimizeFile;
745
667
  exports.saltyFileExtensions = saltyFileExtensions;
746
668
  exports.saltyFileRegExp = saltyFileRegExp;
package/compiler/index.js CHANGED
@@ -7,86 +7,11 @@ import { existsSync, mkdirSync, statSync, readdirSync, readFileSync, writeFileSy
7
7
  import { readFile } from "fs/promises";
8
8
  import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-CqBQc3eQ.js";
9
9
  import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
10
- import { getPackageJson } from "./get-files.js";
11
- import { createLogger, transports, format } from "winston";
10
+ import { l as logger, d as detectCurrentModuleType, s as saltyReset, a as dotCase } from "../salty-reset-StBt2yzJ.js";
12
11
  import { mergeObjects, mergeFactories } from "../css/merge.js";
13
12
  import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
14
13
  import { getFunctionRange } from "./get-function-range.js";
15
14
  import { resolveExportValue, getCorePackageRoot } from "./helpers.js";
16
- const readPackageJsonModule = async (dirname) => {
17
- const packageJsonContent = await getPackageJson(dirname);
18
- if (!packageJsonContent) return void 0;
19
- return packageJsonContent.type;
20
- };
21
- let cachedModuleType;
22
- const detectCurrentModuleType = async (dirname) => {
23
- if (cachedModuleType) return cachedModuleType;
24
- const packageJsonModule = await readPackageJsonModule(dirname);
25
- if (packageJsonModule === "module") cachedModuleType = "esm";
26
- else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
27
- else if (import.meta.url.endsWith(".cjs")) cachedModuleType = "cjs";
28
- return cachedModuleType || "esm";
29
- };
30
- const logger = createLogger({
31
- level: "debug",
32
- format: format.combine(format.colorize(), format.cli()),
33
- transports: [new transports.Console({})]
34
- });
35
- const logError = (message) => {
36
- logger.error(message);
37
- };
38
- function dotCase(str) {
39
- if (!str) return "";
40
- if (typeof str !== "string") return dotCase(String(str));
41
- return str.replace(/[^\d\w]/g, ".");
42
- }
43
- const saltyReset = {
44
- /** Set box model to border-box */
45
- "*, *::before, *::after": {
46
- boxSizing: "border-box"
47
- },
48
- /** Remove default margin and padding */
49
- "*": {
50
- margin: 0
51
- },
52
- /** Remove adjust font properties */
53
- html: {
54
- lineHeight: 1.15,
55
- textSizeAdjust: "100%",
56
- WebkitFontSmoothing: "antialiased"
57
- },
58
- /** Make media elements responsive */
59
- "img, picture, video, canvas, svg": {
60
- display: "block",
61
- maxWidth: "100%"
62
- },
63
- /** Avoid overflow of text */
64
- "p, h1, h2, h3, h4, h5, h6": {
65
- overflowWrap: "break-word"
66
- },
67
- /** Improve text wrapping */
68
- p: {
69
- textWrap: "pretty"
70
- },
71
- "h1, h2, h3, h4, h5, h6": {
72
- textWrap: "balance"
73
- },
74
- /** Improve link color */
75
- a: {
76
- color: "currentColor"
77
- },
78
- /** Improve button line height */
79
- button: {
80
- lineHeight: "1em",
81
- color: "currentColor"
82
- },
83
- /** Improve form elements */
84
- "input, optgroup, select, textarea": {
85
- fontFamily: "inherit",
86
- fontSize: "100%",
87
- lineHeight: "1.15em"
88
- }
89
- };
90
15
  const cache = {
91
16
  externalModules: [],
92
17
  rcFile: void 0,
@@ -713,7 +638,6 @@ ${current}`;
713
638
  return void 0;
714
639
  };
715
640
  export {
716
- logError as a,
717
641
  compileSaltyFile,
718
642
  generateConfigStyles,
719
643
  generateCss,
@@ -721,7 +645,6 @@ export {
721
645
  getConfig,
722
646
  getDestDir,
723
647
  isSaltyFile,
724
- logger as l,
725
648
  minimizeFile,
726
649
  saltyFileExtensions,
727
650
  saltyFileRegExp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.303",
3
+ "version": "0.0.1-alpha.304",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -51,6 +51,10 @@
51
51
  "import": "./compiler/index.js",
52
52
  "require": "./compiler/index.cjs"
53
53
  },
54
+ "./compiler/as-class": {
55
+ "import": "./compiler/as-class.js",
56
+ "require": "./compiler/as-class.cjs"
57
+ },
54
58
  "./compiler/get-files": {
55
59
  "import": "./compiler/get-files.js",
56
60
  "require": "./compiler/get-files.cjs"
@@ -0,0 +1,83 @@
1
+ import { getPackageJson } from "./compiler/get-files.js";
2
+ import { createLogger, transports, format } from "winston";
3
+ const readPackageJsonModule = async (dirname) => {
4
+ const packageJsonContent = await getPackageJson(dirname);
5
+ if (!packageJsonContent) return void 0;
6
+ return packageJsonContent.type;
7
+ };
8
+ let cachedModuleType;
9
+ const detectCurrentModuleType = async (dirname) => {
10
+ if (cachedModuleType) return cachedModuleType;
11
+ const packageJsonModule = await readPackageJsonModule(dirname);
12
+ if (packageJsonModule === "module") cachedModuleType = "esm";
13
+ else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
14
+ else if (import.meta.url.endsWith(".cjs")) cachedModuleType = "cjs";
15
+ return cachedModuleType || "esm";
16
+ };
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
+ function dotCase(str) {
26
+ if (!str) return "";
27
+ if (typeof str !== "string") return dotCase(String(str));
28
+ return str.replace(/[^\d\w]/g, ".");
29
+ }
30
+ const saltyReset = {
31
+ /** Set box model to border-box */
32
+ "*, *::before, *::after": {
33
+ boxSizing: "border-box"
34
+ },
35
+ /** Remove default margin and padding */
36
+ "*": {
37
+ margin: 0
38
+ },
39
+ /** Remove adjust font properties */
40
+ html: {
41
+ lineHeight: 1.15,
42
+ textSizeAdjust: "100%",
43
+ WebkitFontSmoothing: "antialiased"
44
+ },
45
+ /** Make media elements responsive */
46
+ "img, picture, video, canvas, svg": {
47
+ display: "block",
48
+ maxWidth: "100%"
49
+ },
50
+ /** Avoid overflow of text */
51
+ "p, h1, h2, h3, h4, h5, h6": {
52
+ overflowWrap: "break-word"
53
+ },
54
+ /** Improve text wrapping */
55
+ p: {
56
+ textWrap: "pretty"
57
+ },
58
+ "h1, h2, h3, h4, h5, h6": {
59
+ textWrap: "balance"
60
+ },
61
+ /** Improve link color */
62
+ a: {
63
+ color: "currentColor"
64
+ },
65
+ /** Improve button line height */
66
+ button: {
67
+ lineHeight: "1em",
68
+ color: "currentColor"
69
+ },
70
+ /** Improve form elements */
71
+ "input, optgroup, select, textarea": {
72
+ fontFamily: "inherit",
73
+ fontSize: "100%",
74
+ lineHeight: "1.15em"
75
+ }
76
+ };
77
+ export {
78
+ dotCase as a,
79
+ logError as b,
80
+ detectCurrentModuleType as d,
81
+ logger as l,
82
+ saltyReset as s
83
+ };
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ const compiler_getFiles = require("./compiler/get-files.cjs");
3
+ const winston = require("winston");
4
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
5
+ const readPackageJsonModule = async (dirname) => {
6
+ const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
7
+ if (!packageJsonContent) return void 0;
8
+ return packageJsonContent.type;
9
+ };
10
+ let cachedModuleType;
11
+ const detectCurrentModuleType = async (dirname) => {
12
+ if (cachedModuleType) return cachedModuleType;
13
+ const packageJsonModule = await readPackageJsonModule(dirname);
14
+ if (packageJsonModule === "module") cachedModuleType = "esm";
15
+ 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-wJhVT2ys.cjs", document.baseURI).href).endsWith(".cjs")) cachedModuleType = "cjs";
17
+ return cachedModuleType || "esm";
18
+ };
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
+ function dotCase(str) {
28
+ if (!str) return "";
29
+ if (typeof str !== "string") return dotCase(String(str));
30
+ return str.replace(/[^\d\w]/g, ".");
31
+ }
32
+ const saltyReset = {
33
+ /** Set box model to border-box */
34
+ "*, *::before, *::after": {
35
+ boxSizing: "border-box"
36
+ },
37
+ /** Remove default margin and padding */
38
+ "*": {
39
+ margin: 0
40
+ },
41
+ /** Remove adjust font properties */
42
+ html: {
43
+ lineHeight: 1.15,
44
+ textSizeAdjust: "100%",
45
+ WebkitFontSmoothing: "antialiased"
46
+ },
47
+ /** Make media elements responsive */
48
+ "img, picture, video, canvas, svg": {
49
+ display: "block",
50
+ maxWidth: "100%"
51
+ },
52
+ /** Avoid overflow of text */
53
+ "p, h1, h2, h3, h4, h5, h6": {
54
+ overflowWrap: "break-word"
55
+ },
56
+ /** Improve text wrapping */
57
+ p: {
58
+ textWrap: "pretty"
59
+ },
60
+ "h1, h2, h3, h4, h5, h6": {
61
+ textWrap: "balance"
62
+ },
63
+ /** Improve link color */
64
+ a: {
65
+ color: "currentColor"
66
+ },
67
+ /** Improve button line height */
68
+ button: {
69
+ lineHeight: "1em",
70
+ color: "currentColor"
71
+ },
72
+ /** Improve form elements */
73
+ "input, optgroup, select, textarea": {
74
+ fontFamily: "inherit",
75
+ fontSize: "100%",
76
+ lineHeight: "1.15em"
77
+ }
78
+ };
79
+ exports.detectCurrentModuleType = detectCurrentModuleType;
80
+ exports.dotCase = dotCase;
81
+ exports.logError = logError;
82
+ exports.logger = logger;
83
+ exports.saltyReset = saltyReset;