@styleframe/core 1.0.1 → 1.0.2

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 (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +21 -0
  3. package/dist/styleframe.d.ts +301 -0
  4. package/dist/styleframe.js +528 -0
  5. package/dist/styleframe.umd.cjs +1 -0
  6. package/package.json +13 -3
  7. package/.tsbuildinfo +0 -1
  8. package/src/index.ts +0 -5
  9. package/src/styleframe.ts +0 -64
  10. package/src/tokens/atRule.test.ts +0 -1013
  11. package/src/tokens/atRule.ts +0 -67
  12. package/src/tokens/css.test.ts +0 -404
  13. package/src/tokens/css.ts +0 -23
  14. package/src/tokens/declarations.test.ts +0 -584
  15. package/src/tokens/declarations.ts +0 -71
  16. package/src/tokens/index.ts +0 -11
  17. package/src/tokens/modifier.test.ts +0 -90
  18. package/src/tokens/modifier.ts +0 -86
  19. package/src/tokens/recipe.test.ts +0 -105
  20. package/src/tokens/recipe.ts +0 -32
  21. package/src/tokens/ref.test.ts +0 -430
  22. package/src/tokens/ref.ts +0 -24
  23. package/src/tokens/root.test.ts +0 -70
  24. package/src/tokens/root.ts +0 -14
  25. package/src/tokens/selector.test.ts +0 -440
  26. package/src/tokens/selector.ts +0 -47
  27. package/src/tokens/theme.test.ts +0 -338
  28. package/src/tokens/theme.ts +0 -26
  29. package/src/tokens/utility.test.ts +0 -1456
  30. package/src/tokens/utility.ts +0 -92
  31. package/src/tokens/variable.test.ts +0 -235
  32. package/src/tokens/variable.ts +0 -42
  33. package/src/typeGuards.test.ts +0 -33
  34. package/src/typeGuards.ts +0 -98
  35. package/src/types/declarations.ts +0 -42
  36. package/src/types/index.ts +0 -3
  37. package/src/types/options.ts +0 -22
  38. package/src/types/tokens.ts +0 -149
  39. package/src/utils/capitalizeFirst.ts +0 -9
  40. package/src/utils/deepClone.ts +0 -317
  41. package/src/utils/getters.test.ts +0 -399
  42. package/src/utils/getters.ts +0 -36
  43. package/src/utils/index.ts +0 -4
  44. package/src/utils/merge.test.ts +0 -978
  45. package/src/utils/merge.ts +0 -73
  46. package/src/vite-env.d.ts +0 -1
  47. package/tsconfig.json +0 -7
  48. package/vite.config.ts +0 -5
@@ -1,73 +0,0 @@
1
- import type { Styleframe } from "../styleframe";
2
- import { isRoot } from "../typeGuards";
3
- import type { Container, Theme, Variable } from "../types";
4
-
5
- export function mergeVariablesArray(a: Variable[], b: Variable[]) {
6
- const variables = [...a];
7
- for (const newVariable of b) {
8
- const existingVariable = variables.find(
9
- (variable) => variable.name === newVariable.name,
10
- );
11
-
12
- if (existingVariable) {
13
- existingVariable.value = newVariable.value;
14
- } else {
15
- variables.push(newVariable);
16
- }
17
- }
18
-
19
- return variables;
20
- }
21
-
22
- export function mergeThemesArray(a: Theme[], b: Theme[]) {
23
- const themes = [...a];
24
- for (const themeToBeAdded of b) {
25
- const existingTheme = themes.find(
26
- (theme) => theme.name === themeToBeAdded.name,
27
- );
28
-
29
- if (existingTheme) {
30
- Object.assign(
31
- existingTheme,
32
- mergeContainers(existingTheme, themeToBeAdded),
33
- );
34
- } else {
35
- themes.push(themeToBeAdded);
36
- }
37
- }
38
-
39
- return themes;
40
- }
41
-
42
- export function mergeContainers<T extends Container>(a: T, b: T) {
43
- return Object.keys(a).reduce<T>(
44
- (acc, key) => {
45
- if (key === "variables") {
46
- acc.variables = mergeVariablesArray(a.variables, b.variables);
47
- } else if (key === "declarations") {
48
- acc.declarations = { ...a.declarations, ...b.declarations };
49
- } else if (key === "themes" && isRoot(acc) && isRoot(a) && isRoot(b)) {
50
- acc.themes = mergeThemesArray(a.themes, b.themes);
51
- } else if (Array.isArray(a[key as keyof T])) {
52
- acc[key as keyof T] = (a[key as keyof T] as unknown[]).concat(
53
- b[key as keyof T],
54
- ) as T[keyof T];
55
- }
56
-
57
- return acc;
58
- },
59
- {
60
- ...a,
61
- ...b,
62
- },
63
- );
64
- }
65
-
66
- export function merge(base: Styleframe, ...instances: Styleframe[]) {
67
- return instances.reduce((prev, curr) => {
68
- return {
69
- ...prev,
70
- root: mergeContainers(prev.root, curr.root),
71
- };
72
- }, base);
73
- }
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "@styleframe/config-typescript",
3
- "compilerOptions": {
4
- "tsBuildInfoFile": ".tsbuildinfo"
5
- },
6
- "include": ["src/**/*.ts", "tsup.config.ts", "vite.config.ts"]
7
- }
package/vite.config.ts DELETED
@@ -1,5 +0,0 @@
1
- import { createViteConfig } from "@styleframe/config-vite";
2
-
3
- const __dirname = new URL(".", import.meta.url).pathname;
4
-
5
- export default createViteConfig("styleframe", __dirname);