create-prisma-php-app 3.3.13 → 3.3.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
CHANGED
|
@@ -1033,13 +1033,6 @@ try {
|
|
|
1033
1033
|
Bootstrap::createUpdateRequestData();
|
|
1034
1034
|
}
|
|
1035
1035
|
|
|
1036
|
-
// If there’s caching
|
|
1037
|
-
if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
|
|
1038
|
-
if ($_ENV['CACHE_ENABLED'] === 'true') {
|
|
1039
|
-
CacheHandler::serveCache(Request::$decodedUri, intval($_ENV['CACHE_TTL']));
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
1036
|
// For wire calls, re-include the files if needed
|
|
1044
1037
|
if (Request::$isWire && !Bootstrap::$secondRequestC69CD) {
|
|
1045
1038
|
if (isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
|
|
@@ -1059,6 +1052,13 @@ try {
|
|
|
1059
1052
|
Bootstrap::wireCallback();
|
|
1060
1053
|
}
|
|
1061
1054
|
|
|
1055
|
+
// If there’s caching
|
|
1056
|
+
if ((!Request::$isWire && !Bootstrap::$secondRequestC69CD) && isset(Bootstrap::$requestFilesData[Request::$decodedUri])) {
|
|
1057
|
+
if ($_ENV['CACHE_ENABLED'] === 'true') {
|
|
1058
|
+
CacheHandler::serveCache(Request::$decodedUri, intval($_ENV['CACHE_TTL']));
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
1062
|
MainLayout::$children = MainLayout::$childLayoutChildren . Bootstrap::getLoadingsFiles();
|
|
1063
1063
|
|
|
1064
1064
|
ob_start();
|
|
@@ -1069,7 +1069,7 @@ try {
|
|
|
1069
1069
|
MainLayout::$html = "<!DOCTYPE html>\n" . MainLayout::$html;
|
|
1070
1070
|
|
|
1071
1071
|
if (
|
|
1072
|
-
http_response_code() === 200 && isset(Bootstrap::$requestFilesData[Request::$decodedUri]['fileName']) && $_ENV['CACHE_ENABLED'] === 'true'
|
|
1072
|
+
http_response_code() === 200 && isset(Bootstrap::$requestFilesData[Request::$decodedUri]['fileName']) && $_ENV['CACHE_ENABLED'] === 'true' && (!Request::$isWire && !Bootstrap::$secondRequestC69CD)
|
|
1073
1073
|
) {
|
|
1074
1074
|
CacheHandler::saveCache(Request::$decodedUri, MainLayout::$html);
|
|
1075
1075
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace Lib\PHPX;
|
|
6
|
+
|
|
7
|
+
use Lib\PHPX\PHPX;
|
|
8
|
+
|
|
9
|
+
class Fragment extends PHPX
|
|
10
|
+
{
|
|
11
|
+
/** @property ?string $as = div|span|section|article|nav|header|footer|main|aside */
|
|
12
|
+
public ?string $as = null;
|
|
13
|
+
public ?string $class = '';
|
|
14
|
+
|
|
15
|
+
public function __construct(array $props = [])
|
|
16
|
+
{
|
|
17
|
+
parent::__construct($props);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public function render(): string
|
|
21
|
+
{
|
|
22
|
+
if ($this->as !== null) {
|
|
23
|
+
$attributes = $this->getAttributes();
|
|
24
|
+
$class = $this->getMergeClasses($this->class);
|
|
25
|
+
$classAttr = $class ? "class=\"{$class}\"" : '';
|
|
26
|
+
|
|
27
|
+
return "<{$this->as} {$classAttr} {$attributes}>{$this->children}</{$this->as}>";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return $this->children;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -68,7 +68,7 @@ class PHPX implements IPHPX
|
|
|
68
68
|
unset($chunk);
|
|
69
69
|
|
|
70
70
|
$merged = PrismaPHPSettings::$option->tailwindcss
|
|
71
|
-
? TwMerge::
|
|
71
|
+
? TwMerge::merge(...$all)
|
|
72
72
|
: $this->mergeClasses(...$all);
|
|
73
73
|
|
|
74
74
|
return str_replace(array_keys($expr), array_values($expr), $merged);
|
|
@@ -424,6 +424,8 @@ class TemplateCompiler
|
|
|
424
424
|
$sectionId = $idx === 0 ? $baseId : "{$baseId}{$idx}";
|
|
425
425
|
|
|
426
426
|
$html = $instance->render();
|
|
427
|
+
$html = self::preprocessFragmentSyntax($html);
|
|
428
|
+
|
|
427
429
|
$fragDom = self::convertToXml($html);
|
|
428
430
|
$root = $fragDom->documentElement;
|
|
429
431
|
foreach ($root->childNodes as $c) {
|
|
@@ -445,6 +447,14 @@ class TemplateCompiler
|
|
|
445
447
|
return $htmlOut;
|
|
446
448
|
}
|
|
447
449
|
|
|
450
|
+
private static function preprocessFragmentSyntax(string $content): string
|
|
451
|
+
{
|
|
452
|
+
$content = preg_replace('/<>/', '<Fragment>', $content);
|
|
453
|
+
$content = preg_replace('/<\/>/', '</Fragment>', $content);
|
|
454
|
+
|
|
455
|
+
return $content;
|
|
456
|
+
}
|
|
457
|
+
|
|
448
458
|
private static function selectComponentMapping(string $componentName): array
|
|
449
459
|
{
|
|
450
460
|
if (!isset(self::$classMappings[$componentName])) {
|
|
@@ -6,8 +6,6 @@ namespace Lib\PHPX;
|
|
|
6
6
|
|
|
7
7
|
class TwMerge
|
|
8
8
|
{
|
|
9
|
-
private const IMPORTANT_MODIFIER = '!';
|
|
10
|
-
|
|
11
9
|
private static array $classGroups = [
|
|
12
10
|
// Layout
|
|
13
11
|
'aspect' => ['aspect-auto', 'aspect-square', 'aspect-video', '/^aspect-\[.+\]$/'],
|
|
@@ -92,13 +90,13 @@ class TwMerge
|
|
|
92
90
|
'space-y' => ['/^-?space-y-(\d+(\.\d+)?|px|reverse|\[.+\])$/'],
|
|
93
91
|
|
|
94
92
|
// Sizing
|
|
95
|
-
'w' => ['/^w-(
|
|
96
|
-
'min-w' => ['/^min-w-(
|
|
97
|
-
'max-w' => ['/^max-w-(
|
|
98
|
-
'h' => ['/^h-(
|
|
99
|
-
'min-h' => ['/^min-h-(
|
|
100
|
-
'max-h' => ['/^max-h-(
|
|
101
|
-
'size' => ['/^size-(
|
|
93
|
+
'w' => ['/^w-(?!$).+$/'],
|
|
94
|
+
'min-w' => ['/^min-w-(?!$).+$/'],
|
|
95
|
+
'max-w' => ['/^max-w-(?!$).+$/'],
|
|
96
|
+
'h' => ['/^h-(?!$).+$/'],
|
|
97
|
+
'min-h' => ['/^min-h-(?!$).+$/'],
|
|
98
|
+
'max-h' => ['/^max-h-(?!$).+$/'],
|
|
99
|
+
'size' => ['/^size-(?!$).+$/'],
|
|
102
100
|
|
|
103
101
|
// Typography
|
|
104
102
|
'font-family' => ['/^font-(sans|serif|mono|\[.+\])$/'],
|
|
@@ -114,9 +112,9 @@ class TwMerge
|
|
|
114
112
|
'list-style-position' => ['/^list-(inside|outside)$/'],
|
|
115
113
|
'list-style-type' => ['/^list-(none|disc|decimal|\[.+\])$/'],
|
|
116
114
|
'text-align' => ['/^text-(left|center|right|justify|start|end)$/'],
|
|
117
|
-
'text-color' => ['/^text-(
|
|
115
|
+
'text-color' => ['/^text-(?!xs$|sm$|base$|lg$|xl$|[2-9]xl$).+$/'],
|
|
118
116
|
'text-decoration' => ['underline', 'overline', 'line-through', 'no-underline'],
|
|
119
|
-
'text-decoration-color' => ['/^decoration-(
|
|
117
|
+
'text-decoration-color' => ['/^decoration-(?!auto$|from-font$|\d+$|px$).+$/'],
|
|
120
118
|
'text-decoration-style' => ['/^decoration-(solid|double|dotted|dashed|wavy)$/'],
|
|
121
119
|
'text-decoration-thickness' => ['/^decoration-(auto|from-font|\d+|px|\[.+\])$/'],
|
|
122
120
|
'text-underline-offset' => ['/^underline-offset-(auto|\d+|px|\[.+\])$/'],
|
|
@@ -132,15 +130,15 @@ class TwMerge
|
|
|
132
130
|
// Backgrounds
|
|
133
131
|
'bg-attachment' => ['/^bg-(fixed|local|scroll)$/'],
|
|
134
132
|
'bg-clip' => ['/^bg-clip-(border|padding|content|text)$/'],
|
|
135
|
-
'bg-color' => ['/^bg-(
|
|
133
|
+
'bg-color' => ['/^bg-(?!fixed$|local$|scroll$|clip-|origin-|no-repeat$|repeat|auto$|cover$|contain$|none$|gradient-to-).+$/'],
|
|
136
134
|
'bg-origin' => ['/^bg-origin-(border|padding|content)$/'],
|
|
137
135
|
'bg-position' => ['/^bg-(bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top|\[.+\])$/'],
|
|
138
136
|
'bg-repeat' => ['/^bg-(no-repeat|repeat|repeat-x|repeat-y|repeat-round|repeat-space)$/'],
|
|
139
137
|
'bg-size' => ['/^bg-(auto|cover|contain|\[.+\])$/'],
|
|
140
138
|
'bg-image' => ['/^bg-(none|gradient-to-(t|tr|r|br|b|bl|l|tl)|\[.+\])$/'],
|
|
141
|
-
'gradient-from' => ['/^from
|
|
142
|
-
'gradient-via' => ['/^via
|
|
143
|
-
'gradient-to' => ['/^to
|
|
139
|
+
'gradient-from' => ['/^from-.+$/'],
|
|
140
|
+
'gradient-via' => ['/^via-.+$/'],
|
|
141
|
+
'gradient-to' => ['/^to-.+$/'],
|
|
144
142
|
|
|
145
143
|
// Borders
|
|
146
144
|
'rounded' => ['/^rounded(-(\w+))?(-(\d+(\.\d+)?|px|full|\[.+\]))?$/'],
|
|
@@ -242,6 +240,8 @@ class TwMerge
|
|
|
242
240
|
'mx' => ['mr', 'ml'],
|
|
243
241
|
'my' => ['mt', 'mb'],
|
|
244
242
|
'font-size' => ['line-height'],
|
|
243
|
+
'bg-color' => ['bg-color'],
|
|
244
|
+
'text-color' => ['text-color'],
|
|
245
245
|
'fvn-normal' => ['fvn-ordinal', 'fvn-slashed-zero', 'fvn-figure', 'fvn-spacing', 'fvn-fraction'],
|
|
246
246
|
'rounded' => ['rounded-s', 'rounded-e', 'rounded-t', 'rounded-r', 'rounded-b', 'rounded-l', 'rounded-ss', 'rounded-se', 'rounded-ee', 'rounded-es', 'rounded-tl', 'rounded-tr', 'rounded-br', 'rounded-bl'],
|
|
247
247
|
'rounded-s' => ['rounded-ss', 'rounded-es'],
|
|
@@ -269,12 +269,7 @@ class TwMerge
|
|
|
269
269
|
'scroll-py' => ['scroll-pt', 'scroll-pb'],
|
|
270
270
|
];
|
|
271
271
|
|
|
272
|
-
public static function merge(string ...$inputs): string
|
|
273
|
-
{
|
|
274
|
-
return self::twMerge(...$inputs);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public static function twMerge(string|array ...$inputs): string
|
|
272
|
+
public static function merge(string|array ...$inputs): string
|
|
278
273
|
{
|
|
279
274
|
$allClasses = [];
|
|
280
275
|
|
|
@@ -292,7 +287,6 @@ class TwMerge
|
|
|
292
287
|
|
|
293
288
|
private static function mergeClassList(array $classes): string
|
|
294
289
|
{
|
|
295
|
-
$classGroupsInConflict = [];
|
|
296
290
|
$result = [];
|
|
297
291
|
|
|
298
292
|
foreach ($classes as $originalClass) {
|
|
@@ -300,96 +294,53 @@ class TwMerge
|
|
|
300
294
|
continue;
|
|
301
295
|
}
|
|
302
296
|
|
|
303
|
-
$
|
|
304
|
-
$modifiers = $modifiersAndClass['modifiers'];
|
|
305
|
-
$baseClass = $modifiersAndClass['baseClass'];
|
|
306
|
-
$hasImportantModifier = $modifiersAndClass['hasImportantModifier'];
|
|
307
|
-
|
|
308
|
-
$classGroup = self::getClassGroup($baseClass);
|
|
309
|
-
if (!$classGroup) {
|
|
310
|
-
$result[] = $originalClass;
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
$variantModifier = implode(':', $modifiers);
|
|
315
|
-
$modifierId = $hasImportantModifier ? $variantModifier . self::IMPORTANT_MODIFIER : $variantModifier;
|
|
316
|
-
$classGroupId = $modifierId . ':' . $classGroup;
|
|
317
|
-
|
|
318
|
-
$conflictGroups = self::getConflictingClassGroups($classGroup);
|
|
297
|
+
$classKey = self::getClassGroup($originalClass);
|
|
319
298
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
unset($result[array_search($classGroupsInConflict[$groupId], $result)]);
|
|
324
|
-
}
|
|
325
|
-
unset($classGroupsInConflict[$groupId]);
|
|
299
|
+
$conflictingKeys = self::getConflictingKeys($classKey);
|
|
300
|
+
foreach ($conflictingKeys as $key) {
|
|
301
|
+
unset($result[$key]);
|
|
326
302
|
}
|
|
327
303
|
|
|
328
|
-
$
|
|
329
|
-
$result[] = $originalClass;
|
|
304
|
+
$result[$classKey] = $originalClass;
|
|
330
305
|
}
|
|
331
306
|
|
|
332
307
|
return implode(' ', array_values($result));
|
|
333
308
|
}
|
|
334
309
|
|
|
335
|
-
private static function
|
|
336
|
-
{
|
|
337
|
-
$modifiers = [];
|
|
338
|
-
$hasImportantModifier = false;
|
|
339
|
-
$baseClass = $className;
|
|
340
|
-
|
|
341
|
-
if (str_starts_with($className, '!')) {
|
|
342
|
-
$hasImportantModifier = true;
|
|
343
|
-
$baseClass = substr($className, 1);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
$parts = explode(':', $baseClass);
|
|
347
|
-
if (count($parts) > 1) {
|
|
348
|
-
$baseClass = array_pop($parts);
|
|
349
|
-
$modifiers = $parts;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return [
|
|
353
|
-
'modifiers' => $modifiers,
|
|
354
|
-
'baseClass' => $baseClass,
|
|
355
|
-
'hasImportantModifier' => $hasImportantModifier
|
|
356
|
-
];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
private static function getClassGroup(string $className): ?string
|
|
310
|
+
private static function getClassGroup(string $class): string
|
|
360
311
|
{
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if ($pattern
|
|
369
|
-
|
|
312
|
+
$pattern = '/^((?:[^:]+:)*)([^:]+)$/';
|
|
313
|
+
if (preg_match($pattern, $class, $matches)) {
|
|
314
|
+
$prefixes = $matches[1];
|
|
315
|
+
$utilityClass = $matches[2];
|
|
316
|
+
|
|
317
|
+
foreach (self::$classGroups as $groupKey => $patterns) {
|
|
318
|
+
foreach ($patterns as $pattern) {
|
|
319
|
+
if (is_string($pattern) && str_starts_with($pattern, '/')) {
|
|
320
|
+
if (preg_match($pattern, $utilityClass)) {
|
|
321
|
+
return $prefixes . $groupKey;
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
if ($pattern === $utilityClass) {
|
|
325
|
+
return $prefixes . $groupKey;
|
|
326
|
+
}
|
|
370
327
|
}
|
|
371
328
|
}
|
|
372
329
|
}
|
|
330
|
+
return $prefixes . $utilityClass;
|
|
373
331
|
}
|
|
374
|
-
return
|
|
332
|
+
return $class;
|
|
375
333
|
}
|
|
376
334
|
|
|
377
|
-
private static function
|
|
335
|
+
private static function getConflictingKeys(string $classKey): array
|
|
378
336
|
{
|
|
379
|
-
$
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
$allConflicts = array_merge($allConflicts, $nestedConflicts);
|
|
337
|
+
$baseClassKey = preg_replace("/^(?:[^:]+:)+/", "", $classKey);
|
|
338
|
+
if (isset(self::$conflictingClassGroups[$baseClassKey])) {
|
|
339
|
+
$prefix = preg_replace("/" . preg_quote($baseClassKey, "/") . '$/i', "", $classKey);
|
|
340
|
+
return array_map(function ($conflict) use ($prefix) {
|
|
341
|
+
return $prefix . $conflict;
|
|
342
|
+
}, self::$conflictingClassGroups[$baseClassKey]);
|
|
386
343
|
}
|
|
387
|
-
|
|
388
|
-
return array_unique($allConflicts);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
public static function mergeClasses(string|array ...$classes): string
|
|
392
|
-
{
|
|
393
|
-
return self::twMerge(...$classes);
|
|
344
|
+
return [$classKey];
|
|
394
345
|
}
|
|
395
346
|
}
|