aliascss 1.4.5 → 1.5.0

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 (75) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bin/aliascss.js +118 -1
  3. package/dist/aliascss.js +1 -1
  4. package/lib/classPrinter.js +347 -21
  5. package/lib/compilers/color.js +5 -5
  6. package/lib/compilers/gradient.js +3 -3
  7. package/lib/compilers/stringAndContent.js +2 -1
  8. package/lib/component-elements.d.ts +155 -0
  9. package/lib/component-elements.js +223 -0
  10. package/lib/config.d.ts +2 -0
  11. package/lib/config.js +3 -1
  12. package/lib/css-properties-all.js +337 -202
  13. package/lib/custom-css-compilers.js +49 -116
  14. package/lib/extras-elements.d.ts +87 -0
  15. package/lib/extras-elements.js +184 -0
  16. package/lib/form-elements.d.ts +75 -0
  17. package/lib/form-elements.js +186 -0
  18. package/lib/layout-elements.d.ts +59 -0
  19. package/lib/layout-elements.js +113 -0
  20. package/lib/nav-elements.d.ts +71 -0
  21. package/lib/nav-elements.js +243 -0
  22. package/lib/node/compileFile-BK-291026.d.ts +27 -0
  23. package/lib/node/compileFile-BK-291026.js +309 -0
  24. package/lib/node/compileFile-bk.d.ts +14 -12
  25. package/lib/node/compileFile-bk.js +263 -252
  26. package/lib/node/compileFile.js +1 -1
  27. package/lib/node/extractClassNamesFromFile.js +208 -86
  28. package/lib/prebuild.d.ts +546 -12
  29. package/lib/prebuild.js +3 -852
  30. package/lib/prefix/PseudoPrefixNew.js +301 -16
  31. package/lib/prefix/attribute-selector.js +4 -2
  32. package/lib/prefix/element-selector.js +93 -20
  33. package/lib/prefix/extractPrefix.d.ts +1 -1
  34. package/lib/prefix/extractPrefix.js +113 -70
  35. package/lib/prefix/pseudoSelectorNew.js +184 -49
  36. package/lib/prefix/responsive.d.ts +13 -9
  37. package/lib/prefix/responsive.js +131 -9
  38. package/lib/returnPropertyAndValue.js +9 -4
  39. package/lib/returnStatement-bk-291026.d.ts +5 -0
  40. package/lib/returnStatement-bk-291026.js +470 -0
  41. package/lib/returnStatement-bk.d.ts +5 -0
  42. package/lib/returnStatement-bk.js +311 -0
  43. package/lib/returnStatement.d.ts +1 -0
  44. package/lib/returnStatement.js +262 -12
  45. package/lib/static/customStaticClassNames.js +35 -35
  46. package/lib/static/staticClassNamesAlias.js +18 -16
  47. package/lib/table-elements.d.ts +39 -0
  48. package/lib/table-elements.js +90 -0
  49. package/lib/utils/helper.d.ts +6 -0
  50. package/lib/utils/helper.js +52 -0
  51. package/lib/x-classes/x-bundle.d.ts +589 -0
  52. package/lib/x-classes/x-bundle.js +12 -0
  53. package/lib/x-classes/x-comps.d.ts +87 -0
  54. package/lib/x-classes/x-comps.js +189 -0
  55. package/lib/x-classes/x-extras.d.ts +155 -0
  56. package/lib/x-classes/x-extras.js +223 -0
  57. package/lib/x-classes/x-form-components.d.ts +75 -0
  58. package/lib/x-classes/x-form-components.js +186 -0
  59. package/lib/x-classes/x-helper-components.d.ts +63 -0
  60. package/lib/x-classes/x-helper-components.js +91 -0
  61. package/lib/x-classes/x-layout-components.d.ts +59 -0
  62. package/lib/x-classes/x-layout-components.js +113 -0
  63. package/lib/x-classes/x-menu.d.ts +23 -0
  64. package/lib/x-classes/x-menu.js +55 -0
  65. package/lib/x-classes/x-navs.d.ts +71 -0
  66. package/lib/x-classes/x-navs.js +243 -0
  67. package/lib/x-classes/x-row-col.d.ts +29 -0
  68. package/lib/x-classes/x-row-col.js +52 -0
  69. package/lib/x-classes/x-table.d.ts +39 -0
  70. package/lib/x-classes/x-table.js +90 -0
  71. package/lib/x-classes/x-theme.d.ts +15 -0
  72. package/lib/x-classes/x-theme.js +32 -0
  73. package/lib/x-imports.d.ts +31 -0
  74. package/lib/x-imports.js +748 -0
  75. package/package.json +1 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ 1.5.0
2
+ New
3
+ - _.(class-name) for class names with "-" after combinators
4
+ - Attribute selectors inside groups: [d-block,[aria-current=true]-c-red]
5
+ - x-row / x-col (flex + gap, no negative margins), x-arrow, x-absolute-*, dividers
6
+ - Pseudo aliases for range/progress parts, :user-valid, :open, :modal, ::picker(select)
7
+ - # is optional in colors (c-#fff and c-fff)
8
+ - Warnings: the failing item in a group, calc() without spaces, ::before:hover
9
+ - CLI: --help, the real --version, exit code 1 on errors, works on Windows
10
+
11
+ Fixed
12
+ - --not(...) with a property function after it
13
+ - Long pseudo names (--placeholder-shown, --scrollbar-thumb, --target-text)
14
+ - --nth-last-of-type-N, the --nthot alias
15
+ - Keywords no longer change class names (_.childbox)
16
+ - Watch mode: no corrupted output, new and deleted files handled, chokidar 4
17
+ - Class extraction when no ignore list is set
18
+
19
+ Changed
20
+ - theme() is now Theme()
21
+ - postcss removed from the browser build (smaller file)
22
+ - Only classes that look like AliasCSS are reported in the console
package/bin/aliascss.js CHANGED
@@ -1,5 +1,122 @@
1
1
  #!/usr/bin/env node
2
2
  import path from 'path';
3
+ import fs from 'fs';
4
+ import { pathToFileURL } from 'url';
5
+ import main, { watch } from '../lib/node/compileFile.js';
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // Usage:
9
+ // aliascss <input-glob> <output.css> [--watch] [--file]
10
+ // aliascss --config [--watch] [--module]
11
+ // aliascss --version | --help
12
+ // ---------------------------------------------------------------------------
13
+
14
+ const KNOWN_FLAGS = ['--watch', '--file', '--config', '--module', '--version', '--help', '-v', '-h'];
15
+ const args = process.argv.slice(2);
16
+ const flags = new Set(args.filter(a => a.startsWith('-')));
17
+ const positional = args.filter(a => !a.startsWith('-')); // flags can now go anywhere
18
+
19
+ // Exit with an error code so scripts and CI notice the failure
20
+ function fail(message) {
21
+ console.error('AliasCSS: ' + message);
22
+ process.exit(1);
23
+ }
24
+
25
+ function printHelp() {
26
+ console.log(`Usage:
27
+ aliascss <input-glob> <output.css> [--watch] [--file]
28
+ aliascss --config [--watch] [--module]
29
+
30
+ Options:
31
+ --config read aliascss.config.js (or .mjs) from the current folder
32
+ --module use aliascss.config.mjs
33
+ --watch recompile when input files change
34
+ --file (with input/output) per-file output mode
35
+ --version print the version
36
+ --help show this help`);
37
+ }
38
+
39
+ // Warn about typos like --wacth instead of silently ignoring them
40
+ for (const f of flags) {
41
+ if (!KNOWN_FLAGS.includes(f)) console.warn(`AliasCSS: unknown option "${f}" (see --help)`);
42
+ }
43
+
44
+ if (flags.has('--help') || flags.has('-h')) {
45
+ printHelp();
46
+ process.exit(0);
47
+ }
48
+
49
+ if (flags.has('--version') || flags.has('-v')) {
50
+ // Read the real version instead of a hard-coded "@1.x.x"
51
+ const pkgUrl = new URL('../package.json', import.meta.url);
52
+ const { version } = JSON.parse(fs.readFileSync(pkgUrl, 'utf8'));
53
+ console.log('aliascss ' + version);
54
+ process.exit(0);
55
+ }
56
+
57
+ const isWatch = flags.has('--watch');
58
+ const isFile = flags.has('--file');
59
+ const isConfig = flags.has('--config');
60
+ const isModule = flags.has('--module');
61
+
62
+ // Create the output file (and its folders) if it doesn't exist yet
63
+ function ensureOutput(output) {
64
+ const full = path.resolve(output);
65
+ if (fs.existsSync(full) && fs.statSync(full).isDirectory()) {
66
+ fail(`output "${output}" is a folder; give a file name, e.g. ${path.join(output, 'aliascss.css')}`);
67
+ }
68
+ if (!fs.existsSync(full)) {
69
+ fs.mkdirSync(path.dirname(full), { recursive: true });
70
+ fs.closeSync(fs.openSync(full, 'w')); // close it: the old code leaked a file handle here
71
+ }
72
+ }
73
+
74
+ function run(config) {
75
+ if (isWatch) watch(config);
76
+ else main(config);
77
+ }
78
+
79
+ if (isConfig) {
80
+ // aliascss.config.mjs when --module is given, otherwise .js first, then .mjs
81
+ const candidates = isModule ? ['aliascss.config.mjs'] : ['aliascss.config.js', 'aliascss.config.mjs'];
82
+ const configFileName = candidates.find(name => fs.existsSync(path.resolve(name)));
83
+ if (!configFileName) fail(`no ${candidates.join(' or ')} found in ${process.cwd()}`);
84
+
85
+ // pathToFileURL: a plain absolute path fails in import() on Windows ("C:\…")
86
+ let configFile;
87
+ try {
88
+ configFile = await import(pathToFileURL(path.resolve(configFileName)).href);
89
+ } catch (error) {
90
+ fail(`could not load ${configFileName}: ${error.message}`);
91
+ }
92
+
93
+ const config = configFile.default;
94
+ if (!config || typeof config !== 'object') fail(`${configFileName} must have a default export (export default { … })`);
95
+ if (!config.output || !config.output.location) fail(`set output.location in ${configFileName}`);
96
+ if (!config.input) fail(`set input (a glob pattern) in ${configFileName}`);
97
+
98
+ ensureOutput(config.output.location);
99
+ run(config);
100
+ } else {
101
+ const [input, output] = positional;
102
+ if (!input || !output) {
103
+ printHelp();
104
+ fail('give an input glob and an output file, or use --config');
105
+ }
106
+
107
+ ensureOutput(output);
108
+ console.log('AliasCSS is compiling…');
109
+ run({
110
+ input,
111
+ output: {
112
+ location: output,
113
+ '--file': isFile,
114
+ },
115
+ });
116
+ }
117
+ /*
118
+ #!/usr/bin/env node
119
+ import path from 'path';
3
120
  import fs from 'fs'
4
121
  import main,{watch} from "../lib/node/compileFile.js";
5
122
  // import pkg from '../package.json' assert { type: "json" };
@@ -103,5 +220,5 @@ if(isConfigFile && fs.existsSync(path.resolve(configFileName))){
103
220
  }
104
221
  //--------------------end of ifelse isConfigFile.......
105
222
 
106
-
223
+ */
107
224