aliascss 1.4.7 → 1.5.1
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/CHANGELOG.md +51 -0
- package/bin/aliascss.js +118 -1
- package/dist/aliascss.js +1 -1
- package/jestconfig.json +1 -3
- package/lib/build/index.js +136 -19
- package/lib/classPrinter.d.ts +1 -1
- package/lib/classPrinter.js +351 -23
- package/lib/compilers/border.js +106 -27
- package/lib/compilers/clipPath.js +79 -6
- package/lib/compilers/color.js +150 -21
- package/lib/compilers/filter.js +90 -3
- package/lib/compilers/font.js +39 -11
- package/lib/compilers/gradient.js +43 -27
- package/lib/compilers/length.js +34 -9
- package/lib/compilers/shadow.js +60 -26
- package/lib/compilers/stringAndContent.js +39 -2
- package/lib/compilers/timingFunction.js +57 -6
- package/lib/compilers/transform.js +118 -48
- package/lib/compilers/transition.js +79 -11
- package/lib/compilers/url.js +53 -3
- package/lib/config.d.ts +1 -0
- package/lib/config.js +1 -0
- package/lib/custom-css-compilers.js +1 -68
- package/lib/index.d.ts +9 -9
- package/lib/node/compileFile-BK-291026.d.ts +27 -0
- package/lib/node/compileFile-BK-291026.js +309 -0
- package/lib/node/compileFile-bk.d.ts +14 -12
- package/lib/node/compileFile-bk.js +263 -252
- package/lib/node/compileFile.js +1 -1
- package/lib/node/extractClassNamesFromFile.js +208 -86
- package/lib/prebuild.d.ts +26 -0
- package/lib/prebuild.js +0 -6
- package/lib/prefix/element-selector.js +93 -20
- package/lib/prefix/extractPrefix.d.ts +1 -1
- package/lib/prefix/extractPrefix.js +113 -70
- package/lib/returnPropertyAndValue-bk-301026.d.ts +30 -0
- package/lib/returnPropertyAndValue-bk-301026.js +219 -0
- package/lib/returnPropertyAndValue.js +26 -25
- package/lib/returnStatement-bk-291026.d.ts +5 -0
- package/lib/returnStatement-bk-291026.js +470 -0
- package/lib/returnStatement.d.ts +1 -0
- package/lib/returnStatement.js +120 -29
- package/lib/utils/helper.js +16 -2
- package/lib/x-classes/x-bundle.d.ts +26 -0
- package/lib/x-classes/x-bundle.js +2 -1
- package/lib/x-classes/x-extras.js +1 -1
- package/lib/x-classes/x-form-components.js +2 -1
- package/lib/x-classes/x-row-col.d.ts +29 -0
- package/lib/x-classes/x-row-col.js +52 -0
- package/llms.txt +326 -0
- package/package.json +3 -1
- package/tsconfig.json +1 -0
- package/tsconfig.test.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## AliasCSS 1.5.1
|
|
2
|
+
|
|
3
|
+
A reliability release: fewer surprises in the browser, quieter consoles and correct negative values everywhere.
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- **Negative values after `:`**
|
|
8
|
+
`--gap:-8px` and fallbacks like `m--gap:-8px` lost their minus sign and compiled to `8px`. They now compile to `-8px`, the same as `m--8px`. `:--8px` still works too.
|
|
9
|
+
```html
|
|
10
|
+
<div class="--x-offset:-8px m--x-offset:-4px"></div>
|
|
11
|
+
<!-- --x-offset: -8px; margin: var(--x-offset, -4px) -->
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- **Script no longer needs `defer`**
|
|
15
|
+
Loading `aliascss.js` in `<head>` without `defer` threw `Failed to execute 'observe' on 'MutationObserver'` and stopped styling new content. The script now waits for the page, with or without `defer`.
|
|
16
|
+
|
|
17
|
+
- **`hidden` always hides**
|
|
18
|
+
`<div hidden class="x-stack">` stayed visible, because any class that sets `display` beats the browser's built-in `[hidden]` style. AliasCSS now adds one rule to the `reset` layer, so `hidden` wins over every display class. `hidden="until-found"` keeps its normal behaviour. This applies to the browser script and to the CLI output.
|
|
19
|
+
|
|
20
|
+
- **Wrong CSS for values that can't be compiled**
|
|
21
|
+
A typo such as `bgc-slateTheme13` produced `.bgc-slateTheme13{slateTheme13}`, with the property missing. It now produces `background-color: slateTheme13` and one clear warning.
|
|
22
|
+
|
|
23
|
+
- **`x-button-icon` with `x-button-sm`**
|
|
24
|
+
Icon buttons combined with a size modifier could shrink to a few pixels wide. They now stay square, and icons inside any `x-button` no longer shrink.
|
|
25
|
+
|
|
26
|
+
### Improvements
|
|
27
|
+
|
|
28
|
+
- **Quieter console**
|
|
29
|
+
Plain class names that aren't AliasCSS (`card-title`, `active`, export names) are no longer reported. Previously each one logged two messages. Classes that look like AliasCSS but fail still get exactly one warning:
|
|
30
|
+
1.5.0
|
|
31
|
+
New
|
|
32
|
+
- _.(class-name) for class names with "-" after combinators
|
|
33
|
+
- Attribute selectors inside groups: [d-block,[aria-current=true]-c-red]
|
|
34
|
+
- x-row / x-col (flex + gap, no negative margins), x-arrow, x-absolute-*, dividers
|
|
35
|
+
- Pseudo aliases for range/progress parts, :user-valid, :open, :modal, ::picker(select)
|
|
36
|
+
- # is optional in colors (c-#fff and c-fff)
|
|
37
|
+
- Warnings: the failing item in a group, calc() without spaces, ::before:hover
|
|
38
|
+
- CLI: --help, the real --version, exit code 1 on errors, works on Windows
|
|
39
|
+
|
|
40
|
+
Fixed
|
|
41
|
+
- --not(...) with a property function after it
|
|
42
|
+
- Long pseudo names (--placeholder-shown, --scrollbar-thumb, --target-text)
|
|
43
|
+
- --nth-last-of-type-N, the --nthot alias
|
|
44
|
+
- Keywords no longer change class names (_.childbox)
|
|
45
|
+
- Watch mode: no corrupted output, new and deleted files handled, chokidar 4
|
|
46
|
+
- Class extraction when no ignore list is set
|
|
47
|
+
|
|
48
|
+
Changed
|
|
49
|
+
- theme() is now Theme()
|
|
50
|
+
- postcss removed from the browser build (smaller file)
|
|
51
|
+
- 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
|
|