@freegamestore/games

中文文档
0.20.3发布于 2026/11/07MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2495

在FreeGameStore上——GameShell,GameTopbar等游戏的共享回放UI原始作. Brand-Consistent,卷轴自由.

中文使用文档
文档目录22 节
  1. 安装
  2. Styling (代号为Tailwind 4)
  3. 快速启动
  4. 构成部分
  5. 游戏壳
  6. 游戏Topbar
  7. 游戏认证
  8. 游戏按钮
  9. 游戏Modal
  10. 游戏覆盖屏幕
  11. 游戏ResultScreen
  12. 游戏确认
  13. 游戏主题切换
  14. 游戏文本化切换
  15. 领导板
  16. 钩子
  17. 用户
  18. 使用引导板
  19. 使用GameSunds 软件
  20. 声音
  21. 出口
  22. 许可证

@ freegamestore/ games (英语)

游戏的共享回放( UI) 原始 freegamestore.online 互联网档案馆的存檔,存档日期2013-12-02. 品牌一致布局,卷轴自由取景口锁,触控方便,并合成音效.

版本 : 0.19.0 (中文(简体) )

安装

npm i @freegamestore/games
# or
pnpm add @freegamestore/games

对等依赖:反应19+.

Styling (代号为Tailwind 4)

组件的样式为 平台上的有轨电车 (单位:千美元)ADR-001 (中文(简体) )) (中文(简体) ). 包船的船级名称,不是CSS,所以 您的游戏汇编它们在 游戏 web/src/index.css,直接在 @import "tailwindcss"数字 :

@import "tailwindcss";
@import "@freegamestore/games/theme.css";
@source "../node_modules/@freegamestore/games/dist";

@theme inline {
  --color-paper: var(--paper);
  --color-panel: var(--panel);
  --color-ink: var(--ink);
  --color-muted: var(--muted);
  --color-line: var(--line);
  --color-accent: var(--accent);
  --color-danger: var(--danger);
  --font-display: "Fraunces", serif;
}
  • @source 让Tailwind扫描这个软件包 dist 课程 组件使用。 没有它,SDK就变得不俗了.
  • theme.css 添加符号映射以外的组件: animate-fgs-* 动画及其键框(它取代 CSS 用于注入的部件, accent-ink, (中文(简体) ), accent-soft 编辑 fgs 半径 和文本大小。 期限和放宽改为: --motion-* 标志.
  • 这个 @theme inline 块是符号映射 template-game-* 携带. 模板上的游戏已经拥有了它.
  • 浮动 UI (Y)GameModal, (中文(简体) ), GameConfirm, (中文(简体) ), StartScreen, (中文(简体) ), GameResultScreen(中文(简体) ) 坐在不透明地上 bg-panel 表面。 只有它的后方是半透明的.
  • 没有在运行时注射。 这个 *_CSS 字符串( r)CONFETTI_CSS, (中文(简体) ), SCORE_POP_CSS, (中文(简体) ), RESULT_SCREEN_CSS, (中文(简体) ), START_SCREEN_CSS以0.19.0去除; GAME_TOKENS_CSS 继续作为文件符号帮助者.
  • 内入 style 仅保留运行时计算的值( 配置件) 位置、分数弹出坐标、交错指数,每个标记 // Dynamic: …。 。 。 . src/styling.test.ts 别的都失败了.
  • 测试和超载的钩子 data-fgs="…" 属性 (单位:千美元)result, (中文(简体) ), confetti, (中文(简体) ), start, (中文(简体) ), start-artwork, (中文(简体) ), score-popup) (中文(简体) ). 旧的 fgs-* 类名已去.

快速启动

import { GameShell, GameTopbar } from '@freegamestore/games'

export default function App() {
  return (
    <GameShell topbar={<GameTopbar title="Chess" />}>
      {/* your game canvas / DOM */}
    </GameShell>
  )
}

构成部分

游戏壳

根布局包装. 锁定游戏到 100svh,防止文档滚动,禁用文本选择和触摸点名。 每款游戏都以此来包装其内容.

<GameShell topbar={<GameTopbar title="Tetris" />}>
  <MyGame />
</GameShell>
Prop类型说明
topbarReactNode?顶条元素( 通常为 <GameTopbar />(中文(简体) )
childrenReactNode游戏内容 — 填充剩余取景口

游戏Topbar

单曲允许上栏. 每场比赛都有相同的字体,平板字和彩色符号.

// Simple: just the title. The score pill is hidden by default (#348)
<GameTopbar title="Tetris" />

// Opt in to the live score pill
<GameTopbar title="Tetris" score={42} showScore />

// Custom stats + play/pause controls
<GameTopbar
  title="Pac-Man"
  stats={[
    { label: 'Score', value: 1200, accent: true },
    { label: 'Lives', value: 3 },
    { label: 'Level', value: 5 },
  ]}
  rules={<p>Eat all the dots. Avoid ghosts.</p>}
  onPlayPause={togglePause}
  paused={isPaused}
  onRestart={restart}
/>
Prop类型说明
titlestring?游戏名称, 左侧
scorenumber?活得分,只显示于 showScore 设定
showScoreboolean?出活计分丸. 默认关闭 (# 348)
statsGameTopbarStat[]?自定义 stat 排行( 活、 关、 时间)
actionsReactNode?右侧按钮( 最大 2)
rulesReactNode?游戏指令 — 显示信息图标, 打开水龙头上的覆盖
onPlayPause() => void?播放/暂停图标按钮
pausedboolean?控制播放/暂停图标状态
onRestart() => void?启动图标按钮

游戏认证

上边栏的签名/ 相机部件 actions 插槽 。 签出时显示"签入",签入时显示"avatar"+降入.

<GameTopbar title="Chess" actions={<GameAuth />} />

无道具——使用 useAuth 内部.

游戏按钮

触摸友好按钮. min 44px触控目标. 四变相 三相相相相.

<GameButton variant="primary" size="lg" onClick={start}>Play Again</GameButton>
<GameButton variant="secondary" size="sm" onClick={undo}>Undo</GameButton>
<GameButton variant="ghost" size="sm" onClick={flip}>Flip</GameButton>
<GameButton variant="danger" onClick={quit}>Quit</GameButton>
Prop类型默认说明
childrenReactNode(必须)按钮内容
variant'primary' | 'secondary' | 'ghost' | 'danger''primary'视觉风格
size'sm' | 'md' | 'lg''md'触摸目标大小
onClick() => void?点击处理器
disabledboolean?false状态
blockboolean?false全宽

大小 : sm (44个px), md (48个px), lg (56px) (英语).

游戏Modal

全屏模式覆盖. 关闭背景点击或退出 .

<GameModal open={showSettings} onClose={() => setShowSettings(false)} title="Settings">
  <p>Game settings here</p>
</GameModal>
Prop类型说明
openboolean模式是否可见
onClose() => void用背景点击或逃逸调用
titlestring?页眉文本
childrenReactNode模块内容

游戏覆盖屏幕

标准游戏覆接有分数,高分,再按下按钮.

<GameOverScreen
  score={1200}
  highScore={1500}
  onPlayAgain={restart}
>
  <Leaderboard {...leaderboard} />
</GameOverScreen>
Prop类型说明
scorenumber最后分数
highScorenumber?个人最佳(出道"新高分!"被打出后出道)
onPlayAgain() => void再次播放处理器
childrenReactNode?分数以下的额外内容

游戏ResultScreen

完成关卡或游戏的动画结果屏幕. 一个胜利显示 倒下孔雀和口音标题。 丢失的卡片是单独显示的. 屏幕打开时动作会集中. 使用 GameOverScreen 一个简单的游戏过卡. GameResultScreen 是动画版.

<GameResultScreen
  tone={won ? 'win' : 'lose'}
  eyebrow="Level 4"
  title={won ? 'Level 4 cleared!' : 'Game over'}
  message={won ? undefined : 'Your tray filled up.'}
  stats={[
    { label: 'Score', value: score.toLocaleString() },
    { label: 'Moves', value: moves },
  ]}
  badge={newBest ? 'New best!' : undefined}
  action={won ? { label: 'Next level', onClick: next } : { label: 'Play again', onClick: restart }}
>
  <Leaderboard {...leaderboard} />
</GameResultScreen>
Prop类型说明
tone'win' | 'lose'win 显示配置和重音标题颜色
eyebrowstring?标题上方的小行, 如级别名称
titlestring标题
messagestring?标题下的一行
stats{ label, value }[]?相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相. value 可能是一个数字
badgeReactNode?突出统计下行,如"新好
action{ label, onClick }主按键. 当屏幕打开时它会被聚焦
childrenReactNode?徽章和动作之间的额外内容

屏幕覆盖了视门 并且有 role="dialog"运动是 animate-fgs-* 水电费 theme.css (见 样式, (中文(简体) ), 关闭 prefers-reduced-motion中, 并隐藏给玩家 谁要求少一点运动。 它的颜色来自平台标志 和它的 持续时间 --motion-* 符号在 国家,与 光主题倒计时 theme.css。 。 。 .

Confetti 用于要庆祝的游戏 在别的地方.

游戏确认

在 GameModal 上创建的确认/取消对话框 .

<GameConfirm
  open={showQuit}
  title="Quit Game?"
  message="Your progress will be lost."
  onConfirm={quit}
  onCancel={() => setShowQuit(false)}
  variant="danger"
/>
Prop类型默认说明
openboolean是否可见
titlestring对话框标题
messagestring文本正文
onConfirm() => void确认处理器
onCancel() => void取消处理器
confirmLabelstring?'Confirm'确认按钮文本
cancelLabelstring?'Cancel'取消按钮文本
variant'default' | 'danger''default'确认按钮样式

游戏主题切换

压缩日月主题切换 (28px). 循环系统/轻/暗. 为上行所设计 actions 插槽 .

<GameTopbar title="Chess" actions={<><GameThemeToggle /><GameTextSizeToggle /></>} />

没有道具.

游戏文本化切换

压缩文本大小切换 (28px). 周期默认/ 大/ 小 。 显示 A/A+/A-。 为上行所设计 actions 插槽 .

<GameTopbar title="Chess" actions={<GameTextSizeToggle />} />

没有道具.

领导板

标签页板显示 (Top / 最近) 。 与 useLeaderboard 钩.

const { topScores, recentScores, loading } = useLeaderboard('chess')

<Leaderboard topScores={topScores} recentScores={recentScores} loading={loading} />
Prop类型说明
topScoresLeaderboardEntry[]有史以来最高分数
recentScoresLeaderboardEntry[]最近得分
loadingboolean装入状态

钩子

用户

FreeGameStore (通过 Google OAuth) 的认证状态 auth.freegamestore.online) (中文(简体) ).

const { user, loading, signIn, signOut } = useAuth()

回返 { user: User | null, loading: boolean, signIn: () => void, signOut: () => void }。 。 。 .

使用引导板

获取并提交分数到平台领导板.

今天没有领导板服务. 领导板工人被移除(# 491),所以领导板总是空的 submitScore 决定 { ok: false }钩子和 <Leaderboard> 继续导出, 因此已有的游戏会继续构建; 在本地保存高分 localStorage。 。 。 .

const { topScores, recentScores, submitScore, loading, refresh } = useLeaderboard('tetris')

// Submit a score
const { ok, rank } = await submitScore(1200)

过 period (协调世界时的一天, YYYY-MM-DD),用于每天的棋盘,例如每日的谜题. 接受它为全局董事会:

const today = new Date().toISOString().slice(0, 10)
const { topScores, submitScore } = useLeaderboard('tile-match', { period: today })

使用GameSunds 软件

通过Web Audio API合成音效. 0音频文件. 所有的声音自动尊重哑巴切换.

const { playMove, playScore, playError, playGameOver, playLevelUp, playDrop, playClear, playTick } = useGameSounds()

// Play a sound (no-op when muted)
playScore()
声音使用大小写
playMove片段被移动,卡片被翻转,按下按钮
playScore得分,匹配,正确的答案
playError答错了,撞了障碍,失去了生命
playGameOver游戏结束——倒数
playLevelUp升级/成绩——升级
playDrop硬投出/ th
playClear清行/ 组合
playTick倒计时勾选/ 计时警告

声音

SDK的"音效提供"中的低等哑弹状态. 游戏应该检查 muted 在播放自定义音频之前.

const { muted, toggle } = useSound()
if (!muted) myCustomAudio.play()

出口

@freegamestore/games → GameShell, GameTopbar, GameAuth, GameButton, GameModal,
                        GameOverScreen, GameConfirm, GameThemeToggle,
                        GameTextSizeToggle, Leaderboard, useAuth, useLeaderboard,
                        useGameSounds, useSound

许可证

麻省理工学院

版本与发布记录

@freegamestore/games 共发布 26 个版本,首次发布于 2026/05/08;过去 12 个月发布了 26 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.20.3latest2026/11/078 天前
0.20.22026/11/078 天前
0.20.12026/11/078 天前
0.20.02026/11/069 天前
0.19.12026/11/0312 天前
0.19.02026/10/3115 天前

关于 @freegamestore/games 的常见问题

@freegamestore/games 是什么?

在FreeGameStore上——GameShell,GameTopbar等游戏的共享回放UI原始作. Brand-Consistent,卷轴自由.

如何安装 @freegamestore/games?

在项目目录运行 npm install @freegamestore/games,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@freegamestore/games 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@freegamestore/games 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@freegamestore/games 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@freegamestore/games 可以商用吗?

@freegamestore/games 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@freegamestore/games 的下载量有多少?

根据 npm 官方下载统计,@freegamestore/games 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,495 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@freegamestore/games 还在维护吗?

最新版本 0.20.3 发布于 2026/11/07(8 天前);至今共发布 26 个版本,其中过去 12 个月发布了 26 个;首次发布于 2026/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。