@webstudio-is/css-engine 0.57.0 → 0.58.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.
@@ -0,0 +1,6 @@
1
+ import type { MediaRuleOptions } from "./rules";
2
+ /**
3
+ * Sort by minWidth descending or maxWidth ascending
4
+ * We want media querries with bigger minWidth to override the smaller once, but the smaller maxWidth to override the bigger once.
5
+ */
6
+ export declare const compareMedia: (optionA: MediaRuleOptions, optionB: MediaRuleOptions) => number;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CssEngine, type CssEngineOptions } from "./css-engine";
2
+ export declare const createCssEngine: (options?: CssEngineOptions) => CssEngine;
@@ -0,0 +1,25 @@
1
+ import type { Style } from "@webstudio-is/css-data";
2
+ import { MediaRule, PlaintextRule, StyleRule, type FontFaceOptions, type MediaRuleOptions } from "./rules";
3
+ import type { TransformValue } from "./to-value";
4
+ type CssRule = {
5
+ style: Style;
6
+ breakpoint?: string;
7
+ };
8
+ export type CssEngineOptions = {
9
+ name?: string;
10
+ };
11
+ export declare class CssEngine {
12
+ #private;
13
+ constructor({ name }: CssEngineOptions);
14
+ addMediaRule(id: string, options?: MediaRuleOptions): MediaRule;
15
+ addStyleRule(selectorText: string, rule: CssRule, transformValue?: TransformValue): StyleRule;
16
+ addPlaintextRule(cssText: string): PlaintextRule | Map<string, PlaintextRule>;
17
+ addFontFaceRule(options: FontFaceOptions): number;
18
+ clear(): void;
19
+ render(): void;
20
+ unmount(): void;
21
+ setAttribute(name: string, value: string): void;
22
+ getAttribute(name: string): string | null | undefined;
23
+ get cssText(): string;
24
+ }
25
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ component: string;
4
+ };
5
+ export default _default;
6
+ export declare const Basic: () => JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { MediaRuleOptions } from "./rules";
2
+ export declare const equalMedia: (left: MediaRuleOptions, right: MediaRuleOptions) => boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { MediaRuleOptions } from "./rules";
2
+ export declare const findApplicableMedia: <Media extends MediaRuleOptions>(media: Media[], width: number) => Media | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export { CssEngine } from "./css-engine";
2
+ export type { AnyRule, StyleRule, MediaRule, PlaintextRule, FontFaceRule, } from "./rules";
3
+ export * from "./create-css-engine";
4
+ export * from "./to-value";
5
+ export * from "./match-media";
6
+ export * from "./equal-media";
7
+ export * from "./compare-media";
8
+ export * from "./find-applicable-media";
@@ -0,0 +1,2 @@
1
+ import type { MediaRuleOptions } from "./rules";
2
+ export declare const matchMedia: (options: MediaRuleOptions, width: number) => boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { Style, StyleProperty, StyleValue } from "@webstudio-is/css-data";
2
+ import { type TransformValue } from "./to-value";
3
+ declare class StylePropertyMap {
4
+ #private;
5
+ onChange?: () => void;
6
+ constructor(transformValue?: TransformValue);
7
+ set(property: StyleProperty, value?: StyleValue): void;
8
+ has(property: StyleProperty): boolean;
9
+ keys(): IterableIterator<"color" | "left" | "right" | "top" | "bottom" | "contain" | "clip" | "content" | `--${string}` | "accentColor" | "alignContent" | "alignItems" | "alignSelf" | "alignTracks" | "animationComposition" | "animationDelay" | "animationDirection" | "animationDuration" | "animationFillMode" | "animationIterationCount" | "animationName" | "animationPlayState" | "animationTimingFunction" | "animationTimeline" | "appearance" | "aspectRatio" | "backdropFilter" | "backfaceVisibility" | "backgroundAttachment" | "backgroundBlendMode" | "backgroundClip" | "backgroundColor" | "backgroundImage" | "backgroundOrigin" | "backgroundPosition" | "backgroundPositionX" | "backgroundPositionY" | "backgroundRepeat" | "backgroundSize" | "blockOverflow" | "blockSize" | "borderBlockColor" | "borderBlockStyle" | "borderBlockWidth" | "borderBlockEndColor" | "borderBlockEndStyle" | "borderBlockEndWidth" | "borderBlockStartColor" | "borderBlockStartStyle" | "borderBlockStartWidth" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderCollapse" | "borderEndEndRadius" | "borderEndStartRadius" | "borderImageOutset" | "borderImageRepeat" | "borderImageSlice" | "borderImageSource" | "borderImageWidth" | "borderInlineColor" | "borderInlineStyle" | "borderInlineWidth" | "borderInlineEndColor" | "borderInlineEndStyle" | "borderInlineEndWidth" | "borderInlineStartColor" | "borderInlineStartStyle" | "borderInlineStartWidth" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderSpacing" | "borderStartEndRadius" | "borderStartStartRadius" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "boxDecorationBreak" | "boxShadow" | "boxSizing" | "breakAfter" | "breakBefore" | "breakInside" | "captionSide" | "caretColor" | "caretShape" | "clear" | "clipPath" | "printColorAdjust" | "colorScheme" | "columnCount" | "columnFill" | "columnGap" | "columnRuleColor" | "columnRuleStyle" | "columnRuleWidth" | "columnSpan" | "columnWidth" | "containIntrinsicBlockSize" | "containIntrinsicHeight" | "containIntrinsicInlineSize" | "containIntrinsicWidth" | "contentVisibility" | "counterIncrement" | "counterReset" | "counterSet" | "cursor" | "direction" | "display" | "emptyCells" | "filter" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "float" | "fontFamily" | "fontFeatureSettings" | "fontKerning" | "fontLanguageOverride" | "fontOpticalSizing" | "fontVariationSettings" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontSynthesis" | "fontVariant" | "fontVariantAlternates" | "fontVariantCaps" | "fontVariantEastAsian" | "fontVariantLigatures" | "fontVariantNumeric" | "fontVariantPosition" | "fontWeight" | "forcedColorAdjust" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumnEnd" | "gridColumnStart" | "gridRowEnd" | "gridRowStart" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "hangingPunctuation" | "height" | "hyphenateCharacter" | "hyphens" | "imageOrientation" | "imageRendering" | "imageResolution" | "initialLetter" | "initialLetterAlign" | "inlineSize" | "inputSecurity" | "insetBlockEnd" | "insetBlockStart" | "insetInlineEnd" | "insetInlineStart" | "isolation" | "justifyContent" | "justifyItems" | "justifySelf" | "justifyTracks" | "letterSpacing" | "lineBreak" | "lineClamp" | "lineHeight" | "lineHeightStep" | "listStyleImage" | "listStylePosition" | "listStyleType" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "marginTrim" | "maskBorderMode" | "maskBorderOutset" | "maskBorderRepeat" | "maskBorderSlice" | "maskBorderSource" | "maskBorderWidth" | "maskClip" | "maskComposite" | "maskImage" | "maskMode" | "maskOrigin" | "maskPosition" | "maskRepeat" | "maskSize" | "maskType" | "masonryAutoFlow" | "mathDepth" | "mathShift" | "mathStyle" | "maxBlockSize" | "maxHeight" | "maxInlineSize" | "maxLines" | "maxWidth" | "minBlockSize" | "minHeight" | "minInlineSize" | "minWidth" | "mixBlendMode" | "objectFit" | "objectPosition" | "offsetAnchor" | "offsetDistance" | "offsetPath" | "offsetPosition" | "offsetRotate" | "opacity" | "order" | "orphans" | "outlineColor" | "outlineOffset" | "outlineStyle" | "outlineWidth" | "overflow" | "overflowAnchor" | "overflowBlock" | "overflowClipMargin" | "overflowInline" | "overflowWrap" | "overflowX" | "overflowY" | "overscrollBehavior" | "overscrollBehaviorBlock" | "overscrollBehaviorInline" | "overscrollBehaviorX" | "overscrollBehaviorY" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "pageBreakAfter" | "pageBreakBefore" | "pageBreakInside" | "paintOrder" | "perspective" | "perspectiveOrigin" | "pointerEvents" | "position" | "quotes" | "resize" | "rotate" | "rowGap" | "rubyAlign" | "rubyMerge" | "rubyPosition" | "scale" | "scrollbarColor" | "scrollbarGutter" | "scrollbarWidth" | "scrollBehavior" | "scrollMarginBlockStart" | "scrollMarginBlockEnd" | "scrollMarginBottom" | "scrollMarginInlineStart" | "scrollMarginInlineEnd" | "scrollMarginLeft" | "scrollMarginRight" | "scrollMarginTop" | "scrollPaddingBlockStart" | "scrollPaddingBlockEnd" | "scrollPaddingBottom" | "scrollPaddingInlineStart" | "scrollPaddingInlineEnd" | "scrollPaddingLeft" | "scrollPaddingRight" | "scrollPaddingTop" | "scrollSnapAlign" | "scrollSnapStop" | "scrollSnapType" | "scrollTimelineAxis" | "scrollTimelineName" | "shapeImageThreshold" | "shapeMargin" | "shapeOutside" | "tabSize" | "tableLayout" | "textAlign" | "textAlignLast" | "textCombineUpright" | "textDecorationColor" | "textDecorationLine" | "textDecorationSkip" | "textDecorationSkipInk" | "textDecorationStyle" | "textDecorationThickness" | "textEmphasisColor" | "textEmphasisPosition" | "textEmphasisStyle" | "textIndent" | "textJustify" | "textOrientation" | "textOverflow" | "textRendering" | "textShadow" | "textSizeAdjust" | "textTransform" | "textUnderlineOffset" | "textUnderlinePosition" | "touchAction" | "transform" | "transformBox" | "transformOrigin" | "transformStyle" | "transitionDelay" | "transitionDuration" | "transitionProperty" | "transitionTimingFunction" | "translate" | "unicodeBidi" | "userSelect" | "verticalAlign" | "visibility" | "whiteSpace" | "widows" | "width" | "willChange" | "wordBreak" | "wordSpacing" | "wordWrap" | "writingMode" | "zIndex">;
10
+ delete(property: StyleProperty): void;
11
+ clear(): void;
12
+ toString(): string;
13
+ }
14
+ export declare class StyleRule {
15
+ #private;
16
+ styleMap: StylePropertyMap;
17
+ selectorText: string;
18
+ onChange?: () => void;
19
+ constructor(selectorText: string, style: Style, transformValue?: TransformValue);
20
+ get cssText(): string;
21
+ }
22
+ export type MediaRuleOptions = {
23
+ minWidth?: number;
24
+ maxWidth?: number;
25
+ mediaType?: "all" | "screen" | "print";
26
+ };
27
+ export declare class MediaRule {
28
+ #private;
29
+ options: MediaRuleOptions;
30
+ rules: Array<StyleRule | PlaintextRule>;
31
+ constructor(options?: MediaRuleOptions);
32
+ insertRule(rule: StyleRule | PlaintextRule): StyleRule | PlaintextRule;
33
+ get cssText(): string;
34
+ }
35
+ export declare class PlaintextRule {
36
+ cssText: string;
37
+ styleMap: StylePropertyMap;
38
+ constructor(cssText: string);
39
+ }
40
+ export type FontFaceOptions = {
41
+ fontFamily: string;
42
+ fontStyle?: "normal" | "italic" | "oblique";
43
+ fontWeight?: number | string;
44
+ fontDisplay: "swap" | "auto" | "block" | "fallback" | "optional";
45
+ src: string;
46
+ };
47
+ export declare class FontFaceRule {
48
+ options: FontFaceOptions;
49
+ constructor(options: FontFaceOptions);
50
+ get cssText(): string;
51
+ }
52
+ export type AnyRule = StyleRule | MediaRule | PlaintextRule | FontFaceRule;
53
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare class StyleElement {
2
+ #private;
3
+ constructor(name?: string);
4
+ get isMounted(): boolean;
5
+ mount(): void;
6
+ unmount(): void;
7
+ render(cssText: string): void;
8
+ setAttribute(name: string, value: string): void;
9
+ getAttribute(name: string): string | null | undefined;
10
+ }
@@ -0,0 +1,6 @@
1
+ import type { StyleElement } from "./style-element";
2
+ export declare class StyleSheet {
3
+ #private;
4
+ constructor(element: StyleElement);
5
+ replaceSync(cssText: string): void;
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { StyleProperty } from "@webstudio-is/css-data";
2
+ export declare const toProperty: (property: StyleProperty) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { StyleValue } from "@webstudio-is/css-data";
2
+ export type TransformValue = (styleValue: StyleValue) => undefined | StyleValue;
3
+ export declare const toValue: (styleValue: undefined | StyleValue, transformValue?: TransformValue) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-engine",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "CSS Renderer for Webstudio",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -9,8 +9,8 @@
9
9
  "hyphenate-style-name": "^1.0.4",
10
10
  "react": "^18.2.0",
11
11
  "react-dom": "^18.2.0",
12
- "@webstudio-is/css-data": "^0.57.0",
13
- "@webstudio-is/fonts": "^0.57.0"
12
+ "@webstudio-is/css-data": "^0.58.0",
13
+ "@webstudio-is/fonts": "^0.58.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@jest/globals": "^29.3.1",
@@ -20,10 +20,10 @@
20
20
  "@types/react-dom": "^18.0.11",
21
21
  "jest": "^29.3.1",
22
22
  "typescript": "5.0.3",
23
- "@webstudio-is/jest-config": "^1.0.4",
23
+ "@webstudio-is/jest-config": "^1.0.5",
24
24
  "@webstudio-is/scripts": "^0.0.0",
25
25
  "@webstudio-is/storybook-config": "^0.0.0",
26
- "@webstudio-is/tsconfig": "^1.0.4"
26
+ "@webstudio-is/tsconfig": "^1.0.5"
27
27
  },
28
28
  "exports": {
29
29
  "source": "./src/index.ts",
@@ -43,7 +43,7 @@
43
43
  "checks": "pnpm typecheck && pnpm lint && pnpm test",
44
44
  "dev": "build-package --watch",
45
45
  "build": "build-package",
46
- "dts": "tsc",
46
+ "dts": "tsc --declarationDir lib/types",
47
47
  "test": "NODE_OPTIONS=--experimental-vm-modules jest",
48
48
  "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
49
49
  "storybook:run": "start-storybook -p 6006",