107 lines
2.5 KiB
JavaScript
107 lines
2.5 KiB
JavaScript
/**
|
|
* Canonical PearData binary host list (64-bit only — no ia32 / armv7).
|
|
* Used by make scripts, predownload-electron, and release tooling.
|
|
*/
|
|
'use strict'
|
|
|
|
/** @type {readonly string[]} */
|
|
const SERVER_LINUX = Object.freeze(['linux-x64', 'linux-arm64'])
|
|
|
|
/** @type {readonly string[]} */
|
|
const ALL_64 = Object.freeze([
|
|
'linux-x64',
|
|
'linux-arm64',
|
|
'darwin-x64',
|
|
'darwin-arm64',
|
|
'win32-x64',
|
|
'win32-arm64',
|
|
])
|
|
|
|
/**
|
|
* Hosts where `@qvac/llm-llamacpp` (and related) ship Bare prebuilds.
|
|
* Matches prebuilds under node_modules/@qvac/llm-llamacpp/prebuilds.
|
|
* win32-arm64 is intentionally absent — QVAC Windows is x64-only today.
|
|
*
|
|
* @see https://docs.qvac.tether.io/installation (Windows: x64)
|
|
* @type {readonly string[]}
|
|
*/
|
|
const QVAC_NATIVE_HOSTS = Object.freeze([
|
|
'linux-x64',
|
|
'linux-arm64',
|
|
'darwin-x64',
|
|
'darwin-arm64',
|
|
'win32-x64',
|
|
])
|
|
|
|
/**
|
|
* @param {string} host e.g. win32-arm64
|
|
* @returns {boolean}
|
|
*/
|
|
function hostSupportsQvacNative(host) {
|
|
return QVAC_NATIVE_HOSTS.includes(host)
|
|
}
|
|
|
|
/**
|
|
* @param {string|undefined} envVal comma-separated override
|
|
* @param {readonly string[]} fallback
|
|
*/
|
|
function parseHostList(envVal, fallback = ALL_64) {
|
|
if (!envVal || !String(envVal).trim()) return [...fallback]
|
|
return String(envVal)
|
|
.split(',')
|
|
.map((s) => s.trim())
|
|
.filter(Boolean)
|
|
}
|
|
|
|
/**
|
|
* electron-forge platform/arch for a host triple
|
|
* @param {string} host
|
|
* @returns {{ platform: string, arch: string }}
|
|
*/
|
|
function hostToElectron(host) {
|
|
const [platform, arch] = host.split('-')
|
|
if (!platform || !arch) throw new Error(`Invalid host: ${host}`)
|
|
return { platform, arch }
|
|
}
|
|
|
|
/**
|
|
* npm script name for client package, or null
|
|
* @param {string} host
|
|
*/
|
|
function clientNpmScript(host) {
|
|
const map = {
|
|
'linux-x64': 'make:client:linux-x64',
|
|
'linux-arm64': 'make:client:linux-arm64',
|
|
'darwin-arm64': 'make:client:darwin-arm64',
|
|
'darwin-x64': 'make:client:darwin-x64',
|
|
'win32-x64': 'make:client:win32-x64',
|
|
'win32-arm64': 'make:client:win32-arm64',
|
|
}
|
|
return map[host] || null
|
|
}
|
|
|
|
/**
|
|
* npm script name for server package, or null
|
|
* @param {string} host
|
|
*/
|
|
function serverNpmScript(host) {
|
|
// Server is Linux-only
|
|
const map = {
|
|
'linux-x64': 'make:server:linux-x64',
|
|
'linux-arm64': 'make:server:linux-arm64',
|
|
}
|
|
return map[host] || null
|
|
}
|
|
|
|
module.exports = {
|
|
SERVER_LINUX,
|
|
ALL_64,
|
|
CLIENT_HOSTS: ALL_64,
|
|
QVAC_NATIVE_HOSTS,
|
|
hostSupportsQvacNative,
|
|
parseHostList,
|
|
hostToElectron,
|
|
clientNpmScript,
|
|
serverNpmScript,
|
|
}
|