Files
filebrowser/http/craft_bridge.go
T

42 lines
1.1 KiB
Go

package fbhttp
import (
_ "embed"
"strconv"
"strings"
"github.com/filebrowser/filebrowser/v2/internal/addons"
)
//go:embed craft_bridge.js
var officeBridge []byte
//go:embed craft_picker.js
var craftPicker []byte
//go:embed deckcraft_compat.js
var deckcraftCompat []byte
// Archive digest prefix produced by the checksum-verified installer. The JS shim
// independently verifies the full WASM digest before accessing its memory layout.
func deckcraftNeedsCompat(id, build string) bool {
return id == "deckcraft" && build == "v0.9.0-38076027b9c1"
}
func needsOfficeBridge(id string, build ...string) bool {
// WordCraft 0.14 added the official parent protocol. Injecting the drop
// adapter too announces readiness before Rust is listening and loses the file.
if id == "wordcraft" && len(build) > 0 {
parts := strings.Split(strings.TrimPrefix(build[0], "v"), ".")
if len(parts) >= 2 {
major, _ := strconv.Atoi(parts[0])
minor, _ := strconv.Atoi(parts[1])
if major > 0 || minor >= 14 {
return false
}
}
}
tool, ok := addons.Find(id)
return ok && tool.Bridge == "drop"
}