@css-hooks/core 2.0.0 → 2.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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  </p>
7
7
 
8
8
  <p align="center">
9
- <a href="https://github.com/css-hooks/css-hooks/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/css-hooks/css-hooks/ci.yml?branch=master" alt="Build Status"></a>
9
+ <a href="https://github.com/css-hooks/css-hooks/actions/workflows/build.yml"><img src="https://img.shields.io/github/actions/workflow/status/css-hooks/css-hooks/build.yml?branch=master" alt="Build Status"></a>
10
10
  <a href="https://www.npmjs.com/org/css-hooks"><img src="https://img.shields.io/npm/v/@css-hooks%2Fcore.svg" alt="Latest Release"></a>
11
11
  <a href="https://github.com/css-hooks/css-hooks/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/css-hooks.svg" alt="License"></a>
12
12
  </p>
package/cjs/index.js CHANGED
@@ -95,6 +95,26 @@ function buildHooksSystem(stringify = genericStringify) {
95
95
  : specHash;
96
96
  });
97
97
 
98
+ function conditionToId(condition) {
99
+ if (condition) {
100
+ if (typeof condition === "string") {
101
+ return hookNameToId(condition);
102
+ }
103
+ if (typeof condition === "object") {
104
+ if (condition.and) {
105
+ return `_${condition.and.map(conditionToId).join("-and-")}_`;
106
+ }
107
+ if (condition.or) {
108
+ return `_${condition.or.map(conditionToId).join("-or-")}_`;
109
+ }
110
+ if (condition.not) {
111
+ return `_-not-${conditionToId(condition.not)}_`;
112
+ }
113
+ }
114
+ }
115
+ return `${condition}`;
116
+ }
117
+
98
118
  function styleSheet() {
99
119
  function variablePair({ id, initial, indents }) {
100
120
  return [0, 1]
@@ -194,7 +214,6 @@ function buildHooksSystem(stringify = genericStringify) {
194
214
 
195
215
  function css(...args) {
196
216
  const style = {};
197
- let conditionCount = 0;
198
217
  const rules = args
199
218
  .filter(rule => rule)
200
219
  .reduce(
@@ -251,7 +270,7 @@ function buildHooksSystem(stringify = genericStringify) {
251
270
  }
252
271
  }
253
272
  return name;
254
- })(`cond${conditionCount++}`, conditionId);
273
+ })(`cond-${hash(conditionToId(conditionId))}`, conditionId);
255
274
  }
256
275
  for (const [property, value] of Object.entries(rule[1])) {
257
276
  const stringifiedValue = stringify(property, value);
package/esm/index.js CHANGED
@@ -94,6 +94,26 @@ export function buildHooksSystem(stringify = genericStringify) {
94
94
  : specHash;
95
95
  });
96
96
 
97
+ function conditionToId(condition) {
98
+ if (condition) {
99
+ if (typeof condition === "string") {
100
+ return hookNameToId(condition);
101
+ }
102
+ if (typeof condition === "object") {
103
+ if (condition.and) {
104
+ return `_${condition.and.map(conditionToId).join("-and-")}_`;
105
+ }
106
+ if (condition.or) {
107
+ return `_${condition.or.map(conditionToId).join("-or-")}_`;
108
+ }
109
+ if (condition.not) {
110
+ return `_-not-${conditionToId(condition.not)}_`;
111
+ }
112
+ }
113
+ }
114
+ return `${condition}`;
115
+ }
116
+
97
117
  function styleSheet() {
98
118
  function variablePair({ id, initial, indents }) {
99
119
  return [0, 1]
@@ -193,7 +213,6 @@ export function buildHooksSystem(stringify = genericStringify) {
193
213
 
194
214
  function css(...args) {
195
215
  const style = {};
196
- let conditionCount = 0;
197
216
  const rules = args
198
217
  .filter(rule => rule)
199
218
  .reduce(
@@ -250,7 +269,7 @@ export function buildHooksSystem(stringify = genericStringify) {
250
269
  }
251
270
  }
252
271
  return name;
253
- })(`cond${conditionCount++}`, conditionId);
272
+ })(`cond-${hash(conditionToId(conditionId))}`, conditionId);
254
273
  }
255
274
  for (const [property, value] of Object.entries(rule[1])) {
256
275
  const stringifiedValue = stringify(property, value);
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@css-hooks/core",
3
3
  "description": "CSS Hooks core library",
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "author": "Nick Saunders",
6
6
  "devDependencies": {
7
7
  "@microsoft/api-extractor": "^7.39.4",
8
8
  "@tsconfig/strictest": "^2.0.1",
9
9
  "@types/color": "^3.0.6",
10
- "@typescript-eslint/eslint-plugin": "^6.3.0",
11
- "@typescript-eslint/parser": "^6.3.0",
10
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
11
+ "@typescript-eslint/parser": "^7.0.0",
12
12
  "ascjs": "^6.0.3",
13
13
  "color": "^4.2.3",
14
14
  "csstype": "^3.1.3",
15
15
  "eslint": "^8.47.0",
16
16
  "eslint-plugin-compat": "^4.2.0",
17
17
  "lightningcss": "^1.23.0",
18
- "puppeteer": "^21.7.0",
18
+ "puppeteer": "^22.0.0",
19
19
  "rimraf": "^5.0.1",
20
20
  "tsc-watch": "^6.0.4",
21
21
  "typescript": "^5.1.6"