@weapp-tailwindcss/merge 1.0.2 → 1.0.4

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/cva.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as class_variance_authority_types from 'class-variance-authority/types';
2
2
  import { cva as cva$1 } from 'class-variance-authority';
3
3
 
4
- declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
4
+ declare function cva(...inputs: Parameters<typeof cva$1>): (...props: Parameters<(props?: class_variance_authority_types.ClassProp | undefined) => string>) => string;
5
5
 
6
6
  export { cva };
package/dist/cva.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as class_variance_authority_types from 'class-variance-authority/types';
2
2
  import { cva as cva$1 } from 'class-variance-authority';
3
3
 
4
- declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
4
+ declare function cva(...inputs: Parameters<typeof cva$1>): (...props: Parameters<(props?: class_variance_authority_types.ClassProp | undefined) => string>) => string;
5
5
 
6
6
  export { cva };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/merge",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "description": "weapp-tailwindcss",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -44,12 +44,13 @@
44
44
  "dependencies": {
45
45
  "class-variance-authority": "^0.7.1",
46
46
  "clsx": "^2.1.1",
47
+ "local-pkg": "^1.1.1",
47
48
  "semver": "^7.7.1",
48
49
  "tailwind-merge": "^3.0.2",
49
50
  "tailwind-merge-v2": "npm:tailwind-merge@^2.6.0"
50
51
  },
51
52
  "devDependencies": {
52
- "weapp-tailwindcss": "4.0.6"
53
+ "weapp-tailwindcss": "4.0.10"
53
54
  },
54
55
  "scripts": {
55
56
  "dev": "tsup --watch --sourcemap",
@@ -1,54 +1,29 @@
1
1
  import fs from 'node:fs'
2
- import { createRequire } from 'node:module'
3
2
  import path from 'node:path'
4
- import process from 'node:process'
3
+ import { getPackageInfoSync } from 'local-pkg'
5
4
  import satisfies from 'semver/functions/satisfies.js'
6
5
 
7
- const require = createRequire(import.meta.url)
8
-
9
- function getPackageVersion(pkgName) {
10
- try {
11
- const pkgPath = path.join(process.cwd(), 'node_modules', pkgName, 'package.json')
12
- if (fs.existsSync(pkgPath)) {
13
- const pkg = require(pkgPath)
14
- return pkg.version
15
- }
16
-
17
- // 尝试从 package.json 读取
18
- const rootPkgPath = path.join(process.cwd(), 'package.json')
19
- if (fs.existsSync(rootPkgPath)) {
20
- const rootPkg = require(rootPkgPath)
21
- return rootPkg.dependencies?.[pkgName] || rootPkg.devDependencies?.[pkgName] || null
22
- }
23
- }
24
- catch (error) {
25
- console.error(`Error reading ${pkgName} version:`, error)
26
- }
27
- return null
28
- }
29
-
30
6
  function main() {
31
7
  const distDir = path.resolve(import.meta.dirname, '../dist')
32
8
 
33
9
  if (!fs.existsSync(distDir)) {
34
10
  return
35
11
  }
12
+ const packageInfo = getPackageInfoSync('tailwindcss')
36
13
 
37
- const tailwindVersion = getPackageVersion('tailwindcss')
38
-
39
- if (!tailwindVersion) {
14
+ if (!packageInfo) {
40
15
  console.warn('tailwindcss not found in the project. Skipping swicth version of tailwind-merge.')
41
16
  return
42
17
  }
43
18
 
44
- let targetVersion = null
19
+ const tailwindVersion = packageInfo.version
20
+
21
+ let targetVersion = 3
45
22
 
46
23
  if (satisfies(tailwindVersion, '^4.0.0')) {
47
24
  targetVersion = 4
48
25
  }
49
- else {
50
- targetVersion = 3
51
- }
26
+
52
27
  console.log(`tailwindcss version: ${tailwindVersion}`)
53
28
  console.log(`Switch version of tailwind-merge to v${targetVersion - 1}.`)
54
29
  for (const ext of ['cjs', 'd.cts', 'd.ts', 'js']) {