@abdokouta/react-support 1.1.0 β 1.2.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/CHANGELOG.md +26 -0
- package/README.md +98 -54
- package/dist/index.d.cts +255 -676
- package/dist/index.d.ts +255 -676
- package/dist/index.js +217 -628
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +219 -628
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.2.0] - 2026-04-05
|
|
6
|
+
|
|
7
|
+
### Refactored
|
|
8
|
+
|
|
9
|
+
- Centralized all types and interfaces into `src/types/` with `.type.ts`
|
|
10
|
+
convention
|
|
11
|
+
- Extracted utility functions into `src/utils/` with `.util.ts` convention
|
|
12
|
+
- Moved `MultipleInstanceManager` into `src/managers/` module
|
|
13
|
+
- Removed `RegistryCollection` adapter β `BaseRegistry` now uses `MapCollection`
|
|
14
|
+
directly
|
|
15
|
+
- Switched all internal imports to `@/*` path aliases
|
|
16
|
+
- Removed facade source files (types extracted to `src/types/`)
|
|
17
|
+
- Updated root barrel to only export types from `src/types/`
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Added `ES2020` and `DOM` libs to tsconfig for `Map`, `URL`, `Buffer`, and
|
|
22
|
+
`btoa` support
|
|
23
|
+
- Added `node` to tsconfig types for Node.js globals
|
|
24
|
+
- Fixed strict null checks in `Str.pluralStudly` and `Str.replaceArray`
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Migrated ESLint config from JS to TypeScript
|
|
29
|
+
- Added `.prettierrc.ts` configuration
|
|
30
|
+
|
|
5
31
|
## [1.0.0] - 2024-03-31
|
|
6
32
|
|
|
7
33
|
### Added
|
package/README.md
CHANGED
|
@@ -1,58 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/pixielity-inc/react-support/main/assets/banner.svg" alt="@abdokouta/react-support" width="100%" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">@abdokouta/react-support</h1>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Laravel-style utilities for JavaScript/TypeScript</strong>
|
|
9
|
+
</p>
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
- π **Chainable**: Fluent, chainable API for elegant code
|
|
14
|
-
- π **Zero Config**: Works out of the box
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@abdokouta/react-support"><img src="https://img.shields.io/npm/v/@abdokouta/react-support.svg?style=flat-square" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@abdokouta/react-support"><img src="https://img.shields.io/npm/dm/@abdokouta/react-support.svg?style=flat-square" alt="npm downloads" /></a>
|
|
14
|
+
<a href="https://github.com/pixielity-inc/react-support/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@abdokouta/react-support.svg?style=flat-square" alt="license" /></a>
|
|
15
|
+
<a href="https://github.com/pixielity-inc/react-support"><img src="https://img.shields.io/github/stars/pixielity-inc/react-support?style=flat-square" alt="GitHub stars" /></a>
|
|
16
|
+
</p>
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
<p align="center">
|
|
19
|
+
Powerful string manipulation, collection handling, facades, and registry patterns inspired by Laravel
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## β¨ Features
|
|
25
|
+
|
|
26
|
+
- π― **Str Class** - 100+ string manipulation methods matching Laravel's API
|
|
27
|
+
- π¦ **Collection** - Array collection with 50+ chainable methods (powered by
|
|
28
|
+
collect.js)
|
|
29
|
+
- πΊοΈ **MapCollection** - Map data structure with collection methods
|
|
30
|
+
- π² **SetCollection** - Set data structure with collection methods
|
|
31
|
+
- ποΈ **BaseRegistry** - Generic registry pattern for building extensible systems
|
|
32
|
+
- π **Facades** - Laravel-style facades for clean service access
|
|
33
|
+
- πͺ **TypeScript** - Full type safety with comprehensive type definitions
|
|
34
|
+
- π **Chainable** - Fluent, chainable API for elegant code
|
|
35
|
+
- π **Zero Config** - Works out of the box
|
|
36
|
+
|
|
37
|
+
## π¦ Installation
|
|
17
38
|
|
|
18
39
|
```bash
|
|
19
|
-
npm install @abdokouta/support
|
|
40
|
+
npm install @abdokouta/react-support
|
|
20
41
|
# or
|
|
21
|
-
pnpm add @abdokouta/support
|
|
42
|
+
pnpm add @abdokouta/react-support
|
|
22
43
|
# or
|
|
23
|
-
yarn add @abdokouta/support
|
|
44
|
+
yarn add @abdokouta/react-support
|
|
24
45
|
```
|
|
25
46
|
|
|
26
|
-
## Usage
|
|
47
|
+
## π Usage
|
|
27
48
|
|
|
28
49
|
### Str Class
|
|
29
50
|
|
|
30
51
|
```typescript
|
|
31
|
-
import { Str } from '@abdokouta/support';
|
|
52
|
+
import { Str } from '@abdokouta/react-support';
|
|
32
53
|
|
|
33
54
|
// String manipulation
|
|
34
|
-
Str.camel('foo_bar');
|
|
35
|
-
Str.snake('fooBar');
|
|
36
|
-
Str.kebab('fooBar');
|
|
37
|
-
Str.studly('foo_bar');
|
|
38
|
-
Str.title('a nice title');
|
|
55
|
+
Str.camel('foo_bar'); // 'fooBar'
|
|
56
|
+
Str.snake('fooBar'); // 'foo_bar'
|
|
57
|
+
Str.kebab('fooBar'); // 'foo-bar'
|
|
58
|
+
Str.studly('foo_bar'); // 'FooBar'
|
|
59
|
+
Str.title('a nice title'); // 'A Nice Title'
|
|
39
60
|
|
|
40
61
|
// String inspection
|
|
41
|
-
Str.contains('This is my name', 'my');
|
|
42
|
-
Str.startsWith('Hello World', 'Hello');
|
|
43
|
-
Str.endsWith('Hello World', 'World');
|
|
44
|
-
Str.isJson('{"key": "value"}');
|
|
45
|
-
Str.isUrl('https://example.com');
|
|
62
|
+
Str.contains('This is my name', 'my'); // true
|
|
63
|
+
Str.startsWith('Hello World', 'Hello'); // true
|
|
64
|
+
Str.endsWith('Hello World', 'World'); // true
|
|
65
|
+
Str.isJson('{"key": "value"}'); // true
|
|
66
|
+
Str.isUrl('https://example.com'); // true
|
|
46
67
|
Str.isUuid('a0a2a2d2-0b87-4a18-83f2-2529882be2de'); // true
|
|
47
68
|
|
|
48
69
|
// String extraction
|
|
49
70
|
Str.after('This is my name', 'This is'); // ' my name'
|
|
50
|
-
Str.before('This is my name', 'my');
|
|
71
|
+
Str.before('This is my name', 'my'); // 'This is '
|
|
51
72
|
Str.between('This is my name', 'This', 'name'); // ' is my '
|
|
52
73
|
|
|
53
74
|
// String modification
|
|
54
|
-
Str.limit('The quick brown fox', 10);
|
|
55
|
-
Str.slug('Laravel 5 Framework', '-');
|
|
75
|
+
Str.limit('The quick brown fox', 10); // 'The quick...'
|
|
76
|
+
Str.slug('Laravel 5 Framework', '-'); // 'laravel-5-framework'
|
|
56
77
|
|
|
57
78
|
// And 80+ more methods!
|
|
58
79
|
```
|
|
@@ -60,65 +81,82 @@ Str.slug('Laravel 5 Framework', '-'); // 'laravel-5-framework'
|
|
|
60
81
|
### Collection (Array)
|
|
61
82
|
|
|
62
83
|
```typescript
|
|
63
|
-
import { collect } from '@abdokouta/support';
|
|
84
|
+
import { collect } from '@abdokouta/react-support';
|
|
64
85
|
|
|
65
86
|
// Create a collection
|
|
66
87
|
const collection = collect([1, 2, 3, 4, 5]);
|
|
67
88
|
|
|
68
89
|
// Chainable methods
|
|
69
90
|
collection
|
|
70
|
-
.filter(item => item > 2)
|
|
71
|
-
.map(item => item * 2)
|
|
72
|
-
.sum();
|
|
91
|
+
.filter((item) => item > 2)
|
|
92
|
+
.map((item) => item * 2)
|
|
93
|
+
.sum(); // 24
|
|
73
94
|
|
|
74
95
|
// Working with objects
|
|
75
96
|
const users = collect([
|
|
76
97
|
{ name: 'John', age: 30 },
|
|
77
98
|
{ name: 'Jane', age: 25 },
|
|
78
|
-
{ name: 'Bob', age: 35 }
|
|
99
|
+
{ name: 'Bob', age: 35 },
|
|
79
100
|
]);
|
|
80
101
|
|
|
81
102
|
users.where('age', '>', 25).pluck('name').all();
|
|
82
103
|
// ['John', 'Bob']
|
|
83
104
|
|
|
84
105
|
// Aggregation
|
|
85
|
-
collect([1, 2, 3, 4, 5]).sum();
|
|
86
|
-
collect([1, 2, 3, 4, 5]).avg();
|
|
87
|
-
collect([1, 2, 3, 4, 5]).max();
|
|
88
|
-
collect([1, 2, 3, 4, 5]).min();
|
|
106
|
+
collect([1, 2, 3, 4, 5]).sum(); // 15
|
|
107
|
+
collect([1, 2, 3, 4, 5]).avg(); // 3
|
|
108
|
+
collect([1, 2, 3, 4, 5]).max(); // 5
|
|
109
|
+
collect([1, 2, 3, 4, 5]).min(); // 1
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Facades
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { Facade, createFacade } from '@abdokouta/react-support';
|
|
116
|
+
import { Container } from '@abdokouta/react-di';
|
|
117
|
+
|
|
118
|
+
// Set the container for facades
|
|
119
|
+
Facade.setFacadeContainer(Container.getContainer());
|
|
120
|
+
|
|
121
|
+
// Create a facade for a service
|
|
122
|
+
const Config = createFacade<IConfigService>('ConfigService');
|
|
123
|
+
|
|
124
|
+
// Use the facade
|
|
125
|
+
Config.get('app.name');
|
|
126
|
+
Config.set('app.debug', true);
|
|
89
127
|
```
|
|
90
128
|
|
|
91
129
|
### MapCollection
|
|
92
130
|
|
|
93
131
|
```typescript
|
|
94
|
-
import { collectMap } from '@abdokouta/support';
|
|
132
|
+
import { collectMap } from '@abdokouta/react-support';
|
|
95
133
|
|
|
96
134
|
const map = collectMap({ name: 'John', age: 30 });
|
|
97
135
|
|
|
98
136
|
map.set('city', 'New York');
|
|
99
|
-
map.get('name');
|
|
100
|
-
map.has('age');
|
|
101
|
-
map.keys();
|
|
102
|
-
map.values();
|
|
137
|
+
map.get('name'); // 'John'
|
|
138
|
+
map.has('age'); // true
|
|
139
|
+
map.keys(); // ['name', 'age', 'city']
|
|
140
|
+
map.values(); // ['John', 30, 'New York']
|
|
103
141
|
```
|
|
104
142
|
|
|
105
143
|
### SetCollection
|
|
106
144
|
|
|
107
145
|
```typescript
|
|
108
|
-
import { collectSet } from '@abdokouta/support';
|
|
146
|
+
import { collectSet } from '@abdokouta/react-support';
|
|
109
147
|
|
|
110
148
|
const set1 = collectSet([1, 2, 3]);
|
|
111
149
|
const set2 = collectSet([2, 3, 4]);
|
|
112
150
|
|
|
113
|
-
set1.union(set2).all();
|
|
114
|
-
set1.intersect(set2).all();
|
|
115
|
-
set1.diff(set2).all();
|
|
151
|
+
set1.union(set2).all(); // [1, 2, 3, 4]
|
|
152
|
+
set1.intersect(set2).all(); // [2, 3]
|
|
153
|
+
set1.diff(set2).all(); // [1]
|
|
116
154
|
```
|
|
117
155
|
|
|
118
156
|
### BaseRegistry
|
|
119
157
|
|
|
120
158
|
```typescript
|
|
121
|
-
import { BaseRegistry } from '@abdokouta/support';
|
|
159
|
+
import { BaseRegistry } from '@abdokouta/react-support';
|
|
122
160
|
|
|
123
161
|
// Create a typed registry
|
|
124
162
|
interface Theme {
|
|
@@ -135,7 +173,7 @@ const themeRegistry = new BaseRegistry<Theme>({
|
|
|
135
173
|
},
|
|
136
174
|
afterAdd: (key, theme) => {
|
|
137
175
|
console.log(`Registered theme: ${theme.name}`);
|
|
138
|
-
}
|
|
176
|
+
},
|
|
139
177
|
});
|
|
140
178
|
|
|
141
179
|
// Register items
|
|
@@ -148,12 +186,18 @@ const allThemes = themeRegistry.getAll();
|
|
|
148
186
|
const hasTheme = themeRegistry.has('dark');
|
|
149
187
|
```
|
|
150
188
|
|
|
151
|
-
## TypeScript Support
|
|
189
|
+
## π TypeScript Support
|
|
152
190
|
|
|
153
191
|
Full TypeScript support with comprehensive type definitions:
|
|
154
192
|
|
|
155
193
|
```typescript
|
|
156
|
-
import {
|
|
194
|
+
import {
|
|
195
|
+
Str,
|
|
196
|
+
Collection,
|
|
197
|
+
MapCollection,
|
|
198
|
+
SetCollection,
|
|
199
|
+
BaseRegistry,
|
|
200
|
+
} from '@abdokouta/react-support';
|
|
157
201
|
|
|
158
202
|
// Type-safe collections
|
|
159
203
|
const numbers: Collection<number> = collect([1, 2, 3]);
|
|
@@ -168,11 +212,11 @@ const tags: SetCollection<string> = collectSet(['tag1', 'tag2']);
|
|
|
168
212
|
const registry = new BaseRegistry<MyType>();
|
|
169
213
|
```
|
|
170
214
|
|
|
171
|
-
## License
|
|
215
|
+
## π License
|
|
172
216
|
|
|
173
217
|
MIT
|
|
174
218
|
|
|
175
|
-
## Credits
|
|
219
|
+
## π Credits
|
|
176
220
|
|
|
177
221
|
- Inspired by [Laravel](https://laravel.com)'s support package
|
|
178
222
|
- Array collections powered by [collect.js](https://collect.js.org/)
|