UNPKG

@dan-uni/dan-any

Version:

A danmaku transformer lib, supporting danmaku from different platforms.

51 lines (50 loc) 1.89 kB
import type { PlatformSource } from './platform'; import { UniDM } from './dm-gen'; export declare class UniID { /** * @description 每个domain下应为唯一值 * @example danuni: 推荐为UUID/ULID/NanoID * bili: midHash hash算法为CRC32 */ id: string; /** * @description 弹幕首次出现的平台域名(注意可以为如localhost等根域名) * ### 预设 * - `{any}.danuni` (若使用IP或无域名,请使用该domain,防止隐私泄露/无法解析) * #### 注意 * - `any`值建议为UUID/ULID/NanoID以防同步错误 * ### 非DanUni弹幕服务建议使用预设,或自行填写域名 */ domain: PlatformSource | string; constructor( /** * @description 每个domain下应为唯一值 * @example danuni: 推荐为UUID/ULID/NanoID * bili: midHash hash算法为CRC32 */ id: string, /** * @description 弹幕首次出现的平台域名(注意可以为如localhost等根域名) * ### 预设 * - `{any}.danuni` (若使用IP或无域名,请使用该domain,防止隐私泄露/无法解析) * #### 注意 * - `any`值建议为UUID/ULID/NanoID以防同步错误 * ### 非DanUni弹幕服务建议使用预设,或自行填写域名 */ domain: PlatformSource | string); static fromString(str: string): UniID; toString(): string; static fromNull(domain?: PlatformSource | 'runtime' | string): UniID; static fromBili({ cid, mid, midHash, }: { cid?: number | bigint | string; mid?: number | bigint; midHash?: string; }): UniID; static fromUnknown(id: string, /** * 可使用预设 */ domain: PlatformSource | string): UniID; } export type DMIDGenerator = (dan: UniDM, slice?: number) => string; export declare function createDMID(dan: UniDM, slice?: number): string;