@pantoken/utils 1.0.1 → 1.0.2
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/dist/index.d.mts +22 -22
- package/dist/token-syntax.d.mts +10 -11
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ import { Token } from "@pantoken/model";
|
|
|
19
19
|
* Every elevation level and alias emitted as `--instui-elevation-<name>` (`resting`, `above`,
|
|
20
20
|
* `topmost`, `depth1`–`depth3`, `card`, `cardHover`). Derived from the geometry + alias maps.
|
|
21
21
|
*/
|
|
22
|
-
declare const ELEVATION_NAMES: readonly string[];
|
|
22
|
+
export declare const ELEVATION_NAMES: readonly string[];
|
|
23
23
|
/**
|
|
24
24
|
* The `--instui-elevation-*` name/value pairs (each a multi-layer `box-shadow`). Values reference the
|
|
25
25
|
* themed drop-shadow colour tokens, so they adapt per theme wherever a token sheet is loaded.
|
|
@@ -33,9 +33,9 @@ declare const ELEVATION_NAMES: readonly string[];
|
|
|
33
33
|
* elevationDeclarations(); // [["--instui-elevation-resting", "…"], ["--instui-elevation-above", "…"], …]
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
declare function elevationDeclarations(): [name: string, value: string][];
|
|
36
|
+
export declare function elevationDeclarations(): [name: string, value: string][];
|
|
37
37
|
/** The elements the ring applies to by default (the common interactive/focusable elements). */
|
|
38
|
-
declare const FOCUSABLE_SELECTOR = "a, button, input, select, textarea, summary, [tabindex]";
|
|
38
|
+
export declare const FOCUSABLE_SELECTOR = "a, button, input, select, textarea, summary, [tabindex]";
|
|
39
39
|
/**
|
|
40
40
|
* The `--instui-focus-outline-*` name/value pairs the ring rules read. Colour/width/offset reference
|
|
41
41
|
* the themed shared focus tokens; the transition, line style, and inset are constants.
|
|
@@ -49,7 +49,7 @@ declare const FOCUSABLE_SELECTOR = "a, button, input, select, textarea, summary,
|
|
|
49
49
|
* focusOutlineDeclarations(); // [["--instui-focus-outline-color", "…"], …]
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
declare function focusOutlineDeclarations(): [name: string, value: string][];
|
|
52
|
+
export declare function focusOutlineDeclarations(): [name: string, value: string][];
|
|
53
53
|
/**
|
|
54
54
|
* The focus-ring rules for a given focusable selector: a transparent resting ring that transitions in
|
|
55
55
|
* on `:focus-visible`, plus the `-focus-color-*` / `-focus-position-inset` / `-focus-within` /
|
|
@@ -58,15 +58,15 @@ declare function focusOutlineDeclarations(): [name: string, value: string][];
|
|
|
58
58
|
* @param selector - The focusable selector the base ring applies to (default {@link FOCUSABLE_SELECTOR}).
|
|
59
59
|
* @returns The CSS rules string.
|
|
60
60
|
*/
|
|
61
|
-
declare function focusOutlineRules(selector?: string): string;
|
|
61
|
+
export declare function focusOutlineRules(selector?: string): string;
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/resolver.d.ts
|
|
64
64
|
/** The colour mode to collapse `light-dark()` to. */
|
|
65
65
|
type Mode = "light" | "dark";
|
|
66
66
|
/** A `var(--custom-prop)` reference (optional fallback); capture group 1 is the property name. */
|
|
67
|
-
declare const VAR_RE: RegExp;
|
|
67
|
+
export declare const VAR_RE: RegExp;
|
|
68
68
|
/** A `light-dark(<light>, <dark>)` value; capture groups 1 and 2 are the two branches. */
|
|
69
|
-
declare const LIGHT_DARK_RE: RegExp;
|
|
69
|
+
export declare const LIGHT_DARK_RE: RegExp;
|
|
70
70
|
/** Options for {@link makeResolver}. */
|
|
71
71
|
interface ResolveOptions {
|
|
72
72
|
/** Collapse `light-dark()` to this branch; omit to keep `light-dark()` intact. */
|
|
@@ -127,7 +127,7 @@ interface ResolveOptions {
|
|
|
127
127
|
* makeResolver(ir, { overrides })("var(--instui-brand)"); // → "#000"
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
|
-
declare function makeResolver(base: readonly Token[], options?: ResolveOptions): (value: string) => string;
|
|
130
|
+
export declare function makeResolver(base: readonly Token[], options?: ResolveOptions): (value: string) => string;
|
|
131
131
|
/**
|
|
132
132
|
* Resolve every token's value against the set (see {@link makeResolver}), keyed by name.
|
|
133
133
|
*
|
|
@@ -147,7 +147,7 @@ declare function makeResolver(base: readonly Token[], options?: ResolveOptions):
|
|
|
147
147
|
* byName.get("--instui-bg"); // → "#000"
|
|
148
148
|
* ```
|
|
149
149
|
*/
|
|
150
|
-
declare function resolveTokens(base: readonly Token[], options?: ResolveOptions): Map<string, string>;
|
|
150
|
+
export declare function resolveTokens(base: readonly Token[], options?: ResolveOptions): Map<string, string>;
|
|
151
151
|
//#endregion
|
|
152
152
|
//#region src/drift.d.ts
|
|
153
153
|
/**
|
|
@@ -161,7 +161,7 @@ declare function resolveTokens(base: readonly Token[], options?: ResolveOptions)
|
|
|
161
161
|
* // → Set { "--instui-color-text-base" }
|
|
162
162
|
* ```
|
|
163
163
|
*/
|
|
164
|
-
declare function extractInstuiRefs(text: string): Set<string>;
|
|
164
|
+
export declare function extractInstuiRefs(text: string): Set<string>;
|
|
165
165
|
/**
|
|
166
166
|
* The set of token names an IR defines.
|
|
167
167
|
*
|
|
@@ -176,7 +176,7 @@ declare function extractInstuiRefs(text: string): Set<string>;
|
|
|
176
176
|
* tokenNames(ir); // → Set { "--instui-leaf" }
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
|
-
declare function tokenNames(ir: readonly Token[]): Set<string>;
|
|
179
|
+
export declare function tokenNames(ir: readonly Token[]): Set<string>;
|
|
180
180
|
/**
|
|
181
181
|
* Drift check: `--instui-*` names in `text` that the IR doesn't define (sorted; empty means no
|
|
182
182
|
* drift). Use for outputs that *reference* tokens defined elsewhere — e.g. the docusaurus/vitepress
|
|
@@ -200,7 +200,7 @@ declare function tokenNames(ir: readonly Token[]): Set<string>;
|
|
|
200
200
|
* unknownReferences("--x: var(--instui-leaf);", ir); // → [] (no drift)
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
|
-
declare function unknownReferences(text: string, ir: readonly Token[]): string[];
|
|
203
|
+
export declare function unknownReferences(text: string, ir: readonly Token[]): string[];
|
|
204
204
|
/**
|
|
205
205
|
* Self-containment check: `--instui-*` names referenced via `var()` in a stylesheet that it never
|
|
206
206
|
* defines (as an `@property` registration or a `--x:` declaration). Sorted; empty means every
|
|
@@ -222,7 +222,7 @@ declare function unknownReferences(text: string, ir: readonly Token[]): string[]
|
|
|
222
222
|
* ); // → ["--instui-b"]
|
|
223
223
|
* ```
|
|
224
224
|
*/
|
|
225
|
-
declare function danglingReferences(css: string): string[];
|
|
225
|
+
export declare function danglingReferences(css: string): string[];
|
|
226
226
|
//#endregion
|
|
227
227
|
//#region src/case.d.ts
|
|
228
228
|
/**
|
|
@@ -240,7 +240,7 @@ declare function danglingReferences(css: string): string[];
|
|
|
240
240
|
* camelCase("color-background-brand"); // → "colorBackgroundBrand"
|
|
241
241
|
* ```
|
|
242
242
|
*/
|
|
243
|
-
declare function camelCase(kebab: string): string;
|
|
243
|
+
export declare function camelCase(kebab: string): string;
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/color.d.ts
|
|
246
246
|
/**
|
|
@@ -268,7 +268,7 @@ interface Rgba {
|
|
|
268
268
|
* parseHexColor("nope"); // → undefined
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
|
-
declare function parseHexColor(hex: string): Rgba | undefined;
|
|
271
|
+
export declare function parseHexColor(hex: string): Rgba | undefined;
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/svg.d.ts
|
|
274
274
|
/**
|
|
@@ -282,7 +282,7 @@ declare function parseHexColor(hex: string): Rgba | undefined;
|
|
|
282
282
|
* Defense-in-depth for SVG decoded from vendored data URIs or contributed by plugins.
|
|
283
283
|
* Not a full HTML parser — relies on the upstream source being trusted and pinned.
|
|
284
284
|
*/
|
|
285
|
-
declare function sanitizeSvg(svg: string): string;
|
|
285
|
+
export declare function sanitizeSvg(svg: string): string;
|
|
286
286
|
//#endregion
|
|
287
287
|
//#region src/spacing.d.ts
|
|
288
288
|
/**
|
|
@@ -305,9 +305,9 @@ interface SpacingStep {
|
|
|
305
305
|
* `@pantoken/components`' spacing/gap utilities and `@pantoken/interactions`' `resolveSpace`, so the
|
|
306
306
|
* two never drift apart.
|
|
307
307
|
*/
|
|
308
|
-
declare const SPACING_STEPS: readonly SpacingStep[];
|
|
308
|
+
export declare const SPACING_STEPS: readonly SpacingStep[];
|
|
309
309
|
/** The `auto` step — margin only, spelled the same both ways. */
|
|
310
|
-
declare const SPACING_AUTO_STEP: SpacingStep;
|
|
310
|
+
export declare const SPACING_AUTO_STEP: SpacingStep;
|
|
311
311
|
//#endregion
|
|
312
312
|
//#region src/utility-css.d.ts
|
|
313
313
|
/**
|
|
@@ -337,7 +337,7 @@ interface UtilityOptions {
|
|
|
337
337
|
* (`globalSelectors`/`chainTargets`), which couldn't reach plugin-authored components and didn't scale
|
|
338
338
|
* to high-cardinality utilities like spacing.
|
|
339
339
|
*/
|
|
340
|
-
declare function globalModifierSelector(p: string, name: string): string;
|
|
340
|
+
export declare function globalModifierSelector(p: string, name: string): string;
|
|
341
341
|
/** One semantic colour family entry: a bare name (resolved against `--instui-color-<family>-<name>`)
|
|
342
342
|
* or an explicit `[name, value]` pair — the second element is `var()`-wrapped if it's a `--custom-prop`
|
|
343
343
|
* name, or used verbatim otherwise (a `light-dark(…)` expression, a raw keyword like `transparent`). */
|
|
@@ -362,7 +362,7 @@ interface ColorUtilityNames {
|
|
|
362
362
|
*
|
|
363
363
|
* @demo self:color-utilities
|
|
364
364
|
*/
|
|
365
|
-
declare function colorUtilitiesCss(names: ColorUtilityNames, options?: UtilityOptions): string;
|
|
365
|
+
export declare function colorUtilitiesCss(names: ColorUtilityNames, options?: UtilityOptions): string;
|
|
366
366
|
/** A set of tokens that all map to one CSS property (e.g. every `--instui-font-weight-*` → `font-weight`). */
|
|
367
367
|
interface TokenUtilityGroup {
|
|
368
368
|
/** The CSS property the tokens set (e.g. `"font-weight"`, `"border-radius"`, `"box-shadow"`). */
|
|
@@ -385,6 +385,6 @@ interface TokenUtilityGroup {
|
|
|
385
385
|
*
|
|
386
386
|
* @demo self:token-utilities
|
|
387
387
|
*/
|
|
388
|
-
declare function tokenUtilitiesCss(groups: readonly TokenUtilityGroup[], options?: UtilityOptions): string;
|
|
388
|
+
export declare function tokenUtilitiesCss(groups: readonly TokenUtilityGroup[], options?: UtilityOptions): string;
|
|
389
389
|
//#endregion
|
|
390
|
-
export {
|
|
390
|
+
export type { ColorUtilityEntry, ColorUtilityNames, Mode, ResolveOptions, Rgba, SpacingStep, TokenUtilityGroup, UtilityOptions };
|
package/dist/token-syntax.d.mts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Token } from "@pantoken/model";
|
|
2
2
|
//#region src/token-syntax.d.ts
|
|
3
3
|
/** A registered, real CSS property name (e.g. `"font-weight"`), matched via `matchProperty()`. */
|
|
4
|
-
type PropertyName = string & {
|
|
4
|
+
export type PropertyName = string & {
|
|
5
5
|
readonly __brand: "PropertyName";
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* A CSS Value Definition Syntax grammar string (CSS Values 4 §2.1: `|` `||` `&&` `[]` `?` `{a,b}`
|
|
9
9
|
* `#`, e.g. `"<length>"` or `"none | <shadow>#"`), matched via `match()`.
|
|
10
10
|
*/
|
|
11
|
-
type Grammar = string & {
|
|
11
|
+
export type Grammar = string & {
|
|
12
12
|
readonly __brand: "Grammar";
|
|
13
13
|
};
|
|
14
14
|
/** An ordered token-name-pattern → value table, checked first-match-wins via {@link firstMatch}. */
|
|
15
|
-
type SyntaxRule<T> = readonly (readonly [RegExp, T])[];
|
|
15
|
+
export type SyntaxRule<T> = readonly (readonly [RegExp, T])[];
|
|
16
16
|
/**
|
|
17
17
|
* Non-standard property grammars `css-tree`/`mdn-data` don't know about —
|
|
18
18
|
* matched by token-name substring, most-specific first, as raw CSS Value Definition Syntax
|
|
@@ -21,7 +21,7 @@ type SyntaxRule<T> = readonly (readonly [RegExp, T])[];
|
|
|
21
21
|
* NOT `<font-family-name>`, which only exists inline inside the real `font-family` property's own
|
|
22
22
|
* definition — that's matched via `TOKEN_NAME_TO_PROPERTY` instead).
|
|
23
23
|
*/
|
|
24
|
-
declare const BESPOKE_SYNTAX: SyntaxRule<Grammar>;
|
|
24
|
+
export declare const BESPOKE_SYNTAX: SyntaxRule<Grammar>;
|
|
25
25
|
/**
|
|
26
26
|
* Real CSS properties, matched by token-name substring — the property name to validate against
|
|
27
27
|
* via `css-tree`'s built-in (`mdn-data`-sourced) lexer. Intentionally conservative: a name pattern
|
|
@@ -47,9 +47,9 @@ declare const BESPOKE_SYNTAX: SyntaxRule<Grammar>;
|
|
|
47
47
|
* here in practice — the bespoke icon-glyph rule above already claims every `instui-icon-*` name
|
|
48
48
|
* first, so `gap` IS included, verified safe once that precedence is accounted for.
|
|
49
49
|
*/
|
|
50
|
-
declare const TOKEN_NAME_TO_PROPERTY: SyntaxRule<PropertyName>;
|
|
50
|
+
export declare const TOKEN_NAME_TO_PROPERTY: SyntaxRule<PropertyName>;
|
|
51
51
|
/** A `namePattern`'s concrete, non-contextual matches against a candidate property, from the real IR. */
|
|
52
|
-
interface PatternCoverage {
|
|
52
|
+
export interface PatternCoverage {
|
|
53
53
|
/** How many concrete (non-contextual) tokens matched `namePattern`. */
|
|
54
54
|
matched: number;
|
|
55
55
|
/** The matches that would FAIL the candidate property's real CSS grammar. */
|
|
@@ -75,12 +75,12 @@ interface PatternCoverage {
|
|
|
75
75
|
* coverage.invalid; // → [] once every matching token is confirmed to be a valid <color>
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
|
-
declare function candidatePropertyCoverage(tokens: readonly {
|
|
78
|
+
export declare function candidatePropertyCoverage(tokens: readonly {
|
|
79
79
|
name: string;
|
|
80
80
|
value: string;
|
|
81
81
|
}[], namePattern: RegExp, candidateProperty: string): PatternCoverage;
|
|
82
82
|
/** One token whose value doesn't satisfy its property's CSS grammar, or whose name maps to none. */
|
|
83
|
-
interface TokenSyntaxIssue {
|
|
83
|
+
export interface TokenSyntaxIssue {
|
|
84
84
|
/** The token's `--instui-*` name. */
|
|
85
85
|
name: string;
|
|
86
86
|
/** The token's resolved value. */
|
|
@@ -114,6 +114,5 @@ interface TokenSyntaxIssue {
|
|
|
114
114
|
* // → [{ name: "--instui-content-quote-font-weight", value: "Medium Italic", kind: "mismatch" }]
|
|
115
115
|
* ```
|
|
116
116
|
*/
|
|
117
|
-
declare function syntaxMismatches(tokens: readonly Token[]): TokenSyntaxIssue[];
|
|
118
|
-
//#endregion
|
|
119
|
-
export { BESPOKE_SYNTAX, Grammar, PatternCoverage, PropertyName, SyntaxRule, TOKEN_NAME_TO_PROPERTY, TokenSyntaxIssue, candidatePropertyCoverage, syntaxMismatches };
|
|
117
|
+
export declare function syntaxMismatches(tokens: readonly Token[]): TokenSyntaxIssue[];
|
|
118
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantoken/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Shared pantoken helpers: token reference resolver, typed regexes (arkregex), name-case, and hex-colour parsing.",
|
|
5
|
-
"homepage": "https://pantoken.
|
|
5
|
+
"homepage": "https://pantoken.app",
|
|
6
6
|
"bugs": "https://github.com/thedannywahl/pantoken/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"provenance": true
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@pantoken/model": "0.3.
|
|
28
|
+
"@pantoken/model": "0.3.2",
|
|
29
29
|
"arkregex": "^0.0.8",
|
|
30
30
|
"css-tree": "^3.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/css-tree": "^3.2.0",
|
|
34
|
-
"@types/node": "^26.
|
|
34
|
+
"@types/node": "^26.5.0",
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.
|
|
37
|
-
"vite-plus": "0.3.
|
|
36
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.1",
|
|
37
|
+
"vite-plus": "0.3.1"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=22.18.0"
|