@ismail-elkorchi/css-parser 0.1.1 → 0.2.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 +64 -78
- package/dist/internal/cssom/declarations.d.ts +36 -0
- package/dist/internal/cssom/declarations.js +177 -0
- package/dist/internal/generated/css-data.d.ts +2 -0
- package/dist/internal/generated/css-data.js +16229 -0
- package/dist/internal/grammar/catalog-types.d.ts +26 -0
- package/dist/internal/grammar/value-definition.d.ts +63 -0
- package/dist/internal/grammar/value-definition.js +439 -0
- package/dist/internal/properties/matcher.d.ts +29 -0
- package/dist/internal/properties/matcher.js +791 -0
- package/dist/internal/properties/registry.d.ts +24 -0
- package/dist/internal/properties/registry.js +52 -0
- package/dist/internal/selectors/matcher.d.ts +96 -0
- package/dist/internal/selectors/matcher.js +616 -0
- package/dist/internal/selectors/parser.d.ts +2 -0
- package/dist/internal/selectors/parser.js +702 -0
- package/dist/internal/selectors/specificity.d.ts +3 -0
- package/dist/internal/selectors/specificity.js +77 -0
- package/dist/internal/selectors/types.d.ts +110 -0
- package/dist/internal/syntax/ast.d.ts +70 -0
- package/dist/internal/syntax/ast.js +1 -0
- package/dist/internal/syntax/characters.d.ts +8 -0
- package/dist/internal/syntax/characters.js +45 -0
- package/dist/internal/syntax/encoding.d.ts +15 -0
- package/dist/internal/syntax/encoding.js +161 -0
- package/dist/internal/syntax/input.d.ts +23 -0
- package/dist/internal/syntax/input.js +184 -0
- package/dist/internal/syntax/parser.d.ts +26 -0
- package/dist/internal/syntax/parser.js +581 -0
- package/dist/internal/syntax/resources.d.ts +28 -0
- package/dist/internal/syntax/resources.js +135 -0
- package/dist/internal/syntax/serialize.d.ts +10 -0
- package/dist/internal/syntax/serialize.js +630 -0
- package/dist/internal/syntax/token-stream.d.ts +16 -0
- package/dist/internal/syntax/token-stream.js +66 -0
- package/dist/internal/syntax/tokenizer.d.ts +21 -0
- package/dist/internal/syntax/tokenizer.js +571 -0
- package/dist/internal/syntax/tokens.d.ts +115 -0
- package/dist/internal/syntax/tokens.js +1 -0
- package/dist/internal/syntax/types.d.ts +46 -0
- package/dist/internal/syntax/types.js +1 -0
- package/dist/mod.d.ts +7 -1
- package/dist/mod.js +7 -1
- package/dist/public/edits.d.ts +12 -0
- package/dist/public/edits.js +195 -0
- package/dist/public/mod.d.ts +13 -69
- package/dist/public/mod.js +12 -1794
- package/dist/public/parse.d.ts +37 -0
- package/dist/public/parse.js +298 -0
- package/dist/public/traversal.d.ts +13 -0
- package/dist/public/traversal.js +96 -0
- package/dist/public/types.d.ts +78 -264
- package/package.json +32 -56
- package/THIRD_PARTY_NOTICES.md +0 -19
- package/dist/internal/csstree-runtime.d.ts +0 -20
- package/dist/internal/csstree-runtime.js +0 -21
- package/dist/internal/encoding/mod.d.ts +0 -1
- package/dist/internal/encoding/mod.js +0 -1
- package/dist/internal/encoding/sniff.d.ts +0 -14
- package/dist/internal/encoding/sniff.js +0 -95
- package/dist/internal/serializer/mod.d.ts +0 -1
- package/dist/internal/serializer/mod.js +0 -1
- package/dist/internal/serializer/serialize.d.ts +0 -3
- package/dist/internal/serializer/serialize.js +0 -89
- package/dist/internal/tokenizer/mod.d.ts +0 -2
- package/dist/internal/tokenizer/mod.js +0 -1
- package/dist/internal/tokenizer/tokenize.d.ts +0 -2
- package/dist/internal/tokenizer/tokenize.js +0 -39
- package/dist/internal/tokenizer/tokens.d.ts +0 -23
- package/dist/internal/tree/build.d.ts +0 -2
- package/dist/internal/tree/build.js +0 -85
- package/dist/internal/tree/mod.d.ts +0 -2
- package/dist/internal/tree/mod.js +0 -1
- package/dist/internal/tree/types.d.ts +0 -25
- package/dist/internal/vendor/csstree/LICENSE +0 -19
- package/dist/internal/vendor/csstree/csstree.esm.js +0 -12
- package/dist/internal/version.d.ts +0 -1
- package/dist/internal/version.js +0 -1
- package/dist/public/index.d.ts +0 -1
- package/dist/public/index.js +0 -1
- /package/dist/internal/{tokenizer/tokens.js → grammar/catalog-types.js} +0 -0
- /package/dist/internal/{tree → selectors}/types.js +0 -0
package/dist/public/types.d.ts
CHANGED
|
@@ -1,279 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export type
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export interface
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export interface
|
|
27
|
-
readonly
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
readonly
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
readonly
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
readonly kind: "token";
|
|
56
|
-
readonly count: number;
|
|
57
|
-
}
|
|
58
|
-
export interface TraceParseEvent {
|
|
59
|
-
readonly seq: number;
|
|
60
|
-
readonly kind: "parse";
|
|
61
|
-
readonly context: ParseContext;
|
|
62
|
-
readonly nodeCount: number;
|
|
63
|
-
readonly errorCount: number;
|
|
64
|
-
}
|
|
65
|
-
export interface TraceParseErrorEvent {
|
|
66
|
-
readonly seq: number;
|
|
67
|
-
readonly kind: "parseError";
|
|
68
|
-
readonly parseErrorId: string;
|
|
69
|
-
readonly startOffset: number | null;
|
|
70
|
-
readonly endOffset: number | null;
|
|
71
|
-
}
|
|
72
|
-
export interface TraceBudgetEvent {
|
|
73
|
-
readonly seq: number;
|
|
74
|
-
readonly kind: "budget";
|
|
75
|
-
readonly budget: BudgetExceededPayload["budget"];
|
|
76
|
-
readonly limit: number | null;
|
|
77
|
-
readonly actual: number;
|
|
78
|
-
readonly status: "ok" | "exceeded";
|
|
79
|
-
}
|
|
80
|
-
export interface TraceStreamEvent {
|
|
81
|
-
readonly seq: number;
|
|
82
|
-
readonly kind: "stream";
|
|
83
|
-
readonly bytesRead: number;
|
|
84
|
-
}
|
|
85
|
-
export type TraceEvent = TraceDecodeEvent | TraceTokenEvent | TraceParseEvent | TraceParseErrorEvent | TraceBudgetEvent | TraceStreamEvent;
|
|
86
|
-
export interface CssNode {
|
|
87
|
-
readonly id: NodeId;
|
|
88
|
-
readonly type: string;
|
|
89
|
-
readonly spanProvenance?: SpanProvenance;
|
|
90
|
-
readonly span?: Span;
|
|
91
|
-
readonly [key: string]: unknown;
|
|
92
|
-
}
|
|
93
|
-
export type NodeVisitor = (node: CssNode, depth: number) => void;
|
|
94
|
-
export interface StyleSheetTree {
|
|
95
|
-
readonly id: NodeId;
|
|
96
|
-
readonly kind: "stylesheet";
|
|
97
|
-
readonly context: "stylesheet";
|
|
98
|
-
readonly root: CssNode;
|
|
99
|
-
readonly children: readonly CssNode[];
|
|
100
|
-
readonly errors: readonly ParseError[];
|
|
101
|
-
readonly trace?: readonly TraceEvent[];
|
|
102
|
-
}
|
|
103
|
-
export interface FragmentTree {
|
|
104
|
-
readonly id: NodeId;
|
|
105
|
-
readonly kind: "fragment";
|
|
106
|
-
readonly context: ParseContext;
|
|
107
|
-
readonly root: CssNode;
|
|
108
|
-
readonly children: readonly CssNode[];
|
|
109
|
-
readonly errors: readonly ParseError[];
|
|
110
|
-
readonly trace?: readonly TraceEvent[];
|
|
111
|
-
}
|
|
112
|
-
export interface OutlineEntry {
|
|
113
|
-
readonly nodeId: NodeId;
|
|
114
|
-
readonly depth: number;
|
|
115
|
-
readonly type: string;
|
|
116
|
-
readonly text: string;
|
|
117
|
-
}
|
|
118
|
-
export interface Outline {
|
|
119
|
-
readonly entries: readonly OutlineEntry[];
|
|
120
|
-
}
|
|
121
|
-
export interface Chunk {
|
|
122
|
-
readonly index: number;
|
|
123
|
-
readonly nodeId: NodeId;
|
|
124
|
-
readonly content: string;
|
|
125
|
-
readonly nodes: number;
|
|
126
|
-
}
|
|
127
|
-
export interface ChunkOptions {
|
|
128
|
-
readonly maxChars?: number;
|
|
129
|
-
readonly maxNodes?: number;
|
|
130
|
-
readonly maxBytes?: number;
|
|
131
|
-
}
|
|
132
|
-
export interface BudgetExceededPayload {
|
|
133
|
-
readonly code: "BUDGET_EXCEEDED";
|
|
134
|
-
readonly budget: "maxInputBytes" | "maxBufferedBytes" | "maxTokens" | "maxNodes" | "maxDepth" | "maxTraceEvents" | "maxTraceBytes" | "maxTimeMs";
|
|
135
|
-
readonly limit: number;
|
|
136
|
-
readonly actual: number;
|
|
137
|
-
}
|
|
1
|
+
import type { CssAtRule, CssBlock, CssDeclaration, CssFunction, CssQualifiedRule, CssSimpleBlock, CssStylesheet, SyntaxFailure, SyntaxSuccess } from "../internal/syntax/ast.js";
|
|
2
|
+
import type { TokenizationResult } from "../internal/syntax/tokens.js";
|
|
3
|
+
import type { EncodingDecision, EncodingOptions, ParserResourceLimits, StreamParserResourceLimits, StreamTokenizerResourceLimits, TokenizerResourceLimits } from "../internal/syntax/types.js";
|
|
4
|
+
export type { CommaSeparatedComponentValuesResult, ComponentValue, ComponentValuesResult, CssAtRule, CssBlock, CssBlockItem, CssDeclaration, CssFunction, CssQualifiedRule, CssRule, CssSimpleBlock, CssStylesheet, ParserDiagnostic, ParserDiagnosticCode, PreservedToken, SyntaxDiagnostic, SyntaxFailure, SyntaxResult, SyntaxSuccess } from "../internal/syntax/ast.js";
|
|
5
|
+
export type { CssToken, TokenizationResult, TokenizerDiagnostic, TokenizerDiagnosticCode } from "../internal/syntax/tokens.js";
|
|
6
|
+
export type { EncodingDecision, EncodingOptions, ParserResourceLimits, ResourceLimitName, ResourceUsage, SelectorResourceLimits, SourcePosition, SourceSpan, StreamParserResourceLimits, StreamTokenizerResourceLimits, TokenizerResourceLimits } from "../internal/syntax/types.js";
|
|
7
|
+
export type { SyntaxParserOptions } from "../internal/syntax/parser.js";
|
|
8
|
+
export type { TokenizerOptions } from "../internal/syntax/tokenizer.js";
|
|
9
|
+
export type { CssSerializationErrorCode, CssSyntaxSerializable } from "../internal/syntax/serialize.js";
|
|
10
|
+
export type { CssDeclarationBlockOptions, CssDeclarationMutation, CssomDeclaration } from "../internal/cssom/declarations.js";
|
|
11
|
+
export type { CssPropertySemantics, CustomPropertySemantics, StandardPropertySemantics } from "../internal/properties/registry.js";
|
|
12
|
+
export type { InvalidPropertyValue, PropertyValidationOptions, PropertyValueValidation, UnsupportedPropertyValue, ValidPropertyValue } from "../internal/properties/matcher.js";
|
|
13
|
+
export type { ComplexSelector, CompoundSelector, SelectorAttribute, SelectorAttributeMatcher, SelectorClass, SelectorCombinator, SelectorDiagnostic, SelectorDiagnosticCode, SelectorId, SelectorList, SelectorNesting, SelectorParseFailure, SelectorParserOptions, SelectorParseResult, SelectorParseSuccess, SelectorPseudoArgument, SelectorPseudoClass, SelectorPseudoElement, SelectorSpecificity, SelectorSpecificityOptions, SelectorType, SimpleSelector } from "../internal/selectors/types.js";
|
|
14
|
+
export type { SelectorAttributeData, SelectorDecision, SelectorDefaultNamespace, SelectorDocumentMode, SelectorElementData, SelectorEnvironment, SelectorMatchOptions, SelectorMatchResult, SelectorNamespaceResolution, SelectorNodeData, SelectorOtherNodeData, SelectorPseudoContext, SelectorQueryResult, SelectorQueryUnknown, SelectorTextData, SelectorTreeAdapter, SelectorUnknownReason } from "../internal/selectors/matcher.js";
|
|
15
|
+
/** Decoding and resource options for stylesheet byte arrays. */
|
|
16
|
+
export interface ParseStylesheetBytesOptions extends EncodingOptions {
|
|
17
|
+
readonly limits?: ParserResourceLimits;
|
|
18
|
+
readonly signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
/** Decoding and resource options for stylesheet byte streams. */
|
|
21
|
+
export interface ParseStylesheetStreamOptions extends EncodingOptions {
|
|
22
|
+
readonly limits?: StreamParserResourceLimits;
|
|
23
|
+
readonly signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
/** Decoding and resource options for tokenizing byte arrays. */
|
|
26
|
+
export interface TokenizeBytesOptions extends EncodingOptions {
|
|
27
|
+
readonly limits?: TokenizerResourceLimits;
|
|
28
|
+
readonly signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
/** Decoding and resource options for tokenizing byte streams. */
|
|
31
|
+
export interface TokenizeStreamOptions extends EncodingOptions {
|
|
32
|
+
readonly limits?: StreamTokenizerResourceLimits;
|
|
33
|
+
/** Cancels decoding or parsing. */
|
|
34
|
+
readonly signal?: AbortSignal;
|
|
35
|
+
}
|
|
36
|
+
/** Parse or tokenization result with the byte-decoding decision. */
|
|
37
|
+
export type DecodedSyntaxResult<T> = (SyntaxSuccess<T> & {
|
|
38
|
+
readonly encoding: EncodingDecision;
|
|
39
|
+
}) | (SyntaxFailure & {
|
|
40
|
+
readonly encoding: EncodingDecision;
|
|
41
|
+
});
|
|
42
|
+
/** Tokenization result with the byte-decoding decision. */
|
|
43
|
+
export interface DecodedTokenizationResult extends TokenizationResult {
|
|
44
|
+
readonly encoding: EncodingDecision;
|
|
45
|
+
}
|
|
46
|
+
/** Structural nodes assigned stable tree-local identifiers. */
|
|
47
|
+
export type CssAstNode = CssStylesheet | CssAtRule | CssQualifiedRule | CssBlock | CssDeclaration | CssFunction | CssSimpleBlock;
|
|
48
|
+
/** A structural node narrowed by its `kind` discriminator. */
|
|
49
|
+
export type CssAstNodeOfKind<K extends CssAstNode["kind"]> = Extract<CssAstNode, {
|
|
50
|
+
readonly kind: K;
|
|
51
|
+
}>;
|
|
52
|
+
/** Called in depth-first order for each structural node. */
|
|
53
|
+
export type CssNodeVisitor = (node: CssAstNode, depth: number, parent: CssAstNode | null) => void;
|
|
54
|
+
/** Removes the input range represented by a parsed node. */
|
|
138
55
|
export interface RemoveNodeEdit {
|
|
139
|
-
readonly kind: "
|
|
140
|
-
readonly target:
|
|
56
|
+
readonly kind: "remove-node";
|
|
57
|
+
readonly target: number;
|
|
141
58
|
}
|
|
59
|
+
/** Replaces the input range represented by a parsed node. */
|
|
142
60
|
export interface ReplaceNodeEdit {
|
|
143
|
-
readonly kind: "
|
|
144
|
-
readonly target:
|
|
145
|
-
readonly css: string;
|
|
146
|
-
}
|
|
147
|
-
export interface InsertCssBeforeEdit {
|
|
148
|
-
readonly kind: "insertCssBefore";
|
|
149
|
-
readonly target: NodeId;
|
|
61
|
+
readonly kind: "replace-node";
|
|
62
|
+
readonly target: number;
|
|
150
63
|
readonly css: string;
|
|
151
64
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
readonly
|
|
65
|
+
/** Inserts CSS at a parsed node boundary. */
|
|
66
|
+
export interface InsertCssEdit {
|
|
67
|
+
readonly kind: "insert-before" | "insert-after";
|
|
68
|
+
readonly target: number;
|
|
155
69
|
readonly css: string;
|
|
156
70
|
}
|
|
157
|
-
|
|
158
|
-
export
|
|
159
|
-
|
|
71
|
+
/** Source-preserving edit addressed by a tree-local node identifier. */
|
|
72
|
+
export type CssSourceEdit = RemoveNodeEdit | ReplaceNodeEdit | InsertCssEdit;
|
|
73
|
+
/** Copies an unchanged half-open source range. */
|
|
74
|
+
export interface PatchCopy {
|
|
75
|
+
readonly kind: "copy";
|
|
160
76
|
readonly start: number;
|
|
161
77
|
readonly end: number;
|
|
162
78
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
readonly
|
|
79
|
+
/** Replaces a half-open source range; an empty range is an insertion. */
|
|
80
|
+
export interface PatchReplace {
|
|
81
|
+
readonly kind: "replace";
|
|
82
|
+
readonly start: number;
|
|
83
|
+
readonly end: number;
|
|
166
84
|
readonly text: string;
|
|
167
85
|
}
|
|
168
|
-
|
|
86
|
+
/** One operation in a validated source patch. */
|
|
87
|
+
export type PatchOperation = PatchCopy | PatchReplace;
|
|
88
|
+
/** Deterministic source transformation produced by {@link computePatch}. */
|
|
169
89
|
export interface PatchPlan {
|
|
170
|
-
readonly
|
|
90
|
+
readonly operations: readonly PatchOperation[];
|
|
171
91
|
readonly result: string;
|
|
172
92
|
}
|
|
173
|
-
export
|
|
174
|
-
readonly code: "NODE_NOT_FOUND" | "MISSING_NODE_SPAN" | "NON_INPUT_SPAN_PROVENANCE" | "OVERLAPPING_EDITS" | "INVALID_EDIT_TARGET";
|
|
175
|
-
readonly target?: NodeId;
|
|
176
|
-
readonly detail?: string;
|
|
177
|
-
}
|
|
178
|
-
export interface SelectorAttributeLike {
|
|
179
|
-
readonly name: string;
|
|
180
|
-
readonly value: string;
|
|
181
|
-
}
|
|
182
|
-
export interface SelectorNodeLike {
|
|
183
|
-
readonly kind?: string;
|
|
184
|
-
readonly type?: string;
|
|
185
|
-
readonly tagName?: string;
|
|
186
|
-
readonly attributes?: readonly SelectorAttributeLike[];
|
|
187
|
-
readonly children?: readonly SelectorNodeLike[];
|
|
188
|
-
readonly [key: string]: unknown;
|
|
189
|
-
}
|
|
190
|
-
export type SelectorCombinator = " " | ">";
|
|
191
|
-
export interface SelectorSimpleType {
|
|
192
|
-
readonly kind: "type";
|
|
193
|
-
readonly name: string;
|
|
194
|
-
readonly universal: boolean;
|
|
195
|
-
}
|
|
196
|
-
export interface SelectorSimpleId {
|
|
197
|
-
readonly kind: "id";
|
|
198
|
-
readonly value: string;
|
|
199
|
-
}
|
|
200
|
-
export interface SelectorSimpleClass {
|
|
201
|
-
readonly kind: "class";
|
|
202
|
-
readonly value: string;
|
|
203
|
-
}
|
|
204
|
-
export interface SelectorSimpleAttribute {
|
|
205
|
-
readonly kind: "attribute";
|
|
206
|
-
readonly name: string;
|
|
207
|
-
readonly matcher: null | "=" | "~=" | "|=" | "^=" | "$=" | "*=";
|
|
208
|
-
readonly value: string | null;
|
|
209
|
-
readonly flags: string | null;
|
|
210
|
-
}
|
|
211
|
-
export type SelectorSimple = SelectorSimpleType | SelectorSimpleId | SelectorSimpleClass | SelectorSimpleAttribute;
|
|
212
|
-
export interface CompiledSelectorCompound {
|
|
213
|
-
readonly simpleSelectors: readonly SelectorSimple[];
|
|
214
|
-
}
|
|
215
|
-
export interface SelectorUnsupportedPart {
|
|
216
|
-
readonly selectorIndex: number;
|
|
217
|
-
readonly partType: string;
|
|
218
|
-
readonly detail: string;
|
|
219
|
-
}
|
|
220
|
-
export interface CompiledSelector {
|
|
221
|
-
readonly selectorIndex: number;
|
|
222
|
-
readonly compounds: readonly CompiledSelectorCompound[];
|
|
223
|
-
readonly combinators: readonly SelectorCombinator[];
|
|
224
|
-
readonly supported: boolean;
|
|
225
|
-
readonly unsupportedParts: readonly SelectorUnsupportedPart[];
|
|
226
|
-
}
|
|
227
|
-
export interface CompiledSelectorList {
|
|
228
|
-
readonly source: string;
|
|
229
|
-
readonly parseErrors: readonly ParseError[];
|
|
230
|
-
readonly selectors: readonly CompiledSelector[];
|
|
231
|
-
readonly supported: boolean;
|
|
232
|
-
readonly unsupportedParts: readonly SelectorUnsupportedPart[];
|
|
233
|
-
}
|
|
234
|
-
export interface SelectorQueryOptions {
|
|
235
|
-
readonly strict?: boolean;
|
|
236
|
-
readonly maxVisitedNodes?: number;
|
|
237
|
-
}
|
|
238
|
-
export interface StyleSignalSpecificity {
|
|
239
|
-
readonly a: number;
|
|
240
|
-
readonly b: number;
|
|
241
|
-
readonly c: number;
|
|
242
|
-
}
|
|
243
|
-
export interface StyleDeclarationSignal {
|
|
244
|
-
readonly declarationNodeId: NodeId;
|
|
245
|
-
readonly property: string;
|
|
246
|
-
readonly value: string;
|
|
247
|
-
readonly important: boolean;
|
|
248
|
-
readonly declarationOrder: number;
|
|
249
|
-
}
|
|
250
|
-
export interface StyleRuleSignal {
|
|
251
|
-
readonly ruleNodeId: NodeId;
|
|
252
|
-
readonly selectorText: string;
|
|
253
|
-
readonly selector: CompiledSelectorList;
|
|
254
|
-
readonly selectorSupported: boolean;
|
|
255
|
-
readonly specificityMax: StyleSignalSpecificity;
|
|
256
|
-
readonly cascadeOrder: number;
|
|
257
|
-
readonly declarations: readonly StyleDeclarationSignal[];
|
|
258
|
-
}
|
|
259
|
-
export interface StyleSignalOptions {
|
|
260
|
-
readonly includeUnsupportedSelectors?: boolean;
|
|
261
|
-
readonly strictSelectors?: boolean;
|
|
262
|
-
}
|
|
263
|
-
export type RenderSignalClass = "visibility-hidden-subtree" | "visibility-hidden-self" | "control-affordance";
|
|
264
|
-
export interface RenderSignal {
|
|
265
|
-
readonly signalClass: RenderSignalClass;
|
|
266
|
-
readonly source: "rule" | "inline";
|
|
267
|
-
readonly property: string;
|
|
268
|
-
readonly value: string;
|
|
269
|
-
readonly important: boolean;
|
|
270
|
-
readonly declarationOrder: number;
|
|
271
|
-
readonly selectorText: string | null;
|
|
272
|
-
readonly declarationNodeId: NodeId;
|
|
273
|
-
readonly ruleNodeId: NodeId | null;
|
|
274
|
-
readonly cascadeOrder: number | null;
|
|
275
|
-
}
|
|
276
|
-
export interface RenderSignalOptions extends StyleSignalOptions {
|
|
277
|
-
readonly includeControlAffordance?: boolean;
|
|
278
|
-
readonly includeVisibilitySignals?: boolean;
|
|
279
|
-
}
|
|
93
|
+
export type PatchPlanningErrorCode = "node-not-found" | "duplicate-node-id" | "span-out-of-bounds" | "overlapping-edits" | "invalid-edit" | "invalid-plan";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ismail-elkorchi/css-parser",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CSS syntax parser, serializer, CSSOM declaration model, property validator, and selector engine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"packageManager": "npm@11.10.0",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
-
"npm": ">=
|
|
16
|
+
"node": ">=20.0.0",
|
|
17
|
+
"npm": ">=10.0.0"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/mod.js",
|
|
20
20
|
"types": "./dist/mod.d.ts",
|
|
@@ -27,64 +27,40 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
29
|
"README.md",
|
|
30
|
-
"LICENSE"
|
|
31
|
-
"THIRD_PARTY_NOTICES.md"
|
|
30
|
+
"LICENSE"
|
|
32
31
|
],
|
|
33
32
|
"scripts": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"test": "npm run test:control",
|
|
39
|
-
"test:control": "npm run build && node --test test/control/**/*.test.js tests/control/**/*.test.js && node scripts/eval/write-stub-reports.mjs",
|
|
40
|
-
"test:conformance": "node scripts/conformance/run-all.mjs",
|
|
41
|
-
"test:encoding": "npm run build && node scripts/conformance/run-encoding-fixtures.mjs",
|
|
42
|
-
"test:tokenizer": "npm run build && node scripts/conformance/run-tokenizer-fixtures.mjs",
|
|
43
|
-
"test:tree": "npm run build && node scripts/conformance/run-tree-fixtures.mjs",
|
|
44
|
-
"test:serializer": "npm run build && node scripts/conformance/run-serializer-fixtures.mjs",
|
|
45
|
-
"test:holdout": "npm run build && node scripts/conformance/run-holdout-fixtures.mjs",
|
|
46
|
-
"test:browser-diff": "npm run build && node scripts/oracles/run-browser-diff.mjs",
|
|
47
|
-
"test:fuzz": "npm run build && node scripts/fuzz/run-fuzz.mjs",
|
|
48
|
-
"test:bench": "npm run build && node --expose-gc scripts/bench/run-bench.mjs",
|
|
49
|
-
"test:bench:stability": "npm run build && node --expose-gc scripts/bench/run-bench-stability.mjs",
|
|
33
|
+
"build": "node scripts/build/build.mjs",
|
|
34
|
+
"check:fast": "npm run lint && npm run typecheck && npm test && npm run generate:check && npm run typecheck:jsr && npm run docs:test:jsr && npm run examples:run",
|
|
35
|
+
"deps:outdated": "npm outdated",
|
|
36
|
+
"docs:test:jsr": "deno test --doc jsr/mod.ts",
|
|
50
37
|
"examples:run": "npm run build && node examples/run-all.mjs",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"smoke:browser": "npm run build && node scripts/smoke/browser-smoke.mjs --report=reports/smoke-browser.json",
|
|
38
|
+
"fmt": "eslint . --fix --max-warnings=0",
|
|
39
|
+
"generate:check": "npm run build && node scripts/generate/css-data.mjs --check",
|
|
40
|
+
"generate:css-data": "npm run build && node scripts/generate/css-data.mjs && npm run build",
|
|
41
|
+
"lint": "eslint . --max-warnings=0",
|
|
42
|
+
"qualification:ci": "node scripts/qualification/run.mjs",
|
|
43
|
+
"qualification:release": "node scripts/qualification/run.mjs --release",
|
|
58
44
|
"smoke:all": "npm run smoke:node && npm run smoke:deno && npm run smoke:bun",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"eval:release": "node scripts/eval/run-eval.mjs --profile=release",
|
|
71
|
-
"eval:hard-gate": "node scripts/eval/run-eval.mjs --profile=hard-gate",
|
|
72
|
-
"docs:required": "node scripts/quality/doc-required.mjs",
|
|
73
|
-
"release:notes:dry-run": "node scripts/release/render-notes.mjs --dry-run",
|
|
74
|
-
"changelog:update:dry-run": "node scripts/release/update-changelog.mjs --dry-run"
|
|
45
|
+
"smoke:browser": "npm run build && node scripts/smoke/browser.mjs",
|
|
46
|
+
"smoke:bun": "npm run build && bun scripts/smoke/runtime.mjs",
|
|
47
|
+
"smoke:deno": "npm run build && deno run --allow-read scripts/smoke/runtime.mjs",
|
|
48
|
+
"smoke:node": "npm run build && node scripts/smoke/runtime.mjs",
|
|
49
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
50
|
+
"test:fuzz": "npm run build && node scripts/qualification/fuzz.mjs",
|
|
51
|
+
"test:oracle": "npm run build && node scripts/qualification/browser-oracle.mjs",
|
|
52
|
+
"test:package": "npm run build && node scripts/qualification/package.mjs",
|
|
53
|
+
"test:performance": "npm run build && node scripts/qualification/performance.mjs",
|
|
54
|
+
"typecheck": "tsc --noEmit -p tsconfig.build.json",
|
|
55
|
+
"typecheck:jsr": "deno check jsr/mod.ts"
|
|
75
56
|
},
|
|
76
57
|
"dependencies": {},
|
|
77
|
-
"overrides": {
|
|
78
|
-
"ajv": "6.14.0"
|
|
79
|
-
},
|
|
80
58
|
"devDependencies": {
|
|
81
|
-
"@eslint/js": "
|
|
82
|
-
"eslint": "
|
|
83
|
-
"eslint-
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"typescript": "5.9.3",
|
|
88
|
-
"typescript-eslint": "8.56.0"
|
|
59
|
+
"@eslint/js": "10.0.1",
|
|
60
|
+
"eslint": "10.8.0",
|
|
61
|
+
"eslint-plugin-boundaries": "7.1.0",
|
|
62
|
+
"playwright": "1.62.0",
|
|
63
|
+
"typescript": "6.0.3",
|
|
64
|
+
"typescript-eslint": "8.65.0"
|
|
89
65
|
}
|
|
90
66
|
}
|
package/THIRD_PARTY_NOTICES.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Third-party notices
|
|
2
|
-
|
|
3
|
-
This repository vendors third-party sources and datasets for deterministic runtime behavior and conformance evaluation.
|
|
4
|
-
|
|
5
|
-
## CSSTree
|
|
6
|
-
- Source: https://github.com/csstree/csstree
|
|
7
|
-
- Package/version: `css-tree@3.1.0`
|
|
8
|
-
- Vendored files: `src/internal/vendor/csstree/csstree.esm.js`
|
|
9
|
-
- License: MIT (`src/internal/vendor/csstree/LICENSE`)
|
|
10
|
-
|
|
11
|
-
## CSSWG draft snapshots
|
|
12
|
-
- Source: https://drafts.csswg.org/
|
|
13
|
-
- Vendored files: `vendor/specs/csswg-drafts/*.html`
|
|
14
|
-
- License: W3C/CSSWG publication terms per draft
|
|
15
|
-
|
|
16
|
-
## Web Platform Tests (WPT)
|
|
17
|
-
- Source: https://github.com/web-platform-tests/wpt
|
|
18
|
-
- Vendored sparse checkout: `vendor/wpt`
|
|
19
|
-
- License: upstream WPT repository license
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type CssTreeParseContext = "stylesheet" | "atrule" | "atrulePrelude" | "mediaQueryList" | "mediaQuery" | "condition" | "rule" | "selectorList" | "selector" | "block" | "declarationList" | "declaration" | "value";
|
|
2
|
-
export interface CssTreeParseError {
|
|
3
|
-
readonly message: string;
|
|
4
|
-
readonly formattedMessage?: string;
|
|
5
|
-
readonly offset?: number;
|
|
6
|
-
readonly line?: number;
|
|
7
|
-
readonly column?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface CssTreeParseOptions {
|
|
10
|
-
readonly context?: CssTreeParseContext;
|
|
11
|
-
readonly positions?: boolean;
|
|
12
|
-
readonly onParseError?: (error: CssTreeParseError) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function parse(source: string, options?: CssTreeParseOptions): unknown;
|
|
15
|
-
export declare function generate(ast: unknown): string;
|
|
16
|
-
export declare function tokenize(source: string, callback: (type: number, start: number, end: number) => void): void;
|
|
17
|
-
export declare function toPlainObject(ast: unknown): unknown;
|
|
18
|
-
export declare function fromPlainObject(ast: Record<string, unknown>): unknown;
|
|
19
|
-
export declare const tokenNames: readonly string[];
|
|
20
|
-
export declare const CSSTREE_VERSION: string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Vendored CSSTree runtime entrypoint.
|
|
2
|
-
// @ts-expect-error Vendored JS module does not include local .d.ts in this repository.
|
|
3
|
-
import * as runtime from "./vendor/csstree/csstree.esm.js";
|
|
4
|
-
const csstree = runtime;
|
|
5
|
-
export function parse(source, options) {
|
|
6
|
-
return csstree.parse(source, options);
|
|
7
|
-
}
|
|
8
|
-
export function generate(ast) {
|
|
9
|
-
return csstree.generate(ast);
|
|
10
|
-
}
|
|
11
|
-
export function tokenize(source, callback) {
|
|
12
|
-
csstree.tokenize(source, callback);
|
|
13
|
-
}
|
|
14
|
-
export function toPlainObject(ast) {
|
|
15
|
-
return csstree.toPlainObject(ast);
|
|
16
|
-
}
|
|
17
|
-
export function fromPlainObject(ast) {
|
|
18
|
-
return csstree.fromPlainObject(ast);
|
|
19
|
-
}
|
|
20
|
-
export const tokenNames = csstree.tokenNames;
|
|
21
|
-
export const CSSTREE_VERSION = csstree.version;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { decodeCssBytes, sniffCssEncoding, type EncodingSniffOptions, type EncodingSniffResult } from "./sniff.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { decodeCssBytes, sniffCssEncoding } from "./sniff.js";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface EncodingSniffOptions {
|
|
2
|
-
readonly transportEncodingLabel?: string;
|
|
3
|
-
readonly maxPrescanBytes?: number;
|
|
4
|
-
readonly defaultEncoding?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface EncodingSniffResult {
|
|
7
|
-
readonly encoding: string;
|
|
8
|
-
readonly source: "bom" | "transport" | "charset" | "default";
|
|
9
|
-
}
|
|
10
|
-
export declare function sniffCssEncoding(bytes: Uint8Array, options?: EncodingSniffOptions): EncodingSniffResult;
|
|
11
|
-
export declare function decodeCssBytes(bytes: Uint8Array, options?: EncodingSniffOptions): {
|
|
12
|
-
text: string;
|
|
13
|
-
sniff: EncodingSniffResult;
|
|
14
|
-
};
|