|
| 1 | +# Changelog |
| 2 | + |
| 3 | +## [1.4.33-1] - 2025-10-28 |
| 4 | + |
| 5 | +### Added |
| 6 | + |
| 7 | +#### Custom Script URL Support |
| 8 | + |
| 9 | +- **New `sdkUrl` prop**: Added ability to specify a custom URL for the Unicorn Studio SDK script |
| 10 | + - Allows loading the SDK from custom CDNs or self-hosted locations |
| 11 | + - Defaults to the official Unicorn Studio CDN URL if not specified |
| 12 | + - Available for both React and Next.js components |
| 13 | + |
| 14 | +### Usage Example |
| 15 | + |
| 16 | +```tsx |
| 17 | +<UnicornScene |
| 18 | + projectId="YOUR_PROJECT_EMBED_ID" |
| 19 | + sdkUrl="https://your-custom-cdn.com/unicornStudio.umd.js" |
| 20 | + width={800} |
| 21 | + height={600} |
| 22 | +/> |
| 23 | +``` |
| 24 | + |
| 25 | +### Technical Details |
| 26 | + |
| 27 | +- Modified both React and Next.js components to accept the new `sdkUrl` prop |
| 28 | +- Updated TypeScript definitions to include the optional `sdkUrl` property |
| 29 | +- Maintains backward compatibility with existing implementations |
| 30 | + |
| 31 | +### Contributors |
| 32 | + |
| 33 | +- @schellenbergk - Added custom script URL support |
| 34 | + |
| 35 | +### Note |
| 36 | + |
| 37 | +Using a custom script URL may violate Unicorn.Studio's Terms of Service. Please consult their legal terms before implementing this feature. |
| 38 | + |
| 39 | +## [1.4.29-1] - 2025-08-15 |
| 40 | + |
| 41 | +### Fixed |
| 42 | + |
| 43 | +#### Next.js App Router Compatibility |
| 44 | + |
| 45 | +- **Prevented duplicate script initialization**: Modified `useUnicornStudioScript` hook to check if UnicornStudio is already loaded before setting the loaded state, preventing duplicate triggers in Next.js App Router environments |
| 46 | +- **Added mount-time script detection**: Added `useEffect` hook to detect if UnicornStudio is already available when the component mounts, ensuring proper initialization in server-side rendered contexts |
| 47 | +- **Improved error handling**: Updated error handler to properly reset the `isLoaded` state when script loading fails |
| 48 | + |
| 49 | +#### Scene Initialization Improvements |
| 50 | + |
| 51 | +- **Prevented concurrent initializations**: Added `isInitializingRef` flag to prevent multiple simultaneous scene initialization attempts, which could occur during React's strict mode or rapid re-renders |
| 52 | +- **Optimized re-initialization logic**: Improved detection of already initialized scenes with the same configuration to avoid unnecessary re-initializations |
| 53 | +- **Better cleanup handling**: Separated cleanup logic into its own `useEffect` to ensure proper resource management on component unmount |
| 54 | +- **Fixed initialization key reset**: Added proper reset of initialization key when projectId or jsonFilePath changes, allowing fresh initialization with new parameters |
| 55 | + |
| 56 | +### Internal |
| 57 | + |
| 58 | +- Removed debug console.log statements |
| 59 | +- Updated package version to include hotfix suffix (-1) |
| 60 | + |
| 61 | +### Technical Details |
| 62 | + |
| 63 | +This hotfix addresses critical issues that were affecting the library's compatibility with Next.js App Router, particularly in scenarios involving: |
| 64 | + |
| 65 | +- Server-side rendering (SSR) |
| 66 | +- React Strict Mode |
| 67 | +- Component remounting and hot module replacement (HMR) |
| 68 | +- Rapid prop changes |
| 69 | + |
| 70 | +The changes ensure more robust initialization and cleanup processes, preventing memory leaks and duplicate scene instances. |
0 commit comments