create-prisma-php-app 2.2.0 → 2.2.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.
@@ -106,6 +106,7 @@ class MainLayout
106
106
  if (str_starts_with(trim($script), '<script')) {
107
107
  $script = preg_replace_callback('/<script\b([^>]*)>/i', function ($m) use ($className) {
108
108
  $attrs = $m[1];
109
+ $className = base64_encode($className);
109
110
 
110
111
  if (!str_contains($attrs, 'pp-sync-script=')) {
111
112
  $attrs .= " pp-sync-script=\"{$className}\"";
@@ -225,9 +225,18 @@ class TemplateCompiler
225
225
  );
226
226
  }
227
227
 
228
- protected static function processNode(DOMNode $node): string
228
+ protected static function processNode(DOMNode $node, bool $inBody = false): string
229
229
  {
230
230
  if ($node instanceof DOMElement) {
231
+ $tag = strtolower($node->nodeName);
232
+ $currentInBody = ($tag === 'body') ? true : $inBody;
233
+
234
+ if ($tag === 'script' && $inBody) {
235
+ if (strtolower($node->getAttribute('type')) !== 'module') {
236
+ $node->setAttribute('type', 'module');
237
+ }
238
+ }
239
+
231
240
  $componentName = $node->nodeName;
232
241
  $attributes = [];
233
242
  foreach ($node->attributes as $attr) {
@@ -239,7 +248,7 @@ class TemplateCompiler
239
248
 
240
249
  $childOutput = [];
241
250
  foreach ($node->childNodes as $child) {
242
- $childOutput[] = self::processNode($child);
251
+ $childOutput[] = self::processNode($child, $currentInBody);
243
252
  }
244
253
  $componentInstance->children = implode('', $childOutput);
245
254
 
@@ -251,7 +260,7 @@ class TemplateCompiler
251
260
  } else {
252
261
  $childOutput = [];
253
262
  foreach ($node->childNodes as $child) {
254
- $childOutput[] = self::processNode($child);
263
+ $childOutput[] = self::processNode($child, $currentInBody);
255
264
  }
256
265
  $attributes['children'] = implode('', $childOutput);
257
266
  return self::renderAsHtml($componentName, $attributes);
@@ -308,7 +317,7 @@ class TemplateCompiler
308
317
  throw new RuntimeException("Class {$className} does not exist.");
309
318
  }
310
319
 
311
- $attributes['pp-sync-script'] = $className;
320
+ $attributes['pp-sync-script'] = base64_encode($className);
312
321
  return new $className($attributes);
313
322
  }
314
323
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",