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

95 lines
4.2 KiB
Swift
Executable File

// Renders the macOS app-icon .iconset from icons/CrossSound.svg: the mark in white
// on a rounded tile of the SVG's own colour, laid out on Apple's icon grid (an
// 824px body centred in a 1024px canvas, room for the drop shadow) so it sits the
// same size as every other Dock icon. Each size is drawn from the vector, so the
// small ones stay sharp. Called by scripts/gen-icns.js — run that, not this.
import AppKit
let args = CommandLine.arguments
guard args.count == 3 else {
FileHandle.standardError.write("usage: swift gen-icns.swift <icon.svg> <out.iconset>\n".data(using: .utf8)!)
exit(2)
}
let svgPath = args[1], outDir = args[2]
// Tile colour = the mark's own fill in the SVG; the mark itself is redrawn white.
var svg = try String(contentsOfFile: svgPath, encoding: .utf8)
let fillRe = try NSRegularExpression(pattern: ##"fill="#([0-9A-Fa-f]{6})""##)
let whole = NSRange(svg.startIndex..., in: svg)
guard let m = fillRe.firstMatch(in: svg, range: whole), let hexRange = Range(m.range(at: 1), in: svg),
let rgb = Int(svg[hexRange], radix: 16) else {
FileHandle.standardError.write("[gen-icns] no fill=\"#rrggbb\" in \(svgPath)\n".data(using: .utf8)!)
exit(1)
}
let tile = CGColor(srgbRed: CGFloat((rgb >> 16) & 0xFF) / 255, green: CGFloat((rgb >> 8) & 0xFF) / 255,
blue: CGFloat(rgb & 0xFF) / 255, alpha: 1)
svg = fillRe.stringByReplacingMatches(in: svg, range: whole, withTemplate: ##"fill="#FFFFFF""##)
guard let mark = NSImage(data: Data(svg.utf8)) else {
FileHandle.standardError.write("[gen-icns] could not load \(svgPath)\n".data(using: .utf8)!)
exit(1)
}
// Layout, in 1024-canvas units.
let canvas: CGFloat = 1024
let body: CGFloat = 824 // Apple's macOS icon body size
let markWidth = body * 0.70 // mark spans 70% of the tile, like the old PNG art
// Apple's icon shape is a continuous-corner "squircle"; a superellipse with n = 5
// matches it closely.
func squircle(in r: CGRect, n: CGFloat = 5, steps: Int = 720) -> CGPath {
let p = CGMutablePath()
let a = r.width / 2, b = r.height / 2
for i in 0..<steps {
let t = CGFloat(i) / CGFloat(steps) * 2 * .pi
let c = cos(t), s = sin(t)
let x = r.midX + a * (c < 0 ? -1 : 1) * pow(abs(c), 2 / n)
let y = r.midY + b * (s < 0 ? -1 : 1) * pow(abs(s), 2 / n)
i == 0 ? p.move(to: CGPoint(x: x, y: y)) : p.addLine(to: CGPoint(x: x, y: y))
}
p.closeSubpath()
return p
}
func render(_ px: Int) -> Data {
let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: px, pixelsHigh: px, bitsPerSample: 8,
samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!
rep.size = NSSize(width: px, height: px)
NSGraphicsContext.saveGraphicsState()
defer { NSGraphicsContext.restoreGraphicsState() }
let gc = NSGraphicsContext(bitmapImageRep: rep)!
NSGraphicsContext.current = gc
let ctx = gc.cgContext
let k = CGFloat(px) / canvas
ctx.scaleBy(x: k, y: k)
// Tile with a soft drop shadow (shadow offset/blur are in device pixels, not
// affected by the scale above, hence the * k).
ctx.saveGState()
ctx.setShadow(offset: CGSize(width: 0, height: -10 * k), blur: 20 * k,
color: CGColor(gray: 0, alpha: 0.3))
ctx.addPath(squircle(in: CGRect(x: (canvas - body) / 2, y: (canvas - body) / 2, width: body, height: body)))
ctx.setFillColor(tile)
ctx.fillPath()
ctx.restoreGState()
// Mark, centred.
let markHeight = markWidth * mark.size.height / mark.size.width
mark.draw(in: NSRect(x: (canvas - markWidth) / 2, y: (canvas - markHeight) / 2,
width: markWidth, height: markHeight))
gc.flushGraphics()
return rep.representation(using: .png, properties: [:])!
}
// .iconset entry name → pixel size (@2x = double-density of the named size)
let layout: [(String, Int)] = [
("icon_16x16.png", 16), ("[email protected]", 32),
("icon_32x32.png", 32), ("[email protected]", 64),
("icon_128x128.png", 128), ("[email protected]", 256),
("icon_256x256.png", 256), ("[email protected]", 512),
("icon_512x512.png", 512), ("[email protected]", 1024),
]
for (name, px) in layout {
try render(px).write(to: URL(fileURLWithPath: outDir).appendingPathComponent(name))
}