Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
move css-data to a package
Oleg Isonen33160e66324b
diff --git a/apps/designer/app/designer/features/style-panel/shared/configs.ts b/apps/designer/app/designer/features/style-panel/shared/configs.tsindex ba604f1c1f..32077e29aa 100644--- a/apps/designer/app/designer/features/style-panel/shared/configs.ts+++ b/apps/designer/app/designer/features/style-panel/shared/configs.ts@@ -1,7 +1,5 @@import {- properties,categories,- keywordValues,type Category,type StyleProperty,type AppliesTo,@@ -39,6 +37,7 @@ import {ColumnGapIcon,} from "@webstudio-is/icons";import { isFeatureEnabled } from "~/shared/feature-flags";+import { keywordValues, properties } from "@webstudio-is/css-data";type BaseStyleConfig = {label: string;diff --git a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.tsindex 7751b31dd9..2e51cad73e 100644--- a/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts+++ b/apps/designer/app/designer/features/style-panel/shared/get-inherited-style.ts@@ -1,9 +1,9 @@-import {- properties,- type StyleValue,- type StyleProperty,+import { properties } from "@webstudio-is/css-data";+import type {+ StyleValue,+ StyleProperty,+ Instance,} from "@webstudio-is/react-sdk";-import { type Instance } from "@webstudio-is/react-sdk";export type InheritedStyle = {[property in StyleProperty]: {diff --git a/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts b/apps/designer/app/designer/features/style-panel/shared/parse-css-value.tsindex 8ede09de52..3a01154a24 100644--- a/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts+++ b/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts@@ -1,6 +1,6 @@import hyphenate from "hyphenate-style-name";-import { units } from "@webstudio-is/react-sdk";import type { StyleProperty, StyleValue, Unit } from "@webstudio-is/react-sdk";+import { units } from "@webstudio-is/css-data";const unitRegex = new RegExp(`${[...units, "number"].join("|")}`);diff --git a/packages/css-data/LICENSE b/packages/css-data/LICENSEnew file mode 100644index 0000000000..1f6edad9a7--- /dev/null+++ b/packages/css-data/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2022 Webstudio++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/packages/css-data/README.md b/packages/css-data/README.mdnew file mode 100644index 0000000000..6353e27471--- /dev/null+++ b/packages/css-data/README.md@@ -0,0 +1,3 @@+# CSS Data++Generated configs and collections from mdn-data into consumable form.diff --git a/packages/react-sdk/bin/mdn-data.ts b/packages/css-data/bin/mdn-data.tssimilarity index 97%rename from packages/react-sdk/bin/mdn-data.tsrename to packages/css-data/bin/mdn-data.tsindex 82c624a7fb..576b26d3ee 100755--- a/packages/react-sdk/bin/mdn-data.ts+++ b/packages/css-data/bin/mdn-data.ts@@ -2,9 +2,9 @@ import { definitionSyntax, type DSNode } from "css-tree";import properties from "mdn-data/css/properties.json";import units from "mdn-data/css/units.json";import syntaxes from "mdn-data/css/syntaxes.json";-import type { StyleValue } from "../src/css";-import { popularityIndex } from "./popularity-index";-+//import type { StyleValue } from "../src/css";+import { popularityIndex } from "../src/popularity-index";+type StyleValue = any;import camelCase from "camelcase";import * as fs from "fs";import * as path from "path";diff --git a/packages/css-data/package.json b/packages/css-data/package.jsonnew file mode 100644index 0000000000..8021032d33--- /dev/null+++ b/packages/css-data/package.json@@ -0,0 +1,42 @@+{+ "name": "@webstudio-is/css-data",+ "version": "0.1.0",+ "description": "CSS Data",+ "author": "Webstudio <[email protected]>",+ "homepage": "https://webstudio.is",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "checks": "yarn typecheck && yarn lint",+ "dev": "tsup --watch",+ "build": "rm -fr lib tsconfig.tsbuildinfo && tsc",+ "build:mdn-data": "tsx ./bin/mdn-data.ts ./src",+ "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0"+ },+ "dependencies": {},+ "devDependencies": {+ "@webstudio-is/jest-config": "*",+ "mdn-data": "2.0.23",+ "tsup": "^6.1.3",+ "typescript": "4.7.4",+ "@types/css-tree": "^1.0.7",+ "css-tree": "^2.1.0",+ "camelcase": "^6.3.0"+ },+ "main": "lib/index.js",+ "types": "lib/index.d.ts",+ "files": [+ "lib/*",+ "README.md",+ "!*.test.*"+ ],+ "license": "MIT",+ "private": false,+ "sideEffects": false,+ "tsup": {+ "entry": [+ "src/index.ts"+ ],+ "format": "cjs",+ "outDir": "lib"+ }+}diff --git a/packages/css-data/src/index.ts b/packages/css-data/src/index.tsnew file mode 100644index 0000000000..f3a1b2bee9--- /dev/null+++ b/packages/css-data/src/index.ts@@ -0,0 +1,3 @@+export * from "./keyword-values";+export * from "./properties";+export * from "./units";diff --git a/packages/react-sdk/src/css/keyword-values.ts b/packages/css-data/src/keyword-values.tssimilarity index 100%rename from packages/react-sdk/src/css/keyword-values.tsrename to packages/css-data/src/keyword-values.tsdiff --git a/packages/react-sdk/bin/popularity-index.ts b/packages/css-data/src/popularity-index.tssimilarity index 100%rename from packages/react-sdk/bin/popularity-index.tsrename to packages/css-data/src/popularity-index.tsdiff --git a/packages/react-sdk/src/css/properties.ts b/packages/css-data/src/properties.tssimilarity index 100%rename from packages/react-sdk/src/css/properties.tsrename to packages/css-data/src/properties.tsdiff --git a/packages/react-sdk/src/css/units.ts b/packages/css-data/src/units.tssimilarity index 100%rename from packages/react-sdk/src/css/units.tsrename to packages/css-data/src/units.tsdiff --git a/packages/css-data/tsconfig.json b/packages/css-data/tsconfig.jsonnew file mode 100644index 0000000000..f298e02ab1--- /dev/null+++ b/packages/css-data/tsconfig.json@@ -0,0 +1,15 @@+{+ // Extends can't use node's resolution rn https://github.com/dividab/tsconfig-paths/issues/209#issuecomment-1177261091+ "extends": "../../node_modules/@webstudio-is/tsconfig/base.json",+ "include": ["./src/**/*.ts"],+ "compilerOptions": {+ "module": "commonjs",+ "target": "ES2020",+ "strict": true,+ "baseUrl": ".",+ "outDir": "./lib",+ "rootDir": "./src"+ },+ // this is auto-generated by update-ts-project-references.ts+ "references": []+}diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.jsonindex b176120cc8..e0691d7634 100644--- a/packages/react-sdk/package.json+++ b/packages/react-sdk/package.json@@ -7,7 +7,6 @@"scripts": {"dev": "tsup --watch","build": "yarn build:lib",- "build:mdn-data": "tsx ./bin/mdn-data.ts ./src/css","build:args": "tsx ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'","typecheck": "tsc --noEmit","build:lib": "rm -fr lib tsconfig.tsbuildinfo && tsc",@@ -32,17 +31,13 @@"@storybook/manager-webpack4": "^6.5.6","@storybook/react": "^6.5.6","@storybook/testing-library": "^0.0.11",- "@types/css-tree": "^1.0.7","@types/fs-extra": "^9.0.13","@types/node": "^17.0.21","@webstudio-is/jest-config": "*","@webstudio-is/prisma-client": "*","babel-loader": "^8.2.5",- "camelcase": "^6.3.0",- "css-tree": "^2.1.0","esbuild": "^0.14.25","esbuild-node-externals": "^1.4.1",- "mdn-data": "2.0.23","react": "^17.0.2","react-docgen-typescript": "^2.2.2","react-dom": "^17.0.2",@@ -62,6 +57,7 @@"@webstudio-is/asset-uploader": "^*","@webstudio-is/fonts": "*","@webstudio-is/icons": "*",+ "@webstudio-is/css-data": "*","@webstudio-is/jest-config": "*","immer": "^9.0.12","mitt": "^3.0.0",diff --git a/packages/react-sdk/src/css/get-browser-style.ts b/packages/react-sdk/src/css/get-browser-style.tsindex 679f9cd9f6..aa1e378219 100644--- a/packages/react-sdk/src/css/get-browser-style.ts+++ b/packages/react-sdk/src/css/get-browser-style.ts@@ -1,8 +1,7 @@import { detectFont } from "detect-font";import type { StyleProperty } from "./types";import type { Style, StyleValue, Unit } from "./schema";-import { properties } from "./properties";-import { units } from "./units";+import { properties, units } from "@webstudio-is/css-data";const unitRegex = new RegExp(`${units.join("|")}`);diff --git a/packages/react-sdk/src/css/index.ts b/packages/react-sdk/src/css/index.tsindex 0465831969..d93705b136 100644--- a/packages/react-sdk/src/css/index.ts+++ b/packages/react-sdk/src/css/index.ts@@ -1,8 +1,5 @@-export * from "./properties";-export * from "./units";export * from "./types";export * from "./schema";export * from "./get-browser-style";export * from "./categories";-export * from "./keyword-values";export * from "./breakpoints";diff --git a/packages/react-sdk/src/css/schema.ts b/packages/react-sdk/src/css/schema.tsindex 6e10af2722..bc30828348 100644--- a/packages/react-sdk/src/css/schema.ts+++ b/packages/react-sdk/src/css/schema.ts@@ -1,5 +1,5 @@+import { units } from "@webstudio-is/css-data";import { z } from "zod";-import { units } from "./units";import { StyleProperty } from "./types";export const Unit = z.union([z.enum(units), z.literal("number")]);diff --git a/packages/react-sdk/src/css/types.ts b/packages/react-sdk/src/css/types.tsindex 7cf39d75e1..058425582a 100644--- a/packages/react-sdk/src/css/types.ts+++ b/packages/react-sdk/src/css/types.ts@@ -1,4 +1,4 @@-import { properties } from "./properties";+import { properties } from "@webstudio-is/css-data";type Properties = typeof properties;diff --git a/packages/react-sdk/tsconfig.json b/packages/react-sdk/tsconfig.jsonindex f2fa0ab9be..4bb16ccc51 100644--- a/packages/react-sdk/tsconfig.json+++ b/packages/react-sdk/tsconfig.json@@ -24,6 +24,10 @@"path": "../asset-uploader"},+ {+ "path": "../css-data"+ },+{"path": "../fonts"},diff --git a/tsconfig.json b/tsconfig.jsonindex 29691a4bb6..d9a15062f3 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -4,6 +4,7 @@"references": [{ "path": "apps/designer" },{ "path": "packages/asset-uploader" },+ { "path": "packages/css-data" },{ "path": "packages/css-engine" },{ "path": "packages/css-vars" },{ "path": "packages/design-system" },@@ -11,7 +12,10 @@{ "path": "packages/http-client" },{ "path": "packages/icons" },{ "path": "packages/prisma-client" },- { "path": "packages/project" },++ {+ "path": "packages/project"+ },{"path": "packages/react-sdk"