@unocss/core 0.62.0 → 0.62.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/dist/index.d.mts CHANGED
@@ -606,6 +606,10 @@ interface ConfigBase<Theme extends object = object> {
606
606
  *
607
607
  */
608
608
  content?: ContentOptions;
609
+ /**
610
+ * Custom transformers to the source code.
611
+ */
612
+ transformers?: SourceCodeTransformer[];
609
613
  }
610
614
  interface OutputCssLayersOptions {
611
615
  /**
package/dist/index.d.ts CHANGED
@@ -606,6 +606,10 @@ interface ConfigBase<Theme extends object = object> {
606
606
  *
607
607
  */
608
608
  content?: ContentOptions;
609
+ /**
610
+ * Custom transformers to the source code.
611
+ */
612
+ transformers?: SourceCodeTransformer[];
609
613
  }
610
614
  interface OutputCssLayersOptions {
611
615
  /**
package/dist/index.mjs CHANGED
@@ -94,7 +94,7 @@ function clearIdenticalEntries(entry) {
94
94
  function entriesToCss(arr) {
95
95
  if (arr == null)
96
96
  return "";
97
- return clearIdenticalEntries(arr).map(([key, value]) => value != null ? `${key}:${value};` : void 0).filter(Boolean).join("");
97
+ return clearIdenticalEntries(arr).map(([key, value]) => value != null && typeof value !== "function" ? `${key}:${value};` : void 0).filter(Boolean).join("");
98
98
  }
99
99
  function isObject(item) {
100
100
  return item && typeof item === "object" && !Array.isArray(item);
@@ -489,47 +489,29 @@ function resolvePresets(preset) {
489
489
  return [root, ...nested];
490
490
  }
491
491
  function mergeContentOptions(optionsArray) {
492
- const mergedResult = {
493
- filesystem: [],
494
- inline: [],
495
- pipeline: {
496
- include: [],
497
- exclude: []
498
- },
499
- plain: []
500
- };
492
+ if (optionsArray.length === 0) {
493
+ return {};
494
+ }
495
+ const pipelineIncludes = [];
496
+ const pipelineExcludes = [];
497
+ let pipelineDisabled = false;
501
498
  for (const options of optionsArray) {
502
- if (options.filesystem) {
503
- mergedResult.filesystem.push(...options.filesystem);
504
- }
505
- if (options.inline) {
506
- mergedResult.inline.push(...options.inline);
507
- }
508
- if (options.plain) {
509
- mergedResult.inline.push(...options.plain);
510
- }
511
- if (options.pipeline !== false) {
512
- if (options.pipeline?.include) {
513
- mergedResult.pipeline?.include?.push(...options.pipeline?.include);
514
- }
515
- if (options.pipeline?.exclude) {
516
- mergedResult.pipeline?.exclude?.push(...options.pipeline?.exclude);
517
- }
499
+ if (options.pipeline === false) {
500
+ pipelineDisabled = true;
518
501
  } else {
519
- mergedResult.pipeline = false;
502
+ pipelineIncludes.push(options.pipeline?.include ?? []);
503
+ pipelineExcludes.push(options.pipeline?.exclude ?? []);
520
504
  }
521
505
  }
522
- if (mergedResult.filesystem) {
523
- mergedResult.filesystem = Array.from(new Set(mergedResult.filesystem));
524
- }
525
- if (mergedResult.inline) {
526
- mergedResult.inline = Array.from(new Set(mergedResult.inline));
527
- }
528
- if (mergedResult.pipeline !== false) {
529
- mergedResult.pipeline.include = Array.from(new Set(mergedResult.pipeline?.include));
530
- mergedResult.pipeline.exclude = Array.from(new Set(mergedResult.pipeline?.exclude));
531
- }
532
- return mergedResult;
506
+ return {
507
+ filesystem: uniq(optionsArray.flatMap((options) => options.filesystem ?? [])),
508
+ inline: uniq(optionsArray.flatMap((options) => options.inline ?? [])),
509
+ plain: uniq(optionsArray.flatMap((options) => options.plain ?? [])),
510
+ pipeline: pipelineDisabled ? false : {
511
+ include: uniq(mergeFilterPatterns(...pipelineIncludes)),
512
+ exclude: uniq(mergeFilterPatterns(...pipelineExcludes))
513
+ }
514
+ };
533
515
  }
534
516
  function resolveConfig(userConfig = {}, defaults = {}) {
535
517
  const config = Object.assign({}, defaults, userConfig);
@@ -606,7 +588,8 @@ function resolveConfig(userConfig = {}, defaults = {}) {
606
588
  safelist: getMerged("safelist"),
607
589
  separators,
608
590
  details: config.details ?? config.envMode === "dev",
609
- content
591
+ content,
592
+ transformers: uniqueBy(getMerged("transformers"), (a, b) => a.name === b.name)
610
593
  };
611
594
  for (const p of sources)
612
595
  p?.configResolved?.(resolved);
@@ -617,10 +600,12 @@ function mergeConfigs(configs) {
617
600
  const config = configs.map((config2) => Object.entries(config2).reduce((acc, [key, value]) => ({
618
601
  ...acc,
619
602
  [key]: maybeArrays.includes(key) ? toArray(value) : value
620
- }), {})).reduce(({ theme: themeA, ...a }, { theme: themeB, ...b }) => {
603
+ }), {})).reduce(({ theme: themeA, content: contentA, ...a }, { theme: themeB, content: contentB, ...b }) => {
621
604
  const c = mergeDeep(a, b, true);
622
605
  if (themeA || themeB)
623
606
  c.theme = mergeThemes([themeA, themeB]);
607
+ if (contentA || contentB)
608
+ c.content = mergeContentOptions([contentA || {}, contentB || {}]);
624
609
  return c;
625
610
  }, {});
626
611
  return config;
@@ -644,11 +629,17 @@ function mergeAutocompleteShorthands(shorthands) {
644
629
  };
645
630
  }, {});
646
631
  }
632
+ function mergeFilterPatterns(...filterPatterns) {
633
+ return filterPatterns.flatMap(flatternFilterPattern);
634
+ }
635
+ function flatternFilterPattern(pattern) {
636
+ return Array.isArray(pattern) ? pattern : pattern ? [pattern] : [];
637
+ }
647
638
  function definePreset(preset) {
648
639
  return preset;
649
640
  }
650
641
 
651
- const version = "0.62.0";
642
+ const version = "0.62.2";
652
643
 
653
644
  var __defProp = Object.defineProperty;
654
645
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/core",
3
3
  "type": "module",
4
- "version": "0.62.0",
4
+ "version": "0.62.2",
5
5
  "description": "The instant on-demand Atomic CSS engine.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",