@webstudio-is/css-data 0.3.0 → 0.4.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.
Files changed (42) hide show
  1. package/lib/__generated__/keyword-values.js +6617 -6615
  2. package/lib/__generated__/properties.js +3200 -3198
  3. package/lib/__generated__/units.js +33 -31
  4. package/lib/cjs/__generated__/keyword-values.cjs +6636 -6617
  5. package/lib/cjs/__generated__/properties.cjs +3219 -3200
  6. package/lib/cjs/__generated__/units.cjs +52 -33
  7. package/lib/cjs/index.cjs +19 -18
  8. package/lib/cjs/popularity-index.cjs +4631 -4612
  9. package/lib/cjs/schema.cjs +83 -53
  10. package/lib/popularity-index.js +4612 -4610
  11. package/lib/schema.js +62 -49
  12. package/package.json +11 -19
  13. package/src/__generated__/keyword-values.ts +6616 -0
  14. package/src/__generated__/properties.ts +3200 -0
  15. package/src/__generated__/units.ts +32 -0
  16. package/{lib/cjs/index.d.ts → src/index.ts} +0 -1
  17. package/src/popularity-index.ts +4611 -0
  18. package/src/schema.ts +103 -0
  19. package/lib/__generated__/keyword-values.d.ts +0 -302
  20. package/lib/__generated__/keyword-values.d.ts.map +0 -1
  21. package/lib/__generated__/properties.d.ts +0 -3199
  22. package/lib/__generated__/properties.d.ts.map +0 -1
  23. package/lib/__generated__/units.d.ts +0 -2
  24. package/lib/__generated__/units.d.ts.map +0 -1
  25. package/lib/cjs/__generated__/keyword-values.d.ts +0 -302
  26. package/lib/cjs/__generated__/keyword-values.d.ts.map +0 -1
  27. package/lib/cjs/__generated__/properties.d.ts +0 -3199
  28. package/lib/cjs/__generated__/properties.d.ts.map +0 -1
  29. package/lib/cjs/__generated__/units.d.ts +0 -2
  30. package/lib/cjs/__generated__/units.d.ts.map +0 -1
  31. package/lib/cjs/index.d.ts.map +0 -1
  32. package/lib/cjs/popularity-index.d.ts +0 -7
  33. package/lib/cjs/popularity-index.d.ts.map +0 -1
  34. package/lib/cjs/schema.d.ts +0 -607
  35. package/lib/cjs/schema.d.ts.map +0 -1
  36. package/lib/index.d.ts +0 -5
  37. package/lib/index.d.ts.map +0 -1
  38. package/lib/popularity-index.d.ts +0 -7
  39. package/lib/popularity-index.d.ts.map +0 -1
  40. package/lib/schema.d.ts +0 -607
  41. package/lib/schema.d.ts.map +0 -1
  42. package/lib/tsconfig.tsbuildinfo +0 -1
package/lib/schema.js CHANGED
@@ -1,55 +1,68 @@
1
1
  import { units } from "./__generated__/units";
2
2
  import { z } from "zod";
3
- export const Unit = z.union([z.enum(units), z.literal("number")]);
4
- export const UnitValue = z.object({
5
- type: z.literal("unit"),
6
- unit: Unit,
7
- value: z.number(),
8
- });
9
- export const KeywordValue = z.object({
10
- type: z.literal("keyword"),
11
- // @todo use exact type
12
- value: z.string(),
13
- });
14
- export const FontFamilyValue = z.object({
15
- type: z.literal("fontFamily"),
16
- value: z.array(z.string()),
17
- });
18
- // We want to be able to render the invalid value
19
- // and show it is invalid visually, without saving it to the db
20
- export const InvalidValue = z.object({
21
- type: z.literal("invalid"),
22
- value: z.string(),
23
- });
24
- export const UnsetValue = z.object({
25
- type: z.literal("unset"),
26
- value: z.literal(""),
27
- });
28
- export const validStaticValueTypes = ["unit", "keyword", "fontFamily"];
29
- export const ValidStaticStyleValue = z.union([
30
- UnitValue,
31
- KeywordValue,
32
- FontFamilyValue,
3
+ const Unit = z.union([z.enum(units), z.literal("number")]);
4
+ const UnitValue = z.object({
5
+ type: z.literal("unit"),
6
+ unit: Unit,
7
+ value: z.number()
8
+ });
9
+ const KeywordValue = z.object({
10
+ type: z.literal("keyword"),
11
+ value: z.string()
12
+ });
13
+ const FontFamilyValue = z.object({
14
+ type: z.literal("fontFamily"),
15
+ value: z.array(z.string())
16
+ });
17
+ const InvalidValue = z.object({
18
+ type: z.literal("invalid"),
19
+ value: z.string()
20
+ });
21
+ const UnsetValue = z.object({
22
+ type: z.literal("unset"),
23
+ value: z.literal("")
24
+ });
25
+ const validStaticValueTypes = ["unit", "keyword", "fontFamily"];
26
+ const ValidStaticStyleValue = z.union([
27
+ UnitValue,
28
+ KeywordValue,
29
+ FontFamilyValue
33
30
  ]);
34
- export const VarValue = z.object({
35
- type: z.literal("var"),
36
- value: z.string(),
37
- fallbacks: z.array(ValidStaticStyleValue),
38
- });
39
- export const StyleValue = z.union([
40
- ValidStaticStyleValue,
41
- InvalidValue,
42
- UnsetValue,
43
- VarValue,
31
+ const VarValue = z.object({
32
+ type: z.literal("var"),
33
+ value: z.string(),
34
+ fallbacks: z.array(ValidStaticStyleValue)
35
+ });
36
+ const StyleValue = z.union([
37
+ ValidStaticStyleValue,
38
+ InvalidValue,
39
+ UnsetValue,
40
+ VarValue
44
41
  ]);
45
- export const Style = z.record(z.string(), StyleValue);
46
- export const CssRule = z.object({
47
- style: Style,
48
- breakpoint: z.optional(z.string()),
42
+ const Style = z.record(z.string(), StyleValue);
43
+ const CssRule = z.object({
44
+ style: Style,
45
+ breakpoint: z.optional(z.string())
49
46
  });
50
- export const Breakpoint = z.object({
51
- id: z.string(),
52
- label: z.string(),
53
- minWidth: z.number(),
47
+ const Breakpoint = z.object({
48
+ id: z.string(),
49
+ label: z.string(),
50
+ minWidth: z.number()
54
51
  });
55
- export const Breakpoints = z.array(Breakpoint);
52
+ const Breakpoints = z.array(Breakpoint);
53
+ export {
54
+ Breakpoint,
55
+ Breakpoints,
56
+ CssRule,
57
+ FontFamilyValue,
58
+ InvalidValue,
59
+ KeywordValue,
60
+ Style,
61
+ StyleValue,
62
+ Unit,
63
+ UnitValue,
64
+ UnsetValue,
65
+ ValidStaticStyleValue,
66
+ VarValue,
67
+ validStaticValueTypes
68
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CSS Data",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -8,21 +8,20 @@
8
8
  "scripts": {
9
9
  "typecheck": "tsc --noEmit",
10
10
  "checks": "yarn typecheck && yarn lint",
11
- "dev": "tsup --watch",
12
- "build:cjs": "tsc --module commonjs --outDir lib/cjs && find lib/cjs -name '*.js' | while read NAME; do mv $NAME ${NAME%.js}.cjs; done",
13
- "build": "rm -fr lib tsconfig.tsbuildinfo && tsc && yarn build:cjs",
14
- "build:mdn-data": "tsx ./bin/mdn-data.ts ./src/__generated__",
11
+ "dev": "build-package --watch",
12
+ "build": "build-package",
13
+ "build:mdn-data": "tsx ./bin/mdn-data.ts ./src/__generated__ && prettier --write \"./src/__generated__/**/*.ts\"",
15
14
  "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
16
15
  "publish-to-npm": "bash ../../bin/publish-to-npm.sh"
17
16
  },
18
17
  "dependencies": {},
19
18
  "devDependencies": {
19
+ "@types/css-tree": "^2.0.0",
20
+ "@webstudio-is/scripts": "*",
21
+ "camelcase": "^6.3.0",
22
+ "css-tree": "^2.3.0",
20
23
  "mdn-data": "2.0.23",
21
- "tsup": "^6.1.3",
22
24
  "typescript": "4.7.4",
23
- "@types/css-tree": "^1.0.7",
24
- "css-tree": "^2.1.0",
25
- "camelcase": "^6.3.0",
26
25
  "zod": "^3.19.1"
27
26
  },
28
27
  "peerDependencies": {
@@ -32,20 +31,13 @@
32
31
  "import": "./lib/index.js",
33
32
  "require": "./lib/cjs/index.cjs"
34
33
  },
35
- "types": "lib/index.d.ts",
34
+ "types": "src/index.ts",
36
35
  "files": [
37
36
  "lib/*",
38
- "README.md",
37
+ "src/*",
39
38
  "!*.test.*"
40
39
  ],
41
40
  "license": "MIT",
42
41
  "private": false,
43
- "sideEffects": false,
44
- "tsup": {
45
- "entry": [
46
- "src/index.ts"
47
- ],
48
- "format": "esm",
49
- "outDir": "lib"
50
- }
42
+ "sideEffects": false
51
43
  }