arekui 1.0.0 → 2.0.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 +49 -0
- package/LICENSE +21 -21
- package/README.md +26 -198
- package/arekui.css +5930 -3279
- package/arekui.d.ts +328 -328
- package/arekui.js +817 -450
- package/assets/img/grunge-wall-texture-freepick-kues1.webp +0 -0
- package/assets/img/logo.png +0 -0
- package/dist/css/arekui.base.min.css +1 -0
- package/dist/css/arekui.broadsheet.min.css +1 -0
- package/dist/css/arekui.brutalist.min.css +1 -0
- package/dist/css/arekui.default.min.css +1 -0
- package/dist/css/arekui.full.min.css +1 -0
- package/dist/css/arekui.min.css +1 -0
- package/dist/css/arekui.neo.min.css +1 -0
- package/dist/css/arekui.pixel.min.css +1 -0
- package/dist/js/arekui.min.js +2 -0
- package/package.json +64 -57
- package/scripts/build-css.js +95 -0
- package/scripts/build-custom.js +287 -318
- package/scripts/build-js.js +68 -0
- package/scripts/clean.js +13 -0
- package/scripts/dev.js +97 -0
- package/scripts/imports.js +18 -0
- package/scripts/split.js +256 -0
- package/src/arekui.base.css +63 -0
- package/src/arekui.broadsheet.css +6 -0
- package/src/arekui.brutalist.css +8 -0
- package/src/arekui.core.css +64 -0
- package/src/arekui.css +22 -5
- package/src/arekui.default.css +6 -0
- package/src/arekui.neo.css +8 -0
- package/src/arekui.pixel.css +8 -0
- package/src/base/brutalist-overrides.css +254 -0
- package/src/base/neo-overrides.css +330 -315
- package/src/base/pixel-overrides.css +336 -0
- package/src/base/reset.css +179 -65
- package/src/base/theme-brutalist.css +111 -0
- package/src/base/theme-default.css +184 -0
- package/src/base/theme-neo.css +108 -0
- package/src/base/theme-pixel.css +111 -0
- package/src/base/tokens.css +59 -302
- package/src/components/accordion.css +32 -33
- package/src/components/alert.css +24 -25
- package/src/components/badge.css +31 -32
- package/src/components/breadcrumb.css +31 -32
- package/src/components/broadsheet.css +264 -0
- package/src/components/button.css +102 -101
- package/src/components/card.css +22 -23
- package/src/components/carousel.css +49 -13
- package/src/components/chat.css +77 -76
- package/src/components/description-list.css +34 -0
- package/src/components/docs.css +252 -0
- package/src/components/empty.css +36 -0
- package/src/components/file-upload.css +49 -50
- package/src/components/footer.css +40 -25
- package/src/components/forms.css +67 -68
- package/src/components/heading.css +27 -0
- package/src/components/hero.css +20 -21
- package/src/components/join.css +12 -13
- package/src/components/kbd.css +15 -0
- package/src/components/link.css +22 -23
- package/src/components/loading.css +109 -0
- package/src/components/menu.css +104 -54
- package/src/components/misc.css +94 -55
- package/src/components/modal.css +30 -31
- package/src/components/navbar.css +166 -36
- package/src/components/pagination.css +50 -45
- package/src/components/popover.css +68 -69
- package/src/components/progress.css +17 -18
- package/src/components/prose.css +78 -78
- package/src/components/rating.css +35 -36
- package/src/components/scroll-top.css +34 -34
- package/src/components/segmented.css +44 -0
- package/src/components/sidebar.css +377 -0
- package/src/components/skeleton.css +52 -52
- package/src/components/spinner.css +36 -0
- package/src/components/swap.css +43 -43
- package/src/components/table.css +20 -21
- package/src/components/tabs.css +22 -23
- package/src/components/tag.css +99 -99
- package/src/components/textured.css +52 -32
- package/src/components/timeline.css +32 -33
- package/src/components/toast.css +132 -132
- package/src/components/tooltip.css +22 -23
- package/src/utilities/borders.css +150 -150
- package/src/utilities/brutalist-utilities.css +49 -0
- package/src/utilities/colors.css +79 -71
- package/src/utilities/hover.css +31 -31
- package/src/utilities/layout.css +98 -98
- package/src/utilities/neo-utilities.css +86 -93
- package/src/utilities/pixel-utilities.css +88 -0
- package/src/utilities/responsive.css +131 -126
- package/src/utilities/sizing.css +98 -89
- package/src/utilities/spacing.css +132 -129
- package/src/utilities/typography.css +95 -92
- package/dist/arekui.min.css +0 -1
- package/dist/arekui.min.js +0 -2
- package/src/components/drawer.css +0 -53
package/scripts/build-custom.js
CHANGED
|
@@ -1,318 +1,287 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/^ar-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/^ar-
|
|
120
|
-
/^ar-
|
|
121
|
-
/^ar-
|
|
122
|
-
/^ar-
|
|
123
|
-
/^ar-
|
|
124
|
-
/^ar-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/^ar-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/^ar-
|
|
132
|
-
/^ar-
|
|
133
|
-
/^ar-
|
|
134
|
-
/^ar-
|
|
135
|
-
/^ar-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/^ar-
|
|
140
|
-
/^ar-
|
|
141
|
-
/^ar-
|
|
142
|
-
/^ar-
|
|
143
|
-
/^ar-
|
|
144
|
-
/^ar-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else {
|
|
289
|
-
console.log(`\x1b[36m⏳\x1b[0m Scanning ${srcDir}...`);
|
|
290
|
-
const classes = scan(srcDir);
|
|
291
|
-
components = detectComponents(classes);
|
|
292
|
-
utilities = detectUtilities(classes);
|
|
293
|
-
console.log(` Found ${classes.size} ar-* tokens`);
|
|
294
|
-
console.log(` Components: ${components.join(", ") || "(none)"}`);
|
|
295
|
-
console.log(` Utilities: ${utilities.join(", ") || "(none)"}`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
fs.writeFileSync(tmpFile, buildCSS(components, utilities), "utf-8");
|
|
299
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
300
|
-
|
|
301
|
-
const result = bundle({
|
|
302
|
-
filename: tmpFile,
|
|
303
|
-
minify: true,
|
|
304
|
-
sourceMap: sourcemap,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
const outFile = path.join(outDir, `${name}.min.css`);
|
|
308
|
-
fs.writeFileSync(outFile, result.code);
|
|
309
|
-
if (sourcemap && result.map) fs.writeFileSync(outFile + ".map", result.map);
|
|
310
|
-
|
|
311
|
-
console.log(`\n\x1b[32m✓\x1b[0m Built → ${outFile}`);
|
|
312
|
-
console.log(
|
|
313
|
-
` ${components.length} components, ${utilities.length} utilities`,
|
|
314
|
-
);
|
|
315
|
-
console.log(` ${(result.code.length / 1024).toFixed(1)}KB`);
|
|
316
|
-
} finally {
|
|
317
|
-
if (fs.existsSync(tmpFile)) fs.unlinkSync(tmpFile);
|
|
318
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { bundle } = require("lightningcss");
|
|
6
|
+
const { BASE_IMPORTS } = require("./imports");
|
|
7
|
+
|
|
8
|
+
function loadConfig() {
|
|
9
|
+
const candidates = ["arekui.config.js", "arekui.config.json"];
|
|
10
|
+
for (const file of candidates) {
|
|
11
|
+
const full = path.resolve(file);
|
|
12
|
+
if (fs.existsSync(full)) {
|
|
13
|
+
try {
|
|
14
|
+
console.log(`\x1b[90m config: ${file}\x1b[0m`);
|
|
15
|
+
return file.endsWith(".json")
|
|
16
|
+
? JSON.parse(fs.readFileSync(full, "utf-8"))
|
|
17
|
+
: require(full);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(`\x1b[31m✗\x1b[0m Failed to load ${file}: ${e.message}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getArg(flags) {
|
|
28
|
+
const idx = process.argv.findIndex((a) => flags.includes(a));
|
|
29
|
+
return idx === -1 ? null : process.argv[idx + 1];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const config = loadConfig();
|
|
33
|
+
|
|
34
|
+
const input = getArg(["-i", "--input"]) || config.input || ".";
|
|
35
|
+
const output = getArg(["-o", "--output"]) || config.output || "assets";
|
|
36
|
+
const name = getArg(["-n", "--name"]) || config.name || "arekui";
|
|
37
|
+
const sourcemap =
|
|
38
|
+
process.argv.includes("--sourcemap") || config.sourcemap === true;
|
|
39
|
+
const full = process.argv.includes("--full") || config.full === true;
|
|
40
|
+
|
|
41
|
+
const srcDir = path.resolve(input);
|
|
42
|
+
const outDir = path.resolve(output);
|
|
43
|
+
|
|
44
|
+
const COMPONENT_CLASSES = {
|
|
45
|
+
accordion: ["ar-accordion", "ar-collapse"],
|
|
46
|
+
alert: ["ar-alert"],
|
|
47
|
+
badge: ["ar-badge"],
|
|
48
|
+
breadcrumb: ["ar-breadcrumb"],
|
|
49
|
+
broadsheet: ["ar-rule-double", "ar-masthead", "ar-folio", "ar-nameplate", "ar-banner", "ar-sheet-cols", "ar-sheet-col", "ar-plate"],
|
|
50
|
+
button: ["ar-btn"],
|
|
51
|
+
card: ["ar-card", "ar-card-body", "ar-card-title", "ar-card-figure"],
|
|
52
|
+
carousel: ["ar-carousel", "ar-carousel-item", "ar-carousel-frame", "ar-carousel-btn", "ar-carousel-btn-prev", "ar-carousel-btn-next"],
|
|
53
|
+
chat: ["ar-chat", "ar-chat-bubble"],
|
|
54
|
+
"description-list": ["ar-dl", "ar-dt", "ar-dd"],
|
|
55
|
+
sidebar: ["ar-sidebar"],
|
|
56
|
+
"file-upload": ["ar-file-upload"],
|
|
57
|
+
footer: ["ar-footer"],
|
|
58
|
+
forms: [
|
|
59
|
+
"ar-input",
|
|
60
|
+
"ar-textarea",
|
|
61
|
+
"ar-select",
|
|
62
|
+
"ar-checkbox",
|
|
63
|
+
"ar-radio",
|
|
64
|
+
"ar-toggle",
|
|
65
|
+
"ar-range",
|
|
66
|
+
"ar-label",
|
|
67
|
+
"ar-fieldset",
|
|
68
|
+
],
|
|
69
|
+
heading: [
|
|
70
|
+
"ar-heading",
|
|
71
|
+
"ar-heading-eyebrow",
|
|
72
|
+
"ar-heading-title",
|
|
73
|
+
"ar-heading-desc",
|
|
74
|
+
"ar-heading-center",
|
|
75
|
+
],
|
|
76
|
+
hero: ["ar-hero"],
|
|
77
|
+
join: ["ar-join"],
|
|
78
|
+
docs: ["ar-docs"],
|
|
79
|
+
empty: ["ar-empty", "ar-empty-icon", "ar-empty-title", "ar-empty-desc", "ar-empty-action"],
|
|
80
|
+
kbd: ["ar-kbd"],
|
|
81
|
+
link: ["ar-link"],
|
|
82
|
+
loading: ["ar-loading"],
|
|
83
|
+
menu: ["ar-menu", "ar-dropdown", "ar-theme-menu"],
|
|
84
|
+
misc: ["ar-divider", "ar-stepper", "ar-step", "ar-avatar", "ar-avatar-group", "ar-avatar-more"],
|
|
85
|
+
modal: ["ar-modal"],
|
|
86
|
+
navbar: ["ar-navbar", "ar-search"],
|
|
87
|
+
pagination: ["ar-pagination"],
|
|
88
|
+
popover: ["ar-popover"],
|
|
89
|
+
progress: ["ar-progress"],
|
|
90
|
+
prose: ["ar-prose"],
|
|
91
|
+
rating: ["ar-rating"],
|
|
92
|
+
"scroll-top": ["ar-scroll-top"],
|
|
93
|
+
segmented: ["ar-segmented", "ar-segmented-input", "ar-segmented-item"],
|
|
94
|
+
skeleton: ["ar-skeleton"],
|
|
95
|
+
spinner: ["ar-spinner"],
|
|
96
|
+
swap: ["ar-swap"],
|
|
97
|
+
table: ["ar-table"],
|
|
98
|
+
tabs: ["ar-tabs", "ar-tab"],
|
|
99
|
+
tag: ["ar-tag"],
|
|
100
|
+
textured: ["ar-bg-img"],
|
|
101
|
+
timeline: ["ar-timeline"],
|
|
102
|
+
toast: ["ar-toast"],
|
|
103
|
+
tooltip: ["ar-tooltip"],
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const UTILITY_PATTERNS = {
|
|
107
|
+
spacing: [
|
|
108
|
+
/^ar-p/,
|
|
109
|
+
/^ar-px/,
|
|
110
|
+
/^ar-py/,
|
|
111
|
+
/^ar-m/,
|
|
112
|
+
/^ar-mt/,
|
|
113
|
+
/^ar-mb/,
|
|
114
|
+
/^ar-my/,
|
|
115
|
+
/^ar-mx/,
|
|
116
|
+
/^ar-gap/,
|
|
117
|
+
],
|
|
118
|
+
layout: [
|
|
119
|
+
/^ar-flex/,
|
|
120
|
+
/^ar-inline-flex/,
|
|
121
|
+
/^ar-flex-col/,
|
|
122
|
+
/^ar-flex-wrap/,
|
|
123
|
+
/^ar-items-/,
|
|
124
|
+
/^ar-justify-/,
|
|
125
|
+
/^ar-grid/,
|
|
126
|
+
/^ar-block/,
|
|
127
|
+
/^ar-hidden/,
|
|
128
|
+
],
|
|
129
|
+
typography: [/^ar-text-/, /^ar-font-/, /^ar-leading-/, /^ar-tracking-/],
|
|
130
|
+
sizing: [
|
|
131
|
+
/^ar-w-/,
|
|
132
|
+
/^ar-h-/,
|
|
133
|
+
/^ar-min-h-/,
|
|
134
|
+
/^ar-max-w-/,
|
|
135
|
+
/^ar-aspect-video/,
|
|
136
|
+
/^ar-object-cover/,
|
|
137
|
+
],
|
|
138
|
+
colors: [
|
|
139
|
+
/^ar-bg-base/,
|
|
140
|
+
/^ar-bg-neutral/,
|
|
141
|
+
/^ar-bg-primary/,
|
|
142
|
+
/^ar-bg-secondary/,
|
|
143
|
+
/^ar-bg-accent/,
|
|
144
|
+
/^ar-text-base/,
|
|
145
|
+
/^ar-text-gray/,
|
|
146
|
+
],
|
|
147
|
+
borders: [/^ar-border/, /^ar-rounded/, /^ar-shadow-/],
|
|
148
|
+
hover: [/^ar-hover-/],
|
|
149
|
+
responsive: [/^ar-md:/, /^ar-lg:/, /^ar-hide/],
|
|
150
|
+
"neo-utilities": [/^ar-neo-/],
|
|
151
|
+
"pixel-utilities": [/^ar-pixel-/],
|
|
152
|
+
"brutalist-utilities": [/^ar-brutalist-/],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
function findSourceFiles(dir) {
|
|
156
|
+
const exts = [".html", ".jsx", ".vue", ".svelte", ".tsx", ".ts", ".js"];
|
|
157
|
+
|
|
158
|
+
// A consumer may point -i at a single file rather than a directory.
|
|
159
|
+
let stat;
|
|
160
|
+
try {
|
|
161
|
+
stat = fs.statSync(dir);
|
|
162
|
+
} catch {
|
|
163
|
+
console.error(`\x1b[31m✗\x1b[0m scan input not found: ${dir}`);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
if (stat.isFile()) {
|
|
167
|
+
const ext = path.extname(dir).toLowerCase();
|
|
168
|
+
if (!exts.includes(ext)) {
|
|
169
|
+
console.error(
|
|
170
|
+
`\x1b[31m✗\x1b[0m ${dir} is not a scannable source - expected one of (${exts.join(" ")}) or a directory`,
|
|
171
|
+
);
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
return [dir];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const files = [];
|
|
178
|
+
|
|
179
|
+
function walk(d) {
|
|
180
|
+
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
181
|
+
const full = path.join(d, entry.name);
|
|
182
|
+
if (
|
|
183
|
+
entry.isDirectory() &&
|
|
184
|
+
!entry.name.startsWith(".") &&
|
|
185
|
+
entry.name !== "node_modules"
|
|
186
|
+
) {
|
|
187
|
+
walk(full);
|
|
188
|
+
} else if (entry.isFile() && exts.includes(path.extname(entry.name))) {
|
|
189
|
+
files.push(full);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
walk(dir);
|
|
194
|
+
return files;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function scan(dir) {
|
|
198
|
+
const files = findSourceFiles(dir);
|
|
199
|
+
const content = files.map((f) => fs.readFileSync(f, "utf-8")).join("\n");
|
|
200
|
+
const tokens = new Set();
|
|
201
|
+
let m;
|
|
202
|
+
const re = /ar-[\w-]+/g;
|
|
203
|
+
while ((m = re.exec(content)) !== null) tokens.add(m[0]);
|
|
204
|
+
return tokens;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Both detectors answer the same question — which named groups have at least
|
|
208
|
+
// one matcher satisfied by a scanned token — so the double loop lives once.
|
|
209
|
+
function detect(groups, classes, isMatch) {
|
|
210
|
+
const found = [];
|
|
211
|
+
for (const [name, matchers] of Object.entries(groups)) {
|
|
212
|
+
for (const cls of classes) {
|
|
213
|
+
if (matchers.some((m) => isMatch(m, cls))) {
|
|
214
|
+
found.push(name);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function detectComponents(classes) {
|
|
223
|
+
return detect(
|
|
224
|
+
COMPONENT_CLASSES,
|
|
225
|
+
classes,
|
|
226
|
+
(pattern, cls) => cls === pattern || cls.startsWith(pattern + "-"),
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function detectUtilities(classes) {
|
|
231
|
+
return detect(UTILITY_PATTERNS, classes, (pattern, cls) => pattern.test(cls));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function buildCSS(components, utilities) {
|
|
235
|
+
const imports = [...BASE_IMPORTS];
|
|
236
|
+
|
|
237
|
+
for (const c of components) {
|
|
238
|
+
imports.push(`@import "./components/${c}.css" layer(components);`);
|
|
239
|
+
}
|
|
240
|
+
for (const u of utilities) {
|
|
241
|
+
imports.push(`@import "./utilities/${u}.css" layer(utilities);`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return `@layer base, components, themes, utilities;\n\n${imports.join("\n")}\n`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const orchestrator = path.join(__dirname, "..", "src", "arekui.css");
|
|
248
|
+
const tmpFile = path.join(path.dirname(orchestrator), "__build.css");
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
let components, utilities;
|
|
252
|
+
|
|
253
|
+
if (full) {
|
|
254
|
+
components = Object.keys(COMPONENT_CLASSES);
|
|
255
|
+
utilities = Object.keys(UTILITY_PATTERNS);
|
|
256
|
+
console.log(`\x1b[36m📦\x1b[0m Including all components`);
|
|
257
|
+
} else {
|
|
258
|
+
console.log(`\x1b[36m⏳\x1b[0m Scanning ${srcDir}...`);
|
|
259
|
+
const classes = scan(srcDir);
|
|
260
|
+
components = detectComponents(classes);
|
|
261
|
+
utilities = detectUtilities(classes);
|
|
262
|
+
console.log(` Found ${classes.size} ar-* tokens`);
|
|
263
|
+
console.log(` Components: ${components.join(", ") || "(none)"}`);
|
|
264
|
+
console.log(` Utilities: ${utilities.join(", ") || "(none)"}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
fs.writeFileSync(tmpFile, buildCSS(components, utilities), "utf-8");
|
|
268
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
269
|
+
|
|
270
|
+
const result = bundle({
|
|
271
|
+
filename: tmpFile,
|
|
272
|
+
minify: true,
|
|
273
|
+
sourceMap: sourcemap,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
const outFile = path.join(outDir, `${name}.min.css`);
|
|
277
|
+
fs.writeFileSync(outFile, result.code);
|
|
278
|
+
if (sourcemap && result.map) fs.writeFileSync(outFile + ".map", result.map);
|
|
279
|
+
|
|
280
|
+
console.log(`\n\x1b[32m✓\x1b[0m Built → ${outFile}`);
|
|
281
|
+
console.log(
|
|
282
|
+
` ${components.length} components, ${utilities.length} utilities`,
|
|
283
|
+
);
|
|
284
|
+
console.log(` ${(result.code.length / 1024).toFixed(1)}KB`);
|
|
285
|
+
} finally {
|
|
286
|
+
if (fs.existsSync(tmpFile)) fs.unlinkSync(tmpFile);
|
|
287
|
+
}
|