@webstudio-is/css-engine 0.56.0 → 0.57.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/package.json +11 -12
- package/src/core/css-engine.stories.tsx +1 -1
- package/src/core/css-engine.test.ts +2 -18
- package/src/core/css-engine.ts +6 -1
- package/src/core/to-value.test.ts +2 -19
- package/lib/types/core/compare-media.d.ts +0 -6
- package/lib/types/core/compare-media.test.d.ts +0 -1
- package/lib/types/core/create-css-engine.d.ts +0 -2
- package/lib/types/core/css-engine.d.ts +0 -20
- package/lib/types/core/css-engine.stories.d.ts +0 -6
- package/lib/types/core/css-engine.test.d.ts +0 -1
- package/lib/types/core/equal-media.d.ts +0 -2
- package/lib/types/core/equal-media.test.d.ts +0 -1
- package/lib/types/core/find-applicable-media.d.ts +0 -2
- package/lib/types/core/find-applicable-media.test.d.ts +0 -1
- package/lib/types/core/index.d.ts +0 -8
- package/lib/types/core/match-media.d.ts +0 -2
- package/lib/types/core/match-media.test.d.ts +0 -1
- package/lib/types/core/rules.d.ts +0 -53
- package/lib/types/core/style-element.d.ts +0 -10
- package/lib/types/core/style-sheet.d.ts +0 -6
- package/lib/types/core/to-property.d.ts +0 -2
- package/lib/types/core/to-property.test.d.ts +0 -1
- package/lib/types/core/to-value.d.ts +0 -3
- package/lib/types/core/to-value.test.d.ts +0 -1
- package/lib/types/index.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "CSS Renderer for Webstudio",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"hyphenate-style-name": "^1.0.4",
|
|
10
|
-
"react": "^
|
|
11
|
-
"react-dom": "^
|
|
12
|
-
"@webstudio-is/
|
|
10
|
+
"react": "^18.2.0",
|
|
11
|
+
"react-dom": "^18.2.0",
|
|
12
|
+
"@webstudio-is/css-data": "^0.57.0",
|
|
13
|
+
"@webstudio-is/fonts": "^0.57.0"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@jest/globals": "^29.3.1",
|
|
16
17
|
"@storybook/react": "^6.5.16",
|
|
17
18
|
"@types/hyphenate-style-name": "^1.0.0",
|
|
18
|
-
"@types/react": "^
|
|
19
|
-
"@types/react-dom": "^
|
|
19
|
+
"@types/react": "^18.0.35",
|
|
20
|
+
"@types/react-dom": "^18.0.11",
|
|
20
21
|
"jest": "^29.3.1",
|
|
21
22
|
"typescript": "5.0.3",
|
|
22
|
-
"@webstudio-is/
|
|
23
|
-
"@webstudio-is/css-data": "^0.56.0",
|
|
24
|
-
"@webstudio-is/jest-config": "^1.0.2",
|
|
23
|
+
"@webstudio-is/jest-config": "^1.0.4",
|
|
25
24
|
"@webstudio-is/scripts": "^0.0.0",
|
|
26
25
|
"@webstudio-is/storybook-config": "^0.0.0",
|
|
27
|
-
"@webstudio-is/tsconfig": "^1.0.
|
|
26
|
+
"@webstudio-is/tsconfig": "^1.0.4"
|
|
28
27
|
},
|
|
29
28
|
"exports": {
|
|
30
29
|
"source": "./src/index.ts",
|
|
@@ -40,11 +39,11 @@
|
|
|
40
39
|
"private": false,
|
|
41
40
|
"sideEffects": false,
|
|
42
41
|
"scripts": {
|
|
43
|
-
"typecheck": "tsc --noEmit",
|
|
42
|
+
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
|
|
44
43
|
"checks": "pnpm typecheck && pnpm lint && pnpm test",
|
|
45
44
|
"dev": "build-package --watch",
|
|
46
45
|
"build": "build-package",
|
|
47
|
-
"dts": "tsc
|
|
46
|
+
"dts": "tsc",
|
|
48
47
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
49
48
|
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
|
|
50
49
|
"storybook:run": "start-storybook -p 6006",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { describe, beforeEach, test, expect } from "@jest/globals";
|
|
2
|
-
import type { Assets } from "@webstudio-is/asset-uploader";
|
|
3
2
|
import { CssEngine } from "./css-engine";
|
|
4
3
|
|
|
5
4
|
const style0 = {
|
|
@@ -352,23 +351,8 @@ describe("CssEngine", () => {
|
|
|
352
351
|
});
|
|
353
352
|
|
|
354
353
|
test("render images with injected asset url", () => {
|
|
355
|
-
const assets
|
|
356
|
-
[
|
|
357
|
-
"1234",
|
|
358
|
-
{
|
|
359
|
-
type: "image",
|
|
360
|
-
path: "foo.png",
|
|
361
|
-
id: "1234567890",
|
|
362
|
-
projectId: "",
|
|
363
|
-
format: "",
|
|
364
|
-
size: 1212,
|
|
365
|
-
name: "img",
|
|
366
|
-
description: "",
|
|
367
|
-
location: "REMOTE",
|
|
368
|
-
createdAt: "",
|
|
369
|
-
meta: { width: 1, height: 2 },
|
|
370
|
-
},
|
|
371
|
-
],
|
|
354
|
+
const assets = new Map<string, { path: string }>([
|
|
355
|
+
["1234", { path: "foo.png" }],
|
|
372
356
|
]);
|
|
373
357
|
const rule = engine.addStyleRule(
|
|
374
358
|
".c",
|
package/src/core/css-engine.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Style } from "@webstudio-is/css-data";
|
|
2
2
|
import {
|
|
3
3
|
FontFaceRule,
|
|
4
4
|
MediaRule,
|
|
@@ -14,6 +14,11 @@ import type { TransformValue } from "./to-value";
|
|
|
14
14
|
|
|
15
15
|
const defaultMediaRuleId = "__default-media-rule__";
|
|
16
16
|
|
|
17
|
+
type CssRule = {
|
|
18
|
+
style: Style;
|
|
19
|
+
breakpoint?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
17
22
|
export type CssEngineOptions = { name?: string };
|
|
18
23
|
|
|
19
24
|
export class CssEngine {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { describe, test, expect } from "@jest/globals";
|
|
2
|
-
import type { Assets } from "@webstudio-is/asset-uploader";
|
|
3
2
|
import { toValue } from "./to-value";
|
|
4
3
|
|
|
5
4
|
describe("Convert WS CSS Values to native CSS strings", () => {
|
|
@@ -74,24 +73,8 @@ describe("Convert WS CSS Values to native CSS strings", () => {
|
|
|
74
73
|
});
|
|
75
74
|
|
|
76
75
|
test("array", () => {
|
|
77
|
-
const assets
|
|
78
|
-
[
|
|
79
|
-
"1234567890",
|
|
80
|
-
{
|
|
81
|
-
type: "image",
|
|
82
|
-
path: "foo.png",
|
|
83
|
-
|
|
84
|
-
id: "1234567890",
|
|
85
|
-
projectId: "",
|
|
86
|
-
format: "",
|
|
87
|
-
size: 1212,
|
|
88
|
-
name: "img",
|
|
89
|
-
description: "",
|
|
90
|
-
location: "REMOTE",
|
|
91
|
-
createdAt: "",
|
|
92
|
-
meta: { width: 1, height: 2 },
|
|
93
|
-
},
|
|
94
|
-
],
|
|
76
|
+
const assets = new Map<string, { path: string }>([
|
|
77
|
+
["1234567890", { path: "foo.png" }],
|
|
95
78
|
]);
|
|
96
79
|
|
|
97
80
|
const value = toValue(
|
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CssRule } from "@webstudio-is/css-data";
|
|
2
|
-
import { MediaRule, PlaintextRule, StyleRule, type FontFaceOptions, type MediaRuleOptions } from "./rules";
|
|
3
|
-
import type { TransformValue } from "./to-value";
|
|
4
|
-
export type CssEngineOptions = {
|
|
5
|
-
name?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare class CssEngine {
|
|
8
|
-
#private;
|
|
9
|
-
constructor({ name }: CssEngineOptions);
|
|
10
|
-
addMediaRule(id: string, options?: MediaRuleOptions): MediaRule;
|
|
11
|
-
addStyleRule(selectorText: string, rule: CssRule, transformValue?: TransformValue): StyleRule;
|
|
12
|
-
addPlaintextRule(cssText: string): PlaintextRule | Map<string, PlaintextRule>;
|
|
13
|
-
addFontFaceRule(options: FontFaceOptions): number;
|
|
14
|
-
clear(): void;
|
|
15
|
-
render(): void;
|
|
16
|
-
unmount(): void;
|
|
17
|
-
setAttribute(name: string, value: string): void;
|
|
18
|
-
getAttribute(name: string): string | null | undefined;
|
|
19
|
-
get cssText(): string;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./core";
|