@unocss/core 0.22.0 → 0.22.1

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
@@ -388,7 +388,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
388
388
  };
389
389
  }
390
390
 
391
- const version = "0.22.0";
391
+ const version = "0.22.1";
392
392
 
393
393
  class UnoGenerator {
394
394
  constructor(userConfig = {}, defaults = {}) {
@@ -513,14 +513,14 @@ class UnoGenerator {
513
513
  return layerCache[layer];
514
514
  let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) ?? 0) - (this.parentOrders.get(b[0]) ?? 0) || a[0]?.localeCompare(b[0] || "") || 0).map(([parent, items]) => {
515
515
  const size = items.length;
516
- const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]).map((a) => [a[0] == null ? a[0] : [a[0]], a[1]]);
516
+ const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2], !!a[4]?.noMerge]).map((a) => [a[0] == null ? a[0] : [a[0]], a[1], a[2]]);
517
517
  if (!sorted.length)
518
518
  return void 0;
519
- const rules = sorted.reverse().map(([selector, body], idx) => {
519
+ const rules = sorted.reverse().map(([selector, body, noMerge], idx) => {
520
520
  if (selector && this.config.mergeSelectors) {
521
521
  for (let i = idx + 1; i < size; i++) {
522
522
  const current = sorted[i];
523
- if (current && current[0] && current[1] === body) {
523
+ if (!noMerge && current && current[0] && current[1] === body) {
524
524
  current[0].push(...selector);
525
525
  return null;
526
526
  }
@@ -718,11 +718,11 @@ function applyScope(css, scope) {
718
718
  else
719
719
  return scope ? `${scope} ${css}` : css;
720
720
  }
721
+ const attributifyRe = /^\[(.+?)(~?=)"(.*)"\]$/;
721
722
  function toEscapedSelector(raw) {
722
- if (raw.startsWith("["))
723
- return raw.replace(/^\[(.+?)(~?=)"(.*)"\]$/, (_, n, s, i) => `[${e(n)}${s}"${e(i)}"]`);
724
- else
725
- return `.${e(raw)}`;
723
+ if (raw.startsWith("[") && attributifyRe.test(raw))
724
+ return raw.replace(attributifyRe, (_, n, s, i) => `[${e(n)}${s}"${e(i)}"]`);
725
+ return `.${e(raw)}`;
726
726
  }
727
727
 
728
728
  exports.BetterMap = BetterMap;
package/dist/index.d.ts CHANGED
@@ -123,6 +123,11 @@ interface RuleMeta {
123
123
  * @default 'default'
124
124
  */
125
125
  layer?: string;
126
+ /**
127
+ * Option to not merge this selector even if the body are the same.
128
+ * @default false
129
+ */
130
+ noMerge?: boolean;
126
131
  /**
127
132
  * Internal rules will only be matched for shortcuts but not the user code.
128
133
  * @default false
package/dist/index.mjs CHANGED
@@ -384,7 +384,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
384
384
  };
385
385
  }
386
386
 
387
- const version = "0.22.0";
387
+ const version = "0.22.1";
388
388
 
389
389
  class UnoGenerator {
390
390
  constructor(userConfig = {}, defaults = {}) {
@@ -509,14 +509,14 @@ class UnoGenerator {
509
509
  return layerCache[layer];
510
510
  let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) ?? 0) - (this.parentOrders.get(b[0]) ?? 0) || a[0]?.localeCompare(b[0] || "") || 0).map(([parent, items]) => {
511
511
  const size = items.length;
512
- const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]).map((a) => [a[0] == null ? a[0] : [a[0]], a[1]]);
512
+ const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2], !!a[4]?.noMerge]).map((a) => [a[0] == null ? a[0] : [a[0]], a[1], a[2]]);
513
513
  if (!sorted.length)
514
514
  return void 0;
515
- const rules = sorted.reverse().map(([selector, body], idx) => {
515
+ const rules = sorted.reverse().map(([selector, body, noMerge], idx) => {
516
516
  if (selector && this.config.mergeSelectors) {
517
517
  for (let i = idx + 1; i < size; i++) {
518
518
  const current = sorted[i];
519
- if (current && current[0] && current[1] === body) {
519
+ if (!noMerge && current && current[0] && current[1] === body) {
520
520
  current[0].push(...selector);
521
521
  return null;
522
522
  }
@@ -714,11 +714,11 @@ function applyScope(css, scope) {
714
714
  else
715
715
  return scope ? `${scope} ${css}` : css;
716
716
  }
717
+ const attributifyRe = /^\[(.+?)(~?=)"(.*)"\]$/;
717
718
  function toEscapedSelector(raw) {
718
- if (raw.startsWith("["))
719
- return raw.replace(/^\[(.+?)(~?=)"(.*)"\]$/, (_, n, s, i) => `[${e(n)}${s}"${e(i)}"]`);
720
- else
721
- return `.${e(raw)}`;
719
+ if (raw.startsWith("[") && attributifyRe.test(raw))
720
+ return raw.replace(attributifyRe, (_, n, s, i) => `[${e(n)}${s}"${e(i)}"]`);
721
+ return `.${e(raw)}`;
722
722
  }
723
723
 
724
724
  export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",