@tokenami/css 0.0.91 → 0.0.93--canary.477.20251166200.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/dist/index.cjs CHANGED
@@ -24,12 +24,14 @@ var Tokenami__namespace = /*#__PURE__*/_interopNamespace(Tokenami);
24
24
 
25
25
  // src/index.ts
26
26
  var _TOKENAMI_CSS = Symbol.for("@tokenami/css");
27
+ var cssCache = Tokenami__namespace.createLRUCache();
28
+ var calcCache = Tokenami__namespace.createLRUCache();
27
29
  var composeStylesMap = /* @__PURE__ */ new WeakMap();
28
30
  function createCss(config, options = { escapeSpecialChars: true }) {
29
31
  globalThis[_TOKENAMI_CSS] = options;
30
32
  function css2(...allStyles) {
31
33
  const cacheId = generateCacheId(allStyles);
32
- const cached = lruCache.get(cacheId);
34
+ const cached = cssCache.get(cacheId);
33
35
  if (cached) return cached;
34
36
  const opts = globalThis[_TOKENAMI_CSS];
35
37
  const overriddenStyles = {};
@@ -56,12 +58,18 @@ function createCss(config, options = { escapeSpecialChars: true }) {
56
58
  const target = isComposedProperty && overriddenComposeStyles[parsedProperty] == null ? overriddenComposeStyles : overriddenStyles;
57
59
  target[parsedProperty] = value;
58
60
  if (isComposedProperty) continue;
59
- if (propertyConfig.isCalc) overriddenStyles[calcToggle] = "/*on*/";
60
- else delete overriddenStyles[calcToggle];
61
+ if (propertyConfig.isCalc) {
62
+ overriddenStyles[calcToggle] = "/*on*/";
63
+ calcCache.set(parsedProperty, 1);
64
+ } else if (value === "inherit" && calcCache.get(parsedProperty)) {
65
+ overriddenStyles[calcToggle] = "inherit";
66
+ } else {
67
+ delete overriddenStyles[calcToggle];
68
+ }
61
69
  }
62
70
  }
63
71
  }
64
- lruCache.set(cacheId, overriddenStyles);
72
+ cssCache.set(cacheId, overriddenStyles);
65
73
  return overriddenStyles;
66
74
  }
67
75
  css2.compose = (styleConfig) => {
@@ -69,7 +77,7 @@ function createCss(config, options = { escapeSpecialChars: true }) {
69
77
  const className = Tokenami__namespace.generateClassName(baseStyles);
70
78
  return function generate(selectedVariants = {}) {
71
79
  const cacheId = generateCacheId([baseStyles, variants, selectedVariants, ...includes]);
72
- const cached = lruCache.get(cacheId);
80
+ const cached = cssCache.get(cacheId);
73
81
  if (cached) return cached;
74
82
  const selectedVariantsEntries = Object.entries(selectedVariants);
75
83
  let variantStyles = [];
@@ -77,8 +85,8 @@ function createCss(config, options = { escapeSpecialChars: true }) {
77
85
  let includeClassNames = [];
78
86
  for (const include of includes) {
79
87
  if (typeof include === "function") {
80
- const [cn2, styles] = include(selectedVariants);
81
- includeClassNames.push(cn2());
88
+ const [cn, styles] = include(selectedVariants);
89
+ includeClassNames.push(cn());
82
90
  includeStyles.push(styles());
83
91
  } else {
84
92
  includeStyles.push(include);
@@ -90,14 +98,16 @@ function createCss(config, options = { escapeSpecialChars: true }) {
90
98
  if (variantValue) variantStyles.push(variantValue);
91
99
  }
92
100
  const result = [
93
- cn.bind(null, ...includeClassNames, className),
101
+ (...classNames) => {
102
+ return [...includeClassNames, className, ...classNames].filter(Boolean).join(" ");
103
+ },
94
104
  (...overrides) => {
95
105
  const styles = {};
96
106
  composeStylesMap.set(styles, baseStyles);
97
107
  return css2.apply(null, [...includeStyles, styles, ...variantStyles, ...overrides]);
98
108
  }
99
109
  ];
100
- lruCache.set(cacheId, result);
110
+ cssCache.set(cacheId, result);
101
111
  return result;
102
112
  };
103
113
  };
@@ -106,15 +116,11 @@ function createCss(config, options = { escapeSpecialChars: true }) {
106
116
  function generateCacheId(objs) {
107
117
  return JSON.stringify(objs, (_, value) => {
108
118
  if (typeof value === "object" && value !== null && composeStylesMap.has(value)) {
109
- return { ...value, ...composeStylesMap.get(value) };
119
+ return { ...composeStylesMap.get(value), ...value };
110
120
  }
111
121
  return value;
112
122
  });
113
123
  }
114
- var lruCache = Tokenami__namespace.createLRUCache(1500);
115
- function cn(...classNames) {
116
- return classNames.filter(Boolean).join(" ");
117
- }
118
124
  function overrideLonghands(style, tokenProperty) {
119
125
  const parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty);
120
126
  const longhands = Tokenami__namespace.mapShorthandToLonghands.get(parts.alias) || [];
package/dist/index.js CHANGED
@@ -3,12 +3,14 @@ export { createConfig } from '@tokenami/config';
3
3
 
4
4
  // src/index.ts
5
5
  var _TOKENAMI_CSS = Symbol.for("@tokenami/css");
6
+ var cssCache = Tokenami.createLRUCache();
7
+ var calcCache = Tokenami.createLRUCache();
6
8
  var composeStylesMap = /* @__PURE__ */ new WeakMap();
7
9
  function createCss(config, options = { escapeSpecialChars: true }) {
8
10
  globalThis[_TOKENAMI_CSS] = options;
9
11
  function css2(...allStyles) {
10
12
  const cacheId = generateCacheId(allStyles);
11
- const cached = lruCache.get(cacheId);
13
+ const cached = cssCache.get(cacheId);
12
14
  if (cached) return cached;
13
15
  const opts = globalThis[_TOKENAMI_CSS];
14
16
  const overriddenStyles = {};
@@ -35,12 +37,18 @@ function createCss(config, options = { escapeSpecialChars: true }) {
35
37
  const target = isComposedProperty && overriddenComposeStyles[parsedProperty] == null ? overriddenComposeStyles : overriddenStyles;
36
38
  target[parsedProperty] = value;
37
39
  if (isComposedProperty) continue;
38
- if (propertyConfig.isCalc) overriddenStyles[calcToggle] = "/*on*/";
39
- else delete overriddenStyles[calcToggle];
40
+ if (propertyConfig.isCalc) {
41
+ overriddenStyles[calcToggle] = "/*on*/";
42
+ calcCache.set(parsedProperty, 1);
43
+ } else if (value === "inherit" && calcCache.get(parsedProperty)) {
44
+ overriddenStyles[calcToggle] = "inherit";
45
+ } else {
46
+ delete overriddenStyles[calcToggle];
47
+ }
40
48
  }
41
49
  }
42
50
  }
43
- lruCache.set(cacheId, overriddenStyles);
51
+ cssCache.set(cacheId, overriddenStyles);
44
52
  return overriddenStyles;
45
53
  }
46
54
  css2.compose = (styleConfig) => {
@@ -48,7 +56,7 @@ function createCss(config, options = { escapeSpecialChars: true }) {
48
56
  const className = Tokenami.generateClassName(baseStyles);
49
57
  return function generate(selectedVariants = {}) {
50
58
  const cacheId = generateCacheId([baseStyles, variants, selectedVariants, ...includes]);
51
- const cached = lruCache.get(cacheId);
59
+ const cached = cssCache.get(cacheId);
52
60
  if (cached) return cached;
53
61
  const selectedVariantsEntries = Object.entries(selectedVariants);
54
62
  let variantStyles = [];
@@ -56,8 +64,8 @@ function createCss(config, options = { escapeSpecialChars: true }) {
56
64
  let includeClassNames = [];
57
65
  for (const include of includes) {
58
66
  if (typeof include === "function") {
59
- const [cn2, styles] = include(selectedVariants);
60
- includeClassNames.push(cn2());
67
+ const [cn, styles] = include(selectedVariants);
68
+ includeClassNames.push(cn());
61
69
  includeStyles.push(styles());
62
70
  } else {
63
71
  includeStyles.push(include);
@@ -69,14 +77,16 @@ function createCss(config, options = { escapeSpecialChars: true }) {
69
77
  if (variantValue) variantStyles.push(variantValue);
70
78
  }
71
79
  const result = [
72
- cn.bind(null, ...includeClassNames, className),
80
+ (...classNames) => {
81
+ return [...includeClassNames, className, ...classNames].filter(Boolean).join(" ");
82
+ },
73
83
  (...overrides) => {
74
84
  const styles = {};
75
85
  composeStylesMap.set(styles, baseStyles);
76
86
  return css2.apply(null, [...includeStyles, styles, ...variantStyles, ...overrides]);
77
87
  }
78
88
  ];
79
- lruCache.set(cacheId, result);
89
+ cssCache.set(cacheId, result);
80
90
  return result;
81
91
  };
82
92
  };
@@ -85,15 +95,11 @@ function createCss(config, options = { escapeSpecialChars: true }) {
85
95
  function generateCacheId(objs) {
86
96
  return JSON.stringify(objs, (_, value) => {
87
97
  if (typeof value === "object" && value !== null && composeStylesMap.has(value)) {
88
- return { ...value, ...composeStylesMap.get(value) };
98
+ return { ...composeStylesMap.get(value), ...value };
89
99
  }
90
100
  return value;
91
101
  });
92
102
  }
93
- var lruCache = Tokenami.createLRUCache(1500);
94
- function cn(...classNames) {
95
- return classNames.filter(Boolean).join(" ");
96
- }
97
103
  function overrideLonghands(style, tokenProperty) {
98
104
  const parts = Tokenami.getTokenPropertySplit(tokenProperty);
99
105
  const longhands = Tokenami.mapShorthandToLonghands.get(parts.alias) || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenami/css",
3
- "version": "0.0.91",
3
+ "version": "0.0.93--canary.477.20251166200.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -32,10 +32,10 @@
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@tokenami/config": "0.0.91"
35
+ "@tokenami/config": "0.0.93--canary.477.20251166200.0"
36
36
  },
37
37
  "devDependencies": {
38
- "tokenami": "0.0.91",
38
+ "tokenami": "0.0.93--canary.477.20251166200.0",
39
39
  "tsup": "^8.4.0",
40
40
  "typescript": "^5.1.3"
41
41
  },
@@ -43,5 +43,5 @@
43
43
  "tokenami": ">= 0",
44
44
  "typescript": ">= 5"
45
45
  },
46
- "gitHead": "aec7d0e54623aaf6e174a7be514f80b5ef97a6df"
46
+ "gitHead": "47fb8e1c544d5b03e145bfb44842ee3984c70f06"
47
47
  }