Files
hyperframes/packages/share/src/host.mjs
T
terencechoandClaude Opus 5.5 f54b2227fd feat(share): extract shared review kernel for local hosts (#7134)
* feat(share): extract shared review kernel for local hosts

* fix: recover completed shares and integrate kernel checks

* fix: terminate ffprobe options before share media input

* fix: verify executable imports without matching JSDoc types

* build: budget the published sharing package

* fix: publish NodeNext-compatible sharing declarations

* fix: invalidate shared renders when linked media changes

* fix: reserve share progress before awaiting upload lock

* fix: copy share build inputs before image dependency install

* fix(share): preserve Desktop snapshots and support portable locks

* fix(share): restrict video uploads to trusted origins

* fix(share): preserve review state across recovery and uploads

* fix(share): preserve review title and feedback attribution

* fix(share): accept legacy review records safely

* build(share): update measured package size budget

* fix(share): preserve feedback cutoff across export retries

* docs(share): describe only the storage origins the signer uses

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 04:35:33 +00:00

47 lines
2.4 KiB
JavaScript

import { promisify } from "node:util";
import { execFile as nodeExecFile } from "node:child_process";
import { signedInRequest as defaultRequest } from "./signedInRequest.mjs";
// @ts-check
/** @typedef {import("./hosts.js").ShareHost} ShareHost */
/** @type {Partial<ShareHost>} */
const host = { execFile: nodeExecFile, signedInRequest: defaultRequest };
/** Bind the host services used by the sharing runtime. @param {Partial<ShareHost>} part */
export const bindShareHost = (part) => void Object.assign(host, part);
/** @template {keyof ShareHost} K @param {K} name @returns {ShareHost[K]} */
const bound = (name) => {
const part = host[name];
if (part === undefined) throw new Error(`No host is bound to share projects (${name}).`);
return /** @type {ShareHost[K]} */ (part);
};
/** @type {ShareHost["normalize"]} */
export const normalize = (path) => bound("normalize")(path);
/** @type {ShareHost["assertOpenProject"]} */
export const assertOpenProject = (path) => bound("assertOpenProject")(path);
/** @type {ShareHost["resolveOpenProjectByPath"]} */
export const resolveOpenProjectByPath = (path) => bound("resolveOpenProjectByPath")(path);
/** @type {ShareHost["listOpenProjects"]} */
export const listOpenProjects = () => bound("listOpenProjects")();
/** @type {ShareHost["homeName"]} */
export const homeName = (path, folder) => bound("homeName")(path, folder);
/** @type {ShareHost["uploadWithProgress"]} */
export const uploadWithProgress = (url, headers, archive, onSent) =>
bound("uploadWithProgress")(url, headers, archive, onSent);
/** @type {ShareHost["signedInRequest"]} */
export const signedInRequest = (deps) => bound("signedInRequest")(deps);
/** @type {ShareHost["latestExportFile"]} */
export const latestExportFile = (dir) => bound("latestExportFile")(dir);
export const reviewUploadOrigins = () =>
host.reviewUploadOrigins ??
(process.env.HYPERFRAMES_REVIEW_UPLOAD_ORIGINS ?? "").split(",").map((origin) => origin.trim());
/** @type {ShareHost["projectFingerprint"]} */
export const projectFingerprint = (dir) => bound("projectFingerprint")(dir);
/** @type {ShareHost["ffBinary"]} */
export const ffBinary = (name) => bound("ffBinary")(name);
export const channelSite = () => bound("channelSite");
export const signinSites = () => bound("signinSites");
/** @param {string} file @param {string[]} args */
export const runFile = (file, args) =>
promisify(bound("execFile"))(file, args, { windowsHide: true });