@umituz/react-native-uuid 1.0.0
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/LICENSE +22 -0
- package/README.md +80 -0
- package/package.json +48 -0
- package/src/index.ts +16 -0
- package/src/infrastructure/utils/UUIDUtils.ts +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ümit UZ
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @umituz/react-native-uuid
|
|
2
|
+
|
|
3
|
+
Cross-platform UUID generation utility for React Native apps using expo-crypto.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @umituz/react-native-uuid
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
- `expo-crypto` >= 15.0.0
|
|
14
|
+
- `react` >= 18.2.0
|
|
15
|
+
- `react-native` >= 0.74.0
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- ✅ Cross-platform UUID generation (iOS, Android, Web)
|
|
20
|
+
- ✅ Uses expo-crypto for secure random UUID generation
|
|
21
|
+
- ✅ TypeScript support
|
|
22
|
+
- ✅ Simple API
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Basic Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { generateUUID } from '@umituz/react-native-uuid';
|
|
30
|
+
|
|
31
|
+
const id = generateUUID();
|
|
32
|
+
// Returns: "550e8400-e29b-41d4-a716-446655440000"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Backward Compatibility
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { uuidv4 } from '@umituz/react-native-uuid';
|
|
39
|
+
|
|
40
|
+
const id = uuidv4();
|
|
41
|
+
// Returns: "550e8400-e29b-41d4-a716-446655440000"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Example: Creating Unique IDs
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { generateUUID } from '@umituz/react-native-uuid';
|
|
48
|
+
|
|
49
|
+
// Create unique project ID
|
|
50
|
+
const projectId = generateUUID();
|
|
51
|
+
|
|
52
|
+
// Create unique scene ID
|
|
53
|
+
const sceneId = generateUUID();
|
|
54
|
+
|
|
55
|
+
// Create unique layer ID
|
|
56
|
+
const layerId = generateUUID();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
### `generateUUID(): string`
|
|
62
|
+
|
|
63
|
+
Generates a v4 UUID using expo-crypto's `randomUUID()` method.
|
|
64
|
+
|
|
65
|
+
**Returns:** A v4 UUID string (e.g., `"550e8400-e29b-41d4-a716-446655440000"`)
|
|
66
|
+
|
|
67
|
+
### `uuidv4(): string`
|
|
68
|
+
|
|
69
|
+
Alias for `generateUUID()` (backward compatibility).
|
|
70
|
+
|
|
71
|
+
**Note:** This is deprecated. Use `generateUUID()` instead.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
76
|
+
|
|
77
|
+
## Author
|
|
78
|
+
|
|
79
|
+
Ümit UZ <umit@umituz.com>
|
|
80
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@umituz/react-native-uuid",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cross-platform UUID generation utility for React Native apps using expo-crypto",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"types": "./src/index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
9
|
+
"lint": "tsc --noEmit",
|
|
10
|
+
"version:minor": "npm version minor -m 'chore: release v%s'",
|
|
11
|
+
"version:major": "npm version major -m 'chore: release v%s'"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react-native",
|
|
15
|
+
"uuid",
|
|
16
|
+
"uuid-generation",
|
|
17
|
+
"expo-crypto",
|
|
18
|
+
"unique-id"
|
|
19
|
+
],
|
|
20
|
+
"author": "Ümit UZ <umit@umituz.com>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/umituz/react-native-uuid"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"expo-crypto": ">=15.0.0",
|
|
28
|
+
"react": ">=18.2.0",
|
|
29
|
+
"react-native": ">=0.74.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^18.2.45",
|
|
33
|
+
"@types/react-native": "^0.73.0",
|
|
34
|
+
"expo-crypto": "^15.0.7",
|
|
35
|
+
"react": "^18.2.0",
|
|
36
|
+
"react-native": "^0.74.0",
|
|
37
|
+
"typescript": "^5.3.3"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"src",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @umituz/react-native-uuid - Public API
|
|
3
|
+
*
|
|
4
|
+
* Cross-platform UUID generation utility for React Native apps
|
|
5
|
+
* Uses expo-crypto for secure UUID generation
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { generateUUID, uuidv4 } from '@umituz/react-native-uuid';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// INFRASTRUCTURE LAYER - Utilities
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export { generateUUID, uuidv4 } from './infrastructure/utils/UUIDUtils';
|
|
16
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID Generation Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides cross-platform UUID generation using expo-crypto.
|
|
5
|
+
* Compatible with React Native (iOS, Android) and Web.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Crypto from 'expo-crypto';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generate a v4 UUID
|
|
12
|
+
* Uses expo-crypto's randomUUID() for secure UUID generation
|
|
13
|
+
*
|
|
14
|
+
* @returns A v4 UUID string
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { generateUUID } from '@umituz/react-native-uuid';
|
|
19
|
+
*
|
|
20
|
+
* const id = generateUUID();
|
|
21
|
+
* // Returns: "550e8400-e29b-41d4-a716-446655440000"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const generateUUID = (): string => {
|
|
25
|
+
return Crypto.randomUUID();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Alias for generateUUID (backward compatibility)
|
|
30
|
+
* @deprecated Use generateUUID() instead
|
|
31
|
+
*/
|
|
32
|
+
export const uuidv4 = generateUUID;
|
|
33
|
+
|