aliascss 1.4.7 → 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.
- package/CHANGELOG.md +22 -0
- package/bin/aliascss.js +118 -1
- package/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +347 -21
- package/lib/config.d.ts +1 -0
- package/lib/config.js +1 -0
- package/lib/custom-css-compilers.js +1 -68
- 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/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 +116 -29
- 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-row-col.d.ts +29 -0
- package/lib/x-classes/x-row-col.js +52 -0
- 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
|
|