create-prisma-php-app 3.1.11 → 4.0.0-alpha.2
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 +10 -10
- package/dist/index.js +12 -8
- package/dist/settings/restart-websocket.bat +1 -1
- package/dist/settings/restart-websocket.ts +2 -9
- package/dist/src/{Lib/Websocket → Websocket}/ConnectionManager.php +1 -1
- package/dist/src/app/error.php +1 -1
- package/dist/src/app/index.php +1 -1
- package/dist/src/app/js/index.js +1 -1
- package/dist/src/app/layout.php +2 -2
- package/dist/{src/Lib/Websocket/websocket-server.php → websocket-server.php} +2 -7
- package/package.json +1 -1
- package/dist/src/Lib/AI/ChatGPTClient.php +0 -147
- package/dist/src/Lib/Auth/Auth.php +0 -544
- package/dist/src/Lib/Auth/AuthConfig.php +0 -89
- package/dist/src/Lib/CacheHandler.php +0 -121
- package/dist/src/Lib/ErrorHandler.php +0 -322
- package/dist/src/Lib/FileManager/UploadFile.php +0 -383
- package/dist/src/Lib/Headers/Boom.php +0 -208
- package/dist/src/Lib/IncludeTracker.php +0 -59
- package/dist/src/Lib/MainLayout.php +0 -215
- package/dist/src/Lib/Middleware/AuthMiddleware.php +0 -154
- package/dist/src/Lib/PHPMailer/Mailer.php +0 -169
- package/dist/src/Lib/PHPX/Exceptions/ComponentValidationException.php +0 -49
- package/dist/src/Lib/PHPX/IPHPX.php +0 -22
- package/dist/src/Lib/PHPX/PHPX.php +0 -173
- package/dist/src/Lib/PHPX/TemplateCompiler.php +0 -571
- package/dist/src/Lib/PHPX/TwMerge.php +0 -195
- package/dist/src/Lib/PHPX/TypeCoercer.php +0 -490
- package/dist/src/Lib/PartialRenderer.php +0 -40
- package/dist/src/Lib/PrismaPHPSettings.php +0 -181
- package/dist/src/Lib/Request.php +0 -476
- package/dist/src/Lib/Set.php +0 -102
- package/dist/src/Lib/StateManager.php +0 -127
- package/dist/src/Lib/Validator.php +0 -738
package/dist/src/Lib/Set.php
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Lib;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @template T
|
|
9
|
-
*/
|
|
10
|
-
final class Set
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* @var array<string|int, T>
|
|
14
|
-
*/
|
|
15
|
-
private array $items = [];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Adds a value to the set.
|
|
19
|
-
*
|
|
20
|
-
* @param T $value The value to add.
|
|
21
|
-
* @return void
|
|
22
|
-
*/
|
|
23
|
-
public function add($value): void
|
|
24
|
-
{
|
|
25
|
-
$key = $this->getKey($value);
|
|
26
|
-
if (!isset($this->items[$key])) {
|
|
27
|
-
$this->items[$key] = $value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Checks whether the set contains a given value.
|
|
33
|
-
*
|
|
34
|
-
* @param T $value The value to check.
|
|
35
|
-
* @return bool True if the value exists in the set, false otherwise.
|
|
36
|
-
*/
|
|
37
|
-
public function has($value): bool
|
|
38
|
-
{
|
|
39
|
-
return isset($this->items[$this->getKey($value)]);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Removes a value from the set.
|
|
44
|
-
*
|
|
45
|
-
* @param T $value The value to remove.
|
|
46
|
-
* @return void
|
|
47
|
-
*/
|
|
48
|
-
public function delete($value): void
|
|
49
|
-
{
|
|
50
|
-
unset($this->items[$this->getKey($value)]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Clears all values from the set.
|
|
55
|
-
*
|
|
56
|
-
* @return void
|
|
57
|
-
*/
|
|
58
|
-
public function clear(): void
|
|
59
|
-
{
|
|
60
|
-
$this->items = [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Retrieves all values from the set, preserving insertion order.
|
|
65
|
-
*
|
|
66
|
-
* @return T[]
|
|
67
|
-
*/
|
|
68
|
-
public function values(): array
|
|
69
|
-
{
|
|
70
|
-
return array_values($this->items);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Returns the number of values in the set.
|
|
75
|
-
*
|
|
76
|
-
* @return int The size of the set.
|
|
77
|
-
*/
|
|
78
|
-
public function size(): int
|
|
79
|
-
{
|
|
80
|
-
return count($this->items);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Generates a unique key for the given value.
|
|
85
|
-
*
|
|
86
|
-
* - For objects, it uses spl_object_id.
|
|
87
|
-
* - For arrays, it uses md5(serialize($value)) to create a unique string.
|
|
88
|
-
* - For other types (scalars), the value itself is used as the key.
|
|
89
|
-
*
|
|
90
|
-
* @param T $value The value for which to generate a key.
|
|
91
|
-
* @return string|int The unique key.
|
|
92
|
-
*/
|
|
93
|
-
private function getKey($value): string|int
|
|
94
|
-
{
|
|
95
|
-
if (is_object($value)) {
|
|
96
|
-
return spl_object_id($value);
|
|
97
|
-
} elseif (is_array($value)) {
|
|
98
|
-
return md5(serialize($value));
|
|
99
|
-
}
|
|
100
|
-
return $value;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Lib;
|
|
6
|
-
|
|
7
|
-
use Lib\Request;
|
|
8
|
-
|
|
9
|
-
class StateManager
|
|
10
|
-
{
|
|
11
|
-
private const APP_STATE = 'app_state_F989A';
|
|
12
|
-
private static array $state = [];
|
|
13
|
-
private static array $listeners = [];
|
|
14
|
-
|
|
15
|
-
public static function init(): void
|
|
16
|
-
{
|
|
17
|
-
self::loadState();
|
|
18
|
-
|
|
19
|
-
if (!Request::$isWire) {
|
|
20
|
-
self::resetState();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Gets the state value for the specified key.
|
|
26
|
-
*
|
|
27
|
-
* @param string|null $key The key of the state value to get.
|
|
28
|
-
* @param mixed $initialValue The initial value to set if the key does not exist.
|
|
29
|
-
* @return mixed The state value for the specified key.
|
|
30
|
-
*/
|
|
31
|
-
public static function getState(?string $key = null, mixed $initialValue = null): mixed
|
|
32
|
-
{
|
|
33
|
-
if ($key === null) {
|
|
34
|
-
return new \ArrayObject(self::$state, \ArrayObject::ARRAY_AS_PROPS);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
$value = self::$state[$key] ?? $initialValue;
|
|
38
|
-
|
|
39
|
-
return is_array($value) ? new \ArrayObject($value, \ArrayObject::ARRAY_AS_PROPS) : $value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Sets the state value for the specified key.
|
|
44
|
-
*
|
|
45
|
-
* @param string $key The key of the state value to set.
|
|
46
|
-
* @param mixed $value The value to set.
|
|
47
|
-
*/
|
|
48
|
-
public static function setState(string $key, mixed $value = null): void
|
|
49
|
-
{
|
|
50
|
-
if (array_key_exists($key, $GLOBALS)) {
|
|
51
|
-
$GLOBALS[$key] = $value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
self::$state[$key] = $value;
|
|
55
|
-
|
|
56
|
-
self::notifyListeners();
|
|
57
|
-
self::saveState();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Subscribes a listener to state changes.
|
|
62
|
-
*
|
|
63
|
-
* @param callable $listener The listener function to subscribe.
|
|
64
|
-
* @return callable A function that can be called to unsubscribe the listener.
|
|
65
|
-
*/
|
|
66
|
-
public static function subscribe(callable $listener): callable
|
|
67
|
-
{
|
|
68
|
-
self::$listeners[] = $listener;
|
|
69
|
-
$listener(self::$state);
|
|
70
|
-
return fn() => self::$listeners = array_filter(self::$listeners, fn($l) => $l !== $listener);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Saves the current state to storage.
|
|
75
|
-
*/
|
|
76
|
-
private static function saveState(): void
|
|
77
|
-
{
|
|
78
|
-
$_SESSION[self::APP_STATE] = json_encode(self::$state, JSON_THROW_ON_ERROR);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Loads the state from storage, if available.
|
|
83
|
-
*/
|
|
84
|
-
public static function loadState(): void
|
|
85
|
-
{
|
|
86
|
-
if (isset($_SESSION[self::APP_STATE])) {
|
|
87
|
-
$loadedState = json_decode($_SESSION[self::APP_STATE], true, 512, JSON_THROW_ON_ERROR);
|
|
88
|
-
if (is_array($loadedState)) {
|
|
89
|
-
self::$state = $loadedState;
|
|
90
|
-
self::notifyListeners();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Resets the application state to an empty array.
|
|
97
|
-
*
|
|
98
|
-
* @param string|null $key The key of the state value to reset.
|
|
99
|
-
*/
|
|
100
|
-
public static function resetState(?string $key = null): void
|
|
101
|
-
{
|
|
102
|
-
if ($key !== null) {
|
|
103
|
-
if (array_key_exists($key, self::$state)) {
|
|
104
|
-
self::$state[$key] = null;
|
|
105
|
-
|
|
106
|
-
if (array_key_exists($key, $GLOBALS)) {
|
|
107
|
-
$GLOBALS[$key] = null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
self::$state = [];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
self::notifyListeners();
|
|
115
|
-
self::saveState();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Notifies all listeners of state changes.
|
|
120
|
-
*/
|
|
121
|
-
private static function notifyListeners(): void
|
|
122
|
-
{
|
|
123
|
-
foreach (self::$listeners as $listener) {
|
|
124
|
-
$listener(self::$state);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|