@navecss/core 0.3.0 → 0.4.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/README.md +21 -4
- package/dist/atom-names-2OreuBx9.d.ts +27 -0
- package/dist/atoms.d.ts +3 -13
- package/dist/atoms.js +2 -1
- package/dist/bin.js +6 -4
- package/dist/{chunk-IZQLFUQU.js → chunk-2A7IUZBH.js} +2 -1
- package/dist/{chunk-LIUB4EES.js → chunk-CUL5PLPI.js} +1 -5
- package/dist/chunk-E5F6YF7A.js +2428 -0
- package/dist/chunk-GZL2VW7C.js +57 -0
- package/dist/{chunk-S7DZUVV3.js → chunk-LADFXRWQ.js} +3 -300
- package/dist/{chunk-R6JJZGXC.js → chunk-LQSGQ2OA.js} +1 -1
- package/dist/chunk-SYNQJNVB.js +302 -0
- package/dist/collect.d.ts +279 -0
- package/dist/collect.js +4 -0
- package/dist/cx.d.ts +1 -1
- package/dist/cx.js +14 -1
- package/dist/lightningcss.d.ts +1 -0
- package/dist/lightningcss.js +6 -4
- package/dist/postcss.d.ts +1 -0
- package/dist/postcss.js +4 -2
- package/dist/standalone.css +2 -0
- package/dist/vite-options-D1-hGA9L.d.ts +86 -0
- package/dist/vite.d.ts +5 -67
- package/dist/vite.js +298 -2192
- package/package.json +6 -2
- package/skills/navecss/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ pnpm add @navecss/core
|
|
|
21
21
|
included, is reachable only through the package's `exports` map: there is no
|
|
22
22
|
`main` field to fall back on.
|
|
23
23
|
- **ES modules.** `@navecss/core/cx`, `@navecss/core/atoms`,
|
|
24
|
-
`@navecss/core/vite`, `@navecss/core/lightningcss` and `@navecss/core/
|
|
24
|
+
`@navecss/core/vite`, `@navecss/core/lightningcss`, `@navecss/core/check` and `@navecss/core/collect` load through `import` only. A `require()` of any of
|
|
25
25
|
them fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`, which reads as though the
|
|
26
26
|
entry point did not exist. In TypeScript, set `moduleResolution` to `bundler`,
|
|
27
27
|
`node16` or `nodenext`; under `node10` their types are not found. A CommonJS
|
|
@@ -316,6 +316,21 @@ what `navePlugin()` does with no options. On the CSS-first path, where `@nave` c
|
|
|
316
316
|
declarations into your own rule, a project that never calls `cx()` and writes no Nave class ships no
|
|
317
317
|
rule from the atom layer.
|
|
318
318
|
|
|
319
|
+
In a build, the plugin also turns each `cx()` call it read into the class string the call returns, so
|
|
320
|
+
the map from atom names to classes does not ship: `cx('flex', 'grid')` becomes `"nave-flex nave-grid"`,
|
|
321
|
+
and `cx('flex', on && 'grid')` becomes `["nave-flex", on && "nave-grid"].filter(Boolean).join(" ")`,
|
|
322
|
+
with each argument evaluated once, in the order you wrote it. A direct `cx.raw()` call becomes the
|
|
323
|
+
same join, and a direct `cx.dynamic()` call a lookup in a map of the atoms in `keep` and `keepFor`.
|
|
324
|
+
The dev server keeps the run-time functions, which return the same strings. A bundle holds neither
|
|
325
|
+
the name map nor the atoms' declarations when every use of `cx` in it is one of those direct calls
|
|
326
|
+
and no module that imports `cx` calls `eval` directly. Two forms keep the map, since the build
|
|
327
|
+
cannot follow the alias: `const r = cx.raw` and `const { raw } = cx`. So does a package listed in
|
|
328
|
+
`keepFor` whose calls the build cannot read, because those calls stay calls to the run-time `cx()`.
|
|
329
|
+
A module that calls `eval` directly keeps its import of `cx`, and with it the map, whatever text it
|
|
330
|
+
runs (`eval('1')` too), because that text can read the module's names and the build cannot read the
|
|
331
|
+
text. An indirect call, `(0, eval)(text)` or `globalThis.eval(text)`, runs its text in the global
|
|
332
|
+
scope, where `cx` is not visible, and does not keep the import.
|
|
333
|
+
|
|
319
334
|
So that nothing is dropped on a guess, a `cx()` call whose atoms the build cannot read fails the
|
|
320
335
|
build. `vite build` reads every module first and fails once, at the end, with a report that lists
|
|
321
336
|
each such use with its file, and its line and column when the source maps lead back to them, then
|
|
@@ -514,9 +529,10 @@ build, that list is the set of atoms its CSS holds, so you can diff it between b
|
|
|
514
529
|
**Shipping every atom.** `navePlugin({ atomic: 'all' })` reads no `cx()` call and ships every atom,
|
|
515
530
|
as the PostCSS plugin does. It suits a project whose Nave classes are mostly written where no build
|
|
516
531
|
reads them, such as a backend's own templates or HTML from a CMS, where listing them in `keep` is
|
|
517
|
-
not practical. It gives up what this section describes: no `cx()` call is read
|
|
518
|
-
that is no atom passes through `cx()` as text,
|
|
519
|
-
maps through every atom. The dev server serves
|
|
532
|
+
not practical. It gives up what this section describes: no `cx()` call is read, checked or turned
|
|
533
|
+
into its class string, so the name map ships, a name that is no atom passes through `cx()` as text,
|
|
534
|
+
as it does without the plugin, and `cx.dynamic()` maps through every atom. The dev server serves
|
|
535
|
+
every atom too, the plugin sets neither
|
|
520
536
|
`optimizeDeps.exclude` nor `resolve.noExternal`, no build writes `nave-used-atoms.json`, and
|
|
521
537
|
`keep`, `keepFor` and `cxModules` are still checked for well-formed values and otherwise do nothing.
|
|
522
538
|
It is also the way out that the plugin's own check names when a build's atom layer does not hold
|
|
@@ -879,3 +895,4 @@ Consumers of `@navecss/tokens` alone get no guide: it ships only in this package
|
|
|
879
895
|
| `@navecss/core/standalone` | The whole stylesheet in one file, with no `@import`, for projects with no bundler |
|
|
880
896
|
| `@navecss/core/postcss` | PostCSS plugin — `navePlugin()` |
|
|
881
897
|
| `@navecss/core/check` | The survival check as a function — `check({ source })` |
|
|
898
|
+
| `@navecss/core/collect` | Reads which atoms a module uses, for build tools; not meant for application code |
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of Nave's built-in atoms, and the class each one gets.
|
|
3
|
+
*
|
|
4
|
+
* cx() needs this and nothing else, so it lives apart from the declaration data in atoms.ts:
|
|
5
|
+
* a module that imports atoms.ts hands a consumer's bundler every atom's CSS declarations,
|
|
6
|
+
* not every bundler can drop them, and cx() would pay that for a name map.
|
|
7
|
+
*
|
|
8
|
+
* atoms.ts is checked against this list (`satisfies Record<AtomName, AtomDefinition>`), so
|
|
9
|
+
* an atom added there and missing here, or the other way round, fails the typecheck. Keep the
|
|
10
|
+
* two in the same order as well: atomic.css is written in the order of atoms.ts, the Vite
|
|
11
|
+
* plugin lists the atoms in the order of this list, and a test holds the two together.
|
|
12
|
+
*/
|
|
13
|
+
declare const atomNames: readonly ["flex", "inlineFlex", "grid", "block", "inlineBlock", "hidden", "flexCol", "flexWrap", "itemsCenter", "itemsStart", "itemsEnd", "justifyCenter", "justifyBetween", "justifyEnd", "flexGrow", "flexShrink0", "gap", "relative", "absolute", "insetFull", "wFull", "hFull", "minW0", "truncate", "srOnly", "srOnlyFocusable", "noWrap", "breakWord", "textLeft", "textCenter", "textRight", "interactive", "focusRing", "disabledState", "rounded", "roundedCard", "roundedFull", "border", "overflowHidden", "overflowAuto", "transition", "container", "hidePhoneOnly", "hideTabletPortraitUp", "hideTabletLandscapeUp", "hideDesktopUp", "stackPhoneOnly", "wFullPhoneOnly"];
|
|
14
|
+
type AtomName = (typeof atomNames)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Converts a camelCase atom name to its nave-kebab-case CSS class name.
|
|
17
|
+
* focusRing → nave-focus-ring
|
|
18
|
+
*/
|
|
19
|
+
declare const toClassName: (name: AtomName) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Map of atom name → global CSS class name.
|
|
22
|
+
* Used by cx() and the directive core's diagnostic hints.
|
|
23
|
+
* Only covers Nave built-in atoms — consumer atoms are @nave-directive only.
|
|
24
|
+
*/
|
|
25
|
+
declare const atomClassMap: Record<AtomName, string>;
|
|
26
|
+
|
|
27
|
+
export { type AtomName as A, atomClassMap as a, toClassName as t };
|
package/dist/atoms.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { A as AtomName, a as atomClassMap, t as toClassName } from './atom-names-2OreuBx9.js';
|
|
2
|
+
|
|
1
3
|
type CSSDeclarations = Record<string, string>;
|
|
2
4
|
type PseudoMap = Record<string, CSSDeclarations>;
|
|
3
5
|
interface MediaBlock {
|
|
@@ -403,17 +405,5 @@ declare const atoms: {
|
|
|
403
405
|
};
|
|
404
406
|
};
|
|
405
407
|
};
|
|
406
|
-
type AtomName = keyof typeof atoms;
|
|
407
|
-
/**
|
|
408
|
-
* Converts a camelCase atom name to its nave-kebab-case CSS class name.
|
|
409
|
-
* focusRing → nave-focus-ring
|
|
410
|
-
*/
|
|
411
|
-
declare const toClassName: (name: AtomName) => string;
|
|
412
|
-
/**
|
|
413
|
-
* Map of atom name → global CSS class name.
|
|
414
|
-
* Used by cx() and the directive core's diagnostic hints.
|
|
415
|
-
* Only covers Nave built-in atoms — consumer atoms are @nave-directive only.
|
|
416
|
-
*/
|
|
417
|
-
declare const atomClassMap: Record<AtomName, string>;
|
|
418
408
|
|
|
419
|
-
export { type AtomDefinition,
|
|
409
|
+
export { type AtomDefinition, atoms };
|
package/dist/atoms.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { atoms } from './chunk-CUL5PLPI.js';
|
|
2
|
+
export { atomClassMap, toClassName } from './chunk-GZL2VW7C.js';
|
package/dist/bin.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { runCheck } from './chunk-XQQCDUV6.js';
|
|
3
|
-
import { splitByteOrderMark, foldedText } from './chunk-
|
|
3
|
+
import { splitByteOrderMark, foldedText } from './chunk-2A7IUZBH.js';
|
|
4
4
|
import { formatFinding } from './chunk-UANF3FGO.js';
|
|
5
|
-
import { validateExtendAtomsHostFree } from './chunk-
|
|
5
|
+
import { validateExtendAtomsHostFree } from './chunk-LQSGQ2OA.js';
|
|
6
6
|
import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
|
|
7
|
-
import { snapshotExtendMap, expandText } from './chunk-
|
|
7
|
+
import { snapshotExtendMap, expandText } from './chunk-LADFXRWQ.js';
|
|
8
8
|
import { createPositionFinder, tokenize, atKeywordName } from './chunk-NFS2REPQ.js';
|
|
9
|
-
import './chunk-
|
|
9
|
+
import './chunk-SYNQJNVB.js';
|
|
10
|
+
import './chunk-CUL5PLPI.js';
|
|
11
|
+
import './chunk-GZL2VW7C.js';
|
|
10
12
|
import { parseArgs } from 'util';
|
|
11
13
|
import { realpathSync, watch, existsSync, statSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
12
14
|
import path2 from 'path';
|
|
@@ -392,9 +392,5 @@ var atoms = {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
|
-
var toClassName = (name) => `nave-${name.replaceAll(/([A-Z])/g, "-$1").toLowerCase()}`;
|
|
396
|
-
var atomClassMap = Object.fromEntries(
|
|
397
|
-
Object.keys(atoms).map((name) => [name, toClassName(name)])
|
|
398
|
-
);
|
|
399
395
|
|
|
400
|
-
export {
|
|
396
|
+
export { atoms };
|