@thi.ng/meta-css 0.18.15 → 0.19.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 +21 -1
- package/README.md +73 -82
- package/index.js +24 -24
- package/package.json +2 -2
- package/specs/_info.mcss.json +1 -1
- package/specs/a11y.mcss.json +2 -2
- package/specs/anim.mcss.json +25 -12
- package/specs/aspect.mcss.json +3 -3
- package/specs/background.mcss.json +6 -6
- package/specs/borders.mcss.json +25 -9
- package/specs/box-sizing.mcss.json +1 -1
- package/specs/color-ops.mcss.json +33 -112
- package/specs/colors.mcss.json +18 -18
- package/specs/content.mcss.json +1 -1
- package/specs/cursor.mcss.json +1 -1
- package/specs/dimensions.mcss.json +7 -7
- package/specs/display.mcss.json +4 -4
- package/specs/effects.mcss.json +2 -2
- package/specs/flex.mcss.json +4 -4
- package/specs/grids.mcss.json +6 -6
- package/specs/icons.mcss.json +2 -2
- package/specs/lists.mcss.json +1 -1
- package/specs/margins.mcss.json +7 -7
- package/specs/mask.mcss.json +2 -2
- package/specs/overflows.mcss.json +1 -1
- package/specs/positions.mcss.json +4 -4
- package/specs/print.mcss.json +1 -1
- package/specs/scroll.mcss.json +3 -3
- package/specs/selection.mcss.json +1 -1
- package/specs/shadows.mcss.json +3 -3
- package/specs/transform.mcss.json +1 -1
- package/specs/typography.mcss.json +25 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-06-
|
|
3
|
+
- **Last updated**: 2025-06-26T13:12:48Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -11,6 +11,26 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [0.19.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.19.0) (2025-06-26)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- add support for string literals in var assignments ([2749c30](https://github.com/thi-ng/umbrella/commit/2749c30))
|
|
19
|
+
- use string lit to ignore white space in var assignments
|
|
20
|
+
- `name="a b c"` => `--name: a b c;`
|
|
21
|
+
- add/update tests
|
|
22
|
+
- add tween-colors() template fn ([a5b8f9d](https://github.com/thi-ng/umbrella/commit/a5b8f9d))
|
|
23
|
+
- add border-style specs ([c4cbd2f](https://github.com/thi-ng/umbrella/commit/c4cbd2f))
|
|
24
|
+
- add/replace color ops ([ba78142](https://github.com/thi-ng/umbrella/commit/ba78142))
|
|
25
|
+
- replace existing `def-rgb/hsl/lch` / `adjust-rgb/hsl/lch` with:
|
|
26
|
+
- `adjust-color()`
|
|
27
|
+
- `lighten-color()`
|
|
28
|
+
- `rotate-color()`
|
|
29
|
+
- `saturate-color()`
|
|
30
|
+
- `with-alpha()`
|
|
31
|
+
- all color ops using `oklch()` now
|
|
32
|
+
- add `font-family()` tpl fn ([38c65d4](https://github.com/thi-ng/umbrella/commit/38c65d4))
|
|
33
|
+
|
|
14
34
|
## [0.18.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.18.0) (2025-02-11)
|
|
15
35
|
|
|
16
36
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
- [Background color](#background-color)
|
|
50
50
|
- [Border color](#border-color)
|
|
51
51
|
- [Border radius](#border-radius)
|
|
52
|
+
- [Border style](#border-style)
|
|
52
53
|
- [Border width](#border-width)
|
|
53
54
|
- [Box sizing](#box-sizing)
|
|
54
55
|
- [Color scheme](#color-scheme)
|
|
@@ -100,8 +101,8 @@
|
|
|
100
101
|
- [Background color](#background-color)
|
|
101
102
|
- [Border color](#border-color)
|
|
102
103
|
- [Color adjustment](#color-adjustment)
|
|
103
|
-
- [Color definitions](#color-definitions)
|
|
104
104
|
- [Color scheme](#color-scheme)
|
|
105
|
+
- [Font families](#font-families)
|
|
105
106
|
- [Fx](#fx)
|
|
106
107
|
- [Grid layout](#grid-layout)
|
|
107
108
|
- [Layout](#layout)
|
|
@@ -1153,7 +1154,7 @@ framework(s)...
|
|
|
1153
1154
|
>
|
|
1154
1155
|
> Since v0.17.0 these templates have been removed, since obsolete now...
|
|
1155
1156
|
|
|
1156
|
-
Currently, there are
|
|
1157
|
+
Currently, there are 968 CSS utility classes (incl. 58 templates) defined in "MetaCSS base" (v0.19.0):
|
|
1157
1158
|
|
|
1158
1159
|
### Classes by category
|
|
1159
1160
|
|
|
@@ -1342,9 +1343,24 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1342
1343
|
- `brt4` (top 1rem)
|
|
1343
1344
|
</details>
|
|
1344
1345
|
|
|
1346
|
+
#### Border style
|
|
1347
|
+
|
|
1348
|
+
<details><summary>9 items:</summary>
|
|
1349
|
+
|
|
1350
|
+
- `bs-dashed`
|
|
1351
|
+
- `bs-dotted`
|
|
1352
|
+
- `bs-double`
|
|
1353
|
+
- `bs-groove`
|
|
1354
|
+
- `bs-inset`
|
|
1355
|
+
- `bs-none`
|
|
1356
|
+
- `bs-outset`
|
|
1357
|
+
- `bs-ridge`
|
|
1358
|
+
- `bs-solid`
|
|
1359
|
+
</details>
|
|
1360
|
+
|
|
1345
1361
|
#### Border width
|
|
1346
1362
|
|
|
1347
|
-
<details><summary>
|
|
1363
|
+
<details><summary>45 items:</summary>
|
|
1348
1364
|
|
|
1349
1365
|
- `bw0` ( 0rem)
|
|
1350
1366
|
- `bw1` ( .125rem)
|
|
@@ -1353,6 +1369,8 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1353
1369
|
- `bw4` ( 1rem)
|
|
1354
1370
|
- `bw5` ( 2rem)
|
|
1355
1371
|
- `bw-1px` ( 1px)
|
|
1372
|
+
- `bw-2px` ( 2px)
|
|
1373
|
+
- `bw-4px` ( 4px)
|
|
1356
1374
|
- `bwb0` (bottom 0rem)
|
|
1357
1375
|
- `bwb1` (bottom .125rem)
|
|
1358
1376
|
- `bwb2` (bottom .25rem)
|
|
@@ -1360,6 +1378,8 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1360
1378
|
- `bwb4` (bottom 1rem)
|
|
1361
1379
|
- `bwb5` (bottom 2rem)
|
|
1362
1380
|
- `bwb-1px` (bottom 1px)
|
|
1381
|
+
- `bwb-2px` (bottom 2px)
|
|
1382
|
+
- `bwb-4px` (bottom 4px)
|
|
1363
1383
|
- `bwl0` (left 0rem)
|
|
1364
1384
|
- `bwl1` (left .125rem)
|
|
1365
1385
|
- `bwl2` (left .25rem)
|
|
@@ -1367,6 +1387,8 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1367
1387
|
- `bwl4` (left 1rem)
|
|
1368
1388
|
- `bwl5` (left 2rem)
|
|
1369
1389
|
- `bwl-1px` (left 1px)
|
|
1390
|
+
- `bwl-2px` (left 2px)
|
|
1391
|
+
- `bwl-4px` (left 4px)
|
|
1370
1392
|
- `bwr0` (right 0rem)
|
|
1371
1393
|
- `bwr1` (right .125rem)
|
|
1372
1394
|
- `bwr2` (right .25rem)
|
|
@@ -1374,6 +1396,8 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1374
1396
|
- `bwr4` (right 1rem)
|
|
1375
1397
|
- `bwr5` (right 2rem)
|
|
1376
1398
|
- `bwr-1px` (right 1px)
|
|
1399
|
+
- `bwr-2px` (right 2px)
|
|
1400
|
+
- `bwr-4px` (right 4px)
|
|
1377
1401
|
- `bwt0` (top 0rem)
|
|
1378
1402
|
- `bwt1` (top .125rem)
|
|
1379
1403
|
- `bwt2` (top .25rem)
|
|
@@ -1381,6 +1405,8 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
1381
1405
|
- `bwt4` (top 1rem)
|
|
1382
1406
|
- `bwt5` (top 2rem)
|
|
1383
1407
|
- `bwt-1px` (top 1px)
|
|
1408
|
+
- `bwt-2px` (top 2px)
|
|
1409
|
+
- `bwt-4px` (top 4px)
|
|
1384
1410
|
</details>
|
|
1385
1411
|
|
|
1386
1412
|
#### Box sizing
|
|
@@ -2319,7 +2345,7 @@ Currently, there are 950 CSS utility classes (incl. 59 templates) defined in "Me
|
|
|
2319
2345
|
|
|
2320
2346
|
#### Animation / transition
|
|
2321
2347
|
|
|
2322
|
-
<details><summary>
|
|
2348
|
+
<details><summary>13 items:</summary>
|
|
2323
2349
|
|
|
2324
2350
|
##### `anim-delay(delay)`
|
|
2325
2351
|
|
|
@@ -2384,6 +2410,12 @@ Animation which rotates element a full turn, looping indefinitely
|
|
|
2384
2410
|
|
|
2385
2411
|
Sets transition-timing-function to `steps(num)`
|
|
2386
2412
|
|
|
2413
|
+
##### `tween-colors(duration)`
|
|
2414
|
+
|
|
2415
|
+
- **duration**: in seconds
|
|
2416
|
+
|
|
2417
|
+
Transition tweening color, background-color, border-color
|
|
2418
|
+
|
|
2387
2419
|
</details>
|
|
2388
2420
|
|
|
2389
2421
|
#### Appearance
|
|
@@ -2438,97 +2470,48 @@ Sets aspect ratio of background. Use with `bg-aspect-ratio-object` on child elem
|
|
|
2438
2470
|
|
|
2439
2471
|
#### Color adjustment
|
|
2440
2472
|
|
|
2441
|
-
<details><summary>
|
|
2442
|
-
|
|
2443
|
-
##### `adjust-hsl(prop, name, hue, sat, lum, alpha)`
|
|
2444
|
-
|
|
2445
|
-
- **prop**: CSS target property
|
|
2446
|
-
- **name**: color variable name (without `--` prefix)
|
|
2447
|
-
- **hue**: offset in degrees
|
|
2448
|
-
- **sat**: factor
|
|
2449
|
-
- **lum**: factor
|
|
2450
|
-
- **alpha**: factor
|
|
2451
|
-
|
|
2452
|
-
Assigns an adjusted version of a `def-hsl()`-defined color to given CSS property.
|
|
2453
|
-
|
|
2454
|
-
##### `adjust-lch(prop, name, luma, chroma, hue, alpha)`
|
|
2455
|
-
|
|
2456
|
-
- **prop**: CSS target property
|
|
2457
|
-
- **name**: color variable name (without `--` prefix)
|
|
2458
|
-
- **luma**: factor
|
|
2459
|
-
- **chroma**: factor
|
|
2460
|
-
- **hue**: offset in degrees
|
|
2461
|
-
- **alpha**: factor
|
|
2462
|
-
|
|
2463
|
-
Assigns an adjusted version of a `def-lch()` defined color to given CSS property.
|
|
2464
|
-
|
|
2465
|
-
##### `adjust-oklch(prop, name, luma, chroma, hue, alpha)`
|
|
2466
|
-
|
|
2467
|
-
- **prop**: CSS target property
|
|
2468
|
-
- **name**: color variable name (without `--` prefix)
|
|
2469
|
-
- **luma**: factor
|
|
2470
|
-
- **chroma**: factor
|
|
2471
|
-
- **hue**: offset in degrees
|
|
2472
|
-
- **alpha**: alpha factor
|
|
2473
|
-
|
|
2474
|
-
Assigns an adjusted version of a `def-oklch()` defined color to given CSS property.
|
|
2475
|
-
|
|
2476
|
-
##### `adjust-rgb(prop, name, red, green, blue, alpha)`
|
|
2477
|
-
|
|
2478
|
-
- **prop**: CSS target property
|
|
2479
|
-
- **name**: color variable name (without `--` prefix)
|
|
2480
|
-
- **red**: factor
|
|
2481
|
-
- **green**: factor
|
|
2482
|
-
- **blue**: factor
|
|
2483
|
-
- **alpha**: factor
|
|
2484
|
-
|
|
2485
|
-
Assigns an adjusted version of a `def-rgb()`-defined color to given CSS property.
|
|
2486
|
-
|
|
2487
|
-
</details>
|
|
2473
|
+
<details><summary>5 items:</summary>
|
|
2488
2474
|
|
|
2489
|
-
|
|
2475
|
+
##### `adjust-color(name, base, l, c, h, a)`
|
|
2490
2476
|
|
|
2491
|
-
|
|
2477
|
+
- **name**: new var name (without `--` prefix)
|
|
2478
|
+
- **base**: color var (without `--` prefix)
|
|
2479
|
+
- **l**: luminance offset
|
|
2480
|
+
- **c**: chroma offset
|
|
2481
|
+
- **h**: hue offset
|
|
2482
|
+
- **a**: alpha offset
|
|
2492
2483
|
|
|
2493
|
-
|
|
2484
|
+
Assigns an adjusted version of `base` color to new variable `name`.
|
|
2494
2485
|
|
|
2495
|
-
-
|
|
2496
|
-
- **hue**: in degrees
|
|
2497
|
-
- **sat**: in percent
|
|
2498
|
-
- **lum**: in percent
|
|
2499
|
-
- **alpha**: in [0,1] range
|
|
2486
|
+
##### `lighten-color(name, base, l)`
|
|
2500
2487
|
|
|
2501
|
-
|
|
2488
|
+
- **name**: new var name (without `--` prefix)
|
|
2489
|
+
- **base**: color var (without `--` prefix)
|
|
2490
|
+
- **l**: luminance offset
|
|
2502
2491
|
|
|
2503
|
-
|
|
2492
|
+
Assigns an luminance-adjusted version of `base` color to new variable `name`.
|
|
2504
2493
|
|
|
2505
|
-
-
|
|
2506
|
-
- **luma**: in percent
|
|
2507
|
-
- **chroma**: in percent
|
|
2508
|
-
- **hue**: in degrees
|
|
2509
|
-
- **alpha**: in [0,1] range
|
|
2494
|
+
##### `rotate-color(name, base, h)`
|
|
2510
2495
|
|
|
2511
|
-
|
|
2496
|
+
- **name**: new var name (without `--` prefix)
|
|
2497
|
+
- **base**: color var (without `--` prefix)
|
|
2498
|
+
- **h**: hue offset
|
|
2512
2499
|
|
|
2513
|
-
|
|
2500
|
+
Assigns an hue-rotated version of `base` color to new variable `name`.
|
|
2514
2501
|
|
|
2515
|
-
-
|
|
2516
|
-
- **luma**: in percent
|
|
2517
|
-
- **chroma**: in percent
|
|
2518
|
-
- **hue**: in degrees
|
|
2519
|
-
- **alpha**: in [0,1] range
|
|
2502
|
+
##### `saturate-color(name, base, l)`
|
|
2520
2503
|
|
|
2521
|
-
|
|
2504
|
+
- **name**: new var name (without `--` prefix)
|
|
2505
|
+
- **base**: color var (without `--` prefix)
|
|
2506
|
+
- **l**: chroma offset
|
|
2522
2507
|
|
|
2523
|
-
|
|
2508
|
+
Assigns an chroma-adjusted version of `base` color to new variable `name`.
|
|
2524
2509
|
|
|
2525
|
-
-
|
|
2526
|
-
- **red**: [0,255] range
|
|
2527
|
-
- **green**: [0,255] range
|
|
2528
|
-
- **blue**: [0,255] range
|
|
2529
|
-
- **alpha**: in [0,1] range
|
|
2510
|
+
##### `with-alpha(name, base, a)`
|
|
2530
2511
|
|
|
2531
|
-
|
|
2512
|
+
- **name**: new var name (without `--` prefix)
|
|
2513
|
+
- **base**: color var (without `--` prefix)
|
|
2514
|
+
- **a**: alpha offset
|
|
2532
2515
|
|
|
2533
2516
|
</details>
|
|
2534
2517
|
|
|
@@ -2573,6 +2556,14 @@ Sets `stroke` color using CSS light-dark() function
|
|
|
2573
2556
|
|
|
2574
2557
|
</details>
|
|
2575
2558
|
|
|
2559
|
+
#### Font families
|
|
2560
|
+
|
|
2561
|
+
##### `font-family(name)`
|
|
2562
|
+
|
|
2563
|
+
- **name**: variable name (without `--` prefix)
|
|
2564
|
+
|
|
2565
|
+
Variable-based font-family
|
|
2566
|
+
|
|
2576
2567
|
#### Fx
|
|
2577
2568
|
|
|
2578
2569
|
##### `bg-blur(radius)`
|
|
@@ -2767,7 +2758,7 @@ The toolchain itself is distributed as CLI bundle with **no runtime
|
|
|
2767
2758
|
dependencies**. The following dependencies are only shown for informational
|
|
2768
2759
|
purposes and are (partially) included in the bundle.
|
|
2769
2760
|
|
|
2770
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 13.
|
|
2761
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 13.92 KB
|
|
2771
2762
|
|
|
2772
2763
|
## Dependencies
|
|
2773
2764
|
|
package/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`),this.parent?.logEntry(
|
|
4
|
-
`};var
|
|
5
|
-
`,start:()=>"",end:""};var
|
|
2
|
+
var rt={default:95,hint:90,multi:90,param:96,required:33};var eo=(o)=>o;function R(o,t=Object.create(null)){return(...n)=>{let r=n.join("-");return r in t?t[r]:t[r]=o(...n)}}var oo=R((o,t)=>o.repeat(t));var Dt=(o)=>/^[a-f0-9]+$/i.test(o);var zt=(o)=>/^[-+]?\d+$/.test(o),jt=(o)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(o);var U=(o,t=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(o(n)+t(n));this.origMessage=n!==void 0?String(n):""}};var ir=U(()=>"illegal argument(s)"),_=(o)=>{throw new ir(o)};var mt=(o)=>jt(o)?parseFloat(o):_(`not a numeric value: ${o}`),Jt=(o)=>o.map(mt),ft=(o)=>Dt(o)?parseInt(o,16):_(`not a hex value: ${o}`),Xt=(o)=>o.map(ft),Et=(o)=>zt(o)?parseInt(o):_(`not an integer: ${o}`),Pt=(o)=>o.map(Et);var Wo=(o,t)=>(n)=>({coerce:o,hint:t,group:"main",...n}),Ro=(o,t)=>(n)=>({hint:Ar(t,n.delim),multi:!0,coerce:o,group:"main",...n}),Ar=(o,t)=>o+(t?`[${t}..]`:""),W=(o)=>({flag:!0,default:!1,group:"flags",...o}),Y=Wo(eo,"STR"),Uo=Ro(eo,"STR"),ff=Wo(mt,"NUM"),Ef=Wo(ft,"HEX"),Yo=Wo(Et,"INT"),Gf=Ro(Jt,"NUM"),Nf=Ro(Xt,"HEX"),Of=Ro(Pt,"INT");var A=((o)=>{return o[o.FINE=0]="FINE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.SEVERE=4]="SEVERE",o[o.NONE=5]="NONE",o})(A||{});var Tr=0;class io{constructor(o,t=A.FINE,n){this.parent=n,this.id=o||`logger-${Tr++}`,this.level=typeof t==="string"?A[t]:t}id;level;addChild(o){return o.parent=this,o}enabled(o){return this.level<=o}fine(...o){this.log(A.FINE,o)}debug(...o){this.log(A.DEBUG,o)}info(...o){this.log(A.INFO,o)}warn(...o){this.log(A.WARN,o)}severe(...o){this.log(A.SEVERE,o)}none(){}log(o,t){this.level<=o&&this.logEntry([o,this.id,Date.now(),...t])}}var bt=(o)=>o.map((t)=>{if(typeof t==="function")t=t();if(!(typeof t==="string"||typeof t==="number"))t=JSON.stringify(t);return t}).join(" ");class Do extends io{constructor(o,t,n,r){super(t,n,r);this.target=o}childLogger(o,t){return new Do(this.target,o,t??this.level,this)}logEntry(o){if(o[0]<this.level)return;this.target.write(`[${A[o[0]]}] ${o[1]}: ${bt(o.slice(3))}
|
|
3
|
+
`),this.parent?.logEntry(o)}}var zo=R((o,t=" ")=>{let n=oo(String(t),o);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<o?r+n.substring(m):r}});var Gt={black:1,blue:5,cyan:7,gray:17,green:3,magenta:6,red:2,white:24,yellow:4,lightBlue:21,lightCyan:23,lightGray:8,lightGreen:19,lightMagenta:22,lightRed:18,lightYellow:20,bgBlack:32,bgBlue:160,bgCyan:224,bgGray:544,bgGreen:96,bgMagenta:192,bgRed:64,bgWhite:768,bgYellow:128,bgLightBlue:672,bgLightCyan:736,bgLightGray:256,bgLightGreen:608,bgLightMagenta:704,bgLightRed:576,bgLightYellow:640};var Fr=(o,t)=>(n)=>o.format(t,n),Nt=(o)=>Object.keys(Gt).reduce((t,n)=>(t[n]=Fr(o,Gt[n]),t),{format:o});var Zt="\x1B[0m";var Sr=["","1","2","1;2","4","1;4","2;4","1;2;4"],jo={format:(o,t)=>jo.start(o)+t+jo.end,start:R((o)=>{let t=[],n=o&15;return n&&t.push(29+(o>>4&1)*60+n),n=o>>5&15,n&&t.push(39+(o>>9&1)*60+n),n=o>>10,n&&t.push(Sr[n]),"\x1B["+t.join(";")+"m"}),end:Zt,prefix:Zt,suffix:`
|
|
4
|
+
`};var Kt={format:(o,t)=>String(t),prefix:"",suffix:`
|
|
5
|
+
`,start:()=>"",end:""};var Jo=Nt(jo),Vt=Nt(Kt);var T=Array.isArray;var wr=(o)=>o.toUpperCase(),qt=(o)=>o.toLowerCase(),Xo=(o)=>o.length?o[0].toUpperCase()+o.substring(1):o,pt=(o,t="-")=>qt(o.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+t+m));var Qt=(o,t="-")=>qt(o).replace(new RegExp(`\\${t}+(\\w)`,"g"),(n,r)=>wr(r));var kt=Object.getPrototypeOf,D=(o)=>{let t;return o!=null&&typeof o==="object"&&((t=kt(o))===null||kt(t)===null)};var Hr=/\x1b\[[0-9;]+m/g,Mr=(o)=>o.replace(Hr,"");var Po=(o)=>Mr(o).length;var vt=(o=!1,t)=>(n)=>o||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,t):String(n);function*to(o,t=/\r?\n/g,n=!1){let r=0,m=o.length,f=~~n,G;if(typeof t==="string")G=new RegExp(t,"g");else if(!t.flags.includes("g"))G=new RegExp(t,t.flags+"g");else G=t;for(;r<m;){let E=G.exec(o);if(!E){yield o.substring(r);return}let N=E[0].length;yield o.substring(r,E.index+f*N),r=E.index+N}}class Ot{n=0;w=[];constructor(o,t){o!=null&&this.add(o,t)}add(o,t=o.length){return this.w.push(o),this.n+=t+~~(this.n>0),this}toString(){return this.w.join(" ")}}var yr={length:(o)=>o.length,split:(o,t)=>t},dt={length:Po,split:(o,t)=>{let n=/\x1b\[[0-9;]+m/g,r=t,m;while(m=n.exec(o)){if(m.index>=t)break;let f=m[0].length;r+=f,t+=f}return r}},lt=(o,t,n,r)=>{let m=o[o.length-1];m&&r-m.n>n?m.add(t,n):o.push(new Ot(t,n))},ur=(o,{width:t,min:n,hard:r,splitter:m},f=0,G=[])=>{let E=m.length(o),N=t-f;if(N<n&&N<E)N=t;while(r&&E>N){let O=m.split(o,N),h=o.substring(0,O);lt(G,h,N,t),o=o.substring(O),N=t,E=m.length(o)}return lt(G,o,E,t),G},Ir=(o,t,n=[])=>{if(!o.length)return n.push(new Ot),n;let r={width:80,min:4,hard:!1,splitter:yr,...t};for(let m of to(o,t.delimWord||/\s/g)){let f=n[n.length-1];ur(m,r,f&&f.n>0?f.n+1:0,n)}return n},gt=(o,t)=>{let n=[];for(let r of to(o,t.delimLine))n=n.concat(Ir(r,t));return n};var Ao=(o,t={})=>{t={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...t};let n=D(t.color)?{...rt,...t.color}:t.color?rt:{},r=oo(" ",t.paramWidth),m=(E)=>E.map((N)=>Wr(N,o[N],t,n,r)),f=Object.keys(o).sort(),G=t.groups?t.groups.map((E)=>[E,f.filter((N)=>o[N].group===E)]).filter((E)=>!!E[1].length):[["options",f]];return[...ht(t.prefix,t.lineWidth),...G.map(([E,N])=>[...t.showGroupNames?[`${Xo(E)}:
|
|
6
6
|
`]:[],...m(N),""].join(`
|
|
7
|
-
`)),...
|
|
8
|
-
`)},Wr=(t,
|
|
9
|
-
`)},Rr=(t
|
|
7
|
+
`)),...ht(t.suffix,t.lineWidth)].join(`
|
|
8
|
+
`)},Wr=(o,t,n,r,m)=>{let f=Rr(t,r),G=Ur(t,r,f),E=To(`--${pt(o)}`,r.param),N=`${G}${E}${f}`,O=t.optional===!1&&t.default===void 0,h=[];O&&h.push("required"),t.multi&&h.push("multiple");let C=Yr(h,r,O)+(t.desc||"")+Dr(t,n,r);return zo(n.paramWidth)(N,Po(N))+ht(C,n.lineWidth-n.paramWidth).map((L,B)=>B>0?m+L:L).join(`
|
|
9
|
+
`)},Rr=(o,t)=>o.hint?To(" "+o.hint,t.hint):"",Ur=(o,t,n)=>o.alias?`${To("-"+o.alias,t.param)}${n}, `:"",Yr=(o,t,n)=>o.length?To(`[${o.join(", ")}] `,n?t.required:t.multi):"",Dr=(o,t,n)=>t.showDefaults&&o.default!=null&&o.default!==!1?To(` (default: ${vt(!0)(o.defaultHint!=null?o.defaultHint:o.default)})`,n.default):"",To=(o,t)=>t!=null?`\x1B[${t}m${o}\x1B[0m`:o,ht=(o,t)=>o?gt(o,{width:t,splitter:dt,hard:!1}):[];var zr=U(()=>"parse error"),xt=(o,t,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return jr(o,t,n)}catch(r){if(n.showUsage)console.log(r.message+`
|
|
10
10
|
|
|
11
|
-
`+
|
|
12
|
-
`),
|
|
11
|
+
`+Ao(o,n.usageOpts));throw new zr(r.message)}},jr=(o,t,n)=>{let r=Jr(o),m={},f,G,E=n.start;for(;E<t.length;){let N=t[E];if(!f){if(n.help.includes(N)){console.log(Ao(o,n.usageOpts));return}let O=Xr(o,r,m,N);if(f=O.id,G=O.spec,E=E+~~(O.state<2),O.state)break}else{if(Pr(G,m,f,N))break;f=null,E++}}return f&&_(`missing value for: --${f}`),{result:br(o,m),index:E,rest:t.slice(E),done:E>=t.length}},Jr=(o)=>Object.entries(o).reduce((t,[n,r])=>r.alias?(t[r.alias]=n,t):t,{}),Xr=(o,t,n,r)=>{if(r[0]==="-"){let m;if(r[1]==="-"){if(r==="--")return{state:1};m=Qt(r.substring(2))}else m=t[r.substring(1)],!m&&_(`unknown option: ${r}`);let f=o[m];if(!f&&_(m),f.flag){if(n[m]=!0,m=void 0,f.fn&&!f.fn("true"))return{state:1,spec:f}}return{state:0,id:m,spec:f}}return{state:2}},Pr=(o,t,n,r)=>{if(/^-[a-z]/i.test(r)&&_(`missing value for: --${n}`),o.multi)T(t[n])?t[n].push(r):t[n]=[r];else t[n]=r;return o.fn&&!o.fn(r)},br=(o,t)=>{let n;for(let r in o)if(n=o[r],t[r]===void 0){if(n.default!==void 0)t[r]=n.default;else if(n.optional===!1)_(`missing arg: --${r}`)}else if(n.coerce)Zr(n,t,r);return t},Zr=(o,t,n)=>{try{if(o.multi&&o.delim)t[n]=t[n].reduce((r,m)=>(r.push(...m.split(o.delim)),r),[]);t[n]=o.coerce(t[n])}catch(r){throw new Error(`arg --${n}: ${r.message}`)}};var st=async(o)=>{let t=o.argv||process.argv,n=!process.env.NO_COLOR,r={prefix:"",color:n,...o.usage};try{let m,f,G=o.start??2;if(o.single){if(m=Object.keys(o.commands)[0],!m)_("no command provided");f=o.commands[m]}else{if(m=t[G],f=o.commands[m],r.prefix+=Kr(o.commands),!f)at(o,r);G++}let E;try{E=xt({...o.opts,...f.opts},t,{showUsage:!0,usageOpts:r,start:G})}catch(O){}if(!E)process.exit(1);if(f.inputs!==void 0&&f.inputs!==E.rest.length)process.stderr.write(`expected ${f.inputs||0} input(s)
|
|
12
|
+
`),at(o,r);let N=await o.ctx({logger:new Do(process.stderr,o.name,"INFO"),format:n?Jo:Vt,opts:E.result,inputs:E.rest},f);if(await f.fn(N),o.post)await o.post(N,f)}catch(m){process.stderr.write(m.message+`
|
|
13
13
|
|
|
14
|
-
`),process.exit(1)}},
|
|
14
|
+
`),process.exit(1)}},at=(o,t)=>{process.stderr.write(Ao(o.opts,t)),process.exit(1)},Kr=(o)=>[`
|
|
15
15
|
Available commands:
|
|
16
|
-
`,...Object.keys(
|
|
16
|
+
`,...Object.keys(o).map((t)=>`${zo(16)(t)}: ${o[t].desc}`),`
|
|
17
17
|
`].join(`
|
|
18
|
-
`);import{existsSync as Vr,mkdirSync as qr,statSync as LE}from"fs";import{dirname as pr}from"path";var Qr=(
|
|
19
|
-
`):
|
|
18
|
+
`);import{existsSync as Vr,mkdirSync as qr,statSync as LE}from"fs";import{dirname as pr}from"path";var Qr=(o)=>o.length>0&&!Vr(o)?(qr(o,{recursive:!0}),!0):!1,ct=(o)=>Qr(pr(o));var X=(o)=>typeof o==="function";var i=(o)=>typeof o==="string";import{readFileSync as vr}from"fs";import{writeFileSync as kr}from"fs";var on=(o,t,n,r,m=!1)=>{if(r?.info(`${m?"[dryrun] ":""}writing file: ${o}`),m)return;ct(o),kr(o,t,!n&&i(t)?"utf-8":n)};var w=(o,t,n="utf-8")=>{return t?.debug("reading file:",o),vr(o,n)},Lt=(o,t,n,r=!1)=>on(o,T(t)?t.join(`
|
|
19
|
+
`):t,"utf-8",n,r);var P=(o,t)=>JSON.parse(w(o,t));var Z=Symbol(),Ct=()=>{};var Fo=Object.freeze({level:A.NONE,addChild(o){return o},childLogger:()=>Fo,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},none(){},logEntry(){}});class _t extends io{set(o){this.parent=o}childLogger(o,t){return new _t(o,t??this.level,this)}logEntry(o){this.parent.logEntry(o)}}var tn=new _t("root",A.FINE,Fo);import{join as Pm}from"path";var Bt=(o,t)=>{if(o===t)return 0;if(o==null)return t==null?0:-1;if(t==null)return o==null?0:1;if(typeof o.compare==="function")return o.compare(t);if(typeof t.compare==="function")return-t.compare(o);return o<t?-1:o>t?1:0};var lr=U(()=>"Assertion failed"),bo=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(o,t)=>{if(typeof o==="function"&&!o()||!o)throw new lr(typeof t==="function"?t():t)}:()=>{};var Zo=(o)=>o!=null&&typeof o!=="function"&&o.length!==void 0;var nn=(o)=>{return(o==null||!o[Symbol.iterator])&&_(`value is not iterable: ${o}`),o};var rn=(o)=>Zo(o)?o:[...nn(o)];var So=(o)=>o[o.length-1];var Ko=(o,t)=>typeof o?.[t]==="function";var F=(o)=>typeof o?.[Symbol.iterator]==="function";var Vo=(o)=>o!=null&&typeof o!=="string"&&typeof o[Symbol.iterator]==="function";var dr=U(()=>"illegal arity"),no=(o)=>{throw new dr(o)};var gr=U(()=>"illegal state"),ro=(o)=>{throw new gr(o)};var mn=["-moz-","-ms-","-o-","-webkit-"],mo={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},qo={rules:`
|
|
20
20
|
`,ruleSep:", ",valSep:" ",decls:`
|
|
21
21
|
`,declStart:` {
|
|
22
22
|
`,declEnd:`}
|
|
23
|
-
`,indent:" ",comments:!0};function
|
|
23
|
+
`,indent:" ",comments:!0};function $t(...o){let[t,n,r,m,f,G,E,N,O,h]=o;switch(o.length){case 0:no(0);case 1:return t;case 2:return(...L)=>t(n(...L));case 3:return(...L)=>t(n(r(...L)));case 4:return(...L)=>t(n(r(m(...L))));case 5:return(...L)=>t(n(r(m(f(...L)))));case 6:return(...L)=>t(n(r(m(f(G(...L))))));case 7:return(...L)=>t(n(r(m(f(G(E(...L)))))));case 8:return(...L)=>t(n(r(m(f(G(E(N(...L))))))));case 9:return(...L)=>t(n(r(m(f(G(E(N(O(...L)))))))));case 10:default:let C=(...L)=>t(n(r(m(f(G(E(N(O(h(...L))))))))));return o.length===10?C:$t(C,...o.slice(10))}}var l=(o)=>Ko(o,"xform")?o.xform():o;function z(...o){return o=o.map(l),$t.apply(null,o)}var K=(o,t)=>[o[0],o[1],t];class wo{value;constructor(o){this.value=o}deref(){return this.value}}var H=(o)=>o instanceof wo,fn=(o)=>o instanceof wo?o:new wo(o),j=(o)=>o instanceof wo?o.deref():o;var xr=(o)=>o.length===2?[void 0,o[1]]:o.length===3?[o[1],o[2]]:no(o.length);function fo(...o){let t=o[0],n=t[0],r=t[1],m=t[2];o=xr(o);let f=o[0]==null?n():o[0],G=o[1];return j(r(Ko(G,"$reduce")?G.$reduce(m,f):Zo(G)?ar(m,f,G):sr(m,f,G)))}var ar=(o,t,n)=>{for(let r=0,m=n.length;r<m;r++)if(t=o(t,n[r]),H(t)){t=t.deref();break}return t},sr=(o,t,n)=>{for(let r of n)if(t=o(t,r),H(t)){t=t.deref();break}return t},Eo=(o,t)=>[o,eo,t],En=(o,t)=>{let n=t.length-1;return F(t[n])?t.length>1?fo(o.apply(null,t.slice(0,n)),t[n]):fo(o(),t[0]):void 0};function Go(o){return o?[...o]:Eo(()=>[],(t,n)=>(t.push(n),t))}function*No(o,t){let n=l(o)(Go()),r=n[1],m=n[2];for(let f of t){let G=m([],f);if(H(G)){yield*j(r(G.deref()));return}if(G.length)yield*G}yield*j(r([]))}function*d(o,t){let n=l(o)([Ct,Ct,(r,m)=>m])[2];for(let r of t){let m=n(Z,r);if(H(m)){if(m=j(m.deref()),m!==Z)yield m;return}if(m!==Z)yield m}}var po=(o,t,n=d)=>{let r=t.length-1;return F(t[r])?t.length>1?n(o.apply(null,t.slice(0,r)),t[r]):n(o(),t[0]):void 0};function et(o,t){return F(t)?No(et(o),i(t)?[t]:t):(n)=>{let r=n[2],m=(f,G)=>{let E=o(G);if(E){for(let N of E)if(f=m(f,N),H(f))break;return f}return r(f,G)};return K(n,m)}}function Gn(o){return et((t)=>Vo(t)?t:void 0,o)}function e(o,t){return F(t)?d(e(o),t):(n)=>{let r=n[2];return K(n,(m,f)=>r(m,o(f)))}}function*Qo(...o){let t=o.length-1;if(t<0)return;let n=new Array(t+1).fill(0),r=o.map(rn),m=r.reduce((f,G)=>f*G.length,1);for(let f=0;f<m;f++){let G=[];for(let E=t;E>=0;E--){let N=r[E],O=n[E];if(O===N.length)n[E]=O=0,E>0&&n[E-1]++;G[E]=N[O]}n[t]++,yield G}}function*Nn(o,t=1/0){while(t-- >0)yield o}function it(o,t){o=o||"";let n=!0;return t?[...t].join(o):Eo(()=>"",(r,m)=>(r=n?r+m:r+o+m,n=!1,r))}function ko(...o){return cr(ko,fo,o)}var cr=(o,t,n)=>{let r,m;switch(n.length){case 4:m=n[3],r=n[2];break;case 3:m=n[2];break;case 2:return e((f)=>o(n[0],n[1],f));default:no(n.length)}return t(l(n[0])(n[1]),r,m)};var om=new Set,tm=":[",On=z(Gn(),e((o)=>o[0]==="&"?o.substring(1):tm.includes(o[0])?o:" "+o)),nm=(o,t)=>z(o,e((n)=>i(n)&&n.startsWith(" .")?n+t:n)),Oo=(o,t,n,r)=>{let m=n.length,f=[],G,E,N=(O,h)=>{let C=null;if(T(h))Oo(o,At(t,f),h,r);else if(F(h)&&!i(h))Oo(o,At(t,f),[...h],r);else if((E=X(h))||(C=r.fns[h]))if(!t.length){if(C)return C.apply(null,n.slice(O+1))(o,r),!0;h(o,r)}else if(E)N(O,h());else _(`quoted fn ('${h}') only allowed at head position`);else if(D(h))G=Object.assign(G||{},h);else if(h!=null)f.push(h)};for(let O=0;O<m;O++)if(N(O,n[O]))return o;return G&&o.push(rm(t,f,G,r)),o},At=(o,t)=>o.length?[...Qo(o,t)]:t,rm=(o,t,n,r)=>{let m=r.format,f=J(r),G=r.scope?nm(On,r.scope):On;return[f,ko(e((E)=>ko(G,it(),T(E)?E:[E]).trim()),it(m.ruleSep),At(o,t)),m.declStart,Ho(n,r),f,m.declEnd].join("")},Ho=(o,t)=>{let n=t.format,r=t.autoprefix||om,m=J(t,t.depth+1),f=[];for(let G in o)if(o.hasOwnProperty(G)){let E=o[G];if(X(E))E=E(o);if(T(E))E=E.map((N)=>T(N)?N.join(" "):N).join(n.ruleSep);if(r.has(G))for(let N of t.vendors)f.push(`${m}${N}${G}:${n.valSep}${E};`);f.push(`${m}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},J=(o,t=o.depth)=>t>1?[...Nn(o.format.indent,t)].join(""):t>0?o.format.indent:"";function hn(o,...t){let n=t.length===1?t[0]:t.reduce((r,m,f)=>{return r[f/(t.length-1)*100|0]=m,r},{});return(r,m)=>{let f=J(m);m.depth++;let G=J(m);r.push(`${f}@keyframes ${o}${m.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))r.push([G,E+"%",m.format.declStart,Ho(n[E],m),G,m.format.declEnd].join(""));return m.depth--,r.push(f+m.format.declEnd),r}}var Ln=(o,t=!1)=>(n,r)=>{let m=J(r),f=J(r,r.depth+1);if(r.format.comments||t)n.push(m+"/*",o.split(`
|
|
24
24
|
`).map((G)=>f+G).join(`
|
|
25
|
-
`),m+"*/");return n};var vt=(t,o,n)=>(r,m)=>{let f=J(m);return r.push(`${f}${t} ${mm(o)}${m.format.declStart}`),m.depth++,Ot(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},mm=(t)=>{if(i(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=Cn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Cn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:mt,vendors:mn,fns:{},depth:0,...o},T(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),D(t)?Ht(t,o):X(t)?t([],o).join(o.format.rules):Ot([],[],T(t)?t:Vt(t)?[...t]:_("invalid rules"),o).join(o.format.rules)};var _n=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var ht=(t,o)=>vt("@media",t,o);function Bn(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var en=(t,o)=>vt("@supports",t,o);var lt={"@comment":Ln,"@import":_n,"@keyframes":hn,"@media":ht,"@namespace":Bn,"@supports":en};var $n=4,An=(t)=>$n=t,M=(t)=>t===(t|0)?String(t):t.toFixed($n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Tn=(t)=>`${M(t)}em`,Fn=(t)=>`${M(t)}ex`;var Sn=(t)=>`${M(t)}rem`,Ao=(t)=>`${M(t)}%`,wn=(t)=>`${M(t)}px`,Hn=(t)=>`${M(t)}vh`,un=(t)=>`${M(t)}vw`,yn=(t)=>`${M(t)}vmin`,Mn=(t)=>`${M(t)}vmax`,In=(t)=>`${t|0}ms`,Wn=(t)=>`${M(t)}s`;var Rn=(t)=>`${M(t)}deg`,Un=(t)=>`${M(t)}rad`,Yn=(t)=>`${M(t)}turn`,Dn=(t)=>`url(${t})`;var S=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(S||{});var fm=0,Em=()=>fm++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Em()}:o;var u=on.childLogger("rstream");class V{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(Gt()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Z;state=S.IDLE;subs=[];deref(){return this.last!==Z?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof V&&!o.xform)t.ensureState(),bt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new V(t,{...o,parent:this});return this.subs.push(n),this.setState(S.ACTIVE),n.setState(S.ACTIVE),this.last!=Z&&n.next(this.last),n}transform(...t){let o,n;if(D(St(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform($(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return u.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<S.UNSUBSCRIBED&&(this.state=S.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){u.debug(this.id,"unsub child",t.id);let o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(t){if(this.state>=S.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(u.debug(this.id,"entering done()"),this.state>=S.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=S.DONE,this.dispatchTo("done"))this.state<S.UNSUBSCRIBED&&this.unsubscribe();u.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&u.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(u.parent!==Ft?u:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=S.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(m){if(!this.error(m))return!1}let r=t==="next"?this.subs:[...this.subs];for(let m=r.length;m-- >0;){n=r[m];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){u.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))H(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){let o=j(t);for(let n=0,r=o.length;n<r&&this.state<S.DONE;n++)this.dispatch(o[n]);return this.state<S.ERROR}ensureState(){if(this.state>=S.DONE)rt(`operation not allowed in state ${S[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var zn=(t,o)=>{let n=new jn(o);return n.next(t),n};class jn extends V{src;_cancel;_inited;constructor(t,o){let[n,r]=X(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,x("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){let n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(r){let m=this.wrapped;if(!m||!m.error||!m.error(r))this.unhandledError(r)}this._inited=!0}return n}unsubscribe(t){let o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){u.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var Jn=(t,o)=>t==="first"||t==="last"&&!o;function To(t){return t?ft(To(),t):Et(()=>({}),(o,[n,r])=>(o[n]=r,o))}var Xn=()=>(t)=>{let o=t[2];return K(t,(n,r)=>{if(r){for(let m of j(r)||[])if(n=o(n,m),H(n))break}return H(r)?fn(n):n})};function Fo(t,o){return F(o)?Nt(Fo(t),o):z($(t),Xn())}function So(t,o){return F(o)?d(So(t),o):$(X(t)?(n)=>[t(n),n]:(n)=>[t,n])}function wo(...t){let o=pt(wo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return $((m)=>{let f=r?{}:m;for(let G in m)f[G]=n(m[G]);return f})}var Pn=(t)=>t;function Ho(...t){let o=pt(Ho,t,Nt);if(o)return o;let{key:n=Pn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:G=0}=t[1],E=T(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},C=([L,B,I])=>{let k=!0;if(r||G<1)return[L,(e)=>{if(m&&f&&N.size>0||!m&&k)e=I(e,h),h={},N.clear(),k=!1;return B(e)},(e,v)=>{let y=n(v);if(E.has(y)){if(h[y]=v,N.add(y),r||bn(E,N))if(e=I(e,h),k=!1,m)h={},N.clear();else h={...h}}return e}];else return[L,(e)=>{if(f&&N.size>0)e=I(e,Zn(O,N)),O.clear(),N.clear();return B(e)},(e,v)=>{let y=n(v);if(E.has(y)){let b=O.get(y);!b&&O.set(y,b=[]),b.length>=G&&rt(`max back pressure (${G}) exceeded for input: ${String(y)}`),b.push(v),N.add(y);while(bn(E,N))if(e=I(e,Zn(O,N)),k=!1,H(e))break}return e}]};return C.keys=()=>E,C.clear=()=>{O.clear(),E.clear(),N.clear(),h={}},C.add=(L)=>{E.add(L)},C.delete=(L,B=!0)=>{if(O.delete(L),E.delete(L),B)N.delete(L),delete h[L]},C}var bn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Zn=(t,o)=>{let n={};for(let r of o){let m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var Kn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var dt=(t)=>new Vn(t);class Vn extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Ho(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=wo((r)=>r[1]);super(void 0,x("streamsync",{...t,xform:t.xform?z(o,n,t.xform):z(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof V?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:So(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){let o=this.sources.get(t);if(o){let n=this.invRealSourceIDs.get(t.id);return u.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){let o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return Kn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){let t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){u.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Jn(this.closeIn,this.sources.size)&&this.done()}}var uo=R((t,o=" ")=>{let n=tt(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?n.substring(m)+r:r}}),p1=uo(2,"0"),Q1=uo(3,"0"),qn=uo(4,"0");var Gm=/\{(\d+)\}/g;var yo=(t,...o)=>o.length>0?t.replace(Gm,(n,r)=>String(o[parseInt(r,10)])):t;var pn=(t)=>({key:(o)=>o,group:Gt(),...t});function Mo(...t){let o=En(Mo,t);if(o)return o;let n=pn(t[0]),[r,m,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=m(G[E]);return G},(G,E)=>{let N=n.key(E);return G[N]=G[N]?f(G[N],E):f(r(),E),G}]}function Io(t,o){return F(o)?d(Io(t),o):(n)=>{let r=n[2];return K(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as dn}from"fs";import{resolve as a}from"path";var Qn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},gt={bundle:W({alias:"b",desc:"Bundle inputs (see `out` option)"})},Lt={include:Ut({alias:"I",desc:"Include CSS files (prepend)"})},xt={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},at={force:Ut({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},kn={media:Ut({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},vn={onlyDecls:W({desc:"Only emit framework decls"})},q={out:Y({alias:"o",desc:"Output file (or stdout)"})},st={prec:Yt({default:3,desc:"Number of fractional digits"})},p={pretty:W({alias:"p",desc:"Pretty print output"})},Ct={noDecls:W({alias:"d",desc:"Don't emit framework decls"})},_t={noHeader:W({desc:"Don't emit generated header comment"})},Bt={scope:Y({desc:"Suffix for CSS class names"})},et={watch:W({alias:"w",desc:"Watch input files for changes"})};import{watch as Nm}from"fs";import{resolve as ln}from"path";var Q=(t,o,n)=>{o=i(o)?o:o.join(`
|
|
26
|
-
`),
|
|
27
|
-
`)},ct=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,ut=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=ln(m);let G=zn(w(m,o),{id:`in${qn(f)}`});return{input:G,watcher:Nm(m,{},(E)=>{if(E==="change")try{G.next(w(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),dt({src:To($(({input:m})=>[m.id,m],r))})},to=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...q,...p,...Bt,...Qn,...et,noWrite:W({desc:"Don't write files, use stdout only"})},fn:Wo};async function Wo(t){let o=P(a(t.opts.specs),t.logger),n=_m(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await hm(t,n);else Mt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>w(a(r),t.logger)),t.opts.out);else if(t.opts.watch)await Om(t,o,n);else if(t.opts.eval)try{Mt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=a(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;Mt(t,o,n,[w(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Om=async(t,o,n)=>{let r=a(t.opts.specs),m,f={process:()=>{try{return o=P(r,t.logger),m.forEach((E)=>E.process()),!0}catch(E){return t.logger.warn(E.message+": "+r),!1}},watcher:dn(r,{},(E)=>{if(E==="change")f.process();else t.logger.warn("specs file removed:",r),G()})},G=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((E)=>E.watcher.close())};m=t.inputs.map((E)=>{E=a(E);let N=!t.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return Mt(t,o,n,[w(E,t.logger)],N),!0}catch(h){if(t.logger.warn(h.message+": "+E),m)G();return!1}};if(!O())process.exit(1);return{process:O,watcher:dn(E,{},(h)=>{if(h==="change")O();else t.logger.warn("input removed:",E),G()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},hm=async(t,o)=>{dt({src:{styles:ut(t.inputs,t.logger),specs:ut([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{Mt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},Mt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},G,E,N,O)=>{let h={logger:t,specs:G,css:{format:m?qt:mt,fns:lt,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},C=o?o.map((L)=>w(a(L),t).trim()):[];if(!r)C.push(ct(G));if(!n&&G.decls.length)C.push(g(G.decls,h.css));N.forEach((L)=>Bm(L,h)),Cm(C,h),Lm(C,h),Q(O,C,t)},Lm=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let G=sn(r[f],m);n.debug("mediaquery rules",f,G),t.push(g(ht(Am(m.media,f),G),o))}},Cm=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=sn(r,m);n.debug("plain rules",f),t.push(g(f,o))},_m=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},G={};if(o.length&&o[0][0]==="@")o=[...ot(w(a(o[0].substring(1)),n))];for(let E of o){if(!E||E.startsWith("//"))continue;let{token:N,query:O}=cn(E,r),h;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);h=[...Io((L)=>C.test(L),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let C of h)n.debug("including class:",C),O?tr(f,O,`.${C}`,C):or(G,`.${C}`,C)}return{mediaQueryRules:f,plainRules:G}},Bm=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=It(),G=It(f),E={root:f,curr:G,scopes:[G]};for(let N of ot(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of em(N)){if(!O)continue;let h=E.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((C)=>C.replace(",","")),h.path=$m(E.scopes);h.state="class"}else if(O==="}")gn(E);else{let C=St(h.sel);if(!C||C.endsWith(","))h.sel.push(O);else h.sel[h.sel.length-1]+=" "+O}break;case"class":if(O==="{")h.state="nest",E.scopes.push(E.curr=It(h));else if(O==="}")gn(E);else{let{token:C,query:L}=cn(O,n);if(!o.classes[C]&&!(nr(C)||mr(C)||rr(C)))_(`unknown class ID: ${C}`);if(L)tr(r,L,h.path,C);else or(m,h.path,C)}break;default:rt(h.state)}}}};function*em(t){let o=-1,n=t.length,r=0,m=0;for(let f=0;f<n;f++){let G=t[f];if(G===" "||G==="\t"){if(!(r||m)&&o>=0)yield t.substring(o,f),o=-1}else if(G==="{"||G==="}"){if(o>=0)yield t.substring(o,f);yield G,o=-1}else if(G==="(")r++;else if(G===")"){if(--r<0)_(`invalid nesting in line: '${t}'`)}else if(G==="["){if(o<0)o=f;m++}else if(G==="]"){if(--m<0)_(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=f}if(r)_("template calls must be fully on a single line");if(m)_("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var yt=":",an="///",It=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),gn=(t)=>{let o=!t.curr.sel.length;if(bt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=St(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=It(t.curr))}else t.scopes.push(t.curr=It(t.root))},$m=(t)=>t.map((o)=>o.sel.join(",")).join(an),sn=(t,o)=>Object.entries(t).map(([n,r])=>im(n,r,o)),im=(t,o,n)=>{let r=[],m=r,f=t.split(an);for(let G=0;G<f.length;G++){let E=f[G].split(",");if(G==f.length-1){let N=Object.assign({},...$((O)=>mr(O)?Sm(O):nr(O)?Tm(O):rr(O)?Fm(n,O):to(n.classes[O]),o));E.push(N)}m.push(E),m=E}return r[0]},cn=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(yt);if(n<0)return{token:t};let r=t.indexOf("("),m=t.indexOf("[");if(r>0||m>0){let E=r>0?m>0?Math.min(r,m):r:m;if(E<n&&t.indexOf(yt)>E)return{token:t};n=t.substring(0,E).lastIndexOf(yt)}let f=t.substring(0,n);if(!f.split(yt).every((E)=>o.has(E)))_(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:f}},Am=(t,o)=>o.split(yt).reduce((n,r)=>Object.assign(n,t[r]),{}),tr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},or=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Tm=(t)=>{let o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Fm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=t.templates[r];if(!f)_(`unknown template: ${r}`);if(m.length!==f.__arity)_(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=yo(E,...m),i(N))N=yo(N,...m);G[E]=N}return G},{})},Sm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},nr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),rr=(t)=>t.includes("(")&&t.endsWith(")"),mr=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Er={deg:Rn,em:Tn,ex:Fn,ms:In,percent:Ao,px:wn,rad:Un,rem:Sn,second:Wn,turn:Yn,url:Dn,vh:Hn,vmax:Mn,vmin:yn,vw:un,"%":Ao},wm={percent:"{0}%",second:"{0}s",url:"url({0})"},Hm={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Gr={desc:"Generate framework rules from specs",opts:{...q,...st,...p,...et},fn:Ro};async function Ro(t){if(t.opts.watch)await um(t);else await Nr(t.inputs.map((o)=>w(o,t.logger)),t.opts,t.logger)}var um=async(t)=>{ut(t.inputs,t.logger).subscribe({next(o){try{Nr(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Nr=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};An(o.prec);for(let m of t){let f=JSON.parse(m);if(Object.assign(r.info,f.info),Object.assign(r.media,f.media),f.decls)r.decls.push(...f.decls);if(f.specs)for(let G of f.specs)try{Or(f,G,r.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)ym(f,G,r.templates,n)}return Q(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Or=(t,o,n,r,m=!1)=>{let f=T(o.vars)?o.vars:[""],G=i(o.props)?{[o.props]:"<v>"}:o.props,E=Mm(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||Hm[O];if(!h)_(`unknown variation ID: ${O}`);for(let[C,L]of Qt(h,Object.keys(E))){let B=s(o.name,O,C,L,E[L]),I=o.unit?s(o.unit,O,C,L,E[L]):void 0,k=m?Wm(I):Im(E[L],I);if(!n[B]){if(n[B]={},o.user!=null)n[B].__user=o.user;if(o.doc!=null)n[B].__doc=Rm(o.doc,O,C,L,k)}else if(!N.has(B))_(`duplicate class ID: ${B}`);N.add(B);let e=-1;for(let[v,y]of Object.entries(G)){let b=s(v,O,C,L,E[L]),oo=s(!I||i(y)?String(y):Er[I](y),O,C,L,k);if(n[B][b]=oo,r.debug(B,b,oo),m)e=fr(oo,fr(b,e))}if(m)n[B].__arity=e+1}}return n},ym=(t,o,n,r)=>Or(t,{...o,values:[""]},n,r,!0),fr=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},Mm=(t,o)=>{let n=i(t.values)?o.tables?.[t.values]||_(`invalid table ID: ${t.values}`):t.values;if(D(n))return n;let r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key==="i"||t.key===void 0?(m,f)=>String(f):_(`invalid key type: ${t.key}`);return n.reduce((m,f,G)=>{return m[r(f,G)]=f,m},{})},Im=(t,o)=>{if(!o||i(t))return t;let n=Er[o];if(!n)_(`invalid unit: ${o}`);return n(t)},Wm=(t)=>t?wm[t]||"{0}"+t:"{0}",s=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Rm=({group:t,desc:o,args:n},r,m,f,G)=>({group:t?s(t,r,m,f,G):"TODO",desc:o?s(o,r,m,f,G):void 0,args:n?n.map((E)=>s(E,r,m,f,G)):void 0});var hr={desc:"Combination of the generate & convert commands",opts:{...gt,...xt,...at,...Lt,...Ct,..._t,...st,...p,...Bt,...et,outCss:Y({desc:"Output file for CSS bundle",optional:!1}),outSpecs:Y({desc:"Output file for framework",optional:!1})},fn:async(t)=>{let{opts:o,inputs:n}=t,[r,m]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},G={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Ro(f),await Wo(G)}};import{resolve as Um}from"path";var _r={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Yt({alias:"l",desc:"Initial heading level",default:1}),title:Y({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{let{logger:o,opts:n,inputs:r}=t,m=P(Um(r[0]),o),f=Ym(m,n);Q(n.out,f,o)}},Ym=(t,{level:o,title:n})=>{let r=Object.keys(t.classes).length,m=Object.keys(t.templates).length,f=[`Currently, there are ${r+m} CSS utility classes (incl. ${m} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${c(o+1)} Classes by category`,"",...Cr(t.classes,zm,o+2),`${c(o+1)} Templates by category`,"",...Cr(t.templates,jm,o+2),`${c(o+1)} Media queries`,"",...Object.entries(t.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(o)} ${n??t.info.name}
|
|
28
|
-
`);return f},Lr=(
|
|
25
|
+
`),m+"*/");return n};var vo=(o,t,n)=>(r,m)=>{let f=J(m);return r.push(`${f}${o} ${mm(t)}${m.format.declStart}`),m.depth++,Oo(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},mm=(o)=>{if(i(o))return o;let t=[];for(let n in o)if(o.hasOwnProperty(n)){let r=o[n];if(r===!0)r=Cn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Cn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;t.push(r)}return t.join(" and ")},Cn=new Set(["all","print","screen"]);var g=(o,t)=>{return t={format:mo,vendors:mn,fns:{},depth:0,...t},T(t.autoprefix)&&(t.autoprefix=new Set(t.autoprefix)),D(o)?Ho(o,t):X(o)?o([],t).join(t.format.rules):Oo([],[],T(o)?o:Vo(o)?[...o]:_("invalid rules"),t).join(t.format.rules)};var _n=(o,...t)=>(n,r)=>(n.push(t.length?`@import url(${o}) ${t.join(r.format.ruleSep)};`:`@import url(${o});`),n);var ho=(o,t)=>vo("@media",o,t);function Bn(...o){return(t,n)=>(t.push(o.length>1?`@namespace ${o[0]} url(${o[1]});`:`@namespace url(${o[0]});`),t)}var $n=(o,t)=>vo("@supports",o,t);var lo={"@comment":Ln,"@import":_n,"@keyframes":hn,"@media":ho,"@namespace":Bn,"@supports":$n};var en=4,An=(o)=>en=o,u=(o)=>o===(o|0)?String(o):o.toFixed(en).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Tn=(o)=>`${u(o)}em`,Fn=(o)=>`${u(o)}ex`;var Sn=(o)=>`${u(o)}rem`,Tt=(o)=>`${u(o)}%`,wn=(o)=>`${u(o)}px`,Hn=(o)=>`${u(o)}vh`,Mn=(o)=>`${u(o)}vw`,yn=(o)=>`${u(o)}vmin`,un=(o)=>`${u(o)}vmax`,In=(o)=>`${o|0}ms`,Wn=(o)=>`${u(o)}s`;var Rn=(o)=>`${u(o)}deg`,Un=(o)=>`${u(o)}rad`,Yn=(o)=>`${u(o)}turn`,Dn=(o)=>`url(${o})`;var S=((o)=>{return o[o.IDLE=0]="IDLE",o[o.ACTIVE=1]="ACTIVE",o[o.DONE=2]="DONE",o[o.UNSUBSCRIBED=3]="UNSUBSCRIBED",o[o.ERROR=4]="ERROR",o})(S||{});var fm=0,Em=()=>fm++,x=(o,t)=>!t||!t.id?{...t,id:o+"-"+Em()}:t;var M=tn.childLogger("rstream");class V{constructor(o,t){this.wrapped=o,t=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...t}),this.parent=t.parent,this.id=t.id,this.closeIn=t.closeIn,this.closeOut=t.closeOut,this.cacheLast=t.cache,t.xform&&(this.xform=t.xform(Go()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=Z;state=S.IDLE;subs=[];deref(){return this.last!==Z?this.last:void 0}getState(){return this.state}setState(o){this.state=o}subscribe(o,t={}){this.ensureState();let n;if(o instanceof V&&!t.xform)o.ensureState(),bo(!o.parent,`sub '${o.id}' already has a parent`),o.parent=this,n=o;else n=new V(o,{...t,parent:this});return this.subs.push(n),this.setState(S.ACTIVE),n.setState(S.ACTIVE),this.last!=Z&&n.next(this.last),n}transform(...o){let t,n;if(D(So(o)))n=o.pop(),t={error:n.error};return this.subscribe(t,x("xform",o.length>0?{...n,xform:z(...o)}:n))}map(o,t){return this.transform(e(o),t||{})}unsubscribe(o){return o?this.unsubscribeChild(o):this.unsubscribeSelf()}unsubscribeSelf(){return M.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<S.UNSUBSCRIBED&&(this.state=S.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(o){M.debug(this.id,"unsub child",o.id);let t=this.subs.indexOf(o);if(t>=0){if(this.subs.splice(t,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(o){if(this.state>=S.DONE)return;this.xform?this.dispatchXform(o):this.dispatch(o)}done(){if(M.debug(this.id,"entering done()"),this.state>=S.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=S.DONE,this.dispatchTo("done"))this.state<S.UNSUBSCRIBED&&this.unsubscribe();M.debug(this.id,"exiting done()")}error(o){let n=this.wrapped?.error;return n&&M.debug(this.id,"attempting wrapped error handler"),n?.(o)||this.unhandledError(o)}unhandledError(o){return(M.parent!==Fo?M:console).warn(this.id,"unhandled error:",o),this.unsubscribe(),this.state=S.ERROR,!1}dispatchTo(o,t){let n=this.wrapped;if(n)try{n[o]&&n[o](t)}catch(m){if(!this.error(m))return!1}let r=o==="next"?this.subs:[...this.subs];for(let m=r.length;m-- >0;){n=r[m];try{n[o]&&n[o](t)}catch(f){if(o==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(o){M.debug(this.id,"dispatch",o),this.cacheLast&&(this.last=o),this.dispatchTo("next",o)}dispatchXform(o){let t;try{t=this.xform[2]([],o)}catch(n){this.error(n);return}if(this.dispatchXformVals(t))H(t)&&this.done()}dispatchXformDone(){let o;try{o=this.xform[1]([])}catch(t){return this.error(t)}return this.dispatchXformVals(o)}dispatchXformVals(o){let t=j(o);for(let n=0,r=t.length;n<r&&this.state<S.DONE;n++)this.dispatch(t[n]);return this.state<S.ERROR}ensureState(){if(this.state>=S.DONE)ro(`operation not allowed in state ${S[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var zn=(o,t)=>{let n=new jn(t);return n.next(o),n};class jn extends V{src;_cancel;_inited;constructor(o,t){let[n,r]=X(o)?[o,t||{}]:[void 0,o||{}];super(r.error?{error:r.error}:void 0,x("stream",r));this.src=n,this._inited=!1}subscribe(o,t={}){let n=super.subscribe(o,t);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(r){let m=this.wrapped;if(!m||!m.error||!m.error(r))this.unhandledError(r)}this._inited=!0}return n}unsubscribe(o){let t=super.unsubscribe(o);if(t&&(!o||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return t}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(o){if(super.error(o))return!0;return this.cancel(),!1}cancel(){if(this._cancel){M.debug(this.id,"cancel");let o=this._cancel;delete this._cancel,o()}}}var Jn=(o,t)=>o==="first"||o==="last"&&!t;function Ft(o){return o?fo(Ft(),o):Eo(()=>({}),(t,[n,r])=>(t[n]=r,t))}var Xn=()=>(o)=>{let t=o[2];return K(o,(n,r)=>{if(r){for(let m of j(r)||[])if(n=t(n,m),H(n))break}return H(r)?fn(n):n})};function St(o,t){return F(t)?No(St(o),t):z(e(o),Xn())}function wt(o,t){return F(t)?d(wt(o),t):e(X(o)?(n)=>[o(n),n]:(n)=>[o,n])}function Ht(...o){let t=po(Ht,o);if(t)return t;let n=o[0],r=o[1]!==!1;return e((m)=>{let f=r?{}:m;for(let G in m)f[G]=n(m[G]);return f})}var Pn=(o)=>o;function Mt(...o){let t=po(Mt,o,No);if(t)return t;let{key:n=Pn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:G=0}=o[1],E=T(o[0])?new Set(o[0]):o[0],N=new Set,O=new Map,h={},C=([L,B,I])=>{let k=!0;if(r||G<1)return[L,($)=>{if(m&&f&&N.size>0||!m&&k)$=I($,h),h={},N.clear(),k=!1;return B($)},($,v)=>{let y=n(v);if(E.has(y)){if(h[y]=v,N.add(y),r||bn(E,N))if($=I($,h),k=!1,m)h={},N.clear();else h={...h}}return $}];else return[L,($)=>{if(f&&N.size>0)$=I($,Zn(O,N)),O.clear(),N.clear();return B($)},($,v)=>{let y=n(v);if(E.has(y)){let b=O.get(y);!b&&O.set(y,b=[]),b.length>=G&&ro(`max back pressure (${G}) exceeded for input: ${String(y)}`),b.push(v),N.add(y);while(bn(E,N))if($=I($,Zn(O,N)),k=!1,H($))break}return $}]};return C.keys=()=>E,C.clear=()=>{O.clear(),E.clear(),N.clear(),h={}},C.add=(L)=>{E.add(L)},C.delete=(L,B=!0)=>{if(O.delete(L),E.delete(L),B)N.delete(L),delete h[L]},C}var bn=(o,t)=>{if(t.size<o.size)return!1;for(let n of o)if(!t.has(n))return!1;return!0},Zn=(o,t)=>{let n={};for(let r of t){let m=o.get(r);n[r]=m.shift(),!m.length&&t.delete(r)}return n};var Kn=(o,t)=>{let n=!0;for(let r of t)n=o.removeID(r)&&n;return n};var go=(o)=>new Vn(o);class Vn extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(o){let t=Mt(new Set,{key:(r)=>r[0],mergeOnly:o.mergeOnly===!0,reset:o.reset===!0,all:o.all!==!1,backPressure:o.backPressure||0}),n=Ht((r)=>r[1]);super(void 0,x("streamsync",{...o,xform:o.xform?z(t,n,o.xform):z(t,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=t,this.clean=!!o.clean,o.src&&this.addAll(o.src)}add(o,t){t||(t=o.id),this.ensureState(),this.psync.add(t),this.realSourceIDs.set(t,o.id),this.invRealSourceIDs.set(o.id,t),this.idSources.set(o.id,o),this.sources.set(o,o.subscribe({next:(n)=>n[1]instanceof V?this.add(n[1]):this.next(n),done:()=>this.markDone(o),__owner:this},{xform:wt(t),id:`in-${t}`}))}addAll(o){for(let t in o)this.psync.add(t);for(let t in o)this.add(o[t],t)}remove(o){let t=this.sources.get(o);if(t){let n=this.invRealSourceIDs.get(o.id);return M.info(`removing src: ${o.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(o.id),this.idSources.delete(o.id),this.sources.delete(o),t.unsubscribe(),!0}return!1}removeID(o){let t=this.getSourceForID(o);return t?this.remove(t):!1}removeAll(o){for(let n of o)this.psync.delete(this.invRealSourceIDs.get(n.id));let t=!0;for(let n of o)t=this.remove(n)&&t;return t}removeAllIDs(o){return Kn(this,o)}getSourceForID(o){return this.idSources.get(this.realSourceIDs.get(o))}getSources(){let o={};for(let[t,n]of this.idSources)o[this.invRealSourceIDs.get(t)]=n;return o}unsubscribe(o){if(!o){M.debug(this.id,"unsub sources");for(let t of this.sources.values())t.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(o)}markDone(o){this.remove(o),Jn(this.closeIn,this.sources.size)&&this.done()}}var yt=R((o,t=" ")=>{let n=oo(String(t),o);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<o?n.substring(m)+r:r}}),p1=yt(2,"0"),Q1=yt(3,"0"),qn=yt(4,"0");var Gm=/\{(\d+)\}/g;var ut=(o,...t)=>t.length>0?o.replace(Gm,(n,r)=>String(t[parseInt(r,10)])):o;var pn=(o)=>({key:(t)=>t,group:Go(),...o});function It(...o){let t=En(It,o);if(t)return t;let n=pn(o[0]),[r,m,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=m(G[E]);return G},(G,E)=>{let N=n.key(E);return G[N]=G[N]?f(G[N],E):f(r(),E),G}]}function Wt(o,t){return F(t)?d(Wt(o),t):(n)=>{let r=n[2];return K(n,(m,f)=>o(f)?r(m,f):m)}}import{watch as dn}from"fs";import{resolve as a}from"path";var Qn={specs:Y({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xo={bundle:W({alias:"b",desc:"Bundle inputs (see `out` option)"})},Lo={include:Uo({alias:"I",desc:"Include CSS files (prepend)"})},ao={eval:Y({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},so={force:Uo({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},kn={media:Uo({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},vn={onlyDecls:W({desc:"Only emit framework decls"})},q={out:Y({alias:"o",desc:"Output file (or stdout)"})},co={prec:Yo({default:3,desc:"Number of fractional digits"})},p={pretty:W({alias:"p",desc:"Pretty print output"})},Co={noDecls:W({alias:"d",desc:"Don't emit framework decls"})},_o={noHeader:W({desc:"Don't emit generated header comment"})},Bo={scope:Y({desc:"Suffix for CSS class names"})},$o={watch:W({alias:"w",desc:"Watch input files for changes"})};import{watch as Nm}from"fs";import{resolve as ln}from"path";var Q=(o,t,n)=>{t=i(t)?t:t.join(`
|
|
26
|
+
`),o?Lt(ln(o),t,n):process.stdout.write(t+`
|
|
27
|
+
`)},ot=({info:{name:o,version:t}})=>`/*! ${o} v${t} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Mo=(o,t)=>{let n=()=>{t.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=o.map((m,f)=>{m=ln(m);let G=zn(w(m,t),{id:`in${qn(f)}`});return{input:G,watcher:Nm(m,{},(E)=>{if(E==="change")try{G.next(w(m,t))}catch(N){t.warn(N.message),n()}else t.warn("input removed:",m),n()})}});return process.on("SIGINT",n),go({src:Ft(e(({input:m})=>[m.id,m],r))})},tt=(o)=>Object.keys(o).reduce((t,n)=>{if(!n.startsWith("__"))t[n]=o[n];return t},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xo,...ao,...so,...Lo,...Co,..._o,...q,...p,...Bo,...Qn,...$o,noWrite:W({desc:"Don't write files, use stdout only"})},fn:Rt};async function Rt(o){let t=P(a(o.opts.specs),o.logger),n=_m(t,o.opts.force||[],o.logger);if(o.opts.bundle)if(o.opts.watch)await hm(o,n);else uo(o,t,n,o.opts.eval?[o.opts.eval]:o.inputs.map((r)=>w(a(r),o.logger)),o.opts.out);else if(o.opts.watch)await Om(o,t,n);else if(o.opts.eval)try{uo(o,t,n,[o.opts.eval])}catch(r){o.logger.warn(r.message)}else for(let r of o.inputs)try{r=a(r);let m=!o.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;uo(o,t,n,[w(r,o.logger)],m)}catch(m){o.logger.warn(m.message)}}var Om=async(o,t,n)=>{let r=a(o.opts.specs),m,f={process:()=>{try{return t=P(r,o.logger),m.forEach((E)=>E.process()),!0}catch(E){return o.logger.warn(E.message+": "+r),!1}},watcher:dn(r,{},(E)=>{if(E==="change")f.process();else o.logger.warn("specs file removed:",r),G()})},G=()=>{o.logger.info("closing watchers..."),f.watcher.close(),m.forEach((E)=>E.watcher.close())};m=o.inputs.map((E)=>{E=a(E);let N=!o.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return uo(o,t,n,[w(E,o.logger)],N),!0}catch(h){if(o.logger.warn(h.message+": "+E),m)G();return!1}};if(!O())process.exit(1);return{process:O,watcher:dn(E,{},(h)=>{if(h==="change")O();else o.logger.warn("input removed:",E),G()})}}),o.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},hm=async(o,t)=>{go({src:{styles:Mo(o.inputs,o.logger),specs:Mo([o.opts.specs],o.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{uo(o,r,t,Object.keys(n).sort().map((m)=>n[m]),o.opts.out)}catch(m){o.logger.warn(m.message)}}})},uo=({logger:o,opts:{include:t,noDecls:n,noHeader:r,pretty:m,scope:f}},G,E,N,O)=>{let h={logger:o,specs:G,css:{format:m?qo:mo,fns:lo,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},C=t?t.map((L)=>w(a(L),o).trim()):[];if(!r)C.push(ot(G));if(!n&&G.decls.length)C.push(g(G.decls,h.css));N.forEach((L)=>Bm(L,h)),Cm(C,h),Lm(C,h),Q(O,C,o)},Lm=(o,{css:t,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let G=sn(r[f],m);n.debug("mediaquery rules",f,G),o.push(g(ho(Am(m.media,f),G),t))}},Cm=(o,{css:t,logger:n,plainRules:r,specs:m})=>{let f=sn(r,m);n.debug("plain rules",f),o.push(g(f,t))},_m=(o,t,n)=>{let r=new Set(Object.keys(o.media)),m=new Set(Object.keys(o.classes)),f={},G={};if(t.length&&t[0][0]==="@")t=[...to(w(a(t[0].substring(1)),n))];for(let E of t){if(!E||E.startsWith("//"))continue;let{token:N,query:O}=cn(E,r),h;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);h=[...Wt((L)=>C.test(L),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let C of h)n.debug("including class:",C),O?or(f,O,`.${C}`,C):tr(G,`.${C}`,C)}return{mediaQueryRules:f,plainRules:G}},Bm=(o,{specs:t,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Io(),G=Io(f),E={root:f,curr:G,scopes:[G]};for(let N of to(o)){if(!N||/^\s*\/\//.test(N))continue;for(let O of $m(N)){if(!O)continue;let h=E.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((C)=>C.replace(",","")),h.path=em(E.scopes);h.state="class"}else if(O==="}")gn(E);else{let C=So(h.sel);if(!C||C.endsWith(","))h.sel.push(O);else h.sel[h.sel.length-1]+=" "+O}break;case"class":if(O==="{")h.state="nest",E.scopes.push(E.curr=Io(h));else if(O==="}")gn(E);else{let{token:C,query:L}=cn(O,n);if(!t.classes[C]&&!(nr(C)||mr(C)||rr(C)))_(`unknown class ID: ${C}`);if(L)or(r,L,h.path,C);else tr(m,h.path,C)}break;default:ro(h.state)}}}};function*$m(o){let t=-1,n=o.length,r=0,m=0,f=!1;for(let G=0;G<n;G++){let E=o[G];if(E==='"'&&!(r||m))if(f)yield o.substring(t,G+1),t=-1,f=!1;else f=!0;else if(E===" "||E==="\t"){if(!(r||m||f)&&t>=0)yield o.substring(t,G),t=-1}else if(E==="{"||E==="}"){if(t>=0)yield o.substring(t,G);yield E,t=-1}else if(E==="(")r++;else if(E===")"){if(--r<0)_(`invalid nesting in line: '${o}'`)}else if(E==="["){if(t<0)t=G;m++}else if(E==="]"){if(--m<0)_(`invalid arg nesting in line: '${o}'`)}else if(t<0)t=G}if(f)_("string literals must be fully on a single line");if(r)_("template calls must be fully on a single line");if(m)_("verbatim properties must be fully on a single line");if(t>=0)yield o.substring(t,n)}var yo=":",an="///",Io=(o)=>({state:"sel",sel:o?[]:["<root>"],path:"",parent:o}),gn=(o)=>{let t=!o.curr.sel.length;if(bo(!!o.curr.parent,"stack underflow"),o.scopes.pop(),o.scopes.length>0){if(o.curr=So(o.scopes),!t&&o.curr.state==="nest")o.scopes.push(o.curr=Io(o.curr))}else o.scopes.push(o.curr=Io(o.root))},em=(o)=>o.map((t)=>t.sel.join(",")).join(an),sn=(o,t)=>Object.entries(o).map(([n,r])=>im(n,r,t)),im=(o,t,n)=>{let r=[],m=r,f=o.split(an);for(let G=0;G<f.length;G++){let E=f[G].split(",");if(G==f.length-1){let N=Object.assign({},...e((O)=>mr(O)?Sm(O):nr(O)?Tm(O):rr(O)?Fm(n,O):tt(n.classes[O]),t));E.push(N)}m.push(E),m=E}return r[0]},cn=(o,t)=>{if(/^::?/.test(o))return{token:o};let n=o.lastIndexOf(yo);if(n<0)return{token:o};let r=o.indexOf("("),m=o.indexOf("[");if(r>0||m>0){let E=r>0?m>0?Math.min(r,m):r:m;if(E<n&&o.indexOf(yo)>E)return{token:o};n=o.substring(0,E).lastIndexOf(yo)}let f=o.substring(0,n);if(!f.split(yo).every((E)=>t.has(E)))_(`invalid media query in token: ${o}`);return{token:o.substring(n+1),query:f}},Am=(o,t)=>t.split(yo).reduce((n,r)=>Object.assign(n,o[r]),{}),or=(o,t,n,r)=>{if(!o[t])o[t]={};(o[t][n]||(o[t][n]=new Set)).add(r)},tr=(o,t,n)=>(o[t]||(o[t]=new Set)).add(n),Tm=(o)=>{let t=o.indexOf("="),n=o.substring(0,t),r=o.substring(t+1);return{[`--${n}`]:r[0]==='"'?r.slice(1,-1):r}},Fm=(o,t)=>{let n=t.indexOf("("),r=t.substring(0,n),m=t.substring(n+1,t.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=o.templates[r];if(!f)_(`unknown template: ${r}`);if(m.length!==f.__arity)_(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,N])=>{if(!E.startsWith("__")){if(E=ut(E,...m),i(N))N=ut(N,...m);G[E]=N}return G},{})},Sm=(o)=>{let[t,n,r]=/^(.+)-\[(.+)\]/.exec(o);return{[n]:r}},nr=(o)=>/^[a-z0-9:_-]+=.+/i.test(o),rr=(o)=>o.includes("(")&&o.endsWith(")"),mr=(o)=>o.indexOf("-[")>0&&o.endsWith("]");var Er={deg:Rn,em:Tn,ex:Fn,ms:In,percent:Tt,px:wn,rad:Un,rem:Sn,second:Wn,turn:Yn,url:Dn,vh:Hn,vmax:un,vmin:yn,vw:Mn,"%":Tt},wm={percent:"{0}%",second:"{0}s",url:"url({0})"},Hm={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"],in:[""],out:[""]},Gr={desc:"Generate framework rules from specs",opts:{...q,...co,...p,...$o},fn:Ut};async function Ut(o){if(o.opts.watch)await Mm(o);else await Nr(o.inputs.map((t)=>w(t,o.logger)),o.opts,o.logger)}var Mm=async(o)=>{Mo(o.inputs,o.logger).subscribe({next(t){try{Nr(Object.keys(t).sort().map((n)=>t[n]),o.opts,o.logger)}catch(n){o.logger.warn(n.message)}}})},Nr=async(o,t,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};An(t.prec);for(let m of o){let f=JSON.parse(m);if(Object.assign(r.info,f.info),Object.assign(r.media,f.media),f.decls)r.decls.push(...f.decls);if(f.specs)for(let G of f.specs)try{Or(f,G,r.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)ym(f,G,r.templates,n)}return Q(t.out,JSON.stringify(r,null,t.pretty?4:0),n),r},Or=(o,t,n,r,m=!1)=>{let f=T(t.vars)?t.vars:[""],G=i(t.props)?{[t.props]:"<v>"}:t.props,E=um(t,o),N=new Set;for(let O of f){let h=o.vars?.[O]||Hm[O];if(!h)_(`unknown variation ID: ${O}`);for(let[C,L]of Qo(h,Object.keys(E))){let B=s(t.name,O,C,L,E[L]),I=t.unit?s(t.unit,O,C,L,E[L]):void 0,k=m?Wm(I):Im(E[L],I);if(!n[B]){if(n[B]={},t.user!=null)n[B].__user=t.user;if(t.doc!=null)n[B].__doc=Rm(t.doc,O,C,L,k)}else if(!N.has(B))_(`duplicate class ID: ${B}`);N.add(B);let $=-1;for(let[v,y]of Object.entries(G)){let b=s(v,O,C,L,E[L]),nt=s(!I||i(y)?String(y):Er[I](y),O,C,L,k);if(n[B][b]=nt,r.debug(B,b,nt),m)$=fr(nt,fr(b,$))}if(m)n[B].__arity=$+1}}return n},ym=(o,t,n,r)=>Or(o,{...t,values:[""]},n,r,!0),fr=(o,t)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(o))t=Math.max(t,+r[1]);return t},um=(o,t)=>{let n=i(o.values)?t.tables?.[o.values]||_(`invalid table ID: ${o.values}`):o.values;if(D(n))return n;let r=o.key==="v"?(m)=>String(m):o.key==="i+1"?(m,f)=>String(f+1):o.key==="i"||o.key===void 0?(m,f)=>String(f):_(`invalid key type: ${o.key}`);return n.reduce((m,f,G)=>{return m[r(f,G)]=f,m},{})},Im=(o,t)=>{if(!t||i(o))return o;let n=Er[t];if(!n)_(`invalid unit: ${t}`);return n(o)},Wm=(o)=>o?wm[o]||"{0}"+o:"{0}",s=(o,t,n,r,m)=>o.replace(/<vid>/g,t).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Rm=({group:o,desc:t,args:n},r,m,f,G)=>({group:o?s(o,r,m,f,G):"TODO",desc:t?s(t,r,m,f,G):void 0,args:n?n.map((E)=>s(E,r,m,f,G)):void 0});var hr={desc:"Combination of the generate & convert commands",opts:{...xo,...ao,...so,...Lo,...Co,..._o,...co,...p,...Bo,...$o,outCss:Y({desc:"Output file for CSS bundle",optional:!1}),outSpecs:Y({desc:"Output file for framework",optional:!1})},fn:async(o)=>{let{opts:t,inputs:n}=o,[r,m]=n.reduce((E,N)=>(E[N.endsWith(".json")?0:1].push(N),E),[[],[]]),f={inputs:r,format:o.format,logger:o.logger,opts:{...t,out:t.outSpecs}},G={inputs:m,format:o.format,logger:o.logger,opts:{...t,noWrite:!1,out:t.outCss,scope:t.scope,specs:t.outSpecs}};await Ut(f),await Rt(G)}};import{resolve as Um}from"path";var _r={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Yo({alias:"l",desc:"Initial heading level",default:1}),title:Y({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(o)=>{let{logger:t,opts:n,inputs:r}=o,m=P(Um(r[0]),t),f=Ym(m,n);Q(n.out,f,t)}},Ym=(o,{level:t,title:n})=>{let r=Object.keys(o.classes).length,m=Object.keys(o.templates).length,f=[`Currently, there are ${r+m} CSS utility classes (incl. ${m} templates) defined in "${o.info.name}" (v${o.info.version}):`,"",`${c(t+1)} Classes by category`,"",...Cr(o.classes,zm,t+2),`${c(t+1)} Templates by category`,"",...Cr(o.templates,jm,t+2),`${c(t+1)} Media queries`,"",...Object.entries(o.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${c(t)} ${n??o.info.name}
|
|
28
|
+
`);return f},Lr=(o)=>o.split(/(\d+)/).map((t)=>{let n=parseInt(t);return isNaN(n)?t:n}),Dm=(o,t)=>{if(/\d+/.test(o)&&/\d+/.test(t)){let n=Lr(o),r=Lr(t),m=n.length;if(m===r.length){for(let f=0;f<m;f++)if(n[f]!==r[f])return Bt(n[f],r[f]);return 0}return n.length-r.length}return Bt(o,t)},Cr=(o,t,n)=>{let r=It({key:([m,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(m)=>m.sort(),(m,f)=>(m.push(f[0]),m)]},Object.entries(o));return St((m)=>{let f=r[m].sort(Dm).map((E)=>t(E,o[E].__doc,n+1)),G=f.length;return[`${c(n)} ${Xo(m)}`,G>3?`
|
|
29
29
|
<details><summary>${G} items:</summary>
|
|
30
30
|
`:"",f.join(`
|
|
31
31
|
`),G>3?`</details>
|
|
32
|
-
`:""]},Object.keys(r).sort())},zm=(t
|
|
32
|
+
`:""]},Object.keys(r).sort())},zm=(o,t)=>{if(!t?.desc)return`- \`${o}\``;let n=t.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${o}\` (${n})`},jm=(o,t,n)=>{if(!t?.args)return`${c(n)} ${o}(...)
|
|
33
33
|
|
|
34
|
-
TODO`;let r=
|
|
35
|
-
${
|
|
34
|
+
TODO`;let r=t.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${c(n)} \`${o}(${r})\``,"",...t.args.map(Jm),t.desc?`
|
|
35
|
+
${t.desc}
|
|
36
36
|
`:""].join(`
|
|
37
|
-
`)},Jm=(
|
|
37
|
+
`)},Jm=(o)=>`- ${o.replace(/^(\w+)/,(t,n)=>`**${n}**`)}`,c=R((o)=>"#".repeat(o));import{resolve as Br}from"path";var er={desc:"Export entire generated framework as CSS",opts:{...Lo,...Co,...vn,...q,...p,..._o,...kn,...Bo},inputs:1,fn:async(o)=>{let{logger:t,opts:{include:n,media:r,noDecls:m,noHeader:f,onlyDecls:G,out:E,pretty:N,scope:O},inputs:h}=o,C={format:N?qo:mo,fns:lo,scope:O},L=P(Br(h[0]),t),B=n?n.map((I)=>w(Br(I),t).trim()):[];if(!f)B.push(ot(L));if(!m&&L.decls.length)B.push(g(L.decls,C));if(!G)B.push(Xm(L,r,C,t));Q(E,B,t)}},Xm=(o,t,n,r)=>{let m=$r("",o);if(t){let f=t[0]==="ALL"?Object.keys(o.media):t;for(let G of f)if(o.media[G])m.push(ho(o.media[G],$r("-"+G,o)));else r.warn(`invalid media query ID: ${G}, skipping...`)}return g(m,n)},$r=(o,t)=>Object.entries(t.classes).map(([n,r])=>[`.${n}${o}`,tt(r)]);var Yt=P(Pm(process.argv[2],"package.json"));st({name:"metacss",opts:{verbose:W({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:hr,doc:_r,export:er,generate:Gr},ctx:async(o)=>{if(o.opts.verbose)o.logger.level=A.DEBUG;return{...o,format:Jo}},start:3,usage:{prefix:`
|
|
38
38
|
\u2588 \u2588 \u2588 \u2502
|
|
39
39
|
\u2588\u2588 \u2588 \u2502
|
|
40
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
41
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
40
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${Yt.name} ${Yt.version}
|
|
41
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${Yt.description}
|
|
42
42
|
\u2588 \u2502
|
|
43
43
|
\u2588 \u2588 \u2502
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/meta-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"status": "alpha",
|
|
114
114
|
"year": 2023
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "7d0ebe53d3cbe515b70645eabf5b31918d02329d\n"
|
|
117
117
|
}
|