1
0
mirror of https://github.com/webstudio-is/webstudio.git synced 2025-03-15 09:45:09 +00:00

Replace @types/css-tree override with patch ()

Split from https://github.com/webstudio-is/webstudio-builder/pull/1634

We may need more things from css-tree and reexporting everything is
harder to maintain so here added patch instead of types override.
This commit is contained in:
Bogdan Chadkin
2023-06-14 17:51:13 +03:00
committed by GitHub
parent 0750cd03f5
commit c40f5e507d
12 changed files with 114 additions and 63 deletions

51
@types/css-tree.d.ts vendored

@ -1,51 +0,0 @@
declare module "css-tree" {
export function parse(
text: string,
options?: import("@types/css-tree").ParseOptions
): import("@types/css-tree").CssNode;
export function walk(
ast: import("@types/css-tree").CssNode,
options:
| import("@types/css-tree").WalkOptionsNoVisit
| import("@types/css-tree").EnterOrLeaveFn
): void;
export function generate(
ast: import("@types/css-tree").CssNode,
options?: import("@types/css-tree").GenerateOptions
): string;
type Match =
| {
syntax: { type: "Property"; name: string };
match: Match[];
}
| {
syntax: { type: "Type"; name: string };
match: Match[];
}
| {
syntax: { type: "Keyword"; name: string };
token: string;
}
| { syntax: null };
type MatchProperty =
| {
matched: null;
error: { message: string };
}
// eslint-disable-next-line @typescript-eslint/ban-types
| {
matched: Match;
error: null;
};
export declare const lexer: {
matchProperty: (
property: string,
ast: import("@types/css-tree").CssNode
) => MatchProperty;
};
}

@ -65,7 +65,8 @@
},
"patchedDependencies": {
"@stitches/react@1.3.1-1": "patches/@stitches__react@1.3.1-1.patch",
"css-tree@2.3.1": "patches/css-tree@2.3.1.patch"
"css-tree@2.3.1": "patches/css-tree@2.3.1.patch",
"@types/css-tree@2.3.1": "patches/@types__css-tree@2.3.1.patch"
}
}
}

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "bin", "../../@types/**/*.d.ts"],
"include": ["src", "bin"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020"

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020"

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020"

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",

@ -1,6 +1,6 @@
{
"extends": "@webstudio-is/tsconfig/base.json",
"include": ["src", "../../@types/**/*.d.ts"],
"include": ["src"],
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",

@ -0,0 +1,97 @@
diff --git a/index.d.ts b/index.d.ts
index e6a09d2756a7d942d7dbf2d6b9437deb06e8eb31..46120815179b6176100a045a599b92ecaa6be89c 100755
--- a/index.d.ts
+++ b/index.d.ts
@@ -546,48 +546,7 @@ export interface WalkOptionsVisit<NodeType extends CssNode = CssNode> {
reverse?: boolean | undefined;
}
-export type WalkOptions =
- WalkOptionsVisit<AnPlusB>
- | WalkOptionsVisit<Atrule>
- | WalkOptionsVisit<AtrulePrelude>
- | WalkOptionsVisit<AttributeSelector>
- | WalkOptionsVisit<Block>
- | WalkOptionsVisit<Brackets>
- | WalkOptionsVisit<CDC>
- | WalkOptionsVisit<CDO>
- | WalkOptionsVisit<ClassSelector>
- | WalkOptionsVisit<Combinator>
- | WalkOptionsVisit<Comment>
- | WalkOptionsVisit<Declaration>
- | WalkOptionsVisit<DeclarationList>
- | WalkOptionsVisit<Dimension>
- | WalkOptionsVisit<FunctionNode>
- | WalkOptionsVisit<Hash>
- | WalkOptionsVisit<IdSelector>
- | WalkOptionsVisit<Identifier>
- | WalkOptionsVisit<MediaFeature>
- | WalkOptionsVisit<MediaQuery>
- | WalkOptionsVisit<MediaQueryList>
- | WalkOptionsVisit<Nth>
- | WalkOptionsVisit<NumberNode>
- | WalkOptionsVisit<Operator>
- | WalkOptionsVisit<Parentheses>
- | WalkOptionsVisit<Percentage>
- | WalkOptionsVisit<PseudoClassSelector>
- | WalkOptionsVisit<PseudoElementSelector>
- | WalkOptionsVisit<Ratio>
- | WalkOptionsVisit<Raw>
- | WalkOptionsVisit<Rule>
- | WalkOptionsVisit<Selector>
- | WalkOptionsVisit<SelectorList>
- | WalkOptionsVisit<StringNode>
- | WalkOptionsVisit<StyleSheet>
- | WalkOptionsVisit<TypeSelector>
- | WalkOptionsVisit<UnicodeRange>
- | WalkOptionsVisit<Url>
- | WalkOptionsVisit<Value>
- | WalkOptionsVisit<WhiteSpace>
- | WalkOptionsNoVisit;
+export type WalkOptions = WalkOptionsNoVisit;
export function walk(ast: CssNode, options: EnterOrLeaveFn | WalkOptions): void;
@@ -851,9 +810,30 @@ export class SyntaxReferenceError extends SyntaxError {
reference: string;
}
-export interface LexerMatchResult {
- error: Error | SyntaxMatchError | SyntaxReferenceError | null;
-}
+type Match =
+ | {
+ syntax: DSNodeProperty;
+ match: Match[];
+ }
+ | {
+ syntax: DSNodeType;
+ match: Match[];
+ }
+ | {
+ syntax: DSNodeKeyword;
+ token: string;
+ }
+ | { syntax: null };
+
+export type LexerMatchResult =
+ | {
+ matched: null;
+ error: Error | SyntaxMatchError | SyntaxReferenceError;
+ }
+ | {
+ matched: Match;
+ error: null;
+ };
export class Lexer {
matchAtruleDescriptor(atruleName: string, descriptorName: string, value: CssNode | string): LexerMatchResult;
@@ -864,6 +844,8 @@ export class Lexer {
match(syntax: DSNode | string, value: CssNode | string): LexerMatchResult;
}
+export declare const lexer: Lexer;
+
export function fork(extension: {
atrules?: Record<string, string> | undefined,
properties?: Record<string, string> | undefined,

10
pnpm-lock.yaml generated

@ -9,6 +9,9 @@ patchedDependencies:
'@stitches/react@1.3.1-1':
hash: knml42mpr6mlzseo3d6gjljiq4
path: patches/@stitches__react@1.3.1-1.patch
'@types/css-tree@2.3.1':
hash: ac22lciodhaj6xmoeignv36gyq
path: patches/@types__css-tree@2.3.1.patch
css-tree@2.3.1:
hash: epgcmebti7rfrc2ej4odb3t4jy
path: patches/css-tree@2.3.1.patch
@ -22,7 +25,7 @@ importers:
version: 6.5.16(@babel/core@7.21.0)(react-dom@18.2.0)(react@18.2.0)(require-from-string@2.0.2)(type-fest@3.7.1)(typescript@5.1.3)
'@types/css-tree':
specifier: ^2.3.1
version: 2.3.1
version: 2.3.1(patch_hash=ac22lciodhaj6xmoeignv36gyq)
'@webstudio-is/eslint-config-custom':
specifier: workspace:^
version: link:packages/eslint-config-custom
@ -470,7 +473,7 @@ importers:
devDependencies:
'@types/css-tree':
specifier: ^2.3.1
version: 2.3.1
version: 2.3.1(patch_hash=ac22lciodhaj6xmoeignv36gyq)
'@webstudio-is/jest-config':
specifier: workspace:^
version: link:../jest-config
@ -8575,9 +8578,10 @@ packages:
/@types/cookie@0.4.1:
resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==}
/@types/css-tree@2.3.1:
/@types/css-tree@2.3.1(patch_hash=ac22lciodhaj6xmoeignv36gyq):
resolution: {integrity: sha512-3m636Jz4d9d+lHVMp6FNLsUWQrfOx1xpm1SBxPbQYSNNgXMe+XswcsDeo1ldyULiuzYyWKk1kmvkLTgNq+215Q==}
dev: true
patched: true
/@types/debug@4.1.7:
resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}