@salty-css/core 0.0.1-alpha.31 → 0.0.1-alpha.311

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +469 -26
  3. package/bin/index.cjs +3 -1
  4. package/bin/index.js +2 -2
  5. package/bin/main.cjs +448 -8
  6. package/bin/main.js +426 -135
  7. package/cache/resolve-dynamic-config-cache.cjs +13 -0
  8. package/cache/resolve-dynamic-config-cache.d.ts +1 -0
  9. package/cache/resolve-dynamic-config-cache.js +13 -0
  10. package/compiler/as-class.cjs +752 -0
  11. package/compiler/as-class.d.ts +52 -0
  12. package/compiler/as-class.js +734 -0
  13. package/compiler/get-files.cjs +25 -0
  14. package/compiler/get-files.d.ts +3 -0
  15. package/compiler/get-files.js +25 -0
  16. package/compiler/get-function-range.cjs +22 -0
  17. package/compiler/get-function-range.d.ts +1 -0
  18. package/compiler/get-function-range.js +22 -0
  19. package/compiler/helpers.cjs +25 -0
  20. package/compiler/helpers.d.ts +5 -0
  21. package/compiler/helpers.js +24 -0
  22. package/config/define-config.d.ts +1 -1
  23. package/config/index.cjs +16 -1
  24. package/config/index.d.ts +2 -1
  25. package/config/index.js +14 -2
  26. package/css/index.cjs +12 -1
  27. package/css/index.d.ts +4 -1
  28. package/css/index.js +10 -2
  29. package/css/keyframes.cjs +49 -0
  30. package/css/keyframes.d.ts +22 -0
  31. package/css/keyframes.js +49 -0
  32. package/css/media.cjs +93 -0
  33. package/css/media.d.ts +87 -0
  34. package/css/media.js +93 -0
  35. package/css/merge.cjs +15 -0
  36. package/css/merge.d.ts +7 -0
  37. package/css/merge.js +15 -0
  38. package/css/token.cjs +4 -0
  39. package/css/token.d.ts +1 -0
  40. package/css/token.js +4 -0
  41. package/define-templates-CVhhgPnd.js +60 -0
  42. package/define-templates-Deq1aCbN.cjs +59 -0
  43. package/factories/define-global-styles.d.ts +7 -0
  44. package/factories/define-media-query.d.ts +8 -0
  45. package/factories/define-templates.d.ts +27 -0
  46. package/factories/define-variables.d.ts +12 -0
  47. package/factories/index.cjs +37 -0
  48. package/factories/index.d.ts +4 -0
  49. package/factories/index.js +37 -0
  50. package/generators/class-name-generator.d.ts +7 -0
  51. package/generators/index.cjs +125 -0
  52. package/generators/index.d.ts +2 -0
  53. package/generators/index.js +125 -0
  54. package/generators/styled-generator.d.ts +20 -0
  55. package/generators/styles-generator.d.ts +22 -0
  56. package/helpers/color.d.ts +18 -0
  57. package/helpers/index.cjs +53 -0
  58. package/helpers/index.d.ts +2 -0
  59. package/helpers/index.js +53 -0
  60. package/helpers/viewport-clamp.d.ts +9 -0
  61. package/index-ByR0nfaf.cjs +4 -0
  62. package/index-DKz1QXqs.js +4 -0
  63. package/package.json +69 -9
  64. package/parse-styles-CS97_e4S.js +232 -0
  65. package/parse-styles-gRr_iCy7.cjs +231 -0
  66. package/parsers/index.cjs +57 -0
  67. package/parsers/index.d.ts +5 -0
  68. package/parsers/index.js +58 -0
  69. package/parsers/parse-modifiers.d.ts +3 -0
  70. package/parsers/parse-styles.d.ts +13 -0
  71. package/parsers/parse-templates.d.ts +4 -0
  72. package/parsers/parse-tokens.d.ts +3 -0
  73. package/parsers/parser-types.d.ts +8 -0
  74. package/parsers/property-name-check.d.ts +1 -0
  75. package/parsers/unit-check.d.ts +7 -0
  76. package/pascal-case-By_l58S-.cjs +7 -0
  77. package/pascal-case-F3Usi5Wf.js +8 -0
  78. package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
  79. package/react-styled-file-U02jek-B.cjs +11 -0
  80. package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
  81. package/react-vanilla-file-D9px70iK.js +18 -0
  82. package/salty.config-DjosWdPw.js +4 -0
  83. package/salty.config-cqavVm2t.cjs +4 -0
  84. package/server/index.cjs +4 -0
  85. package/server/index.d.ts +1 -0
  86. package/server/index.js +4 -0
  87. package/server/should-restart.d.ts +1 -0
  88. package/should-restart-CQsyHls3.cjs +17 -0
  89. package/should-restart-CXIO0jxY.js +18 -0
  90. package/templates/salty-reset.d.ts +2 -0
  91. package/to-hash-DSoCPs8D.js +33 -0
  92. package/to-hash-DT2ImSPA.cjs +32 -0
  93. package/types/cli-types.d.ts +10 -0
  94. package/types/config-types.d.ts +85 -0
  95. package/types/index.d.ts +57 -23
  96. package/util/dot-case.d.ts +1 -0
  97. package/util/index.cjs +13 -1
  98. package/util/index.js +10 -8
  99. package/util/module-type.d.ts +1 -0
  100. package/viewport-clamp-CEmzmcSj.cjs +10 -0
  101. package/viewport-clamp-K553uXu3.js +11 -0
  102. package/compiler/index.cjs +0 -11
  103. package/compiler/index.d.ts +0 -16
  104. package/compiler/index.js +0 -174
  105. package/config/config-types.d.ts +0 -59
  106. package/dash-case-DKzpenwY.cjs +0 -1
  107. package/dash-case-DMQMcCO6.js +0 -19
  108. package/generator/index.cjs +0 -1
  109. package/generator/index.d.ts +0 -1
  110. package/generator/index.js +0 -61
  111. package/generator/parse-modifiers.d.ts +0 -3
  112. package/generator/parse-styles.d.ts +0 -2
  113. package/generator/parse-templates.d.ts +0 -2
  114. package/generator/parse-tokens.d.ts +0 -2
  115. package/generator/parser-types.d.ts +0 -4
  116. package/generator/style-generator.d.ts +0 -28
  117. package/index-84Wroia-.cjs +0 -1
  118. package/index-D_732b92.js +0 -4
  119. package/parse-templates-D4p3pgQR.js +0 -92
  120. package/parse-templates-W0YfTmOT.cjs +0 -8
  121. package/pascal-case-BQpR5PdN.js +0 -6
  122. package/pascal-case-iWoaJWwT.cjs +0 -1
  123. package/react-styled-file-Dkubsz-U.cjs +0 -8
  124. package/salty.config-BupieCfE.cjs +0 -6
  125. package/salty.config-D9ANEDiH.js +0 -9
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const fs = require("fs");
4
+ const promises = require("fs/promises");
5
+ const path = require("path");
6
+ const getSaltyRcPath = (dirname) => {
7
+ if (!dirname || dirname === "/") throw new Error("Could not find .saltyrc.json file");
8
+ const rcPath = path.join(dirname, ".saltyrc.json");
9
+ if (!fs.existsSync(rcPath)) return getSaltyRcPath(path.join(dirname, ".."));
10
+ return rcPath;
11
+ };
12
+ const getPackageJsonPath = (dirname) => {
13
+ if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
14
+ const packageJsonPath = path.join(dirname, "package.json");
15
+ if (!fs.existsSync(packageJsonPath)) return getPackageJsonPath(path.join(dirname, ".."));
16
+ return packageJsonPath;
17
+ };
18
+ const getPackageJson = async (dirname) => {
19
+ const packageJsonPath = getPackageJsonPath(dirname);
20
+ const packageJsonContent = await promises.readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
21
+ return packageJsonContent;
22
+ };
23
+ exports.getPackageJson = getPackageJson;
24
+ exports.getPackageJsonPath = getPackageJsonPath;
25
+ exports.getSaltyRcPath = getSaltyRcPath;
@@ -0,0 +1,3 @@
1
+ export declare const getSaltyRcPath: (dirname: string) => string;
2
+ export declare const getPackageJsonPath: (dirname: string) => string;
3
+ export declare const getPackageJson: (dirname: string) => Promise<any>;
@@ -0,0 +1,25 @@
1
+ import { existsSync } from "fs";
2
+ import { readFile } from "fs/promises";
3
+ import { join } from "path";
4
+ const getSaltyRcPath = (dirname) => {
5
+ if (!dirname || dirname === "/") throw new Error("Could not find .saltyrc.json file");
6
+ const rcPath = join(dirname, ".saltyrc.json");
7
+ if (!existsSync(rcPath)) return getSaltyRcPath(join(dirname, ".."));
8
+ return rcPath;
9
+ };
10
+ const getPackageJsonPath = (dirname) => {
11
+ if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
12
+ const packageJsonPath = join(dirname, "package.json");
13
+ if (!existsSync(packageJsonPath)) return getPackageJsonPath(join(dirname, ".."));
14
+ return packageJsonPath;
15
+ };
16
+ const getPackageJson = async (dirname) => {
17
+ const packageJsonPath = getPackageJsonPath(dirname);
18
+ const packageJsonContent = await readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
19
+ return packageJsonContent;
20
+ };
21
+ export {
22
+ getPackageJson,
23
+ getPackageJsonPath,
24
+ getSaltyRcPath
25
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const ts = require("typescript");
4
+ const getFunctionRange = (contents, name) => {
5
+ return new Promise((resolve, reject) => {
6
+ const timeout = setTimeout(() => {
7
+ reject(new Error("Timeout"));
8
+ }, 100);
9
+ const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
10
+ function visit(node) {
11
+ if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
12
+ const start = node.getStart();
13
+ const end = node.getEnd();
14
+ clearTimeout(timeout);
15
+ resolve([start, end]);
16
+ }
17
+ node.forEachChild(visit);
18
+ }
19
+ visit(sourceFile);
20
+ });
21
+ };
22
+ exports.getFunctionRange = getFunctionRange;
@@ -0,0 +1 @@
1
+ export declare const getFunctionRange: (contents: string, name: string) => Promise<[number, number]>;
@@ -0,0 +1,22 @@
1
+ import ts from "typescript";
2
+ const getFunctionRange = (contents, name) => {
3
+ return new Promise((resolve, reject) => {
4
+ const timeout = setTimeout(() => {
5
+ reject(new Error("Timeout"));
6
+ }, 100);
7
+ const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
8
+ function visit(node) {
9
+ if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
10
+ const start = node.getStart();
11
+ const end = node.getEnd();
12
+ clearTimeout(timeout);
13
+ resolve([start, end]);
14
+ }
15
+ node.forEachChild(visit);
16
+ }
17
+ visit(sourceFile);
18
+ });
19
+ };
20
+ export {
21
+ getFunctionRange
22
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path = require("path");
4
+ var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
5
+ const getCorePackageRoot = () => {
6
+ let { pathname } = new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/helpers.cjs", document.baseURI).href);
7
+ while (/core\/?(src\/)?$/.test(pathname) === false) {
8
+ pathname = path.join(pathname, "../");
9
+ }
10
+ return pathname;
11
+ };
12
+ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
13
+ if (_level >= maxLevel) return value;
14
+ if (value instanceof Promise) return await resolveExportValue(await value, _level + 1, maxLevel);
15
+ if (typeof value === "function" && "_shouldResolve" in value) return await resolveExportValue(await value(), _level + 1, maxLevel);
16
+ return value;
17
+ };
18
+ const saltyFileExtensions = ["salty", "css", "styles", "styled"];
19
+ const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
20
+ const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
21
+ exports.getCorePackageRoot = getCorePackageRoot;
22
+ exports.isSaltyFile = isSaltyFile;
23
+ exports.resolveExportValue = resolveExportValue;
24
+ exports.saltyFileExtensions = saltyFileExtensions;
25
+ exports.saltyFileRegExp = saltyFileRegExp;
@@ -0,0 +1,5 @@
1
+ export declare const getCorePackageRoot: () => string;
2
+ export declare const resolveExportValue: <T>(value: unknown, maxLevel?: number, _level?: number) => Promise<T>;
3
+ export declare const saltyFileExtensions: string[];
4
+ export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
5
+ export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
@@ -0,0 +1,24 @@
1
+ import { join } from "path";
2
+ const getCorePackageRoot = () => {
3
+ let { pathname } = new URL(import.meta.url);
4
+ while (/core\/?(src\/)?$/.test(pathname) === false) {
5
+ pathname = join(pathname, "../");
6
+ }
7
+ return pathname;
8
+ };
9
+ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
10
+ if (_level >= maxLevel) return value;
11
+ if (value instanceof Promise) return await resolveExportValue(await value, _level + 1, maxLevel);
12
+ if (typeof value === "function" && "_shouldResolve" in value) return await resolveExportValue(await value(), _level + 1, maxLevel);
13
+ return value;
14
+ };
15
+ const saltyFileExtensions = ["salty", "css", "styles", "styled"];
16
+ const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
17
+ const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
18
+ export {
19
+ getCorePackageRoot,
20
+ isSaltyFile,
21
+ resolveExportValue,
22
+ saltyFileExtensions,
23
+ saltyFileRegExp
24
+ };
@@ -1,2 +1,2 @@
1
- import { SaltyConfig } from './config-types';
1
+ import { SaltyConfig } from '../types/config-types';
2
2
  export declare const defineConfig: <T extends SaltyConfig>(config: T) => T;
package/config/index.cjs CHANGED
@@ -1 +1,16 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>e;exports.defineConfig=n;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const factories_index = require("../factories/index.cjs");
4
+ const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
5
+ const defineConfig = (config) => {
6
+ return config;
7
+ };
8
+ exports.GlobalStylesFactory = factories_index.GlobalStylesFactory;
9
+ exports.VariablesFactory = factories_index.VariablesFactory;
10
+ exports.defineGlobalStyles = factories_index.defineGlobalStyles;
11
+ exports.defineMediaQuery = factories_index.defineMediaQuery;
12
+ exports.defineVariables = factories_index.defineVariables;
13
+ exports.TemplateFactory = defineTemplates.TemplateFactory;
14
+ exports.TemplatesFactory = defineTemplates.TemplatesFactory;
15
+ exports.defineTemplates = defineTemplates.defineTemplates;
16
+ exports.defineConfig = defineConfig;
package/config/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from './config-types';
2
1
  export * from './define-config';
2
+ export * from '../factories';
3
+ export * from '../types/config-types';
package/config/index.js CHANGED
@@ -1,4 +1,16 @@
1
- const n = (e) => e;
1
+ import { GlobalStylesFactory, VariablesFactory, defineGlobalStyles, defineMediaQuery, defineVariables } from "../factories/index.js";
2
+ import { T, a, d } from "../define-templates-CVhhgPnd.js";
3
+ const defineConfig = (config) => {
4
+ return config;
5
+ };
2
6
  export {
3
- n as defineConfig
7
+ GlobalStylesFactory,
8
+ T as TemplateFactory,
9
+ a as TemplatesFactory,
10
+ VariablesFactory,
11
+ defineConfig,
12
+ defineGlobalStyles,
13
+ defineMediaQuery,
14
+ d as defineTemplates,
15
+ defineVariables
4
16
  };
package/css/index.cjs CHANGED
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=e=>`{${e}}`;exports.token=t;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const css_keyframes = require("./keyframes.cjs");
4
+ const css_media = require("./media.cjs");
5
+ const css_token = require("./token.cjs");
6
+ const css_merge = require("./merge.cjs");
7
+ exports.keyframes = css_keyframes.keyframes;
8
+ exports.MediaQueryFactory = css_media.MediaQueryFactory;
9
+ exports.media = css_media.media;
10
+ exports.token = css_token.token;
11
+ exports.mergeFactories = css_merge.mergeFactories;
12
+ exports.mergeObjects = css_merge.mergeObjects;
package/css/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export declare const token: <T extends VariableTokens>(token: T) => string;
1
+ export * from './keyframes';
2
+ export * from './media';
3
+ export * from './token';
4
+ export * from './merge';
package/css/index.js CHANGED
@@ -1,4 +1,12 @@
1
- const t = (o) => `{${o}}`;
1
+ import { keyframes } from "./keyframes.js";
2
+ import { MediaQueryFactory, media } from "./media.js";
3
+ import { token } from "./token.js";
4
+ import { mergeFactories, mergeObjects } from "./merge.js";
2
5
  export {
3
- t as token
6
+ MediaQueryFactory,
7
+ keyframes,
8
+ media,
9
+ mergeFactories,
10
+ mergeObjects,
11
+ token
4
12
  };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const parseStyles = require("../parse-styles-gRr_iCy7.cjs");
4
+ const toHash = require("../to-hash-DT2ImSPA.cjs");
5
+ const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
6
+ const modifyKeyframes = async (params = {}) => {
7
+ const animationName = _name || toHash.toHash(keyframes2);
8
+ const fn = async () => {
9
+ const {
10
+ duration = "500ms",
11
+ easing = "ease-in-out",
12
+ delay = "0s",
13
+ iterationCount = "1",
14
+ direction = "normal",
15
+ fillMode = "forwards",
16
+ playState = "running"
17
+ } = { ..._params, ...params };
18
+ const animation = `${animationName} ${duration} ${easing} ${delay} ${iterationCount} ${direction} ${fillMode} ${playState}`;
19
+ if (!appendInitialStyles) return animation;
20
+ const startingFrom = keyframes2.from || keyframes2["0%"];
21
+ if (!startingFrom) return animation;
22
+ const startStyles = await parseStyles.parseAndJoinStyles(startingFrom, "");
23
+ return `${animation};${startStyles}`;
24
+ };
25
+ const entries = Object.entries(keyframes2);
26
+ const promises = entries.map(async ([key, value]) => {
27
+ if (!value) return "";
28
+ const styles = await parseStyles.parseAndJoinStyles(value, "");
29
+ const keyStr = typeof key === "number" ? `${key}%` : key;
30
+ return `${keyStr}{${styles}}`;
31
+ });
32
+ const resolved = await Promise.all(promises);
33
+ const keyframesCss = resolved.join("");
34
+ const css = `@keyframes ${animationName} {${keyframesCss}}`;
35
+ Object.assign(fn, {
36
+ toString: fn,
37
+ isKeyframes: true,
38
+ animationName,
39
+ css,
40
+ keyframes: keyframes2
41
+ });
42
+ return fn;
43
+ };
44
+ Object.assign(modifyKeyframes, {
45
+ _shouldResolve: true
46
+ });
47
+ return modifyKeyframes;
48
+ };
49
+ exports.keyframes = keyframes;
@@ -0,0 +1,22 @@
1
+ import { CssStyles, StyleValue } from '../types';
2
+ type KeyframeKeys = number | 'from' | 'to' | `${number}%`;
3
+ type Keyframes = {
4
+ [key in KeyframeKeys]?: CssStyles;
5
+ };
6
+ interface KeyframesConfig {
7
+ animationName?: string;
8
+ appendInitialStyles?: boolean;
9
+ params?: KeyframesParams;
10
+ }
11
+ interface KeyframesParams {
12
+ duration?: string;
13
+ delay?: string;
14
+ iterationCount?: string | number;
15
+ easing?: StyleValue<'animationTimingFunction'>;
16
+ direction?: StyleValue<'animationDirection'>;
17
+ fillMode?: StyleValue<'animationFillMode'>;
18
+ playState?: StyleValue<'animationPlayState'>;
19
+ }
20
+ type KeyframesProps = Keyframes & KeyframesConfig;
21
+ export declare const keyframes: ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes }: KeyframesProps) => (params?: KeyframesParams) => Promise<() => Promise<string>>;
22
+ export {};
@@ -0,0 +1,49 @@
1
+ import { p as parseAndJoinStyles } from "../parse-styles-CS97_e4S.js";
2
+ import { t as toHash } from "../to-hash-DSoCPs8D.js";
3
+ const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
4
+ const modifyKeyframes = async (params = {}) => {
5
+ const animationName = _name || toHash(keyframes2);
6
+ const fn = async () => {
7
+ const {
8
+ duration = "500ms",
9
+ easing = "ease-in-out",
10
+ delay = "0s",
11
+ iterationCount = "1",
12
+ direction = "normal",
13
+ fillMode = "forwards",
14
+ playState = "running"
15
+ } = { ..._params, ...params };
16
+ const animation = `${animationName} ${duration} ${easing} ${delay} ${iterationCount} ${direction} ${fillMode} ${playState}`;
17
+ if (!appendInitialStyles) return animation;
18
+ const startingFrom = keyframes2.from || keyframes2["0%"];
19
+ if (!startingFrom) return animation;
20
+ const startStyles = await parseAndJoinStyles(startingFrom, "");
21
+ return `${animation};${startStyles}`;
22
+ };
23
+ const entries = Object.entries(keyframes2);
24
+ const promises = entries.map(async ([key, value]) => {
25
+ if (!value) return "";
26
+ const styles = await parseAndJoinStyles(value, "");
27
+ const keyStr = typeof key === "number" ? `${key}%` : key;
28
+ return `${keyStr}{${styles}}`;
29
+ });
30
+ const resolved = await Promise.all(promises);
31
+ const keyframesCss = resolved.join("");
32
+ const css = `@keyframes ${animationName} {${keyframesCss}}`;
33
+ Object.assign(fn, {
34
+ toString: fn,
35
+ isKeyframes: true,
36
+ animationName,
37
+ css,
38
+ keyframes: keyframes2
39
+ });
40
+ return fn;
41
+ };
42
+ Object.assign(modifyKeyframes, {
43
+ _shouldResolve: true
44
+ });
45
+ return modifyKeyframes;
46
+ };
47
+ export {
48
+ keyframes
49
+ };
package/css/media.cjs ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
+ class MediaQueryFactory {
7
+ constructor(base = "@media") {
8
+ __publicField(this, "next", (value) => {
9
+ const str = new String(value);
10
+ Object.assign(str, {
11
+ get isMedia() {
12
+ return true;
13
+ },
14
+ get and() {
15
+ return new MediaQueryFactory(`${value} and`);
16
+ },
17
+ get or() {
18
+ return new MediaQueryFactory(`${value},`);
19
+ }
20
+ });
21
+ return str;
22
+ });
23
+ this.base = base;
24
+ }
25
+ custom(value) {
26
+ return this.next(`${this.base} ${value}`);
27
+ }
28
+ minWidth(width) {
29
+ const _width = typeof width === "number" ? `${width}px` : width;
30
+ const value = `${this.base} (min-width: ${_width})`;
31
+ return this.next(value);
32
+ }
33
+ maxWidth(width) {
34
+ const _width = typeof width === "number" ? `${width}px` : width;
35
+ const value = `${this.base} (max-width: ${_width})`;
36
+ return this.next(value);
37
+ }
38
+ minHeight(height) {
39
+ const _height = typeof height === "number" ? `${height}px` : height;
40
+ const value = `${this.base} (min-height: ${_height})`;
41
+ return this.next(value);
42
+ }
43
+ maxHeight(height) {
44
+ const _height = typeof height === "number" ? `${height}px` : height;
45
+ const value = `${this.base} (max-height: ${_height})`;
46
+ return this.next(value);
47
+ }
48
+ get portrait() {
49
+ const value = `${this.base} (orientation: portrait)`;
50
+ return this.next(value);
51
+ }
52
+ get landscape() {
53
+ const value = `${this.base} (orientation: landscape)`;
54
+ return this.next(value);
55
+ }
56
+ prefersColorScheme(scheme) {
57
+ const value = `${this.base} (prefers-color-scheme: ${scheme})`;
58
+ return this.next(value);
59
+ }
60
+ get dark() {
61
+ return this.prefersColorScheme("dark");
62
+ }
63
+ get light() {
64
+ return this.prefersColorScheme("light");
65
+ }
66
+ get print() {
67
+ const value = `${this.base} print`;
68
+ return this.next(value);
69
+ }
70
+ get screen() {
71
+ const value = `${this.base} screen`;
72
+ return this.next(value);
73
+ }
74
+ get speech() {
75
+ const value = `${this.base} speech`;
76
+ return this.next(value);
77
+ }
78
+ get all() {
79
+ const value = `${this.base} all`;
80
+ return this.next(value);
81
+ }
82
+ get not() {
83
+ const value = `${this.base} not`;
84
+ return this.next(value);
85
+ }
86
+ get reducedMotion() {
87
+ const value = `${this.base} (prefers-reduced-motion: reduce)`;
88
+ return this.next(value);
89
+ }
90
+ }
91
+ const media = new MediaQueryFactory();
92
+ exports.MediaQueryFactory = MediaQueryFactory;
93
+ exports.media = media;
package/css/media.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import { OrString, OrNumber } from '../types/util-types';
2
+ export declare class MediaQueryFactory {
3
+ private base;
4
+ constructor(base?: string);
5
+ private next;
6
+ custom(value: string): string & {
7
+ isMedia: boolean;
8
+ and: MediaQueryFactory;
9
+ or: MediaQueryFactory;
10
+ };
11
+ minWidth(width: OrString | OrNumber): string & {
12
+ isMedia: boolean;
13
+ and: MediaQueryFactory;
14
+ or: MediaQueryFactory;
15
+ };
16
+ maxWidth(width: OrString | OrNumber): string & {
17
+ isMedia: boolean;
18
+ and: MediaQueryFactory;
19
+ or: MediaQueryFactory;
20
+ };
21
+ minHeight(height: OrString | OrNumber): string & {
22
+ isMedia: boolean;
23
+ and: MediaQueryFactory;
24
+ or: MediaQueryFactory;
25
+ };
26
+ maxHeight(height: OrString | OrNumber): string & {
27
+ isMedia: boolean;
28
+ and: MediaQueryFactory;
29
+ or: MediaQueryFactory;
30
+ };
31
+ get portrait(): string & {
32
+ isMedia: boolean;
33
+ and: MediaQueryFactory;
34
+ or: MediaQueryFactory;
35
+ };
36
+ get landscape(): string & {
37
+ isMedia: boolean;
38
+ and: MediaQueryFactory;
39
+ or: MediaQueryFactory;
40
+ };
41
+ prefersColorScheme(scheme: 'dark' | 'light' | OrString): string & {
42
+ isMedia: boolean;
43
+ and: MediaQueryFactory;
44
+ or: MediaQueryFactory;
45
+ };
46
+ get dark(): string & {
47
+ isMedia: boolean;
48
+ and: MediaQueryFactory;
49
+ or: MediaQueryFactory;
50
+ };
51
+ get light(): string & {
52
+ isMedia: boolean;
53
+ and: MediaQueryFactory;
54
+ or: MediaQueryFactory;
55
+ };
56
+ get print(): string & {
57
+ isMedia: boolean;
58
+ and: MediaQueryFactory;
59
+ or: MediaQueryFactory;
60
+ };
61
+ get screen(): string & {
62
+ isMedia: boolean;
63
+ and: MediaQueryFactory;
64
+ or: MediaQueryFactory;
65
+ };
66
+ get speech(): string & {
67
+ isMedia: boolean;
68
+ and: MediaQueryFactory;
69
+ or: MediaQueryFactory;
70
+ };
71
+ get all(): string & {
72
+ isMedia: boolean;
73
+ and: MediaQueryFactory;
74
+ or: MediaQueryFactory;
75
+ };
76
+ get not(): string & {
77
+ isMedia: boolean;
78
+ and: MediaQueryFactory;
79
+ or: MediaQueryFactory;
80
+ };
81
+ get reducedMotion(): string & {
82
+ isMedia: boolean;
83
+ and: MediaQueryFactory;
84
+ or: MediaQueryFactory;
85
+ };
86
+ }
87
+ export declare const media: MediaQueryFactory;
package/css/media.js ADDED
@@ -0,0 +1,93 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ class MediaQueryFactory {
5
+ constructor(base = "@media") {
6
+ __publicField(this, "next", (value) => {
7
+ const str = new String(value);
8
+ Object.assign(str, {
9
+ get isMedia() {
10
+ return true;
11
+ },
12
+ get and() {
13
+ return new MediaQueryFactory(`${value} and`);
14
+ },
15
+ get or() {
16
+ return new MediaQueryFactory(`${value},`);
17
+ }
18
+ });
19
+ return str;
20
+ });
21
+ this.base = base;
22
+ }
23
+ custom(value) {
24
+ return this.next(`${this.base} ${value}`);
25
+ }
26
+ minWidth(width) {
27
+ const _width = typeof width === "number" ? `${width}px` : width;
28
+ const value = `${this.base} (min-width: ${_width})`;
29
+ return this.next(value);
30
+ }
31
+ maxWidth(width) {
32
+ const _width = typeof width === "number" ? `${width}px` : width;
33
+ const value = `${this.base} (max-width: ${_width})`;
34
+ return this.next(value);
35
+ }
36
+ minHeight(height) {
37
+ const _height = typeof height === "number" ? `${height}px` : height;
38
+ const value = `${this.base} (min-height: ${_height})`;
39
+ return this.next(value);
40
+ }
41
+ maxHeight(height) {
42
+ const _height = typeof height === "number" ? `${height}px` : height;
43
+ const value = `${this.base} (max-height: ${_height})`;
44
+ return this.next(value);
45
+ }
46
+ get portrait() {
47
+ const value = `${this.base} (orientation: portrait)`;
48
+ return this.next(value);
49
+ }
50
+ get landscape() {
51
+ const value = `${this.base} (orientation: landscape)`;
52
+ return this.next(value);
53
+ }
54
+ prefersColorScheme(scheme) {
55
+ const value = `${this.base} (prefers-color-scheme: ${scheme})`;
56
+ return this.next(value);
57
+ }
58
+ get dark() {
59
+ return this.prefersColorScheme("dark");
60
+ }
61
+ get light() {
62
+ return this.prefersColorScheme("light");
63
+ }
64
+ get print() {
65
+ const value = `${this.base} print`;
66
+ return this.next(value);
67
+ }
68
+ get screen() {
69
+ const value = `${this.base} screen`;
70
+ return this.next(value);
71
+ }
72
+ get speech() {
73
+ const value = `${this.base} speech`;
74
+ return this.next(value);
75
+ }
76
+ get all() {
77
+ const value = `${this.base} all`;
78
+ return this.next(value);
79
+ }
80
+ get not() {
81
+ const value = `${this.base} not`;
82
+ return this.next(value);
83
+ }
84
+ get reducedMotion() {
85
+ const value = `${this.base} (prefers-reduced-motion: reduce)`;
86
+ return this.next(value);
87
+ }
88
+ }
89
+ const media = new MediaQueryFactory();
90
+ export {
91
+ MediaQueryFactory,
92
+ media
93
+ };
package/css/merge.cjs ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const mergeObjects = (...styles) => {
4
+ return styles.flat().reduce((acc, style) => {
5
+ if (style == null ? void 0 : style._current) return { ...acc, ...style._current };
6
+ return { ...acc, ...style };
7
+ }, {});
8
+ };
9
+ const mergeFactories = (...factories) => {
10
+ return factories.flat().reduce((acc, factory) => {
11
+ return { ...acc, ...factory._children };
12
+ }, {});
13
+ };
14
+ exports.mergeFactories = mergeFactories;
15
+ exports.mergeObjects = mergeObjects;
package/css/merge.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ interface StyleFactory {
2
+ _current: Record<string, any>;
3
+ _children: Record<string, any>;
4
+ }
5
+ export declare const mergeObjects: <T = any>(...styles: any[]) => T;
6
+ export declare const mergeFactories: <T extends StyleFactory>(...factories: T[][]) => T;
7
+ export {};