Files
cover-studio/src/sources/index.ts
T
im0o 83f27d9e90 feat: 图库双源接入(Pexels+Unsplash,统一 PhotoProvider)与几何预设扩充
- providers.ts: PHOTO_PROVIDERS 注册表,Pexels 在前(dev 速率高);providerById
- unsplash.ts: 改造成 PhotoProvider(parseUnsplashResponse/unsplashProvider/
  notifyDownload),共享 PhotoProviderError 定义在此叶模块避免注册表互引成环;
  legacy searchUnsplash/unsplashStatus/toAsset/trackDownload 保留(基座旧
  SourcePanel 还在用,删了这轮 typecheck 过不了)
- pexels.ts(新): parsePexelsResponse 纯函数 + pexelsProvider;Authorization 头;
  fullUrl 取 large2x(≈1880)不取原图;无下载统计端点,不实现 notifyDownload
- 没配 key 一律静默 missing,search 抛 PhotoProviderError,模块顶层不抛
- geometry.ts: 新增 GEOMETRY_PRESETS 16 条(固定图案+人工配色,新背景菜单卡片
  数据源)+ 4 个新图案家族(waves/dots/horizon/glow)渲染,复用线性亮度钳制
  保证白字对比度;公开 GeometryKind 不动(旧面板缩略图字典闭合),遗留种子机制
  原样;导出 contrastToWhite/relativeLuminance 供自验
- selfcheck: 手写官方形状样本断言两家解析、缺失态/错误类、预设数量与对比度
2026-09-05 18:24:11 +08:00

60 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 背景来源汇总出口。
*
* 各来源都写成一个自包含模块,统一产出 `BackgroundAsset`(形状见 `@/types`):
* - upload.ts 本地文件 → object URL
* - geometry.ts 预设几何底纹:纯函数派生 + 渲染;`GEOMETRY_PRESETS` 是
* 新背景菜单的卡片数据源(固定图案 + 人工配色,无种子),
* `GEOMETRY_KINDS` 是 legacy 的种子随机配色 4 种
* - pexels.ts / unsplash.ts 图库搜索,都实现 `PhotoProvider` 接口,
* Pexels 在前(`PHOTO_PROVIDERS` 见 providers.ts)
*
* T4 时代的 legacy 函数面(`searchUnsplash` / `toAsset` 等)保留到旧
* SourcePanel 被 t13 清掉为止;新界面一律走 `PHOTO_PROVIDERS`。
*/
export { fromUpload, releaseObjectUrl, pickImageFiles } from "./upload";
export {
deriveGeometryParams,
derivePresetParams,
renderGeometry,
geometryToDataUrl,
createGeometryAsset,
createPresetAsset,
GEOMETRY_KINDS,
GEOMETRY_PRESETS,
contrastToWhite,
relativeLuminance,
} from "./geometry";
export type {
GeometryParams,
GeometryKind,
RenderKind,
GeometryPreset,
RGB,
} from "./geometry";
export {
unsplashStatus,
searchUnsplash,
trackDownload,
toAsset,
parseUnsplashResponse,
unsplashProvider,
} from "./unsplash";
export type { UnsplashStatus, UnsplashPhoto } from "./unsplash";
export { parsePexelsResponse, pexelsProvider } from "./pexels";
export { PHOTO_PROVIDERS, providerById, PhotoProviderError } from "./providers";
export type {
BackgroundAsset,
Attribution,
StockPhoto,
PhotoProvider,
PhotoProviderId,
PhotoProviderStatus,
} from "../types";