Skip to content

Commit

Permalink
update import type definition #41
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Jul 21, 2024
1 parent cfbea69 commit c8f14fc
Show file tree
Hide file tree
Showing 42 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import {transform} from '@tbela99/css-parser/web';

Javascript module from cdn

```javascript
```html

<script type="module">
Expand Down
1 change: 1 addition & 0 deletions dist/index-umd-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -9525,6 +9525,7 @@
const path = resolve(url, currentFile).absolute;
t = new URL(path, self.origin);
}
// @ts-ignore
return fetch(t, t.origin != self.origin ? { mode: 'cors' } : {}).then(parseResponse);
}

Expand Down
1 change: 1 addition & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

var process = require('node:process');
var promises = require('node:fs/promises');

exports.EnumToken = void 0;
Expand Down
10 changes: 5 additions & 5 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,11 @@ export declare interface MinifyFeature {

ordering: number;

register: (options: MinifyOptions | ParserOptions) => void;
run: (ast: AstRule | AstAtRule, options: ParserOptions = {}, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: {
[key: string]: any
}) => void;
cleanup?: (ast: AstRuleStyleSheet, options: ParserOptions = {}, context: { [key: string]: any }) => void;
register(options: MinifyOptions | ParserOptions): void;

// run(ast: AstRule | AstAtRule, options: ParserOptions = {}, parent: AstRule | AstAtRule | AstRuleStyleSheet, context: { [key: string]: any }): void;

// cleanup?(ast: AstRuleStyleSheet, options: ParserOptions = {}, context: { [key: string]: any }): void;
}

export declare interface MinifyFeature {
Expand Down
1 change: 1 addition & 0 deletions dist/node/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
export { EnumToken } from '../lib/ast/types.js';
export { minify } from '../lib/ast/minify.js';
export { walk, walkValues } from '../lib/ast/walk.js';
Expand Down
1 change: 1 addition & 0 deletions dist/web/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async function load(url, currentFile) {
const path = resolve(url, currentFile).absolute;
t = new URL(path, self.origin);
}
// @ts-ignore
return fetch(t, t.origin != self.origin ? { mode: 'cors' } : {}).then(parseResponse);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {combinators, splitRule} from "./minify";
import {parseString} from "../parser";
import {walkValues} from "./walk";
import {renderToken} from "../renderer";
import {AstAtRule, AstNode, AstRule, AstRuleStyleSheet, Token} from "../../@types/index.d.ts";
import type {AstAtRule, AstNode, AstRule, AstRuleStyleSheet, Token} from "../../@types/index.d.ts";
import {EnumToken} from "./types";

export function expand(ast: AstNode): AstNode {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/features/calc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstAtRule,
AstDeclaration,
AstRule,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/features/inlinecssvariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstAtRule, AstComment,
AstDeclaration,
AstRule, AstRuleList,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/features/shorthand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {PropertyList} from "../../parser/declaration";
import {EnumToken} from "../types";
import {AstAtRule, AstRule, AstRuleStyleSheet, MinifyOptions, PropertyListOptions} from "../../../@types/index.d.ts";
import type {AstAtRule, AstRule, AstRuleStyleSheet, MinifyOptions, PropertyListOptions} from "../../../@types/index.d.ts";

export class ComputeShorthandFeature {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/math/expression.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
BinaryExpressionNode,
BinaryExpressionToken,
FractionToken,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/math/math.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {FractionToken} from "../../../@types/index.d.ts";
import type {FractionToken} from "../../../@types/index.d.ts";
import {EnumToken} from "../types";
import {reduceNumber} from "../../renderer";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/minify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {replaceCompound} from './expand';
import {doRender, renderToken} from "../renderer";
import * as allFeatures from "./features";
import {walkValues} from "./walk";
import {
import type {
AstAtRule,
AstDeclaration,
AstNode,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/validate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {EnumToken} from "./types";
import {AstNode} from "../../@types/index.d.ts";
import type {AstNode} from "../../@types/index.d.ts";

export function validateNode(node: AstNode, expected?: EnumToken): boolean {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/ast/walk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstNode,
AstRuleList, BinaryExpressionToken,
FunctionToken,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/declaration/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstDeclaration,
AstNode,
PropertyListOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/declaration/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstDeclaration,
IdentToken, PropertiesConfig,
PropertyMapType,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/declaration/set.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstDeclaration,
DimensionToken,
LiteralToken,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {renderToken} from "../renderer";
import {COLORS_NAMES} from "../renderer/color";
import {combinators, definedPropertySettings, EnumToken, expand, funcLike, minify, walk, walkValues} from "../ast";
import {tokenize} from "./tokenize";
import {
import type {
AstAtRule,
AstComment,
AstDeclaration,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/tokenize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {isDigit, isNewLine, isNonPrintable, isWhiteSpace} from "./utils";
import {Position, TokenizeResult} from "../../@types/index.d.ts";
import type {Position, TokenizeResult} from "../../@types/index.d.ts";
import {EnumToken} from "../ast";

declare type InputStream = string;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import config from '../../../config.json' assert {type: 'json'};
import {PropertiesConfig} from "../../../@types/index.d.ts";
import type {PropertiesConfig} from "../../../@types/index.d.ts";

export const getConfig = () => <PropertiesConfig>config;
2 changes: 1 addition & 1 deletion src/lib/parser/utils/declaration.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AstDeclaration, ErrorDescription, FunctionToken, ParensToken, Position, Token} from "../../../@types/index.d.ts";
import type {AstDeclaration, ErrorDescription, FunctionToken, ParensToken, Position, Token} from "../../../@types/index.d.ts";
import {EnumToken, walkValues} from "../../ast";
import {isWhiteSpace} from "./syntax";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/utils/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import {colorsFunc} from "../../renderer";
import {COLORS_NAMES} from "../../renderer/color";
import {
import type {
AngleToken,
DimensionToken,
FunctionToken,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parser/utils/type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {EnumToken} from "../../ast";
import {IdentToken, PropertyMapType, Token} from "../../../@types/index.d.ts";
import type {IdentToken, PropertyMapType, Token} from "../../../@types/index.d.ts";

// https://www.w3.org/TR/css-values-4/#math-function
export const funcList: string[] = ['clamp', 'calc'];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/color.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AngleToken,
ColorKind,
ColorSpace,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/colormix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken, IdentToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, IdentToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {isPolarColorspace, isRectangularOrthogonalColorspace} from "../../parser";
import {EnumToken} from "../../ast";
import {getNumber} from "./color";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/hex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken, IdentToken, NumberToken, PercentageToken} from "../../../@types/index.d.ts";
import type {ColorToken, IdentToken, NumberToken, PercentageToken} from "../../../@types/index.d.ts";
import {EnumToken} from "../../ast";
import {getNumber, minmax} from "./color";
import {cmyk2rgb, hsl2rgb, hwb2rgb, lab2rgb, lch2rgb, oklab2rgb, oklch2rgb} from "./rgb";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/hsl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {hwb2hsv} from "./hsv";
import {ColorToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getNumber} from "./color";
import {hex2rgb, lab2rgb, lch2rgb, oklab2rgb, oklch2rgb} from "./rgb";
import {getComponents} from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/hwb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {hsl2hsv} from "./hsv";
import {AngleToken, ColorToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {AngleToken, ColorToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getComponents} from "./utils";
import {getAngle, getNumber} from "./color";
import {EnumToken} from "../../ast";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/lab.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {D50, e, getComponents, k} from "./utils";
import {srgb2xyz, xyzd502srgb} from "./xyz";
import {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {hex2srgb, hsl2srgb, hwb2srgb, oklch2srgb, rgb2srgb} from "./srgb";
import {getLCHComponents} from "./lch";
import {getOKLABComponents, OKLab_to_XYZ} from "./oklab";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/lch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getComponents} from "./utils";
import {getAngle, getNumber} from "./color";
import {EnumToken} from "../../ast";
Expand Down
3 changes: 1 addition & 2 deletions src/lib/renderer/color/oklab.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {getComponents, multiplyMatrices} from "./utils";
import {srgb2lsrgbvalues, hex2srgb, hsl2srgb, hwb2srgb, lab2srgb, lch2srgb, rgb2srgb, lsrgb2srgbvalues} from "./srgb";
import {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getNumber} from "./color";
import {EnumToken} from "../../ast";
import {getOKLCHComponents} from "./oklch";
import {lch2labvalues} from "./lab";
import {eq} from "../../parser/utils/eq";

export function hex2oklab(token: ColorToken) {

Expand Down
4 changes: 2 additions & 2 deletions src/lib/renderer/color/oklch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getComponents, powerlessColorComponent} from "./utils";
import type {ColorToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {getComponents} from "./utils";
import {getAngle, getNumber} from "./color";
import {EnumToken} from "../../ast";
import {lab2lchvalues} from "./lch";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/relativecolor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {convert, getNumber} from "./color";
import {EnumToken, walkValues} from "../../ast";
import {reduceNumber} from "../render";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/rgb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken} from "../../../@types/index.d.ts";
import type {ColorToken} from "../../../@types/index.d.ts";
import {minmax} from "./color";
import {COLORS_NAMES} from "./utils";
import {expandHexValue} from "./hex";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/srgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// srgb-linear -> srgb
// 0 <= r, g, b <= 1
import {COLORS_NAMES, getComponents} from "./utils";
import {ColorToken, DimensionToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import type {ColorToken, DimensionToken, IdentToken, NumberToken, PercentageToken, Token} from "../../../@types/index.d.ts";
import {color2srgbvalues, getAngle, getNumber} from "./color";
import {EnumToken} from "../../ast";
import {getLABComponents, Lab_to_sRGB, lch2labvalues} from "./lab";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/utils/components.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorToken, NumberToken, Token} from "../../../../@types/index.d.ts";
import type {ColorToken, NumberToken, Token} from "../../../../@types/index.d.ts";
import {EnumToken} from "../../../ast";
import {COLORS_NAMES} from "./constants";
import {expandHexValue} from "../hex";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/color/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ColorSpace, IdentToken} from "../../../../@types/index.d.ts";
import type {ColorSpace, IdentToken} from "../../../../@types/index.d.ts";
import {EnumToken} from "../../../ast";

export const colorRange = {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/render.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AngleToken,
AstAtRule,
AstComment,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/renderer/sourcemap/sourcemap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Location, SourceMapObject} from "../../../@types/index.d.ts";
import type {Location, SourceMapObject} from "../../../@types/index.d.ts";
import {encode} from "./lib";

export class SourceMap {
Expand Down
2 changes: 1 addition & 1 deletion src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstNode,
ParseResult,
ParserOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/web/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
AstNode,
ParseResult,
ParserOptions,
Expand Down

0 comments on commit c8f14fc

Please sign in to comment.