Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.4 KB
Raw Blame
// Room data is transient and bounded. It never describes a media route.
export const MAX_CHAT_CODE_POINTS = 280;
export const INTERACTION_INTERVAL_MS = 800;
export const REACTION_DURATION_MS = 2400;
export const REACTION_IDS = ["thumbsup", "thumbsdown", "laugh", "clown", "eyeroll", "eyes", "wow", "wave", "heart", "clap", "party", "fire", "star", "sleep", "tomato", "poop"] as const;
export type ReactionId = typeof REACTION_IDS[number];
// Published 2.1 Servers predate the optional reaction command registry.
export const BASELINE_REACTION_IDS: readonly ReactionId[] = ["wave", "heart", "clap", "laugh", "wow", "party", "fire", "eyes", "star", "sleep", "tomato", "poop"];
export const isThrow = (reaction: string) => reaction === "tomato" || reaction === "poop";
export const REACTION_GLYPHS: Record<ReactionId, string> = {
  wave: "👋", heart: "❤️", clap: "👏", laugh: "😂", wow: "🤯", party: "🎉",
  fire: "🔥", eyes: "👀", star: "⭐", sleep: "😴", tomato: "🍅", poop: "💩",
  clown: "🤡", eyeroll: "🙄",
  thumbsup: "👍", thumbsdown: "👎",
};

const forbiddenText = /[\p{Cc}\p{Zl}\p{Zp}\u061c\u200b\u200e\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff\uD800-\uDFFF]/u;
export function normalizeChatText(value: string): string | null {
  if (forbiddenText.test(value)) return null;
  const text = value.normalize("NFC").trim();
  return text && Array.from(text).length <= MAX_CHAT_CODE_POINTS ? text : null;
}