@unocss/core 0.29.2 → 0.29.3

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
@@ -357,7 +357,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
357
357
  };
358
358
  }
359
359
 
360
- const version = "0.29.2";
360
+ const version = "0.29.3";
361
361
 
362
362
  class UnoGenerator {
363
363
  constructor(userConfig = {}, defaults = {}) {
@@ -426,7 +426,7 @@ class UnoGenerator {
426
426
  this._cache.set(cacheKey, null);
427
427
  return;
428
428
  }
429
- const context = this.makeContext(raw, [alias || applied[0], applied[1], applied[2]]);
429
+ const context = this.makeContext(raw, [alias || applied[0], applied[1], applied[2], applied[3]]);
430
430
  const expanded = this.expandShortcut(context.currentSelector, context);
431
431
  if (expanded) {
432
432
  const utils = await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]);
@@ -534,7 +534,7 @@ class UnoGenerator {
534
534
  };
535
535
  }
536
536
  matchVariants(raw, current) {
537
- const usedVariants = /* @__PURE__ */ new Set();
537
+ const variants = /* @__PURE__ */ new Set();
538
538
  const handlers = [];
539
539
  let processed = current || raw;
540
540
  let applied = false;
@@ -546,7 +546,7 @@ class UnoGenerator {
546
546
  while (true) {
547
547
  applied = false;
548
548
  for (const v of this.config.variants) {
549
- if (!v.multiPass && usedVariants.has(v))
549
+ if (!v.multiPass && variants.has(v))
550
550
  continue;
551
551
  let handler = v.match(processed, context);
552
552
  if (!handler)
@@ -557,7 +557,7 @@ class UnoGenerator {
557
557
  if (Array.isArray(handler.parent))
558
558
  this.parentOrders.set(handler.parent[0], handler.parent[1]);
559
559
  handlers.push(handler);
560
- usedVariants.add(v);
560
+ variants.add(v);
561
561
  applied = true;
562
562
  break;
563
563
  }
@@ -566,7 +566,7 @@ class UnoGenerator {
566
566
  if (handlers.length > 500)
567
567
  throw new Error(`Too many variants applied to "${raw}"`);
568
568
  }
569
- return [raw, processed, handlers];
569
+ return [raw, processed, handlers, variants];
570
570
  }
571
571
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
572
572
  const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
package/dist/index.d.ts CHANGED
@@ -223,7 +223,7 @@ interface RuleMeta {
223
223
  /**
224
224
  * Templates to provide autocomplete suggestions
225
225
  */
226
- autocomplete?: AutoCompleteTemplate | AutoCompleteTemplate[];
226
+ autocomplete?: Arrayable<AutoCompleteTemplate>;
227
227
  /**
228
228
  * Internal rules will only be matched for shortcuts but not the user code.
229
229
  * @default false
@@ -289,6 +289,10 @@ interface VariantObject<Theme extends {} = {}> {
289
289
  * @default false
290
290
  */
291
291
  multiPass?: boolean;
292
+ /**
293
+ * Custom function for auto complete
294
+ */
295
+ autocomplete?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
292
296
  }
293
297
  declare type Variant<Theme extends {} = {}> = VariantFunction<Theme> | VariantObject<Theme>;
294
298
  declare type Preprocessor = (matcher: string) => string | undefined;
@@ -496,14 +500,15 @@ interface GenerateResult {
496
500
  declare type VariantMatchedResult = readonly [
497
501
  raw: string,
498
502
  current: string,
499
- variants: VariantHandler[]
503
+ variantHandlers: VariantHandler[],
504
+ variants: Set<Variant>
500
505
  ];
501
506
  declare type ParsedUtil = readonly [
502
507
  index: number,
503
508
  raw: string,
504
509
  entries: CSSEntries,
505
510
  meta: RuleMeta | undefined,
506
- variants: VariantHandler[]
511
+ variantHandlers: VariantHandler[]
507
512
  ];
508
513
  declare type RawUtil = readonly [
509
514
  index: number,
package/dist/index.mjs CHANGED
@@ -353,7 +353,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
353
353
  };
354
354
  }
355
355
 
356
- const version = "0.29.2";
356
+ const version = "0.29.3";
357
357
 
358
358
  class UnoGenerator {
359
359
  constructor(userConfig = {}, defaults = {}) {
@@ -422,7 +422,7 @@ class UnoGenerator {
422
422
  this._cache.set(cacheKey, null);
423
423
  return;
424
424
  }
425
- const context = this.makeContext(raw, [alias || applied[0], applied[1], applied[2]]);
425
+ const context = this.makeContext(raw, [alias || applied[0], applied[1], applied[2], applied[3]]);
426
426
  const expanded = this.expandShortcut(context.currentSelector, context);
427
427
  if (expanded) {
428
428
  const utils = await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]);
@@ -530,7 +530,7 @@ class UnoGenerator {
530
530
  };
531
531
  }
532
532
  matchVariants(raw, current) {
533
- const usedVariants = /* @__PURE__ */ new Set();
533
+ const variants = /* @__PURE__ */ new Set();
534
534
  const handlers = [];
535
535
  let processed = current || raw;
536
536
  let applied = false;
@@ -542,7 +542,7 @@ class UnoGenerator {
542
542
  while (true) {
543
543
  applied = false;
544
544
  for (const v of this.config.variants) {
545
- if (!v.multiPass && usedVariants.has(v))
545
+ if (!v.multiPass && variants.has(v))
546
546
  continue;
547
547
  let handler = v.match(processed, context);
548
548
  if (!handler)
@@ -553,7 +553,7 @@ class UnoGenerator {
553
553
  if (Array.isArray(handler.parent))
554
554
  this.parentOrders.set(handler.parent[0], handler.parent[1]);
555
555
  handlers.push(handler);
556
- usedVariants.add(v);
556
+ variants.add(v);
557
557
  applied = true;
558
558
  break;
559
559
  }
@@ -562,7 +562,7 @@ class UnoGenerator {
562
562
  if (handlers.length > 500)
563
563
  throw new Error(`Too many variants applied to "${raw}"`);
564
564
  }
565
- return [raw, processed, handlers];
565
+ return [raw, processed, handlers, variants];
566
566
  }
567
567
  applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
568
568
  const handlers = [...variantHandlers].sort((a, b) => (a.order || 0) - (b.order || 0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
- "version": "0.29.2",
3
+ "version": "0.29.3",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "keywords": [
6
6
  "unocss",