Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/hub/scripts/build-xet-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,31 @@ if [[ -n "$OUTPUT_DIR" ]]; then
log "Output copied to: $OUTPUT_DIR"
fi

# Detect operating system for base64 command compatibility
OS=$(uname)
if [[ "$OS" == "Darwin" ]]; then
BASE64_CMD="base64 -i"
log "Detected macOS - using base64 -i flag"
else
BASE64_CMD="base64"
log "Detected Linux/Unix - using standard base64"
fi

# copy the generated hf_xet_thin_wasm_bg.js to the hub package and hf_xet_thin_wasm_bg.wasm to the hub package
cp "$CLONE_DIR/$PACKAGE/pkg/hf_xet_thin_wasm_bg.js" "./src/vendor/xet-chunk/chunker_wasm_bg.js"
cp "$CLONE_DIR/$PACKAGE/pkg/hf_xet_thin_wasm_bg.wasm.d.ts" "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.d.ts"
cat << 'EOF' > "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.base64.ts"
cat << EOF > "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.base64.ts"
// Generated by build-xet-wasm.sh
// Repository: $REPO_URL
// Branch: $BRANCH
// Package: $PACKAGE
// JS Target: $JS_TARGET
// Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")

export const wasmBase64 = atob(
`
\`
EOF
base64 "$CLONE_DIR/$PACKAGE/pkg/hf_xet_thin_wasm_bg.wasm" | fold -w 100 >> "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.base64.ts"
$BASE64_CMD "$CLONE_DIR/$PACKAGE/pkg/hf_xet_thin_wasm_bg.wasm" | fold -w 100 >> "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.base64.ts"
cat << 'EOF' >> "./src/vendor/xet-chunk/chunker_wasm_bg.wasm.base64.ts"
`
.trim()
Expand Down
Loading
Loading