@unocss/preset-tagify 0.58.9 → 0.59.0-beta.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/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-tagify",
3
- "version": "0.58.9",
3
+ "type": "module",
4
+ "version": "0.59.0-beta.1",
4
5
  "description": "Tagify preset for UnoCSS",
5
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
7
  "license": "MIT",
@@ -21,19 +22,18 @@
21
22
  "sideEffects": false,
22
23
  "exports": {
23
24
  ".": {
24
- "types": "./dist/index.d.ts",
25
- "import": "./dist/index.mjs",
26
- "require": "./dist/index.cjs"
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
27
  }
28
28
  },
29
- "main": "./dist/index.cjs",
29
+ "main": "./dist/index.mjs",
30
30
  "module": "./dist/index.mjs",
31
31
  "types": "./dist/index.d.ts",
32
32
  "files": [
33
33
  "dist"
34
34
  ],
35
35
  "dependencies": {
36
- "@unocss/core": "0.58.9"
36
+ "@unocss/core": "0.59.0-beta.1"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "unbuild",
package/dist/index.cjs DELETED
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const core = require('@unocss/core');
6
-
7
- const MARKER = "__TAGIFY__";
8
- const htmlTagRE = /<([\w\d-:]+)/g;
9
- function extractorTagify(options) {
10
- const {
11
- prefix = "",
12
- excludedTags = ["b", /^h\d+$/, "table"]
13
- } = options;
14
- return {
15
- name: "tagify",
16
- extract({ code }) {
17
- return Array.from(code.matchAll(htmlTagRE)).filter(({ 1: match }) => {
18
- for (const exclude of excludedTags) {
19
- if (typeof exclude === "string") {
20
- if (match === exclude)
21
- return false;
22
- } else {
23
- if (exclude.test(match))
24
- return false;
25
- }
26
- }
27
- return match.startsWith(prefix);
28
- }).map(([, matched]) => `${MARKER}${matched}`);
29
- }
30
- };
31
- }
32
-
33
- function variantTagify(options) {
34
- const { extraProperties } = options;
35
- const prefix = `${MARKER}${options.prefix ?? ""}`;
36
- return {
37
- name: "tagify",
38
- match(input) {
39
- if (!input.startsWith(prefix))
40
- return;
41
- const matcher = input.slice(prefix.length);
42
- const handler = {
43
- matcher,
44
- selector: (i) => i.slice(MARKER.length + 1)
45
- };
46
- if (extraProperties) {
47
- if (typeof extraProperties === "function")
48
- handler.body = (entries) => [...entries, ...Object.entries(extraProperties(matcher) ?? {})];
49
- else
50
- handler.body = (entries) => [...entries, ...Object.entries(extraProperties)];
51
- }
52
- return handler;
53
- }
54
- };
55
- }
56
-
57
- const presetTagify = core.definePreset((options = {}) => {
58
- const {
59
- defaultExtractor = true
60
- } = options;
61
- const variants = [
62
- variantTagify(options)
63
- ];
64
- const extractors = [
65
- extractorTagify(options)
66
- ];
67
- return {
68
- name: "@unocss/preset-tagify",
69
- variants,
70
- extractors,
71
- extractorDefault: defaultExtractor ? void 0 : false
72
- };
73
- });
74
-
75
- exports.MARKER = MARKER;
76
- exports.default = presetTagify;
77
- exports.extractorTagify = extractorTagify;
78
- exports.htmlTagRE = htmlTagRE;
79
- exports.presetTagify = presetTagify;
80
- exports.variantTagify = variantTagify;
package/dist/index.d.cts DELETED
@@ -1,33 +0,0 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { Extractor, VariantObject } from '@unocss/core';
3
-
4
- interface TagifyOptions {
5
- /**
6
- * The prefix to use for the tagify variant.
7
- */
8
- prefix?: string;
9
- /**
10
- * Tags excluded from processing.
11
- * @default ['b', /^h\d+$/, 'table']
12
- */
13
- excludedTags?: (string | RegExp)[];
14
- /**
15
- * Extra CSS properties to apply to matched rules
16
- */
17
- extraProperties?: Record<string, string> | ((matched: string) => Partial<Record<string, string>>);
18
- /**
19
- * Enable default extractor
20
- * @default true
21
- */
22
- defaultExtractor?: boolean;
23
- }
24
-
25
- declare const MARKER = "__TAGIFY__";
26
- declare const htmlTagRE: RegExp;
27
- declare function extractorTagify(options: TagifyOptions): Extractor;
28
-
29
- declare function variantTagify(options: TagifyOptions): VariantObject;
30
-
31
- declare const presetTagify: _unocss_core.PresetFactory<object, TagifyOptions>;
32
-
33
- export { MARKER, type TagifyOptions, presetTagify as default, extractorTagify, htmlTagRE, presetTagify, variantTagify };