@tokenami/css 0.0.99--canary.514.27870246935.0 → 0.0.99

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
@@ -26,28 +26,28 @@ var Tokenami__namespace = /*#__PURE__*/_interopNamespace(Tokenami);
26
26
  var _TOKENAMI_CSS = Symbol.for("@tokenami/css");
27
27
  function createCss(config, options = { escapeSpecialChars: true }) {
28
28
  globalThis[_TOKENAMI_CSS] = options;
29
- const cssCache = Tokenami__namespace.createLRUCache();
30
- const propCache = Tokenami__namespace.createLRUCache();
31
- const composeMap = /* @__PURE__ */ new WeakMap();
32
- const calcStore = /* @__PURE__ */ new Set();
29
+ let cssCache = Tokenami__namespace.createLRUCache();
30
+ let propCache = Tokenami__namespace.createLRUCache();
31
+ let composeMap = /* @__PURE__ */ new WeakMap();
32
+ let calcStore = /* @__PURE__ */ new Set();
33
33
  function css2(...allStyles) {
34
- const id = generateSxId(allStyles);
35
- const cached = cssCache.get(id);
34
+ let id = generateSxId(allStyles);
35
+ let cached = cssCache.get(id);
36
36
  if (cached) return cached;
37
- const opts = globalThis[_TOKENAMI_CSS];
38
- const result = {};
39
- const composeResult = {};
37
+ let opts = globalThis[_TOKENAMI_CSS];
38
+ let result = {};
39
+ let composeResult = {};
40
40
  composeMap.set(result, composeResult);
41
41
  function add(key, value, composed) {
42
- const config2 = getProperty(key, opts);
42
+ let config2 = getProperty(key, opts);
43
43
  if (!config2) {
44
44
  result[key] = value;
45
45
  return;
46
46
  }
47
- for (const [prop, overrides] of config2) {
48
- overrideLonghands(result, overrides);
49
- const prop__calc = Tokenami__namespace.calcProperty(prop);
50
- const target = composed && composeResult[prop] == null ? composeResult : result;
47
+ for (let [prop, overrides] of config2) {
48
+ if (overrides.length) overrideLonghands(result, overrides);
49
+ let prop__calc = Tokenami__namespace.calcProperty(prop);
50
+ let target = composed && composeResult[prop] == null ? composeResult : result;
51
51
  target[prop] = value;
52
52
  if (composed) continue;
53
53
  if (typeof value === "number" && value !== 0) {
@@ -60,63 +60,63 @@ function createCss(config, options = { escapeSpecialChars: true }) {
60
60
  }
61
61
  }
62
62
  }
63
- for (const styles of allStyles) {
63
+ for (let styles of allStyles) {
64
64
  if (!styles) continue;
65
- const composeSx = composeMap.get(styles) ?? {};
66
- for (const key in composeSx) add(key, composeSx[key], true);
67
- for (const key in styles) add(key, styles[key], composeSx[key] != null);
65
+ let composeSx = composeMap.get(styles) ?? {};
66
+ for (let key in composeSx) add(key, composeSx[key], true);
67
+ for (let key in styles) add(key, styles[key], composeSx[key] != null);
68
68
  }
69
69
  cssCache.set(id, result);
70
70
  return result;
71
71
  }
72
72
  css2.compose = (input) => {
73
- const { includes = [], variants, ...baseSx } = input;
74
- const cn = Tokenami__namespace.generateClassName(baseSx);
75
- const cache = Tokenami__namespace.createLRUCache();
73
+ let { includes = [], variants, ...composeSx } = input;
74
+ let cn = Tokenami__namespace.generateClassName(composeSx);
75
+ let cache = Tokenami__namespace.createLRUCache();
76
76
  return function generate(currVariants = {}) {
77
77
  let id = stringId(currVariants);
78
- const cached = cache.get(id);
78
+ let cached = cache.get(id);
79
79
  if (cached) return cached;
80
- const variantSx = [];
81
- const includeSx = [];
82
- const includeCn = [];
83
- for (const incl of includes) {
80
+ let baseSx = {};
81
+ let variantSx = [];
82
+ let includeSx = [];
83
+ let includeCn = [];
84
+ for (let incl of includes) {
84
85
  if (typeof incl === "function") {
85
- const [cn2, sx] = incl(currVariants);
86
+ let [cn2, sx] = incl(currVariants);
86
87
  includeCn.push(cn2());
87
88
  includeSx.push(sx());
88
89
  } else {
89
90
  includeSx.push(incl);
90
91
  }
91
92
  }
92
- for (const [key, variant] of Object.entries(currVariants)) {
93
+ for (const key in currVariants) {
94
+ const variant = currVariants[key];
93
95
  const group = variants?.[key];
94
96
  const value = group?.[variant];
95
97
  if (value) variantSx.push(value);
96
98
  }
97
- const result = [
99
+ let result = [
98
100
  (...cns) => [...includeCn, cn, ...cns].filter(Boolean).join(" "),
99
- (...sx) => {
100
- const base = {};
101
- composeMap.set(base, baseSx);
102
- return css2(...includeSx, base, ...variantSx, ...sx);
103
- }
101
+ // @ts-ignore
102
+ (...sx) => css2(...includeSx, baseSx, ...variantSx, ...sx)
104
103
  ];
104
+ composeMap.set(baseSx, composeSx);
105
105
  cache.set(id, result);
106
106
  return result;
107
107
  };
108
108
  };
109
109
  function getProperty(key, opts) {
110
- const cached = propCache.get(key);
110
+ let cached = propCache.get(key);
111
111
  if (cached !== void 0) return cached;
112
- const tokenProperty = Tokenami__namespace.TokenProperty.safeParse(key);
112
+ let tokenProperty = Tokenami__namespace.TokenProperty.safeParse(key);
113
113
  if (!tokenProperty.success) return propCache.set(key, 0);
114
- const parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty.output);
115
- const cssProperties = config.aliases?.[parts.alias] || [parts.alias];
116
- const properties = [];
117
- for (const cssProperty of cssProperties) {
118
- const longProperty = Tokenami__namespace.createLonghandProperty(tokenProperty.output, cssProperty);
119
- const parsedProperty = Tokenami__namespace.parseProperty(longProperty, opts);
114
+ let parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty.output);
115
+ let cssProperties = config.aliases?.[parts.alias] || [parts.alias];
116
+ let properties = [];
117
+ for (let cssProperty of cssProperties) {
118
+ let longProperty = Tokenami__namespace.createLonghandProperty(tokenProperty.output, cssProperty);
119
+ let parsedProperty = Tokenami__namespace.parseProperty(longProperty, opts);
120
120
  properties.push([parsedProperty, getLonghandOverrides(parsedProperty)]);
121
121
  }
122
122
  propCache.set(key, properties);
@@ -124,9 +124,9 @@ function createCss(config, options = { escapeSpecialChars: true }) {
124
124
  }
125
125
  function generateSxId(objs) {
126
126
  let id = "";
127
- for (const obj of objs) {
127
+ for (let obj of objs) {
128
128
  if (!obj) continue;
129
- const composeSx = composeMap.get(obj);
129
+ let composeSx = composeMap.get(obj);
130
130
  if (composeSx) id += stringId(composeSx);
131
131
  id += stringId(obj);
132
132
  }
@@ -134,15 +134,15 @@ function createCss(config, options = { escapeSpecialChars: true }) {
134
134
  }
135
135
  function stringId(obj) {
136
136
  let id = "";
137
- for (const key in obj) id += key + ":" + String(obj[key]) + ";";
137
+ for (let key in obj) id += key + ":" + String(obj[key]) + ";";
138
138
  return id;
139
139
  }
140
140
  function overrideLonghands(result, overrides) {
141
- const composeSx = composeMap.get(result);
142
- for (const [longProp, calcProp] of overrides) {
143
- const composeValue = composeSx?.[longProp];
141
+ let composeSx = composeMap.get(result);
142
+ for (let [longProp, calcProp] of overrides) {
143
+ let composeValue = composeSx?.[longProp];
144
144
  if (composeValue) {
145
- const value = composeValue ?? result[longProp];
145
+ let value = composeValue ?? result[longProp];
146
146
  if (typeof value === "number") result[calcProp] = "initial";
147
147
  result[longProp] = "initial";
148
148
  } else {
@@ -152,12 +152,12 @@ function createCss(config, options = { escapeSpecialChars: true }) {
152
152
  }
153
153
  }
154
154
  function getLonghandOverrides(tokenProperty) {
155
- const parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty);
156
- const longhands = Tokenami__namespace.mapShorthandToLonghands.get(parts.alias) || [];
157
- const overrides = [];
158
- for (const long of longhands) {
159
- const longProp = Tokenami__namespace.createLonghandProperty(tokenProperty, long);
160
- const calcProp = Tokenami__namespace.calcProperty(longProp);
155
+ let parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty);
156
+ let longhands = Tokenami__namespace.mapShorthandToLonghands.get(parts.alias) || [];
157
+ let overrides = [];
158
+ for (let long of longhands) {
159
+ let longProp = Tokenami__namespace.createLonghandProperty(tokenProperty, long);
160
+ let calcProp = Tokenami__namespace.calcProperty(longProp);
161
161
  overrides.push([longProp, calcProp], ...getLonghandOverrides(longProp));
162
162
  }
163
163
  return overrides;
package/dist/index.d.cts CHANGED
@@ -41,7 +41,7 @@ declare function createCss(config: Pick<Tokenami.Config, 'aliases'>, options?: C
41
41
  (allStyles_0: TokenamiProperties, ...allStyles_1: TokenamiOverride[]): TokenamiCSS;
42
42
  compose<T>(input: TokenamiComposeInput<T>): TokenamiComposeOutput<T>;
43
43
  };
44
- declare const css: {
44
+ declare let css: {
45
45
  (allStyles_0: TokenamiProperties, ...allStyles_1: TokenamiOverride[]): TokenamiCSS;
46
46
  compose<T>(input: TokenamiComposeInput<T>): TokenamiComposeOutput<T>;
47
47
  };
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ declare function createCss(config: Pick<Tokenami.Config, 'aliases'>, options?: C
41
41
  (allStyles_0: TokenamiProperties, ...allStyles_1: TokenamiOverride[]): TokenamiCSS;
42
42
  compose<T>(input: TokenamiComposeInput<T>): TokenamiComposeOutput<T>;
43
43
  };
44
- declare const css: {
44
+ declare let css: {
45
45
  (allStyles_0: TokenamiProperties, ...allStyles_1: TokenamiOverride[]): TokenamiCSS;
46
46
  compose<T>(input: TokenamiComposeInput<T>): TokenamiComposeOutput<T>;
47
47
  };
package/dist/index.js CHANGED
@@ -5,28 +5,28 @@ export { createConfig } from '@tokenami/config';
5
5
  var _TOKENAMI_CSS = Symbol.for("@tokenami/css");
6
6
  function createCss(config, options = { escapeSpecialChars: true }) {
7
7
  globalThis[_TOKENAMI_CSS] = options;
8
- const cssCache = Tokenami.createLRUCache();
9
- const propCache = Tokenami.createLRUCache();
10
- const composeMap = /* @__PURE__ */ new WeakMap();
11
- const calcStore = /* @__PURE__ */ new Set();
8
+ let cssCache = Tokenami.createLRUCache();
9
+ let propCache = Tokenami.createLRUCache();
10
+ let composeMap = /* @__PURE__ */ new WeakMap();
11
+ let calcStore = /* @__PURE__ */ new Set();
12
12
  function css2(...allStyles) {
13
- const id = generateSxId(allStyles);
14
- const cached = cssCache.get(id);
13
+ let id = generateSxId(allStyles);
14
+ let cached = cssCache.get(id);
15
15
  if (cached) return cached;
16
- const opts = globalThis[_TOKENAMI_CSS];
17
- const result = {};
18
- const composeResult = {};
16
+ let opts = globalThis[_TOKENAMI_CSS];
17
+ let result = {};
18
+ let composeResult = {};
19
19
  composeMap.set(result, composeResult);
20
20
  function add(key, value, composed) {
21
- const config2 = getProperty(key, opts);
21
+ let config2 = getProperty(key, opts);
22
22
  if (!config2) {
23
23
  result[key] = value;
24
24
  return;
25
25
  }
26
- for (const [prop, overrides] of config2) {
27
- overrideLonghands(result, overrides);
28
- const prop__calc = Tokenami.calcProperty(prop);
29
- const target = composed && composeResult[prop] == null ? composeResult : result;
26
+ for (let [prop, overrides] of config2) {
27
+ if (overrides.length) overrideLonghands(result, overrides);
28
+ let prop__calc = Tokenami.calcProperty(prop);
29
+ let target = composed && composeResult[prop] == null ? composeResult : result;
30
30
  target[prop] = value;
31
31
  if (composed) continue;
32
32
  if (typeof value === "number" && value !== 0) {
@@ -39,63 +39,63 @@ function createCss(config, options = { escapeSpecialChars: true }) {
39
39
  }
40
40
  }
41
41
  }
42
- for (const styles of allStyles) {
42
+ for (let styles of allStyles) {
43
43
  if (!styles) continue;
44
- const composeSx = composeMap.get(styles) ?? {};
45
- for (const key in composeSx) add(key, composeSx[key], true);
46
- for (const key in styles) add(key, styles[key], composeSx[key] != null);
44
+ let composeSx = composeMap.get(styles) ?? {};
45
+ for (let key in composeSx) add(key, composeSx[key], true);
46
+ for (let key in styles) add(key, styles[key], composeSx[key] != null);
47
47
  }
48
48
  cssCache.set(id, result);
49
49
  return result;
50
50
  }
51
51
  css2.compose = (input) => {
52
- const { includes = [], variants, ...baseSx } = input;
53
- const cn = Tokenami.generateClassName(baseSx);
54
- const cache = Tokenami.createLRUCache();
52
+ let { includes = [], variants, ...composeSx } = input;
53
+ let cn = Tokenami.generateClassName(composeSx);
54
+ let cache = Tokenami.createLRUCache();
55
55
  return function generate(currVariants = {}) {
56
56
  let id = stringId(currVariants);
57
- const cached = cache.get(id);
57
+ let cached = cache.get(id);
58
58
  if (cached) return cached;
59
- const variantSx = [];
60
- const includeSx = [];
61
- const includeCn = [];
62
- for (const incl of includes) {
59
+ let baseSx = {};
60
+ let variantSx = [];
61
+ let includeSx = [];
62
+ let includeCn = [];
63
+ for (let incl of includes) {
63
64
  if (typeof incl === "function") {
64
- const [cn2, sx] = incl(currVariants);
65
+ let [cn2, sx] = incl(currVariants);
65
66
  includeCn.push(cn2());
66
67
  includeSx.push(sx());
67
68
  } else {
68
69
  includeSx.push(incl);
69
70
  }
70
71
  }
71
- for (const [key, variant] of Object.entries(currVariants)) {
72
+ for (const key in currVariants) {
73
+ const variant = currVariants[key];
72
74
  const group = variants?.[key];
73
75
  const value = group?.[variant];
74
76
  if (value) variantSx.push(value);
75
77
  }
76
- const result = [
78
+ let result = [
77
79
  (...cns) => [...includeCn, cn, ...cns].filter(Boolean).join(" "),
78
- (...sx) => {
79
- const base = {};
80
- composeMap.set(base, baseSx);
81
- return css2(...includeSx, base, ...variantSx, ...sx);
82
- }
80
+ // @ts-ignore
81
+ (...sx) => css2(...includeSx, baseSx, ...variantSx, ...sx)
83
82
  ];
83
+ composeMap.set(baseSx, composeSx);
84
84
  cache.set(id, result);
85
85
  return result;
86
86
  };
87
87
  };
88
88
  function getProperty(key, opts) {
89
- const cached = propCache.get(key);
89
+ let cached = propCache.get(key);
90
90
  if (cached !== void 0) return cached;
91
- const tokenProperty = Tokenami.TokenProperty.safeParse(key);
91
+ let tokenProperty = Tokenami.TokenProperty.safeParse(key);
92
92
  if (!tokenProperty.success) return propCache.set(key, 0);
93
- const parts = Tokenami.getTokenPropertySplit(tokenProperty.output);
94
- const cssProperties = config.aliases?.[parts.alias] || [parts.alias];
95
- const properties = [];
96
- for (const cssProperty of cssProperties) {
97
- const longProperty = Tokenami.createLonghandProperty(tokenProperty.output, cssProperty);
98
- const parsedProperty = Tokenami.parseProperty(longProperty, opts);
93
+ let parts = Tokenami.getTokenPropertySplit(tokenProperty.output);
94
+ let cssProperties = config.aliases?.[parts.alias] || [parts.alias];
95
+ let properties = [];
96
+ for (let cssProperty of cssProperties) {
97
+ let longProperty = Tokenami.createLonghandProperty(tokenProperty.output, cssProperty);
98
+ let parsedProperty = Tokenami.parseProperty(longProperty, opts);
99
99
  properties.push([parsedProperty, getLonghandOverrides(parsedProperty)]);
100
100
  }
101
101
  propCache.set(key, properties);
@@ -103,9 +103,9 @@ function createCss(config, options = { escapeSpecialChars: true }) {
103
103
  }
104
104
  function generateSxId(objs) {
105
105
  let id = "";
106
- for (const obj of objs) {
106
+ for (let obj of objs) {
107
107
  if (!obj) continue;
108
- const composeSx = composeMap.get(obj);
108
+ let composeSx = composeMap.get(obj);
109
109
  if (composeSx) id += stringId(composeSx);
110
110
  id += stringId(obj);
111
111
  }
@@ -113,15 +113,15 @@ function createCss(config, options = { escapeSpecialChars: true }) {
113
113
  }
114
114
  function stringId(obj) {
115
115
  let id = "";
116
- for (const key in obj) id += key + ":" + String(obj[key]) + ";";
116
+ for (let key in obj) id += key + ":" + String(obj[key]) + ";";
117
117
  return id;
118
118
  }
119
119
  function overrideLonghands(result, overrides) {
120
- const composeSx = composeMap.get(result);
121
- for (const [longProp, calcProp] of overrides) {
122
- const composeValue = composeSx?.[longProp];
120
+ let composeSx = composeMap.get(result);
121
+ for (let [longProp, calcProp] of overrides) {
122
+ let composeValue = composeSx?.[longProp];
123
123
  if (composeValue) {
124
- const value = composeValue ?? result[longProp];
124
+ let value = composeValue ?? result[longProp];
125
125
  if (typeof value === "number") result[calcProp] = "initial";
126
126
  result[longProp] = "initial";
127
127
  } else {
@@ -131,12 +131,12 @@ function createCss(config, options = { escapeSpecialChars: true }) {
131
131
  }
132
132
  }
133
133
  function getLonghandOverrides(tokenProperty) {
134
- const parts = Tokenami.getTokenPropertySplit(tokenProperty);
135
- const longhands = Tokenami.mapShorthandToLonghands.get(parts.alias) || [];
136
- const overrides = [];
137
- for (const long of longhands) {
138
- const longProp = Tokenami.createLonghandProperty(tokenProperty, long);
139
- const calcProp = Tokenami.calcProperty(longProp);
134
+ let parts = Tokenami.getTokenPropertySplit(tokenProperty);
135
+ let longhands = Tokenami.mapShorthandToLonghands.get(parts.alias) || [];
136
+ let overrides = [];
137
+ for (let long of longhands) {
138
+ let longProp = Tokenami.createLonghandProperty(tokenProperty, long);
139
+ let calcProp = Tokenami.calcProperty(longProp);
140
140
  overrides.push([longProp, calcProp], ...getLonghandOverrides(longProp));
141
141
  }
142
142
  return overrides;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenami/css",
3
- "version": "0.0.99--canary.514.27870246935.0",
3
+ "version": "0.0.99",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -34,10 +34,10 @@
34
34
  "typecheck": "tsc --noEmit"
35
35
  },
36
36
  "dependencies": {
37
- "@tokenami/config": "0.0.99--canary.514.27870246935.0"
37
+ "@tokenami/config": "0.0.99"
38
38
  },
39
39
  "devDependencies": {
40
- "tokenami": "0.0.99--canary.514.27870246935.0",
40
+ "tokenami": "0.0.99",
41
41
  "tsup": "^8.4.0",
42
42
  "typescript": "^5.1.3",
43
43
  "vitest": "^3.2.6"
@@ -46,5 +46,5 @@
46
46
  "tokenami": ">= 0",
47
47
  "typescript": ">= 5"
48
48
  },
49
- "gitHead": "a50df9906a3a587a3f2228f52c31fd9b6d9127b3"
49
+ "gitHead": "67c7e835e51a37c13a112d736a951f834e120d07"
50
50
  }