@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 CHANGED
@@ -1,30 +1,29 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-engine",
3
- "version": "0.56.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": "^17.0.2",
11
- "react-dom": "^17.0.2",
12
- "@webstudio-is/fonts": "^0.56.0"
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": "^17.0.24",
19
- "@types/react-dom": "^17.0.9",
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/asset-uploader": "^0.56.0",
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.3"
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 --emitDeclarationOnly --declaration --declarationDir lib/types",
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",
@@ -34,7 +34,7 @@ export const Basic = () => {
34
34
  onClick={() => {
35
35
  engine.addStyleRule(".test", {
36
36
  style: {
37
- background: { type: "keyword", value: "yellow" },
37
+ backgroundColor: { type: "keyword", value: "yellow" },
38
38
  },
39
39
  breakpoint: "0",
40
40
  });
@@ -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: Assets = new Map([
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",
@@ -1,4 +1,4 @@
1
- import type { CssRule } from "@webstudio-is/css-data";
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: Assets = new Map([
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,2 +0,0 @@
1
- import { CssEngine, type CssEngineOptions } from "./css-engine";
2
- export declare const createCssEngine: (options?: CssEngineOptions) => CssEngine;
@@ -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,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare const _default: {
3
- component: string;
4
- };
5
- export default _default;
6
- export declare const Basic: () => JSX.Element;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { MediaRuleOptions } from "./rules";
2
- export declare const equalMedia: (left: MediaRuleOptions, right: MediaRuleOptions) => boolean;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { MediaRuleOptions } from "./rules";
2
- export declare const findApplicableMedia: <Media extends MediaRuleOptions>(media: Media[], width: number) => Media | undefined;
@@ -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,2 +0,0 @@
1
- import type { MediaRuleOptions } from "./rules";
2
- export declare const matchMedia: (options: MediaRuleOptions, width: number) => boolean;
@@ -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,6 +0,0 @@
1
- import type { StyleElement } from "./style-element";
2
- export declare class StyleSheet {
3
- #private;
4
- constructor(element: StyleElement);
5
- replaceSync(cssText: string): void;
6
- }
@@ -1,2 +0,0 @@
1
- import type { StyleProperty } from "@webstudio-is/css-data";
2
- export declare const toProperty: (property: StyleProperty) => string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from "./core";