@stacksjs/ts-css 0.1.0 → 0.1.1
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 +37 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.js +6143 -1106
- package/dist/optimize/clean/comment.d.ts +1 -1
- package/dist/optimize/clean/declaration.d.ts +1 -1
- package/dist/optimize/compress/color.d.ts +5 -0
- package/dist/optimize/compress/index.d.ts +1 -1
- package/dist/optimize/compress/number.d.ts +9 -0
- package/dist/optimize/index.d.ts +2 -2
- package/dist/optimize/minify.d.ts +1 -1
- package/dist/optimize/specificity.d.ts +2 -2
- package/dist/parse/index.d.ts +1 -1
- package/dist/select/attributes.d.ts +3 -0
- package/dist/select/general.d.ts +6 -0
- package/dist/select/helpers/always-true.d.ts +6 -0
- package/dist/select/helpers/querying.d.ts +10 -0
- package/dist/select/index.d.ts +1 -1
- package/dist/select/pseudo-selectors/index.d.ts +10 -0
- package/dist/select/pseudo-selectors/selectors.d.ts +4 -0
- package/package.json +6 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CssNode } from '../../parse';
|
|
1
|
+
import type { CssNode } from '../../parse/index';
|
|
2
2
|
export declare function removeComments(ast: CssNode, options?: { exclamation?: boolean | 'first-exclamation' }): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CssNode } from '../../parse';
|
|
1
|
+
import type { CssNode } from '../../parse/index';
|
|
2
2
|
export declare function dedupeDeclarations(ast: CssNode): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function shortenHex(hex: string): string;
|
|
2
|
+
export declare function colorNameToHex(name: string): string | null;
|
|
3
|
+
export declare function hexToShortName(hex: string): string | null;
|
|
4
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
5
|
+
export declare function compressRgbToHex(value: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function compressNumber(value: string): string;
|
|
2
|
+
export declare function compressDimension(value: string, unit: string): { value: string, unit: string };
|
|
3
|
+
export declare function compressPercentage(value: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Round a numeric string to `precision` decimal places. Returns the input
|
|
6
|
+
* unchanged when it's not a finite number — calling sites should still
|
|
7
|
+
* follow up with `compressNumber` to strip leading zeros etc.
|
|
8
|
+
*/
|
|
9
|
+
export declare function roundNumberString(value: string, precision: number): string;
|
package/dist/optimize/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const syntax: { specificity: typeof _specificity };
|
|
|
7
7
|
* CSS minifier — the API surface that csso users (notably SVGO's
|
|
8
8
|
* `minifyStyles` and `inlineStyles`) depend on.
|
|
9
9
|
*/
|
|
10
|
-
export { dedupeDeclarations, removeComments } from './clean';
|
|
11
|
-
export { compressTree } from './compress';
|
|
10
|
+
export { dedupeDeclarations, removeComments } from './clean/index';
|
|
11
|
+
export { compressTree } from './compress/index';
|
|
12
12
|
export { minify, minifyBlock } from './minify';
|
|
13
13
|
export { specificity, specificityToString } from './specificity';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CssNode } from '../parse';
|
|
1
|
+
import type { CssNode } from '../parse/index';
|
|
2
2
|
export declare function minify(source: string, options?: MinifyOptions): MinifyResult;
|
|
3
3
|
export declare function minifyBlock(source: string, options?: MinifyOptions): MinifyResult;
|
|
4
4
|
export declare interface MinifyOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CssNode } from '../parse';
|
|
2
|
-
import type { Selector as WhatSelector } from '../what';
|
|
1
|
+
import type { CssNode } from '../parse/index';
|
|
2
|
+
import type { Selector as WhatSelector } from '../what/index';
|
|
3
3
|
export declare function specificity(input: CssNode | WhatSelector[][] | WhatSelector[] | string): Specificity;
|
|
4
4
|
export declare function specificityToString(s: Specificity): string;
|
|
5
5
|
export type Specificity = [number, number, number];
|
package/dist/parse/index.d.ts
CHANGED
|
@@ -53,6 +53,6 @@ export type { WalkContext, WalkVisitor } from './walker';
|
|
|
53
53
|
export { clone } from './clone';
|
|
54
54
|
export { generate } from './generator';
|
|
55
55
|
export { CssList as List, makeList } from './list';
|
|
56
|
-
export { parse, TokenType } from './parser';
|
|
56
|
+
export { parse, TokenType } from './parser/index';
|
|
57
57
|
export { decodeName, Tokenizer } from './tokenizer';
|
|
58
58
|
export { walk } from './walker';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AttributeSelectorNode } from '../what/index';
|
|
2
|
+
import type { CompiledQuery, Options } from './types';
|
|
3
|
+
export declare function compileAttribute<Node, ElementNode extends Node>(selector: AttributeSelectorNode, options: Options<Node, ElementNode>, next: CompiledQuery<ElementNode>): CompiledQuery<ElementNode>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ALWAYS_TRUE } from './helpers/always-true';
|
|
2
|
+
import type { CompiledQuery, Options } from './types';
|
|
3
|
+
import type { Selector } from '../what/index';
|
|
4
|
+
export declare function compileToken<Node, ElementNode extends Node>(token: Selector, options: Options<Node, ElementNode>, next: Compiled<ElementNode>): Compiled<ElementNode>;
|
|
5
|
+
declare type Compiled<E> = CompiledQuery<E>;
|
|
6
|
+
export { ALWAYS_TRUE };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Adapter, CompiledQuery } from '../types';
|
|
2
|
+
export declare function findAll<Node, ElementNode extends Node>(query: CompiledQuery<ElementNode>, nodes: ReadonlyArray<Node>, adapter: Adapter<Node, ElementNode>, xmlMode: boolean): ElementNode[];
|
|
3
|
+
export declare function findOne<Node, ElementNode extends Node>(query: CompiledQuery<ElementNode>, nodes: ReadonlyArray<Node>, adapter: Adapter<Node, ElementNode>, xmlMode: boolean): ElementNode | null;
|
|
4
|
+
/**
|
|
5
|
+
* Convert the user-supplied root into a search context. Mirrors
|
|
6
|
+
* `css-select`'s `prepareContext` — a single root node is replaced by its
|
|
7
|
+
* children (so the root itself isn't a candidate); arrays go through
|
|
8
|
+
* `removeSubsets` to avoid testing nested selections twice.
|
|
9
|
+
*/
|
|
10
|
+
export declare function prepareContext<Node, ElementNode extends Node>(elements: Node | Node[], adapter: Adapter<Node, ElementNode>): ReadonlyArray<Node>;
|
package/dist/select/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { compileGeneric } from './selectors';
|
|
2
|
+
import type { CompiledQuery, Options } from '../types';
|
|
3
|
+
import type { Selector } from '../../what/index';
|
|
4
|
+
export declare function compilePseudo<Node, ElementNode extends Node>(token: PseudoToken, options: Options<Node, ElementNode>, next: CompiledQuery<ElementNode>): CompiledQuery<ElementNode>;
|
|
5
|
+
declare interface PseudoToken {
|
|
6
|
+
type: 'pseudo' | 'pseudo-element'
|
|
7
|
+
name: string
|
|
8
|
+
data: string | Selector[][] | null
|
|
9
|
+
}
|
|
10
|
+
export { compileGeneric };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompiledQuery, Options } from '../types';
|
|
2
|
+
import type { Selector } from '../../what/index';
|
|
3
|
+
export declare function compileGeneric<Node, ElementNode extends Node>(segments: Selector[][], options: Options<Node, ElementNode>): CompiledQuery<ElementNode>;
|
|
4
|
+
export declare function parseAndCompile<Node, ElementNode extends Node>(tokens: Selector[], options: Options<Node, ElementNode>): CompiledQuery<ElementNode>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ts-css",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Pure-TypeScript CSS toolkit for Bun/Node — parser, walker, generator, selector engine, and minifier. Zero runtime deps.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -86,10 +86,9 @@
|
|
|
86
86
|
"lint:fix": "bunx --bun pickier . --fix",
|
|
87
87
|
"changelog": "bunx --bun logsmith --verbose",
|
|
88
88
|
"changelog:generate": "bunx --bun logsmith --output CHANGELOG.md",
|
|
89
|
-
"release": "
|
|
90
|
-
"release:patch": "
|
|
91
|
-
"release:minor": "
|
|
92
|
-
"postinstall": "bunx git-hooks",
|
|
89
|
+
"release": "bunx --bun bumpx prompt --recursive",
|
|
90
|
+
"release:patch": "bunx --bun bumpx patch --yes --recursive",
|
|
91
|
+
"release:minor": "bunx --bun bumpx minor --yes --recursive",
|
|
93
92
|
"dev:docs": "bun --bun bunpress dev docs",
|
|
94
93
|
"build:docs": "bun --bun bunpress build docs",
|
|
95
94
|
"preview:docs": "bun --bun bunpress preview docs",
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
"@types/bun": "latest",
|
|
105
104
|
"@types/css-tree": "^2.3.11",
|
|
106
105
|
"@types/csso": "^5.0.4",
|
|
107
|
-
"better-dx": "^0.2.
|
|
106
|
+
"better-dx": "^0.2.15",
|
|
108
107
|
"css-select": "^7.0.0",
|
|
109
108
|
"css-tree": "^3.2.1",
|
|
110
109
|
"css-what": "^8.0.0",
|
|
@@ -113,7 +112,7 @@
|
|
|
113
112
|
},
|
|
114
113
|
"git-hooks": {
|
|
115
114
|
"pre-commit": {
|
|
116
|
-
"
|
|
115
|
+
"staged-lint": {
|
|
117
116
|
"*.{js,ts,json,yaml,yml,md}": "bunx --bun pickier lint --fix"
|
|
118
117
|
},
|
|
119
118
|
"autoRestage": true
|