#!/bin/bash

# This script creates a CDN-ready version of the SDK

# Ensure we're in the SDK directory
cd "$(dirname "$0")"

# Create a dist-cdn directory
mkdir -p dist-cdn

# Build the SDK
echo "Building the SDK..."
npm run build

# Copy the browser-compatible version
cp ../test-app/sdk-dist/realtimecursor-browser.js dist-cdn/realtimecursor.min.js
cp ../test-app/sdk-dist/cursor.css dist-cdn/realtimecursor.min.css

# Create a version with the version number
VERSION=$(node -p "require('./package.json').version")
cp dist-cdn/realtimecursor.min.js "dist-cdn/realtimecursor-$VERSION.min.js"
cp dist-cdn/realtimecursor.min.css "dist-cdn/realtimecursor-$VERSION.min.css"

echo "Done! CDN-ready files created in dist-cdn/"