From 1f1472460353d711a5db85a02c9ebc42d6a6dbad Mon Sep 17 00:00:00 2001 From: Thorsten Bus Date: Mon, 30 Mar 2026 08:00:17 +0200 Subject: [PATCH] fix(generator): uppercase UUIDs to match ProPresenter format --- php/src/ProFileGenerator.php | 40 ++++++++++++++++++++++++++++-- php/tests/ProFileGeneratorTest.php | 3 +++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/php/src/ProFileGenerator.php b/php/src/ProFileGenerator.php index a0b52f5..c31e27d 100644 --- a/php/src/ProFileGenerator.php +++ b/php/src/ProFileGenerator.php @@ -46,6 +46,7 @@ use Rv\Data\Slide; use Rv\Data\Slide\Element as SlideElement; use Rv\Data\Slide\Element\TextScroller; use Rv\Data\URL; +use Rv\Data\URL\LocalRelativePath; use Rv\Data\URL\Platform as UrlPlatform; use Rv\Data\UUID; use Rv\Data\Version; @@ -243,6 +244,7 @@ final class ProFileGenerator { $url = new URL(); $url->setAbsoluteString($absoluteUrl); + $url->setLocal(self::buildLocalRelativePath($absoluteUrl)); $url->setPlatform(UrlPlatform::PLATFORM_MACOS); $metadata = new Metadata(); @@ -533,6 +535,40 @@ RTF); return $message; } + private static function buildLocalRelativePath(string $absoluteUrl): LocalRelativePath + { + $path = $absoluteUrl; + if (str_starts_with($path, 'file:///')) { + $path = substr($path, 7); + } + + $rootMappings = [ + '/Downloads/' => LocalRelativePath\Root::ROOT_USER_DOWNLOADS, + '/Documents/' => LocalRelativePath\Root::ROOT_USER_DOCUMENTS, + '/Music/' => LocalRelativePath\Root::ROOT_USER_MUSIC, + '/Pictures/' => LocalRelativePath\Root::ROOT_USER_PICTURES, + '/Movies/' => LocalRelativePath\Root::ROOT_USER_VIDEOS, + '/Desktop/' => LocalRelativePath\Root::ROOT_USER_DESKTOP, + ]; + + $root = LocalRelativePath\Root::ROOT_BOOT_VOLUME; + $relativePath = ltrim($path, '/'); + + if (preg_match('#^/Users/[^/]+(/\w+/)(.+)$#', $path, $matches)) { + $dirSegment = $matches[1]; + if (isset($rootMappings[$dirSegment])) { + $root = $rootMappings[$dirSegment]; + $relativePath = $matches[2]; + } + } + + $local = new LocalRelativePath(); + $local->setRoot($root); + $local->setPath($relativePath); + + return $local; + } + private static function newUuidString(): string { $bytes = random_bytes(16); @@ -540,13 +576,13 @@ RTF); $bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80); $hex = bin2hex($bytes); - return sprintf( + return strtoupper(sprintf( '%s-%s-%s-%s-%s', substr($hex, 0, 8), substr($hex, 8, 4), substr($hex, 12, 4), substr($hex, 16, 4), substr($hex, 20, 12), - ); + )); } } diff --git a/php/tests/ProFileGeneratorTest.php b/php/tests/ProFileGeneratorTest.php index 0ad15a3..e4aa74c 100644 --- a/php/tests/ProFileGeneratorTest.php +++ b/php/tests/ProFileGeneratorTest.php @@ -66,6 +66,9 @@ class ProFileGeneratorTest extends TestCase $groups = $song->getGroupsForArrangement($arrangement); $this->assertCount(1, $groups); $this->assertSame('Verse 1', $groups[0]->getName()); + + // Verify UUID is uppercase + $this->assertMatchesRegularExpression('/^[A-F0-9]{8}-[A-F0-9]{4}-4[A-F0-9]{3}-[89AB][A-F0-9]{3}-[A-F0-9]{12}$/', $song->getUuid()); } #[Test]