unocss-transformer-alias 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -1,6 +1,22 @@
1
- # unocss-transformer-alias [![npm](https://img.shields.io/npm/v/unocss-transformer-alias.svg)](https://npmjs.com/package/unocss-transformer-alias)
2
-
3
- Transform alias for UnoCSS shortcuts.
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/unpreset/unocss-transformer-alias/main/public/logo.svg" style="width:100px;" />
3
+ </p>
4
+
5
+ <h1 align="center">unocss-transformer-alias</h1>
6
+
7
+ <p align="center">🌈 Transform alias for UnoCSS shortcuts.</p>
8
+
9
+ <p align="center">
10
+ <a>
11
+ <img src="https://img.shields.io/npm/v/unocss-transformer-alias?style=flat&colorA=080f12&colorB=1fa669" alt="npm version" />
12
+ </a>
13
+ <a>
14
+ <img src="https://img.shields.io/npm/dm/unocss-transformer-alias?style=flat&colorA=080f12&colorB=1fa669" alt="npm downloads" />
15
+ </a>
16
+ <a>
17
+ <img src="https://img.shields.io/github/license/unpreset/unocss-transformer-alias.svg?style=flat&colorA=080f12&colorB=1fa669" alt="License" />
18
+ </a>
19
+ </p>
4
20
 
5
21
  ## Install
6
22
  ```shell
@@ -38,7 +54,7 @@ Will be transformed to:
38
54
  <div px-2 py-3 bg-blue-500 text-white rounded>
39
55
  <div class="px-2 py-3 bg-blue-500 text-white rounded bg-red4:10 text-red5 rounded" />
40
56
  <div class="btn-blue px-2 py-3 bg-blue-500 text-white rounded bg-blue4:10 text-blue5 rounded" />
41
- ```
57
+ ```
42
58
 
43
59
  ## Options
44
60
 
@@ -52,6 +68,7 @@ transformerAlias({
52
68
  * @default "*"
53
69
  */
54
70
  prefix?: string
71
+
55
72
  /**
56
73
  * Prefix for your alias and keep the original class.
57
74
  *
@@ -81,7 +98,6 @@ interface KeepOption {
81
98
  - [UnoCSS Issue #2543](https://github.com/unocss/unocss/issues/2543)
82
99
  - [WindiCSS Alias Config](https://windicss.org/integrations/vite.html#alias-config)
83
100
 
84
-
85
101
  ## License
86
102
 
87
103
  MIT License &copy; 2023-PRESENT [Chris](https://github.com/zyyv)
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@ async function transformAlias(code, uno, {
19
19
  } = {}) {
20
20
  if (typeof keep === "string")
21
21
  keep = { prefix: keep, block: true };
22
- const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-]+)`, "g");
22
+ const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-:]+)`, "g");
23
23
  const map = /* @__PURE__ */ new Map();
24
24
  for (const item of Array.from(code.original.matchAll(extraRE))) {
25
25
  let result = map.get(item[0]);
@@ -0,0 +1,36 @@
1
+ import { SourceCodeTransformer, UnoGenerator, ShortcutValue } from '@unocss/core';
2
+ import MagicString from 'magic-string';
3
+
4
+ interface KeepOption {
5
+ /**
6
+ * keep prefix for your alias.
7
+ *
8
+ * @default '+'
9
+ */
10
+ prefix: string;
11
+ /**
12
+ * Decedide whether to put it in `blocklist`.
13
+ *
14
+ * @default true
15
+ */
16
+ block: boolean;
17
+ }
18
+ interface TransformerAliasOptions {
19
+ /**
20
+ * Prefix for your alias.
21
+ *
22
+ * @default "*"
23
+ */
24
+ prefix?: string;
25
+ /**
26
+ * Prefix for your alias and keep the original class.
27
+ *
28
+ * @default '+'
29
+ */
30
+ keep?: string | KeepOption;
31
+ }
32
+ declare function transformerAlias(options?: TransformerAliasOptions): SourceCodeTransformer;
33
+ declare function transformAlias(code: MagicString, uno: UnoGenerator, { prefix, keep, }?: TransformerAliasOptions): Promise<void>;
34
+ declare function expandShortcut(input: string, uno: UnoGenerator, depth?: number): Promise<[ShortcutValue[]] | undefined>;
35
+
36
+ export { type KeepOption, type TransformerAliasOptions, transformerAlias as default, expandShortcut, transformAlias };
@@ -0,0 +1,36 @@
1
+ import { SourceCodeTransformer, UnoGenerator, ShortcutValue } from '@unocss/core';
2
+ import MagicString from 'magic-string';
3
+
4
+ interface KeepOption {
5
+ /**
6
+ * keep prefix for your alias.
7
+ *
8
+ * @default '+'
9
+ */
10
+ prefix: string;
11
+ /**
12
+ * Decedide whether to put it in `blocklist`.
13
+ *
14
+ * @default true
15
+ */
16
+ block: boolean;
17
+ }
18
+ interface TransformerAliasOptions {
19
+ /**
20
+ * Prefix for your alias.
21
+ *
22
+ * @default "*"
23
+ */
24
+ prefix?: string;
25
+ /**
26
+ * Prefix for your alias and keep the original class.
27
+ *
28
+ * @default '+'
29
+ */
30
+ keep?: string | KeepOption;
31
+ }
32
+ declare function transformerAlias(options?: TransformerAliasOptions): SourceCodeTransformer;
33
+ declare function transformAlias(code: MagicString, uno: UnoGenerator, { prefix, keep, }?: TransformerAliasOptions): Promise<void>;
34
+ declare function expandShortcut(input: string, uno: UnoGenerator, depth?: number): Promise<[ShortcutValue[]] | undefined>;
35
+
36
+ export { type KeepOption, type TransformerAliasOptions, transformerAlias as default, expandShortcut, transformAlias };
package/dist/index.d.ts CHANGED
@@ -33,4 +33,4 @@ declare function transformerAlias(options?: TransformerAliasOptions): SourceCode
33
33
  declare function transformAlias(code: MagicString, uno: UnoGenerator, { prefix, keep, }?: TransformerAliasOptions): Promise<void>;
34
34
  declare function expandShortcut(input: string, uno: UnoGenerator, depth?: number): Promise<[ShortcutValue[]] | undefined>;
35
35
 
36
- export { KeepOption, TransformerAliasOptions, transformerAlias as default, expandShortcut, transformAlias };
36
+ export { type KeepOption, type TransformerAliasOptions, transformerAlias as default, expandShortcut, transformAlias };
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ async function transformAlias(code, uno, {
15
15
  } = {}) {
16
16
  if (typeof keep === "string")
17
17
  keep = { prefix: keep, block: true };
18
- const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-]+)`, "g");
18
+ const extraRE = new RegExp(`(${escapeRegExp(prefix)}|${escapeRegExp(keep.prefix)})([\\w-:]+)`, "g");
19
19
  const map = /* @__PURE__ */ new Map();
20
20
  for (const item of Array.from(code.original.matchAll(extraRE))) {
21
21
  let result = map.get(item[0]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unocss-transformer-alias",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "description": "Transform alias for UnoCSS shortcuts",
6
6
  "author": "Chris <https://github.com/zyyv>",
7
7
  "license": "MIT",
@@ -14,15 +14,16 @@
14
14
  "url": "https://github.com/zyyv/unocss-transformer-alias/issues"
15
15
  },
16
16
  "keywords": [
17
- "UnoCSS",
18
- "UnoCSS transformer"
17
+ "unpreset",
18
+ "unocss",
19
+ "unocss transformer"
19
20
  ],
20
21
  "sideEffects": false,
21
22
  "exports": {
22
23
  ".": {
23
24
  "types": "./dist/index.d.ts",
24
- "require": "./dist/index.cjs",
25
- "import": "./dist/index.mjs"
25
+ "import": "./dist/index.mjs",
26
+ "require": "./dist/index.cjs"
26
27
  }
27
28
  },
28
29
  "main": "./dist/index.cjs",
@@ -40,29 +41,30 @@
40
41
  "dist"
41
42
  ],
42
43
  "dependencies": {
43
- "@unocss/core": "^0.51.8"
44
+ "@unocss/core": "^0.61.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@antfu/eslint-config": "^0.38.5",
47
- "@babel/types": "^7.21.5",
48
- "@types/node": "^18.16.2",
49
- "bumpp": "^9.1.0",
50
- "eslint": "^8.39.0",
51
- "esno": "^0.16.3",
52
- "magic-string": "^0.30.0",
53
- "typescript": "^5.0.4",
54
- "unbuild": "^1.2.1",
55
- "vite": "^4.3.3",
56
- "vitest": "^0.30.1"
47
+ "@antfu/eslint-config": "^2.21.2",
48
+ "@babel/types": "^7.24.7",
49
+ "@types/node": "^20.14.9",
50
+ "bumpp": "^9.4.1",
51
+ "eslint": "^9.6.0",
52
+ "esno": "^4.7.0",
53
+ "magic-string": "^0.30.10",
54
+ "typescript": "^5.5.3",
55
+ "unbuild": "^2.0.0",
56
+ "vite": "^5.3.3",
57
+ "vitest": "^1.6.0"
57
58
  },
58
59
  "scripts": {
59
60
  "build": "unbuild",
60
61
  "dev": "unbuild --stub",
61
62
  "release": "bumpp --commit --push --tag && pnpm publish",
62
63
  "lint": "eslint .",
64
+ "lint:fix": "eslint . --fix",
63
65
  "test": "vitest",
64
66
  "test:update": "vitest -u",
65
- "typecheck": "tcs --noEmit",
67
+ "typecheck": "tsc --noEmit",
66
68
  "play": "npm -C playground run dev"
67
69
  }
68
70
  }