@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.
Files changed (127) 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 +449 -8
  6. package/bin/main.js +427 -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 +674 -0
  11. package/compiler/as-class.d.ts +52 -0
  12. package/compiler/as-class.js +657 -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/compiler/index.cjs +668 -11
  23. package/compiler/index.d.ts +22 -11
  24. package/compiler/index.js +630 -153
  25. package/config/define-config.d.ts +1 -1
  26. package/config/index.cjs +16 -1
  27. package/config/index.d.ts +2 -1
  28. package/config/index.js +14 -2
  29. package/css/index.cjs +12 -1
  30. package/css/index.d.ts +4 -1
  31. package/css/index.js +10 -2
  32. package/css/keyframes.cjs +49 -0
  33. package/css/keyframes.d.ts +22 -0
  34. package/css/keyframes.js +49 -0
  35. package/css/media.cjs +93 -0
  36. package/css/media.d.ts +87 -0
  37. package/css/media.js +93 -0
  38. package/css/merge.cjs +15 -0
  39. package/css/merge.d.ts +7 -0
  40. package/css/merge.js +15 -0
  41. package/css/token.cjs +4 -0
  42. package/css/token.d.ts +1 -0
  43. package/css/token.js +4 -0
  44. package/define-templates-CVhhgPnd.js +60 -0
  45. package/define-templates-Deq1aCbN.cjs +59 -0
  46. package/factories/define-global-styles.d.ts +7 -0
  47. package/factories/define-media-query.d.ts +8 -0
  48. package/factories/define-templates.d.ts +27 -0
  49. package/factories/define-variables.d.ts +12 -0
  50. package/factories/index.cjs +37 -0
  51. package/factories/index.d.ts +4 -0
  52. package/factories/index.js +37 -0
  53. package/generators/class-name-generator.d.ts +7 -0
  54. package/generators/index.cjs +125 -0
  55. package/generators/index.d.ts +2 -0
  56. package/generators/index.js +125 -0
  57. package/generators/styled-generator.d.ts +20 -0
  58. package/generators/styles-generator.d.ts +22 -0
  59. package/helpers/color.d.ts +18 -0
  60. package/helpers/index.cjs +53 -0
  61. package/helpers/index.d.ts +2 -0
  62. package/helpers/index.js +53 -0
  63. package/helpers/viewport-clamp.d.ts +9 -0
  64. package/index-ByR0nfaf.cjs +4 -0
  65. package/index-DKz1QXqs.js +4 -0
  66. package/package.json +70 -6
  67. package/parse-styles-CS97_e4S.js +232 -0
  68. package/parse-styles-gRr_iCy7.cjs +231 -0
  69. package/parsers/index.cjs +57 -0
  70. package/parsers/index.d.ts +5 -0
  71. package/parsers/index.js +58 -0
  72. package/parsers/parse-modifiers.d.ts +3 -0
  73. package/parsers/parse-styles.d.ts +13 -0
  74. package/parsers/parse-templates.d.ts +4 -0
  75. package/parsers/parse-tokens.d.ts +3 -0
  76. package/parsers/parser-types.d.ts +8 -0
  77. package/parsers/property-name-check.d.ts +1 -0
  78. package/parsers/unit-check.d.ts +7 -0
  79. package/pascal-case-By_l58S-.cjs +7 -0
  80. package/pascal-case-F3Usi5Wf.js +8 -0
  81. package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
  82. package/react-styled-file-U02jek-B.cjs +11 -0
  83. package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
  84. package/react-vanilla-file-D9px70iK.js +18 -0
  85. package/salty-reset-D1VR51zL.js +83 -0
  86. package/salty-reset-zWMaTt2Q.cjs +83 -0
  87. package/salty.config-DjosWdPw.js +4 -0
  88. package/salty.config-cqavVm2t.cjs +4 -0
  89. package/server/index.cjs +4 -0
  90. package/server/index.d.ts +1 -0
  91. package/server/index.js +4 -0
  92. package/server/should-restart.d.ts +1 -0
  93. package/should-restart-5jI-bzz0.js +18 -0
  94. package/should-restart-DoaGoD5T.cjs +17 -0
  95. package/templates/salty-reset.d.ts +2 -0
  96. package/to-hash-DSoCPs8D.js +33 -0
  97. package/to-hash-DT2ImSPA.cjs +32 -0
  98. package/types/cli-types.d.ts +10 -0
  99. package/types/config-types.d.ts +85 -0
  100. package/types/index.d.ts +57 -23
  101. package/util/dot-case.d.ts +1 -0
  102. package/util/index.cjs +13 -1
  103. package/util/index.js +10 -8
  104. package/util/module-type.d.ts +1 -0
  105. package/viewport-clamp-CEmzmcSj.cjs +10 -0
  106. package/viewport-clamp-K553uXu3.js +11 -0
  107. package/config/config-types.d.ts +0 -59
  108. package/dash-case-DKzpenwY.cjs +0 -1
  109. package/dash-case-DMQMcCO6.js +0 -19
  110. package/generator/index.cjs +0 -1
  111. package/generator/index.d.ts +0 -1
  112. package/generator/index.js +0 -61
  113. package/generator/parse-modifiers.d.ts +0 -3
  114. package/generator/parse-styles.d.ts +0 -2
  115. package/generator/parse-templates.d.ts +0 -2
  116. package/generator/parse-tokens.d.ts +0 -2
  117. package/generator/parser-types.d.ts +0 -4
  118. package/generator/style-generator.d.ts +0 -28
  119. package/index-84Wroia-.cjs +0 -1
  120. package/index-D_732b92.js +0 -4
  121. package/parse-templates-D4p3pgQR.js +0 -92
  122. package/parse-templates-W0YfTmOT.cjs +0 -8
  123. package/pascal-case-BQpR5PdN.js +0 -6
  124. package/pascal-case-iWoaJWwT.cjs +0 -1
  125. package/react-styled-file-Dkubsz-U.cjs +0 -8
  126. package/salty.config-BupieCfE.cjs +0 -6
  127. package/salty.config-D9ANEDiH.js +0 -9
@@ -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
+ };