From 04006497c1278299906178d5258799ed70ae9642 Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 11:25:09 +0530 Subject: [PATCH 1/7] refactor: improve import handling in modify-layout.ts to prevent duplicates and enhance CSS import checks --- .../src/util/init/modify-layout.ts | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/packages/gluestack-ui/src/util/init/modify-layout.ts b/packages/gluestack-ui/src/util/init/modify-layout.ts index 82e30b220..089ae7a23 100644 --- a/packages/gluestack-ui/src/util/init/modify-layout.ts +++ b/packages/gluestack-ui/src/util/init/modify-layout.ts @@ -237,54 +237,65 @@ async function modifyReactNativeLayout( */ function addImportsToFile(content: string, newImports: string): string { // Split new imports into individual import statements - const newImportLines = newImports.split('\n').filter(line => line.trim()); - + const newImportLines = newImports.split('\n').filter((line) => line.trim()); + // Find existing imports const importRegex = /^import\s+.*?;?\s*$/gm; const existingImports = content.match(importRegex) || []; - + // Check which imports already exist to avoid duplicates const importsToAdd: string[] = []; - - newImportLines.forEach(newImport => { + const cssBareImportRegex = /^import\s+['"]([^'\"]+)['"];?\s*$/; + + newImportLines.forEach((newImport) => { const newImportTrimmed = newImport.trim(); - + // Skip empty lines if (!newImportTrimmed) return; - + // Extract the import path for comparison const importPathMatch = newImportTrimmed.match(/from\s+['"]([^'"]+)['"]/); const importPath = importPathMatch ? importPathMatch[1] : ''; - + // For CSS imports, check the import path directly - const isCssImport = newImportTrimmed.match(/^import\s+['"][^'"]+['"];?\s*$/); - + const isCssImport = cssBareImportRegex.test(newImportTrimmed); + const newCssPath = isCssImport + ? newImportTrimmed.match(cssBareImportRegex)?.[1] || '' + : ''; + // Extract imported items for more precise matching const importItemsMatch = newImportTrimmed.match(/import\s+(.+?)\s+from/); const importItems = importItemsMatch ? importItemsMatch[1].trim() : ''; - + // Check if this import already exists - const isDuplicate = existingImports.some(existingImport => { + const isDuplicate = existingImports.some((existingImport) => { const existingPathMatch = existingImport.match(/from\s+['"]([^'"]+)['"]/); const existingPath = existingPathMatch ? existingPathMatch[1] : ''; - + // For CSS imports, just compare paths if (isCssImport) { - const existingIsCssImport = existingImport.match(/^import\s+['"][^'"]+['"];?\s*$/); - return existingIsCssImport && existingPath === importPath; + const existingCssMatch = existingImport.match(cssBareImportRegex); + const existingIsCssImport = Boolean(existingCssMatch); + const existingCssPath = existingCssMatch ? existingCssMatch[1] : ''; + return existingIsCssImport && existingCssPath === newCssPath; } - + const existingItemsMatch = existingImport.match(/import\s+(.+?)\s+from/); - const existingItems = existingItemsMatch ? existingItemsMatch[1].trim() : ''; - + const existingItems = existingItemsMatch + ? existingItemsMatch[1].trim() + : ''; + // Check if same path and similar import structure - return existingPath === importPath && ( - existingItems === importItems || - (importItems.includes('GluestackUIProvider') && existingItems.includes('GluestackUIProvider')) || - (importItems.includes('StyledJsxRegistry') && existingItems.includes('StyledJsxRegistry')) + return ( + existingPath === importPath && + (existingItems === importItems || + (importItems.includes('GluestackUIProvider') && + existingItems.includes('GluestackUIProvider')) || + (importItems.includes('StyledJsxRegistry') && + existingItems.includes('StyledJsxRegistry'))) ); }); - + if (!isDuplicate) { importsToAdd.push(newImportTrimmed); } From ec6c9a907840937bdd0291aefe6a96f6ca5110ae Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 11:26:49 +0530 Subject: [PATCH 2/7] chore: update version to 3.0.4 and fix global.css imports in changelog --- packages/gluestack-ui/CHANGELOG.md | 6 ++++++ packages/gluestack-ui/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/gluestack-ui/CHANGELOG.md b/packages/gluestack-ui/CHANGELOG.md index 244f5dc38..de24b378e 100644 --- a/packages/gluestack-ui/CHANGELOG.md +++ b/packages/gluestack-ui/CHANGELOG.md @@ -1,5 +1,11 @@ ## 0.4.9-alpha.0 (2023-07-21) +## 3.0.4 + +### Patch Changes + +- fix: fixed global.css imports + ## 3.0.3 ### Patch Changes diff --git a/packages/gluestack-ui/package.json b/packages/gluestack-ui/package.json index 40d6deb8a..313004f97 100644 --- a/packages/gluestack-ui/package.json +++ b/packages/gluestack-ui/package.json @@ -1,6 +1,6 @@ { "name": "gluestack-ui", - "version": "3.0.3", + "version": "3.0.4", "main": "dist/index.js", "bin": { "gluestack-ui": "./dist/index.js" From c5eb9eee76553e04523c84cf9afd3b3ef3400ff7 Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 12:23:02 +0530 Subject: [PATCH 3/7] fix: update VariantProps import path to use @gluestack-ui/utils/nativewind-utils in button component files --- apps/starter-kit-expo/components/ui/button/index.tsx | 2 +- apps/starter-kit-next/components/ui/button/index.tsx | 2 +- src/components/ui/button/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/starter-kit-expo/components/ui/button/index.tsx b/apps/starter-kit-expo/components/ui/button/index.tsx index b75e6d5b5..b44b2a229 100644 --- a/apps/starter-kit-expo/components/ui/button/index.tsx +++ b/apps/starter-kit-expo/components/ui/button/index.tsx @@ -8,7 +8,7 @@ import { } from '@gluestack-ui/utils/nativewind-utils'; import { cssInterop } from 'nativewind'; import { ActivityIndicator, Pressable, Text, View } from 'react-native'; -import type { VariantProps } from 'tailwind-variants'; +import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator'; const SCOPE = 'BUTTON'; diff --git a/apps/starter-kit-next/components/ui/button/index.tsx b/apps/starter-kit-next/components/ui/button/index.tsx index b75e6d5b5..b44b2a229 100644 --- a/apps/starter-kit-next/components/ui/button/index.tsx +++ b/apps/starter-kit-next/components/ui/button/index.tsx @@ -8,7 +8,7 @@ import { } from '@gluestack-ui/utils/nativewind-utils'; import { cssInterop } from 'nativewind'; import { ActivityIndicator, Pressable, Text, View } from 'react-native'; -import type { VariantProps } from 'tailwind-variants'; +import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator'; const SCOPE = 'BUTTON'; diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx index b75e6d5b5..b44b2a229 100644 --- a/src/components/ui/button/index.tsx +++ b/src/components/ui/button/index.tsx @@ -8,7 +8,7 @@ import { } from '@gluestack-ui/utils/nativewind-utils'; import { cssInterop } from 'nativewind'; import { ActivityIndicator, Pressable, Text, View } from 'react-native'; -import type { VariantProps } from 'tailwind-variants'; +import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator'; const SCOPE = 'BUTTON'; From db7aeba7e52e451b307df823e876276f91a515ac Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 13:02:40 +0530 Subject: [PATCH 4/7] refactor: clean up type definitions and ensure consistent formatting in nativewind-utils --- packages/gluestack-utils/src/nativewind-utils/types.ts | 8 ++++---- .../src/nativewind-utils/utils/deepMerge.ts | 2 +- .../gluestack-utils/src/nativewind-utils/utils/index.ts | 2 +- src/components/ui/button/index.tsx | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/gluestack-utils/src/nativewind-utils/types.ts b/packages/gluestack-utils/src/nativewind-utils/types.ts index 71834d95b..5b39ccbfd 100644 --- a/packages/gluestack-utils/src/nativewind-utils/types.ts +++ b/packages/gluestack-utils/src/nativewind-utils/types.ts @@ -37,7 +37,7 @@ export type TVA = { ES extends undefined ? {} : ES >, EV extends TVVariants = E['variants'], - ES extends TVSlots = E['slots'] extends TVSlots ? E['slots'] : undefined, + ES extends TVSlots = E['slots'] extends TVSlots ? E['slots'] : undefined >( options: { /** @@ -94,7 +94,7 @@ export type TVReturnType< EV extends TVVariants, ES extends TVSlots, // @ts-expect-error - E extends TVReturnType = undefined, + E extends TVReturnType = undefined > = { ( props?: TVProps & { @@ -125,7 +125,7 @@ type HasSlots = S extends undefined type TVSlotsWithBase< S extends TVSlots, - B extends ClassValue, + B extends ClassValue > = B extends undefined ? keyof S : keyof S | TVBaseName; type TVBaseName = 'base'; @@ -135,4 +135,4 @@ export type VariantProps any> = Omit< className?: string; }, 'parentVariants' ->; +>; \ No newline at end of file diff --git a/packages/gluestack-utils/src/nativewind-utils/utils/deepMerge.ts b/packages/gluestack-utils/src/nativewind-utils/utils/deepMerge.ts index af4766bc5..84fdfaca7 100644 --- a/packages/gluestack-utils/src/nativewind-utils/utils/deepMerge.ts +++ b/packages/gluestack-utils/src/nativewind-utils/utils/deepMerge.ts @@ -21,4 +21,4 @@ export function deepMergeObjects(...objects: any) { } return prev; }, {}); -} +} \ No newline at end of file diff --git a/packages/gluestack-utils/src/nativewind-utils/utils/index.ts b/packages/gluestack-utils/src/nativewind-utils/utils/index.ts index 721d9581d..ce0fb4dba 100644 --- a/packages/gluestack-utils/src/nativewind-utils/utils/index.ts +++ b/packages/gluestack-utils/src/nativewind-utils/utils/index.ts @@ -62,4 +62,4 @@ export function extractDataClassName(className: string, states: any) { }); return classNamesFinal; -} +} \ No newline at end of file diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx index b44b2a229..f655aa1c3 100644 --- a/src/components/ui/button/index.tsx +++ b/src/components/ui/button/index.tsx @@ -420,8 +420,8 @@ const ButtonGroup = React.forwardRef< className={buttonGroupStyle({ class: className, space, - isAttached: isAttached as boolean, - flexDirection: flexDirection as any, + isAttached, + flexDirection, })} {...props} ref={ref} From cd1278dcc426f3c7a52fdfc0730b06e3c9ccd8fb Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 13:06:03 +0530 Subject: [PATCH 5/7] chore: update version to 3.0.4 and fix tva config in changelog --- packages/gluestack-utils/CHANGELOG.md | 6 ++++++ packages/gluestack-utils/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/gluestack-utils/CHANGELOG.md b/packages/gluestack-utils/CHANGELOG.md index 8a1a583a2..f5004a18e 100644 --- a/packages/gluestack-utils/CHANGELOG.md +++ b/packages/gluestack-utils/CHANGELOG.md @@ -1,5 +1,11 @@ # @gluestack-ui/utils +## 3.0.4 + +### Patch Changes + +- fix: tva config + ## 3.0.3 ### Patch Changes diff --git a/packages/gluestack-utils/package.json b/packages/gluestack-utils/package.json index cf6ad1814..9ef2a610e 100644 --- a/packages/gluestack-utils/package.json +++ b/packages/gluestack-utils/package.json @@ -1,6 +1,6 @@ { "name": "@gluestack-ui/utils", - "version": "3.0.3", + "version": "3.0.4", "description": "Utility functions and hooks for gluestack-ui", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", From ac73c5ad12b2f89a9cf6b01f4d92c301c4882fa4 Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Mon, 8 Sep 2025 16:24:17 +0530 Subject: [PATCH 6/7] chore: bump version to 3.0.3 and update @gluestack-ui/utils dependency --- packages/gluestack-core/CHANGELOG.md | 6 ++++++ packages/gluestack-core/package.json | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/gluestack-core/CHANGELOG.md b/packages/gluestack-core/CHANGELOG.md index 13e92f5fe..b33c991c1 100644 --- a/packages/gluestack-core/CHANGELOG.md +++ b/packages/gluestack-core/CHANGELOG.md @@ -1,5 +1,11 @@ # @gluestack-ui/core +## 3.0.3 + +### Patch Changes + +- chore: updated utils version + ## 3.0.2 ### Patch Changes diff --git a/packages/gluestack-core/package.json b/packages/gluestack-core/package.json index af5664c0f..57d67b56f 100644 --- a/packages/gluestack-core/package.json +++ b/packages/gluestack-core/package.json @@ -1,7 +1,7 @@ { "name": "@gluestack-ui/core", "description": "Universal UI components for React Native, Expo, and Next.js", - "version": "3.0.2", + "version": "3.0.3", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", "types": "./lib/esm/index.d.ts", @@ -157,7 +157,7 @@ } }, "dependencies": { - "@gluestack-ui/utils": "^3.0.2", + "@gluestack-ui/utils": "^3.0.4", "react-native-svg": "^15.12.0" }, "peerDependencies": { From 859177d661ae1342c5f19eec0ca0758420a2b2d6 Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Tue, 9 Sep 2025 12:42:21 +0530 Subject: [PATCH 7/7] chore: update @gluestack-ui/core and @gluestack-ui/utils to versions 3.0.5 and 3.0.6 respectively --- apps/starter-kit-expo/package.json | 4 ++-- apps/starter-kit-expo/yarn.lock | 28 +++++++++------------------ packages/gluestack-core/CHANGELOG.md | 14 ++++++++++++++ packages/gluestack-core/package.json | 4 ++-- packages/gluestack-utils/CHANGELOG.md | 12 ++++++++++++ packages/gluestack-utils/package.json | 10 +++++++--- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/apps/starter-kit-expo/package.json b/apps/starter-kit-expo/package.json index 745c254fc..20f5d19ab 100644 --- a/apps/starter-kit-expo/package.json +++ b/apps/starter-kit-expo/package.json @@ -17,8 +17,8 @@ "dependencies": { "@expo/html-elements": "^0.12.5", "@expo/vector-icons": "^14.1.0", - "@gluestack-ui/core": "3.0.2", - "@gluestack-ui/utils": "3.0.2", + "@gluestack-ui/core": "^3.0.4", + "@gluestack-ui/utils": "^3.0.5", "@gorhom/bottom-sheet": "^5.0.0-alpha.11", "@legendapp/motion": "^2.4.0", "@react-aria/utils": "^3.29.0", diff --git a/apps/starter-kit-expo/yarn.lock b/apps/starter-kit-expo/yarn.lock index 8a103a0b5..25059f8b9 100644 --- a/apps/starter-kit-expo/yarn.lock +++ b/apps/starter-kit-expo/yarn.lock @@ -1136,28 +1136,18 @@ dependencies: tslib "^2.8.0" -"@gluestack-ui/core@^1.2.10": - version "1.2.10" - resolved "https://registry.npmjs.org/@gluestack-ui/core/-/core-1.2.10.tgz#2be465638e2098fb54c9a5274258ee430973f568" - integrity sha512-ilHiV/vifimZ+1Vo8PIJ8hnMgO7xosEDKl+YwELlVeaAUFBOeN+kj0jEERJy6NxKBEVZeW7lGYFaJ01fw4xDkg== +"@gluestack-ui/core@^3.0.4": + version "3.0.4" + resolved "https://registry.npmjs.org/@gluestack-ui/core/-/core-3.0.4.tgz#426eea6cd2aebd5e3c11c30fe4231cb4d6260e11" + integrity sha512-Xai2E/iumjtVTVM/0klYcdfDAuS3fOJNOIvl8aU4x45bv2EH0aS/iGhAMiU1C1SQDY3uVn8fck4FFJaJNuEAfg== dependencies: - "@gluestack-ui/utils" "*" + "@gluestack-ui/utils" "^3.0.5" react-native-svg "^15.12.0" -"@gluestack-ui/utils@*": - version "0.1.16" - resolved "https://registry.npmjs.org/@gluestack-ui/utils/-/utils-0.1.16.tgz#a1d0a825483a49496061b2ad546fb39e06f78888" - integrity sha512-23ADKc1msn8ST2pQNfc8nPpM8HyFFi01cKN2MTmj6LMMJUzmBMJxPa3jOE66IQUuowO7V0ZQ5G8+mvJrTB+H3w== - dependencies: - dom-helpers "^6.0.1" - react-aria "^3.41.1" - react-stately "^3.39.0" - tailwind-variants "0.1.14" - -"@gluestack-ui/utils@^1.0.23": - version "1.0.23" - resolved "https://registry.npmjs.org/@gluestack-ui/utils/-/utils-1.0.23.tgz#365a114b6bf643712f28c0342962e87e805ae3fa" - integrity sha512-Kk9oXlpPlhRAy+a3xwsHxDWpbEfxYF5vXTaaaMBm/zi+rIT3i/6MOarT6s77hr4mhX4iYN85ANFxophmtDj7jQ== +"@gluestack-ui/utils@^3.0.5": + version "3.0.5" + resolved "https://registry.npmjs.org/@gluestack-ui/utils/-/utils-3.0.5.tgz#22b553d9e9586269673bfb8bfb324686d1860b1a" + integrity sha512-3CxHP7c5OVOw37FRKP4RFmQtOhYeTXFkZAevU44Aql0HIi1NjTnYXc3WJhuW9cBhKJsYbV0dzKkMKIWZ1fS8Gg== dependencies: dom-helpers "^6.0.1" react-aria "^3.41.1" diff --git a/packages/gluestack-core/CHANGELOG.md b/packages/gluestack-core/CHANGELOG.md index b33c991c1..9c21828aa 100644 --- a/packages/gluestack-core/CHANGELOG.md +++ b/packages/gluestack-core/CHANGELOG.md @@ -1,5 +1,19 @@ # @gluestack-ui/core +## 3.0.5 + +### Patch Changes + +- chore: updated utils version + +## 3.0.4 + +### Patch Changes + +- chore: bumped utils version +- Updated dependencies + - @gluestack-ui/utils@3.0.5 + ## 3.0.3 ### Patch Changes diff --git a/packages/gluestack-core/package.json b/packages/gluestack-core/package.json index 57d67b56f..57fef3f91 100644 --- a/packages/gluestack-core/package.json +++ b/packages/gluestack-core/package.json @@ -1,7 +1,7 @@ { "name": "@gluestack-ui/core", "description": "Universal UI components for React Native, Expo, and Next.js", - "version": "3.0.3", + "version": "3.0.5", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", "types": "./lib/esm/index.d.ts", @@ -157,7 +157,7 @@ } }, "dependencies": { - "@gluestack-ui/utils": "^3.0.4", + "@gluestack-ui/utils": "^3.0.6", "react-native-svg": "^15.12.0" }, "peerDependencies": { diff --git a/packages/gluestack-utils/CHANGELOG.md b/packages/gluestack-utils/CHANGELOG.md index f5004a18e..124780e5f 100644 --- a/packages/gluestack-utils/CHANGELOG.md +++ b/packages/gluestack-utils/CHANGELOG.md @@ -1,5 +1,17 @@ # @gluestack-ui/utils +## 3.0.6 + +### Patch Changes + +- chore: try to figure out types issue + +## 3.0.5 + +### Patch Changes + +- chore: updated tsconfig + ## 3.0.4 ### Patch Changes diff --git a/packages/gluestack-utils/package.json b/packages/gluestack-utils/package.json index 9ef2a610e..40e686974 100644 --- a/packages/gluestack-utils/package.json +++ b/packages/gluestack-utils/package.json @@ -1,6 +1,6 @@ { "name": "@gluestack-ui/utils", - "version": "3.0.4", + "version": "3.0.6", "description": "Utility functions and hooks for gluestack-ui", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", @@ -95,8 +95,12 @@ "expo", "nextjs", "cross-platform", - "utilities", + "utils", "hooks", - "aria" + "aria", + "nativewind", + "gluestack-ui", + "universal", + "typescript" ] }