@salty-css/core 0.0.1-alpha.31 → 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/.saltyrc.schema.json +48 -0
- package/README.md +469 -26
- package/bin/index.cjs +3 -1
- package/bin/index.js +2 -2
- package/bin/main.cjs +449 -8
- package/bin/main.js +427 -135
- package/cache/resolve-dynamic-config-cache.cjs +13 -0
- package/cache/resolve-dynamic-config-cache.d.ts +1 -0
- package/cache/resolve-dynamic-config-cache.js +13 -0
- package/compiler/as-class.cjs +674 -0
- package/compiler/as-class.d.ts +52 -0
- package/compiler/as-class.js +657 -0
- package/compiler/get-files.cjs +25 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/get-files.js +25 -0
- package/compiler/get-function-range.cjs +22 -0
- package/compiler/get-function-range.d.ts +1 -0
- package/compiler/get-function-range.js +22 -0
- package/compiler/helpers.cjs +25 -0
- package/compiler/helpers.d.ts +5 -0
- package/compiler/helpers.js +24 -0
- package/compiler/index.cjs +668 -11
- package/compiler/index.d.ts +22 -11
- package/compiler/index.js +630 -153
- package/config/define-config.d.ts +1 -1
- package/config/index.cjs +16 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +14 -2
- package/css/index.cjs +12 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +10 -2
- package/css/keyframes.cjs +49 -0
- package/css/keyframes.d.ts +22 -0
- package/css/keyframes.js +49 -0
- package/css/media.cjs +93 -0
- package/css/media.d.ts +87 -0
- package/css/media.js +93 -0
- package/css/merge.cjs +15 -0
- package/css/merge.d.ts +7 -0
- package/css/merge.js +15 -0
- package/css/token.cjs +4 -0
- package/css/token.d.ts +1 -0
- package/css/token.js +4 -0
- package/define-templates-CVhhgPnd.js +60 -0
- package/define-templates-Deq1aCbN.cjs +59 -0
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-media-query.d.ts +8 -0
- package/factories/define-templates.d.ts +27 -0
- package/factories/define-variables.d.ts +12 -0
- package/factories/index.cjs +37 -0
- package/factories/index.d.ts +4 -0
- package/factories/index.js +37 -0
- package/generators/class-name-generator.d.ts +7 -0
- package/generators/index.cjs +125 -0
- package/generators/index.d.ts +2 -0
- package/generators/index.js +125 -0
- package/generators/styled-generator.d.ts +20 -0
- package/generators/styles-generator.d.ts +22 -0
- package/helpers/color.d.ts +18 -0
- package/helpers/index.cjs +53 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +53 -0
- package/helpers/viewport-clamp.d.ts +9 -0
- package/index-ByR0nfaf.cjs +4 -0
- package/index-DKz1QXqs.js +4 -0
- package/package.json +70 -6
- package/parse-styles-CS97_e4S.js +232 -0
- package/parse-styles-gRr_iCy7.cjs +231 -0
- package/parsers/index.cjs +57 -0
- package/parsers/index.d.ts +5 -0
- package/parsers/index.js +58 -0
- package/parsers/parse-modifiers.d.ts +3 -0
- package/parsers/parse-styles.d.ts +13 -0
- package/parsers/parse-templates.d.ts +4 -0
- package/parsers/parse-tokens.d.ts +3 -0
- package/parsers/parser-types.d.ts +8 -0
- package/parsers/property-name-check.d.ts +1 -0
- package/parsers/unit-check.d.ts +7 -0
- package/pascal-case-By_l58S-.cjs +7 -0
- package/pascal-case-F3Usi5Wf.js +8 -0
- package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
- package/react-styled-file-U02jek-B.cjs +11 -0
- package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
- package/react-vanilla-file-D9px70iK.js +18 -0
- package/salty-reset-D1VR51zL.js +83 -0
- package/salty-reset-zWMaTt2Q.cjs +83 -0
- package/salty.config-DjosWdPw.js +4 -0
- package/salty.config-cqavVm2t.cjs +4 -0
- package/server/index.cjs +4 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +4 -0
- package/server/should-restart.d.ts +1 -0
- package/should-restart-5jI-bzz0.js +18 -0
- package/should-restart-DoaGoD5T.cjs +17 -0
- package/templates/salty-reset.d.ts +2 -0
- package/to-hash-DSoCPs8D.js +33 -0
- package/to-hash-DT2ImSPA.cjs +32 -0
- package/types/cli-types.d.ts +10 -0
- package/types/config-types.d.ts +85 -0
- package/types/index.d.ts +57 -23
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +13 -1
- package/util/index.js +10 -8
- package/util/module-type.d.ts +1 -0
- package/viewport-clamp-CEmzmcSj.cjs +10 -0
- package/viewport-clamp-K553uXu3.js +11 -0
- package/config/config-types.d.ts +0 -59
- package/dash-case-DKzpenwY.cjs +0 -1
- package/dash-case-DMQMcCO6.js +0 -19
- package/generator/index.cjs +0 -1
- package/generator/index.d.ts +0 -1
- package/generator/index.js +0 -61
- package/generator/parse-modifiers.d.ts +0 -3
- package/generator/parse-styles.d.ts +0 -2
- package/generator/parse-templates.d.ts +0 -2
- package/generator/parse-tokens.d.ts +0 -2
- package/generator/parser-types.d.ts +0 -4
- package/generator/style-generator.d.ts +0 -28
- package/index-84Wroia-.cjs +0 -1
- package/index-D_732b92.js +0 -4
- package/parse-templates-D4p3pgQR.js +0 -92
- package/parse-templates-W0YfTmOT.cjs +0 -8
- package/pascal-case-BQpR5PdN.js +0 -6
- package/pascal-case-iWoaJWwT.cjs +0 -1
- package/react-styled-file-Dkubsz-U.cjs +0 -8
- package/salty.config-BupieCfE.cjs +0 -6
- package/salty.config-D9ANEDiH.js +0 -9
package/parsers/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
const parseTemplates = async (obj, path = []) => {
|
|
5
|
+
if (!obj) return "";
|
|
6
|
+
const classes = [];
|
|
7
|
+
const levelStyles = {};
|
|
8
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
9
|
+
if (typeof value === "function") ;
|
|
10
|
+
else if (value && typeof value === "object") {
|
|
11
|
+
const _key = key.trim();
|
|
12
|
+
const result = await parseTemplates(value, [...path, _key]);
|
|
13
|
+
classes.push(result);
|
|
14
|
+
} else {
|
|
15
|
+
levelStyles[key] = value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (Object.keys(levelStyles).length) {
|
|
19
|
+
const className = path.map(dashCase).join("-");
|
|
20
|
+
const hashClass = "t_" + toHash(className, 4);
|
|
21
|
+
const result = await parseAndJoinStyles(levelStyles, `.${className}, .${hashClass}`);
|
|
22
|
+
classes.push(result);
|
|
23
|
+
}
|
|
24
|
+
return classes.join("\n");
|
|
25
|
+
};
|
|
26
|
+
const getTemplateKeys = (templates) => {
|
|
27
|
+
return Object.keys(templates);
|
|
28
|
+
};
|
|
29
|
+
const getTemplateTypes = (templates) => {
|
|
30
|
+
if (!templates) return {};
|
|
31
|
+
return Object.entries(templates).reduce((acc, [key, value]) => {
|
|
32
|
+
if (typeof value === "function") {
|
|
33
|
+
acc[key] = "any";
|
|
34
|
+
} else if (typeof value === "object")
|
|
35
|
+
acc[key] = getTemplateTokens(value).map((val) => `"${val}"`).join(" | ");
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
};
|
|
39
|
+
const getTemplateTokens = (templates, parent = "", templateTokens = /* @__PURE__ */ new Set()) => {
|
|
40
|
+
if (!templates) return [];
|
|
41
|
+
Object.entries(templates).forEach(([key, value]) => {
|
|
42
|
+
const keyValue = parent ? `${parent}.${key}` : key;
|
|
43
|
+
if (typeof value === "object") return getTemplateTokens(value, keyValue, templateTokens);
|
|
44
|
+
return templateTokens.add(parent);
|
|
45
|
+
});
|
|
46
|
+
return [...templateTokens];
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
getTemplateKeys,
|
|
50
|
+
getTemplateTokens,
|
|
51
|
+
getTemplateTypes,
|
|
52
|
+
parseAndJoinStyles,
|
|
53
|
+
c as parseStyles,
|
|
54
|
+
parseTemplates,
|
|
55
|
+
b as parseValueModifiers,
|
|
56
|
+
d as parseValueTokens,
|
|
57
|
+
a as parseVariableTokens
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CachedConfig, SaltyConfig } from '../types/config-types';
|
|
2
|
+
/**
|
|
3
|
+
* Transform styles object to css string with or without scope
|
|
4
|
+
* @param styles CSS as JS object
|
|
5
|
+
* @param currentScope Scope of the styles, for class names full path with dot separator is required
|
|
6
|
+
* @param config Salty config object to allow use of templates and media queries etc.
|
|
7
|
+
* @param omitTemplates If true, static templates will be ignored
|
|
8
|
+
* @returns CSS strings that can be injected to the .css file or used inside of styles tag
|
|
9
|
+
* - First item is the main class with all the styles
|
|
10
|
+
* - Rest of the items are child selectors or media queries etc.
|
|
11
|
+
*/
|
|
12
|
+
export declare const parseStyles: <T extends object>(styles?: T, currentScope?: string, config?: (SaltyConfig & CachedConfig) | CachedConfig | undefined, omitTemplates?: boolean) => Promise<string[]>;
|
|
13
|
+
export declare const parseAndJoinStyles: <T extends object>(styles: T, currentClass: string, config?: (SaltyConfig & CachedConfig) | undefined, omitTemplates?: boolean) => Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const parseTemplates: <T extends object>(obj: T, path?: PropertyKey[]) => Promise<string>;
|
|
2
|
+
export declare const getTemplateKeys: <T extends object>(templates: T) => string[];
|
|
3
|
+
export declare const getTemplateTypes: <T extends object>(templates: T) => Record<string, string>;
|
|
4
|
+
export declare const getTemplateTokens: <T extends object>(templates: T, parent?: string, templateTokens?: Set<string>) => string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ValueParserReturnValue {
|
|
2
|
+
transformed: string;
|
|
3
|
+
additionalCss?: object[];
|
|
4
|
+
}
|
|
5
|
+
type StyleValueModifierFunctionReturnValue = undefined | ValueParserReturnValue;
|
|
6
|
+
export type SyncronousStyleValueModifierFunction = (current: unknown) => StyleValueModifierFunctionReturnValue;
|
|
7
|
+
export type StyleValueModifierFunction = (current: string) => Promise<StyleValueModifierFunctionReturnValue> | StyleValueModifierFunctionReturnValue;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const propertyNameCheck: (key: string) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SaltyConfig } from '../config';
|
|
2
|
+
/**
|
|
3
|
+
* Add unit to a number value based on property name
|
|
4
|
+
* @param key - The property name
|
|
5
|
+
* @param value - The value to add unit to
|
|
6
|
+
*/
|
|
7
|
+
export declare const addUnit: (key: string, value: string | number, config?: SaltyConfig) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function pascalCase(str) {
|
|
3
|
+
if (!str) return "";
|
|
4
|
+
if (typeof str !== "string") return pascalCase(String(str));
|
|
5
|
+
return str.replace(/\s/g, "-").replace(/[-_]([a-z0-9])/g, (g) => g[1].toUpperCase()).replace(/^[a-z]/, (g) => g.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
exports.pascalCase = pascalCase;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function pascalCase(str) {
|
|
2
|
+
if (!str) return "";
|
|
3
|
+
if (typeof str !== "string") return pascalCase(String(str));
|
|
4
|
+
return str.replace(/\s/g, "-").replace(/[-_]([a-z0-9])/g, (g) => g[1].toUpperCase()).replace(/^[a-z]/, (g) => g.toUpperCase());
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
pascalCase as p
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const reactStyledFile = `import { styled } from "@salty-css/react/styled";
|
|
2
2
|
|
|
3
3
|
export const <%- name %> = styled('<%- tag %>', {
|
|
4
4
|
<% if(className) { %>className: '<%- className %>',<% } %>
|
|
@@ -7,5 +7,5 @@ export const <%- name %> = styled('<%- tag %>', {
|
|
|
7
7
|
}
|
|
8
8
|
})`;
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
reactStyledFile as default
|
|
11
11
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactStyledFile = `import { styled } from "@salty-css/react/styled";
|
|
4
|
+
|
|
5
|
+
export const <%- name %> = styled('<%- tag %>', {
|
|
6
|
+
<% if(className) { %>className: '<%- className %>',<% } %>
|
|
7
|
+
base: {
|
|
8
|
+
// Add your styles here
|
|
9
|
+
}
|
|
10
|
+
})`;
|
|
11
|
+
exports.default = reactStyledFile;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactVanillaFile = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
|
4
|
+
|
|
5
|
+
interface <%- componentName %>Props {
|
|
6
|
+
text?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
|
10
|
+
return (
|
|
11
|
+
<<%- styledComponentName %>>
|
|
12
|
+
{text}
|
|
13
|
+
</<%- styledComponentName %>>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default <%- componentName %>;`;
|
|
18
|
+
exports.default = reactVanillaFile;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const reactVanillaFile = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
|
|
2
|
+
|
|
3
|
+
interface <%- componentName %>Props {
|
|
4
|
+
text?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
|
|
8
|
+
return (
|
|
9
|
+
<<%- styledComponentName %>>
|
|
10
|
+
{text}
|
|
11
|
+
</<%- styledComponentName %>>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default <%- componentName %>;`;
|
|
16
|
+
export {
|
|
17
|
+
reactVanillaFile as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
};
|
|
11
|
+
const readPackageJsonModule = async (dirname) => {
|
|
12
|
+
const packageJsonContent = await getPackageJson(dirname);
|
|
13
|
+
if (!packageJsonContent) return void 0;
|
|
14
|
+
return packageJsonContent.type;
|
|
15
|
+
};
|
|
16
|
+
let cachedModuleType;
|
|
17
|
+
const detectCurrentModuleType = async (dirname) => {
|
|
18
|
+
if (cachedModuleType) return cachedModuleType;
|
|
19
|
+
const packageJsonModule = await readPackageJsonModule(dirname);
|
|
20
|
+
if (packageJsonModule === "module") cachedModuleType = "esm";
|
|
21
|
+
else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
|
|
22
|
+
else if (import.meta.url.endsWith(".cjs")) cachedModuleType = "cjs";
|
|
23
|
+
return cachedModuleType || "esm";
|
|
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 winston = require("winston");
|
|
3
|
+
const compiler_getFiles = require("./compiler/get-files.cjs");
|
|
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
|
+
};
|
|
13
|
+
const readPackageJsonModule = async (dirname) => {
|
|
14
|
+
const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
|
|
15
|
+
if (!packageJsonContent) return void 0;
|
|
16
|
+
return packageJsonContent.type;
|
|
17
|
+
};
|
|
18
|
+
let cachedModuleType;
|
|
19
|
+
const detectCurrentModuleType = async (dirname) => {
|
|
20
|
+
if (cachedModuleType) return cachedModuleType;
|
|
21
|
+
const packageJsonModule = await readPackageJsonModule(dirname);
|
|
22
|
+
if (packageJsonModule === "module") cachedModuleType = "esm";
|
|
23
|
+
else if (packageJsonModule === "commonjs") cachedModuleType = "cjs";
|
|
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";
|
|
25
|
+
return cachedModuleType || "esm";
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const salty_config = "import { defineConfig } from '@salty-css/core/config';\n\nexport const config = defineConfig({\n // Add your custom config here\n externalModules: ['react', 'react-dom']\n});\n";
|
|
4
|
+
exports.default = salty_config;
|
package/server/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './should-restart';
|
package/server/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const checkShouldRestart: (filename: string) => Promise<boolean>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { isSaltyFile } from "./compiler/index.js";
|
|
3
|
+
const checkShouldRestart = async (filename) => {
|
|
4
|
+
if (!filename) return false;
|
|
5
|
+
if (filename.includes("node_modules")) return false;
|
|
6
|
+
if (filename.includes("saltygen")) return false;
|
|
7
|
+
const isConfig = filename.includes("salty.config");
|
|
8
|
+
if (isConfig) return true;
|
|
9
|
+
const isSalty = isSaltyFile(filename);
|
|
10
|
+
if (!isSalty) return false;
|
|
11
|
+
const contents = await readFile(filename, "utf-8");
|
|
12
|
+
if (/.+define[A-Z]\w+/.test(contents)) return true;
|
|
13
|
+
if (/.+keyframes\(.+/.test(contents)) return true;
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
checkShouldRestart as c
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const promises = require("fs/promises");
|
|
3
|
+
const compiler_index = require("./compiler/index.cjs");
|
|
4
|
+
const checkShouldRestart = async (filename) => {
|
|
5
|
+
if (!filename) return false;
|
|
6
|
+
if (filename.includes("node_modules")) return false;
|
|
7
|
+
if (filename.includes("saltygen")) return false;
|
|
8
|
+
const isConfig = filename.includes("salty.config");
|
|
9
|
+
if (isConfig) return true;
|
|
10
|
+
const isSalty = compiler_index.isSaltyFile(filename);
|
|
11
|
+
if (!isSalty) return false;
|
|
12
|
+
const contents = await promises.readFile(filename, "utf-8");
|
|
13
|
+
if (/.+define[A-Z]\w+/.test(contents)) return true;
|
|
14
|
+
if (/.+keyframes\(.+/.test(contents)) return true;
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
exports.checkShouldRestart = checkShouldRestart;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
const toAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
9
|
+
const toAlphabeticName = (code, length) => {
|
|
10
|
+
let name = "";
|
|
11
|
+
let x;
|
|
12
|
+
for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toAlphabeticChar(x % 52) + name;
|
|
13
|
+
name = toAlphabeticChar(x % 52) + name;
|
|
14
|
+
if (name.length < length) {
|
|
15
|
+
name = name.padStart(length, "a");
|
|
16
|
+
} else if (name.length > length) {
|
|
17
|
+
name = name.slice(-length);
|
|
18
|
+
}
|
|
19
|
+
return name;
|
|
20
|
+
};
|
|
21
|
+
const toPhash = (h, x) => {
|
|
22
|
+
let i = x.length;
|
|
23
|
+
while (i) h = h * 33 ^ x.charCodeAt(--i);
|
|
24
|
+
return h;
|
|
25
|
+
};
|
|
26
|
+
const toHash = (value, length = 5) => {
|
|
27
|
+
const numericHash = toPhash(5381, JSON.stringify(value)) >>> 0;
|
|
28
|
+
return toAlphabeticName(numericHash, length);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
dashCase as d,
|
|
32
|
+
toHash as t
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
const toAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
10
|
+
const toAlphabeticName = (code, length) => {
|
|
11
|
+
let name = "";
|
|
12
|
+
let x;
|
|
13
|
+
for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toAlphabeticChar(x % 52) + name;
|
|
14
|
+
name = toAlphabeticChar(x % 52) + name;
|
|
15
|
+
if (name.length < length) {
|
|
16
|
+
name = name.padStart(length, "a");
|
|
17
|
+
} else if (name.length > length) {
|
|
18
|
+
name = name.slice(-length);
|
|
19
|
+
}
|
|
20
|
+
return name;
|
|
21
|
+
};
|
|
22
|
+
const toPhash = (h, x) => {
|
|
23
|
+
let i = x.length;
|
|
24
|
+
while (i) h = h * 33 ^ x.charCodeAt(--i);
|
|
25
|
+
return h;
|
|
26
|
+
};
|
|
27
|
+
const toHash = (value, length = 5) => {
|
|
28
|
+
const numericHash = toPhash(5381, JSON.stringify(value)) >>> 0;
|
|
29
|
+
return toAlphabeticName(numericHash, length);
|
|
30
|
+
};
|
|
31
|
+
exports.dashCase = dashCase;
|
|
32
|
+
exports.toHash = toHash;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { BaseStyles, CssStyles, MediaQueryStyles } from '../types';
|
|
2
|
+
import { OrString } from '../types/util-types';
|
|
3
|
+
export type GlobalStyles = Record<string, BaseStyles>;
|
|
4
|
+
export type CssVariableTokensObject = Record<string, unknown>;
|
|
5
|
+
export interface CssResponsiveVariables {
|
|
6
|
+
[key: string]: CssVariableTokensObject;
|
|
7
|
+
}
|
|
8
|
+
export interface CssConditionalVariables {
|
|
9
|
+
[key: PropertyKey]: {
|
|
10
|
+
[key: PropertyKey]: CssVariableTokensObject;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface SaltyVariables {
|
|
14
|
+
responsive?: CssResponsiveVariables;
|
|
15
|
+
conditional?: CssConditionalVariables;
|
|
16
|
+
[key: string]: undefined | string | number | CssVariableTokensObject;
|
|
17
|
+
}
|
|
18
|
+
type CssTemplate = MediaQueryStyles | CssStyles | {
|
|
19
|
+
[key: PropertyKey]: CssTemplate;
|
|
20
|
+
};
|
|
21
|
+
export interface CssTemplateObject {
|
|
22
|
+
[key: PropertyKey]: CssTemplate;
|
|
23
|
+
}
|
|
24
|
+
export interface CssTemplateFunction {
|
|
25
|
+
(value: any): CssTemplate;
|
|
26
|
+
}
|
|
27
|
+
export interface CssTemplates {
|
|
28
|
+
[key: PropertyKey]: CssTemplateObject | CssTemplateFunction;
|
|
29
|
+
}
|
|
30
|
+
export interface CssModifier {
|
|
31
|
+
pattern: RegExp;
|
|
32
|
+
transform: (regexMatch: string) => {
|
|
33
|
+
css?: CssStyles;
|
|
34
|
+
value: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export type CssModifiers = Record<string, CssModifier>;
|
|
38
|
+
export interface SaltyConfig {
|
|
39
|
+
/**
|
|
40
|
+
* The import strategy to use when importing css files.
|
|
41
|
+
* - `root` will import the css file from the root of the project.
|
|
42
|
+
* - `component` will import the css file from the component's directory.
|
|
43
|
+
*/
|
|
44
|
+
importStrategy?: 'root' | 'component';
|
|
45
|
+
/**
|
|
46
|
+
* Base level variables that can be used in all styles as they are applied globally to :root.
|
|
47
|
+
@param responsive Variables that are defined for different media queries.
|
|
48
|
+
@param conditional Variables that are defined for different parent selectors (classes or data attributes).
|
|
49
|
+
*/
|
|
50
|
+
variables?: SaltyVariables;
|
|
51
|
+
/**
|
|
52
|
+
* The global styles that are imported in the root of the project.
|
|
53
|
+
*/
|
|
54
|
+
reset?: 'default' | 'none' | GlobalStyles;
|
|
55
|
+
/**
|
|
56
|
+
* The global styles that are imported in the root of the project.
|
|
57
|
+
*/
|
|
58
|
+
global?: GlobalStyles;
|
|
59
|
+
/**
|
|
60
|
+
* The templates that can be used in styles to create reusable css.
|
|
61
|
+
*/
|
|
62
|
+
templates?: CssTemplates;
|
|
63
|
+
/**
|
|
64
|
+
* The modifiers that can transform css values.
|
|
65
|
+
*/
|
|
66
|
+
modifiers?: CssModifiers;
|
|
67
|
+
/**
|
|
68
|
+
* Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
|
|
69
|
+
*/
|
|
70
|
+
externalModules?: ('react' | 'react-dom' | OrString)[];
|
|
71
|
+
/**
|
|
72
|
+
* default unit for px based properties when providing a number value. Default is 'px'.
|
|
73
|
+
*/
|
|
74
|
+
defaultUnit?: 'px' | 'rem' | 'em' | 'vh' | 'vw' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'ex' | 'fr' | 'percent' | `viewport-clamp:${number}` | OrString;
|
|
75
|
+
}
|
|
76
|
+
export interface CachedConfig {
|
|
77
|
+
templates: CssTemplates;
|
|
78
|
+
staticVariables: Record<string, any>;
|
|
79
|
+
mediaQueries: Record<string, string>;
|
|
80
|
+
modifiers?: CssModifiers;
|
|
81
|
+
templatePaths: {
|
|
82
|
+
[key: string]: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export {};
|