Files
RedLintu16andClaude Opus 5.5 b67b29b40b CrossSound desktop with the DRM stubbed out
A single-commit snapshot of better-remote (7a8c4cb plus the uncommitted
remote.js work), with every DRM-bearing piece replaced by a stub that keeps
the same interface:

- src/ui/drm.js: no DRM pipelines; needsDrm/isDrmUrl false,
  bestEncryptedTranscoding null, playDrmAudio rejects. The engine switcher
  and drmVjs* helpers stay as no-ops.
- src/electron/drm.ts: initCdm/setupLicenseCors no-ops; the drm:license and
  api:stream:drm-info IPC handlers reject with "DRM is not available".
- src/api/soundcloud.ts: resolveEncryptedStream keeps its signature, rejects.
- src/electron/main.ts: license host dropped from the header rewrite.
- src/ui/pb-lease.js: the expiry self-check uses a placeholder URL instead
  of a captured DRM manifest URL (same policy values, still passes).
- scripts/vmp-sign.js, forge.config.js vmpSign: Widevine signing skipped,
  so no castLabs EVS account is needed to run or package.
- README: says DRM is stubbed here.

Go+ tracks SoundCloud only serves encrypted are unplayable and skipped;
previews and everything else play as before. No history: the private
branches' DRM code is not reachable from this commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-14 10:06:08 -07:00

120 lines
4.5 KiB
JavaScript
Executable File

'use strict'
// CrossSound — Stream Deck plugin auto-installer.
//
// A Stream Deck plugin's lifecycle is owned by Elgato's Stream Deck software
// (it spawns bin/plugin.js with the WebSocket registration args), NOT by us —
// so CrossSound can't "launch" the plugin directly. What we CAN do is drop the
// bundled .sdPlugin into Elgato's Plugins folder on startup; Stream Deck then
// auto-detects it and runs it, and it connects to the bridge CrossSound already
// serves on 127.0.0.1:52124 (see streamdeck.js). Net effect: open CrossSound →
// the plugin is present and live in Stream Deck, no manual install.
//
// No-ops cleanly if Stream Deck isn't installed. Idempotent: only copies when
// the bundled plugin's manifest Version differs from the installed one.
const fs = require('fs')
const os = require('os')
const path = require('path')
const PLUGIN_ID = 'com.redlintu16.crosssound.sdPlugin'
// Elgato's per-user Plugins directory (Stream Deck is Windows/macOS only).
function pluginsDir() {
if (process.platform === 'win32') {
return process.env.APPDATA
? path.join(process.env.APPDATA, 'Elgato', 'StreamDeck', 'Plugins')
: null
}
if (process.platform === 'darwin') {
return path.join(os.homedir(), 'Library', 'Application Support', 'com.elgato.StreamDeck', 'Plugins')
}
return null
}
// Where the bundled plugin lives: unpacked next to the app resources when
// packaged (forge `extraResource`), or the repo's streamdeck-plugin/ in dev.
function sourceDir(isPackaged) {
return isPackaged
? path.join(process.resourcesPath, PLUGIN_ID)
: path.join(__dirname, '..', 'streamdeck-plugin', PLUGIN_ID)
}
function manifestVersion(dir) {
try {
return JSON.parse(fs.readFileSync(path.join(dir, 'manifest.json'), 'utf8')).Version || ''
} catch {
return ''
}
}
function copyDir(src, dst) {
fs.mkdirSync(dst, { recursive: true })
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
const s = path.join(src, entry.name)
const d = path.join(dst, entry.name)
if (entry.isDirectory()) copyDir(s, d)
else fs.copyFileSync(s, d)
}
}
// Copy the bundled plugin into Elgato's Plugins folder if missing/outdated.
// Best-effort: any failure (Stream Deck not installed, files locked because the
// plugin is currently running, permissions) is swallowed — the plugin either
// keeps its existing copy or simply isn't installed, and CrossSound runs fine.
function ensureInstalled(isPackaged) {
try {
const base = pluginsDir()
if (!base || !fs.existsSync(base)) return // Stream Deck not installed → nothing to do
const src = sourceDir(isPackaged)
if (!fs.existsSync(src)) {
console.warn('[streamdeck] bundled plugin not found at', src)
return
}
// Never install an UN-BUILT plugin — one missing the compiled CodePath
// (bin/plugin.js) is one Stream Deck "can't find". Build it first
// (npm run build in streamdeck-plugin/).
if (!fs.existsSync(path.join(src, 'bin', 'plugin.js'))) {
console.warn('[streamdeck] source plugin not built (no bin/plugin.js) — skipping install')
return
}
const dst = path.join(base, PLUGIN_ID)
const srcVer = manifestVersion(src)
const dstVer = fs.existsSync(dst) ? manifestVersion(dst) : ''
// Re-copy on a version change OR if the installed copy is incomplete (a prior
// copy of an un-built plugin, missing bin/plugin.js).
const dstComplete = fs.existsSync(path.join(dst, 'bin', 'plugin.js'))
if (dstVer && dstVer === srcVer && dstComplete) return // up to date & complete
copyDir(src, dst)
console.log(`[streamdeck] plugin ${dstVer ? `updated ${dstVer} -> ${srcVer}` : `installed ${srcVer}`} at ${dst}`)
} catch (e) {
// Most common: EBUSY/EPERM when Stream Deck holds the running plugin's files.
// Harmless — it'll update on a future launch when the files are free.
console.warn('[streamdeck] plugin auto-install skipped:', e.message)
}
}
// Remove the plugin from Elgato's Plugins folder (the Settings "remove" action).
// Returns true if the folder is now absent (removed or never there).
function uninstall() {
try {
const base = pluginsDir()
if (!base) return false
const dst = path.join(base, PLUGIN_ID)
if (fs.existsSync(dst)) {
fs.rmSync(dst, { recursive: true, force: true })
console.log('[streamdeck] plugin removed from', dst)
}
return true
} catch (e) {
console.warn('[streamdeck] plugin removal failed:', e.message)
return false
}
}
module.exports = { ensureInstalled, uninstall }