create-prisma-php-app 2.0.0-beta.13 → 2.0.0-beta.15
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/bootstrap.php +4 -4
- package/dist/src/Lib/PHPX/TwMerge.php +30 -75
- package/dist/src/Lib/Request.php +12 -0
- package/package.json +1 -1
package/dist/bootstrap.php
CHANGED
|
@@ -64,7 +64,7 @@ final class Bootstrap
|
|
|
64
64
|
|
|
65
65
|
Request::$pathname = $contentInfo['pathname'] ? '/' . $contentInfo['pathname'] : '/';
|
|
66
66
|
Request::$uri = $contentInfo['uri'] ? $contentInfo['uri'] : '/';
|
|
67
|
-
Request::$decodedUri =
|
|
67
|
+
Request::$decodedUri = Request::getDecodedUrl(Request::$uri);
|
|
68
68
|
|
|
69
69
|
if (is_file(self::$contentToInclude)) {
|
|
70
70
|
Request::$fileToInclude = basename(self::$contentToInclude);
|
|
@@ -675,7 +675,7 @@ final class Bootstrap
|
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
-
$currentUrl =
|
|
678
|
+
$currentUrl = Request::getDecodedUrl(Request::$uri);
|
|
679
679
|
|
|
680
680
|
if (isset($currentData[$currentUrl])) {
|
|
681
681
|
$currentData[$currentUrl]['includedFiles'] = array_values(array_unique(
|
|
@@ -687,7 +687,7 @@ final class Bootstrap
|
|
|
687
687
|
}
|
|
688
688
|
} else {
|
|
689
689
|
$currentData[$currentUrl] = [
|
|
690
|
-
'url' =>
|
|
690
|
+
'url' => Request::$uri,
|
|
691
691
|
'fileName' => self::convertUrlToFileName($currentUrl),
|
|
692
692
|
'isCacheable' => CacheHandler::$isCacheable,
|
|
693
693
|
'cacheTtl' => CacheHandler::$ttl,
|
|
@@ -707,7 +707,7 @@ final class Bootstrap
|
|
|
707
707
|
{
|
|
708
708
|
$url = trim($url, '/');
|
|
709
709
|
$fileName = preg_replace('/[^a-zA-Z0-9-_]/', '_', $url);
|
|
710
|
-
return $fileName
|
|
710
|
+
return $fileName ? mb_strtolower($fileName, 'UTF-8') : 'index';
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
private static function authenticateUserToken(): void
|
|
@@ -9,7 +9,6 @@ class TwMerge
|
|
|
9
9
|
private static $classGroupPatterns = [
|
|
10
10
|
// **General Padding classes**
|
|
11
11
|
"p" => "/^p-/",
|
|
12
|
-
|
|
13
12
|
// **Specific Padding classes**
|
|
14
13
|
"pt" => "/^pt-/",
|
|
15
14
|
"pr" => "/^pr-/",
|
|
@@ -17,7 +16,6 @@ class TwMerge
|
|
|
17
16
|
"pl" => "/^pl-/",
|
|
18
17
|
"px" => "/^px-/",
|
|
19
18
|
"py" => "/^py-/",
|
|
20
|
-
|
|
21
19
|
// **Margin classes**
|
|
22
20
|
"m" => "/^m-/",
|
|
23
21
|
"mt" => "/^mt-/",
|
|
@@ -26,60 +24,42 @@ class TwMerge
|
|
|
26
24
|
"ml" => "/^ml-/",
|
|
27
25
|
"mx" => "/^mx-/",
|
|
28
26
|
"my" => "/^my-/",
|
|
29
|
-
|
|
30
27
|
// **Background color classes**
|
|
31
28
|
"bg" => "/^bg-/",
|
|
32
|
-
|
|
33
|
-
// **Text size classes
|
|
29
|
+
// **Text size classes**
|
|
34
30
|
"text-size" => '/^text-(xs|sm|base|lg|xl|[2-9]xl)$/',
|
|
35
|
-
|
|
36
31
|
// **Text alignment classes**
|
|
37
32
|
"text-alignment" => '/^text-(left|center|right|justify)$/',
|
|
38
|
-
|
|
39
|
-
// **Text color classes
|
|
33
|
+
// **Text color classes**
|
|
40
34
|
"text-color" => '/^text-(?!xs$|sm$|base$|lg$|xl$|[2-9]xl$).+$/',
|
|
41
|
-
|
|
42
35
|
// **Text transform classes**
|
|
43
|
-
"text-transform" =>
|
|
44
|
-
'/^text-(uppercase|lowercase|capitalize|normal-case)$/',
|
|
45
|
-
|
|
36
|
+
"text-transform" => '/^text-(uppercase|lowercase|capitalize|normal-case)$/',
|
|
46
37
|
// **Text decoration classes**
|
|
47
38
|
"text-decoration" => '/^text-(underline|line-through|no-underline)$/',
|
|
48
|
-
|
|
49
39
|
// **Border width classes**
|
|
50
40
|
"border-width" => '/^border(-[0-9]+)?$/',
|
|
51
|
-
|
|
52
41
|
// **Border color classes**
|
|
53
42
|
"border-color" => "/^border-(?![0-9])/",
|
|
54
|
-
|
|
55
43
|
// **Border radius classes**
|
|
56
44
|
"rounded" => '/^rounded(-.*)?$/',
|
|
57
|
-
|
|
58
45
|
// **Font weight classes**
|
|
59
|
-
"font" =>
|
|
60
|
-
'/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/',
|
|
61
|
-
|
|
46
|
+
"font" => '/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/',
|
|
62
47
|
// **Hover background color classes**
|
|
63
48
|
"hover:bg" => "/^hover:bg-/",
|
|
64
|
-
|
|
65
49
|
// **Hover text color classes**
|
|
66
50
|
"hover:text" => "/^hover:text-/",
|
|
67
|
-
|
|
68
51
|
// **Transition classes**
|
|
69
52
|
"transition" => '/^transition(-[a-z]+)?$/',
|
|
70
|
-
|
|
71
|
-
// **Opacity classes
|
|
53
|
+
// **Opacity classes**
|
|
72
54
|
"opacity" => '/^opacity(-[0-9]+)?$/',
|
|
73
|
-
|
|
74
55
|
// **Flexbox alignment classes**
|
|
75
56
|
"justify" => "/^justify-(start|end|center|between|around|evenly)$/",
|
|
76
|
-
|
|
77
57
|
// **Flexbox alignment classes**
|
|
78
58
|
"items" => "/^items-(start|end|center|baseline|stretch)$/",
|
|
79
|
-
|
|
80
59
|
// **Width classes**
|
|
81
60
|
"w" => "/^w-(full|[0-9]+|\\[.+\\])$/",
|
|
82
|
-
|
|
61
|
+
// **Max-width classes**
|
|
62
|
+
"max-w" => '/^max-w-(full|[0-9]+|\\[.+\\]|[a-zA-Z]+)$/',
|
|
83
63
|
// **Other utility classes can be added here**
|
|
84
64
|
];
|
|
85
65
|
|
|
@@ -92,7 +72,6 @@ class TwMerge
|
|
|
92
72
|
"pr" => ["pr"],
|
|
93
73
|
"pb" => ["pb"],
|
|
94
74
|
"pl" => ["pl"],
|
|
95
|
-
|
|
96
75
|
// **Margin conflict groups**
|
|
97
76
|
"m" => ["m", "mx", "my", "mt", "mr", "mb", "ml"],
|
|
98
77
|
"mx" => ["mx", "ml", "mr"],
|
|
@@ -101,57 +80,37 @@ class TwMerge
|
|
|
101
80
|
"mr" => ["mr"],
|
|
102
81
|
"mb" => ["mb"],
|
|
103
82
|
"ml" => ["ml"],
|
|
104
|
-
|
|
105
83
|
// **Border width conflict group**
|
|
106
84
|
"border-width" => ["border-width"],
|
|
107
|
-
|
|
108
85
|
// **Border color conflict group**
|
|
109
86
|
"border-color" => ["border-color"],
|
|
110
|
-
|
|
111
87
|
// **Text size conflict group**
|
|
112
88
|
"text-size" => ["text-size"],
|
|
113
|
-
|
|
114
89
|
// **Text color conflict group**
|
|
115
90
|
"text-color" => ["text-color"],
|
|
116
|
-
|
|
117
91
|
// **Text alignment conflict group**
|
|
118
92
|
"text-alignment" => ["text-alignment"],
|
|
119
|
-
|
|
120
93
|
// **Text transform conflict group**
|
|
121
94
|
"text-transform" => ["text-transform"],
|
|
122
|
-
|
|
123
95
|
// **Text decoration conflict group**
|
|
124
96
|
"text-decoration" => ["text-decoration"],
|
|
125
|
-
|
|
126
|
-
// **Opacity conflict group
|
|
97
|
+
// **Opacity conflict group**
|
|
127
98
|
"opacity" => ["opacity"],
|
|
128
|
-
|
|
129
99
|
// **Flexbox alignment conflict group**
|
|
130
100
|
"justify" => ["justify"],
|
|
131
|
-
|
|
132
101
|
// **Flexbox alignment conflict group**
|
|
133
102
|
"items" => ["items"],
|
|
134
|
-
|
|
135
103
|
// **Width conflict group**
|
|
136
|
-
"w" => ["w"],
|
|
137
|
-
|
|
104
|
+
"w" => ["w", "max-w"],
|
|
105
|
+
// **Max-width conflict group**
|
|
106
|
+
"max-w" => ["max-w"],
|
|
138
107
|
// **Add other conflict groups as needed**
|
|
139
108
|
];
|
|
140
109
|
|
|
141
110
|
/**
|
|
142
111
|
* Merges multiple CSS class strings or arrays of CSS class strings into a single, optimized CSS class string.
|
|
143
112
|
*
|
|
144
|
-
*
|
|
145
|
-
* duplicate or conflicting classes, and prioritizes the last occurrence of a class. It splits class strings
|
|
146
|
-
* by whitespace, handles conflicting class groups, and ensures a clean and well-formatted output.
|
|
147
|
-
*
|
|
148
|
-
* ### Features:
|
|
149
|
-
* - Accepts individual class strings or arrays of class strings.
|
|
150
|
-
* - Automatically handles arrays by flattening them into individual strings.
|
|
151
|
-
* - Removes duplicate or conflicting classes based on class groups.
|
|
152
|
-
* - Combines all classes into a single string, properly formatted and optimized.
|
|
153
|
-
*
|
|
154
|
-
* @param string|array ...$classes The CSS classes to be merged. Each argument can be a string or an array of strings.
|
|
113
|
+
* @param string|array ...$classes The CSS classes to be merged.
|
|
155
114
|
* @return string A single CSS class string with duplicates and conflicts resolved.
|
|
156
115
|
*/
|
|
157
116
|
public static function mergeClasses(string|array ...$classes): string
|
|
@@ -170,9 +129,7 @@ class TwMerge
|
|
|
170
129
|
|
|
171
130
|
// If the class is non-responsive (no colon), remove any responsive variants for the same base
|
|
172
131
|
if (strpos($classKey, ':') === false) {
|
|
173
|
-
// The base group is the class key itself (e.g. "justify")
|
|
174
132
|
$baseGroup = $classKey;
|
|
175
|
-
// Remove any entries that end with the same base group but have a prefix (e.g. "sm:justify")
|
|
176
133
|
foreach ($classArray as $existingKey => $existingClass) {
|
|
177
134
|
if ($existingKey !== $baseGroup && substr($existingKey, -strlen($baseGroup)) === $baseGroup) {
|
|
178
135
|
unset($classArray[$existingKey]);
|
|
@@ -180,10 +137,22 @@ class TwMerge
|
|
|
180
137
|
}
|
|
181
138
|
}
|
|
182
139
|
|
|
183
|
-
//
|
|
184
|
-
$
|
|
140
|
+
// If the class belongs to the max-w group and a corresponding w class exists for the same prefix, skip it.
|
|
141
|
+
$baseClassKey = preg_replace("/^(?:[a-z-]+:)+/", "", $classKey);
|
|
142
|
+
if ($baseClassKey === "max-w") {
|
|
143
|
+
if (preg_match("/^((?:[a-z-]+:)*)max-w$/", $classKey, $prefixMatches)) {
|
|
144
|
+
$prefix = $prefixMatches[1] ?? "";
|
|
145
|
+
} else {
|
|
146
|
+
$prefix = "";
|
|
147
|
+
}
|
|
148
|
+
$wKey = $prefix . "w";
|
|
149
|
+
if (isset($classArray[$wKey])) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
185
153
|
|
|
186
|
-
// Remove
|
|
154
|
+
// Remove conflicting classes based on the conflict groups
|
|
155
|
+
$conflictingKeys = self::getConflictingKeys($classKey);
|
|
187
156
|
foreach ($conflictingKeys as $key) {
|
|
188
157
|
unset($classArray[$key]);
|
|
189
158
|
}
|
|
@@ -203,23 +172,17 @@ class TwMerge
|
|
|
203
172
|
{
|
|
204
173
|
// Match optional prefixes (responsive and variants)
|
|
205
174
|
$pattern = '/^((?:[a-z-]+:)*)(.+)$/';
|
|
206
|
-
|
|
207
175
|
if (preg_match($pattern, $class, $matches)) {
|
|
208
|
-
$prefixes = $matches[1];
|
|
209
|
-
$utilityClass = $matches[2];
|
|
176
|
+
$prefixes = $matches[1];
|
|
177
|
+
$utilityClass = $matches[2];
|
|
210
178
|
|
|
211
|
-
// Now match utilityClass against patterns
|
|
212
179
|
foreach (self::$classGroupPatterns as $groupKey => $regex) {
|
|
213
180
|
if (preg_match($regex, $utilityClass)) {
|
|
214
181
|
return $prefixes . $groupKey;
|
|
215
182
|
}
|
|
216
183
|
}
|
|
217
|
-
|
|
218
|
-
// If no match, use the full class
|
|
219
184
|
return $prefixes . $utilityClass;
|
|
220
185
|
}
|
|
221
|
-
|
|
222
|
-
// For classes without a recognizable prefix, return the class itself
|
|
223
186
|
return $class;
|
|
224
187
|
}
|
|
225
188
|
|
|
@@ -227,20 +190,12 @@ class TwMerge
|
|
|
227
190
|
{
|
|
228
191
|
// Remove any responsive or variant prefixes
|
|
229
192
|
$baseClassKey = preg_replace("/^(?:[a-z-]+:)+/", "", $classKey);
|
|
230
|
-
|
|
231
|
-
// Check for conflicts
|
|
232
193
|
if (isset(self::$conflictGroups[$baseClassKey])) {
|
|
233
|
-
|
|
234
|
-
$prefix = preg_replace(
|
|
235
|
-
"/" . preg_quote($baseClassKey, "/") . '$/',
|
|
236
|
-
"",
|
|
237
|
-
$classKey
|
|
238
|
-
);
|
|
194
|
+
$prefix = preg_replace("/" . preg_quote($baseClassKey, "/") . '$/', "", $classKey);
|
|
239
195
|
return array_map(function ($conflict) use ($prefix) {
|
|
240
196
|
return $prefix . $conflict;
|
|
241
197
|
}, self::$conflictGroups[$baseClassKey]);
|
|
242
198
|
}
|
|
243
|
-
|
|
244
199
|
return [$classKey];
|
|
245
200
|
}
|
|
246
201
|
}
|
package/dist/src/Lib/Request.php
CHANGED
|
@@ -457,4 +457,16 @@ class Request
|
|
|
457
457
|
|
|
458
458
|
exit;
|
|
459
459
|
}
|
|
460
|
+
|
|
461
|
+
public static function getDecodedUrl(string $uri): string
|
|
462
|
+
{
|
|
463
|
+
$parsedUrl = parse_url($uri);
|
|
464
|
+
|
|
465
|
+
$queryString = isset($parsedUrl['query']) ? '?' . urldecode($parsedUrl['query']) : '';
|
|
466
|
+
$path = $parsedUrl['path'] ?? '';
|
|
467
|
+
|
|
468
|
+
$decodedUrl = urldecode($path . $queryString);
|
|
469
|
+
|
|
470
|
+
return $decodedUrl;
|
|
471
|
+
}
|
|
460
472
|
}
|