create-prisma-php-app 3.4.4 → 3.4.5

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.
@@ -20,6 +20,8 @@ class MainLayout
20
20
  private static ?Set $footerScripts = null;
21
21
  private static array $customMetadata = [];
22
22
 
23
+ private static array $processedScripts = [];
24
+
23
25
  public static function init(): void
24
26
  {
25
27
  if (self::$headScripts === null) {
@@ -28,6 +30,7 @@ class MainLayout
28
30
  if (self::$footerScripts === null) {
29
31
  self::$footerScripts = new Set();
30
32
  }
33
+ self::$processedScripts = [];
31
34
  }
32
35
 
33
36
  /**
@@ -55,11 +58,19 @@ class MainLayout
55
58
  $callerClass = $trace[1]['class'] ?? 'Unknown';
56
59
 
57
60
  foreach ($scripts as $script) {
61
+ $scriptKey = md5(trim($script));
62
+
58
63
  if (strpos($script, '<script') !== false) {
59
64
  $taggedScript = "<!-- class:" . $callerClass . " -->\n" . $script;
60
- self::$footerScripts->add($taggedScript);
65
+ if (!isset(self::$processedScripts[$scriptKey])) {
66
+ self::$footerScripts->add($taggedScript);
67
+ self::$processedScripts[$scriptKey] = true;
68
+ }
61
69
  } else {
62
- self::$footerScripts->add($script);
70
+ if (!isset(self::$processedScripts[$scriptKey])) {
71
+ self::$footerScripts->add($script);
72
+ self::$processedScripts[$scriptKey] = true;
73
+ }
63
74
  }
64
75
  }
65
76
  }
@@ -97,6 +108,7 @@ class MainLayout
97
108
  public static function outputFooterScripts(): string
98
109
  {
99
110
  $processed = [];
111
+ $componentCounter = 0;
100
112
 
101
113
  foreach (self::$footerScripts->values() as $script) {
102
114
  if (preg_match('/<!-- class:([^\s]+) -->/', $script, $matches)) {
@@ -106,9 +118,11 @@ class MainLayout
106
118
  if (str_starts_with(trim($script), '<script')) {
107
119
  $script = preg_replace_callback(
108
120
  '/<script\b([^>]*)>/i',
109
- function ($m) use ($rawClassName) {
121
+ function ($m) use ($rawClassName, &$componentCounter) {
110
122
  $attrs = $m[1];
111
- $encodedClass = 's' . base_convert(sprintf('%u', crc32($rawClassName)), 10, 36);
123
+ $scriptHash = substr(md5($m[0]), 0, 8);
124
+ $encodedClass = 's' . base_convert(sprintf('%u', crc32($rawClassName . $componentCounter . $scriptHash)), 10, 36);
125
+ $componentCounter++;
112
126
 
113
127
  if (!str_contains($attrs, 'pp-component=')) {
114
128
  $attrs .= " pp-component=\"{$encodedClass}\"";
@@ -150,6 +164,7 @@ class MainLayout
150
164
  public static function clearFooterScripts(): void
151
165
  {
152
166
  self::$footerScripts->clear();
167
+ self::$processedScripts = [];
153
168
  }
154
169
 
155
170
  /**
@@ -118,9 +118,7 @@ class PHPX implements IPHPX
118
118
  array_flip(array_merge($reserved, $exclude))
119
119
  );
120
120
 
121
- foreach ($params as $k => $v) {
122
- $props[$k] = $v;
123
- }
121
+ $props = array_merge($params, $props);
124
122
 
125
123
  $pairs = array_map(
126
124
  static fn($k, $v) => sprintf(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",