@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.
- package/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/dist/styleframe.d.ts +301 -0
- package/dist/styleframe.js +528 -0
- package/dist/styleframe.umd.cjs +1 -0
- package/package.json +13 -3
- package/.tsbuildinfo +0 -1
- package/src/index.ts +0 -5
- package/src/styleframe.ts +0 -64
- package/src/tokens/atRule.test.ts +0 -1013
- package/src/tokens/atRule.ts +0 -67
- package/src/tokens/css.test.ts +0 -404
- package/src/tokens/css.ts +0 -23
- package/src/tokens/declarations.test.ts +0 -584
- package/src/tokens/declarations.ts +0 -71
- package/src/tokens/index.ts +0 -11
- package/src/tokens/modifier.test.ts +0 -90
- package/src/tokens/modifier.ts +0 -86
- package/src/tokens/recipe.test.ts +0 -105
- package/src/tokens/recipe.ts +0 -32
- package/src/tokens/ref.test.ts +0 -430
- package/src/tokens/ref.ts +0 -24
- package/src/tokens/root.test.ts +0 -70
- package/src/tokens/root.ts +0 -14
- package/src/tokens/selector.test.ts +0 -440
- package/src/tokens/selector.ts +0 -47
- package/src/tokens/theme.test.ts +0 -338
- package/src/tokens/theme.ts +0 -26
- package/src/tokens/utility.test.ts +0 -1456
- package/src/tokens/utility.ts +0 -92
- package/src/tokens/variable.test.ts +0 -235
- package/src/tokens/variable.ts +0 -42
- package/src/typeGuards.test.ts +0 -33
- package/src/typeGuards.ts +0 -98
- package/src/types/declarations.ts +0 -42
- package/src/types/index.ts +0 -3
- package/src/types/options.ts +0 -22
- package/src/types/tokens.ts +0 -149
- package/src/utils/capitalizeFirst.ts +0 -9
- package/src/utils/deepClone.ts +0 -317
- package/src/utils/getters.test.ts +0 -399
- package/src/utils/getters.ts +0 -36
- package/src/utils/index.ts +0 -4
- package/src/utils/merge.test.ts +0 -978
- package/src/utils/merge.ts +0 -73
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -7
- package/vite.config.ts +0 -5
package/src/utils/merge.ts
DELETED
|
@@ -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