@plumeria/utils 18.2.10 → 18.2.11

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 (2) hide show
  1. package/dist/mergeRules.js +17 -4
  2. package/package.json +2 -2
@@ -2,6 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeRules = void 0;
4
4
  const zss_engine_1 = require("zss-engine");
5
+ const conditionOf = (node) => `@${node.name} ${node.params}`;
6
+ function sortByImplication(nodes) {
7
+ const blockedBy = nodes.map((node, i) => nodes.filter((other, j) => i !== j && (0, zss_engine_1.impliesCondition)(conditionOf(node), conditionOf(other))));
8
+ const emitted = new Set();
9
+ const sorted = [];
10
+ while (sorted.length < nodes.length) {
11
+ const next = nodes.findIndex((node, i) => !emitted.has(node) && blockedBy[i].every((other) => emitted.has(other)));
12
+ if (next === -1)
13
+ return nodes;
14
+ emitted.add(nodes[next]);
15
+ sorted.push(nodes[next]);
16
+ }
17
+ return sorted;
18
+ }
5
19
  function mergeContainer(container) {
6
20
  if (!container.nodes)
7
21
  return;
@@ -34,10 +48,9 @@ function mergeContainer(container) {
34
48
  for (const node of [...rules.values(), ...atRules.values()]) {
35
49
  mergeContainer(node);
36
50
  }
37
- for (const node of [...container.nodes]) {
38
- if (node.type === 'atrule' && (0, zss_engine_1.isAtRule)(`@${node.name}`)) {
39
- container.append(node);
40
- }
51
+ const conditionals = [...container.nodes].filter((node) => node.type === 'atrule' && (0, zss_engine_1.isAtRule)(`@${node.name}`));
52
+ for (const node of sortByImplication(conditionals)) {
53
+ container.append(node);
41
54
  }
42
55
  }
43
56
  const mergeRules = () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "18.2.10",
3
+ "version": "18.2.11",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "@swc/core": "1.15.47",
26
26
  "lightningcss": "^1.32.0",
27
27
  "postcss": "8.5.25",
28
- "zss-engine": "2.4.3"
28
+ "zss-engine": "2.5.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",