#!/bin/bash # Build script for FileBrowser Widget # This script creates a unified distribution in dist/ that works for both: # 1. NPM distribution (includes package.json, TypeScript definitions, README) # 2. Direct embedding (includes bundled Uppy.js dependencies) set -e echo "๐Ÿ”ง Building FileBrowser Widget..." # Clean previous builds echo "๐Ÿงน Cleaning previous builds..." rm -rf dist/ # Build with wasm-pack directly to dist directory echo "๐Ÿ“ฆ Building WASM package directly to dist/..." wasm-pack build --target web --out-dir dist --release # Download and bundle Uppy.js dependencies for self-contained use echo "๐Ÿ“ฆ Downloading Uppy.js dependencies..." curl -s "https://releases.transloadit.com/uppy/v3.25.4/uppy.min.js" -o dist/uppy.min.js curl -s "https://releases.transloadit.com/uppy/v3.25.4/uppy.min.css" -o dist/uppy.min.css # Verify files were downloaded correctly if [ -s dist/uppy.min.js ] && [ -s dist/uppy.min.css ]; then echo "โœ… Uppy.js bundled successfully ($(wc -c < dist/uppy.min.js) bytes JS, $(wc -c < dist/uppy.min.css) bytes CSS)" else echo "โŒ Failed to download Uppy.js files" exit 1 fi echo "โœ… Build complete!" echo "" echo "๐Ÿ“ฆ Unified distribution created in dist/ with:" echo " ๐Ÿ”น NPM support: package.json, TypeScript definitions, README" echo " ๐Ÿ”น Direct embedding: bundled Uppy.js dependencies" echo " ๐Ÿ”น Self-contained: no external dependencies required" echo "" echo "๐ŸŒ Use 'cargo run --example server' to test the widget" echo "๐Ÿ“ฆ Use 'npm publish dist/' to publish to npm" echo "" echo "๐ŸŽฏ All widget files ready in dist/ directory:" echo " - file_browser_widget.js ($(wc -c < dist/file_browser_widget.js 2>/dev/null || echo '0') bytes)" echo " - file_browser_widget_bg.wasm ($(wc -c < dist/file_browser_widget_bg.wasm 2>/dev/null || echo '0') bytes)" echo " - uppy.min.js ($(wc -c < dist/uppy.min.js 2>/dev/null || echo '0') bytes)" echo " - uppy.min.css ($(wc -c < dist/uppy.min.css 2>/dev/null || echo '0') bytes)" echo " - package.json, *.d.ts, README.md (npm metadata)"