mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Phase 0 of docs/blossom-plan.md. No UX; off-by-default ("off = no trace").
- Vendored: pinned [email protected] bundled by scripts/build-blossom-sdk.mjs
→ vendor/blossom-client-sdk.bundle.min.js (esbuild, browser ESM, ~27KB). The
optional @cashu/cashu-ts peer dep (BUD-07 payments, only reached on a lazy 402
branch bitvid never hits) is aliased to a throwing stub. `npm run build:blossom-sdk`.
- Flag: FEATURE_BLOSSOM_STORAGE wired like FEATURE_AUDIO_INGEST / _BITCOIN_CONNECT
(instance-config → config → constants), default FALSE.
- Service: js/services/blossomService.js implements the same
uploadFile({…}) → {url,key} contract as s3UploadService (so a later
isBlossomProvider branch drops into mediaUploader). Lazy-loads the SDK; core
path = createUploadAuth(signer, sha256) + multiServerUpload (BUD-11 auth via
bitvid's existing signer, BUD-04 mirror). Torrent parity + result-shape mapping +
mediaUploader wiring + Storage-pane config land in Phase 1.
Tests: tests/blossom-service.test.mjs (5 — availability gate + input guards).
Lint + build clean. Nothing wired into the app yet.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
// Bundles blossom-client-sdk into a single self-contained ESM file that bitvid
|
|
// lazy-imports behind FEATURE_BLOSSOM_STORAGE (docs/blossom-plan.md, TODO #30).
|
|
// Mirrors the bitcoin-connect / floating-ui vendor steps. Pinned via the exact
|
|
// devDependency version in package.json.
|
|
import { build } from "esbuild";
|
|
import { mkdir, copyFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const entryPoint = path.join(repoRoot, "scripts/vendor/blossom-sdk-entry.mjs");
|
|
const vendorDir = path.join(repoRoot, "vendor");
|
|
const outFile = path.join(vendorDir, "blossom-client-sdk.bundle.min.js");
|
|
const licenseSrc = path.join(
|
|
repoRoot,
|
|
"node_modules/blossom-client-sdk/LICENSE.txt",
|
|
);
|
|
const licenseOut = path.join(vendorDir, "blossom-client-sdk.LICENSE");
|
|
|
|
await mkdir(vendorDir, { recursive: true });
|
|
|
|
await build({
|
|
bundle: true,
|
|
entryPoints: [entryPoint],
|
|
outfile: outFile,
|
|
format: "esm",
|
|
splitting: false,
|
|
platform: "browser",
|
|
target: ["es2020"],
|
|
minify: true,
|
|
sourcemap: false,
|
|
define: {
|
|
"process.env.NODE_ENV": '"production"',
|
|
global: "globalThis",
|
|
},
|
|
// @cashu/cashu-ts is an OPTIONAL peer dep the SDK only lazy-imports on the
|
|
// BUD-07 payment branch (HTTP 402). bitvid uses free Blossom servers, so alias
|
|
// it to a throwing stub instead of pulling the dep.
|
|
alias: {
|
|
"@cashu/cashu-ts": path.join(repoRoot, "scripts/vendor/cashu-stub.mjs"),
|
|
},
|
|
logLevel: "info",
|
|
});
|
|
|
|
try {
|
|
await copyFile(licenseSrc, licenseOut);
|
|
} catch (error) {
|
|
console.warn("[build-blossom-sdk] could not copy LICENSE:", error.message);
|
|
}
|
|
|
|
console.log("[build-blossom-sdk] wrote", path.relative(repoRoot, outFile));
|