npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@my-games/2048-vue

v0.3.2

Published

Vue 3 SFC adapter for the @my-games/2048-core game engine — Composition API, mobile-ready, with expectimax AI hook. 2048 的 Vue 3 组件适配器。

Readme

@my-games/2048-vue

2048 游戏的 Vue 3 组件适配器(Composition API + SFC)。

安装

pnpm add @my-games/2048-vue vue

用法

<script setup lang="ts">
import { Game2048 } from '@my-games/2048-vue';
import '@my-games/2048-vue/style.css';

function onMove(dir, gained) {
  console.log(dir, gained);
}
</script>

<template>
  <Game2048
    :size="4"
    save-key="my-app:2048:save"
    best-key="my-app:2048:best"
    :enable-ai="false"
    @move="onMove"
  />
</template>

样式必须显式引入:vite lib 模式把内部 CSS import 抽到 dist/index.css, JS bundle 不再引用。消费者入口加一次 import '@my-games/2048-vue/style.css' (或从 core 引 import '@my-games/2048-core/styles.css',内容一致)。

Props

| Prop | 类型 | 默认 | 说明 | | --- | --- | --- | --- | | size | 3 \| 4 \| 5 \| 6 | 4 | 棋盘边长 | | storage | SaveStorage \| null | localStorage | 传 null 关闭持久化(SSR) | | saveKey | string | game-2048:save | 存档键,多实例分开 | | bestKey | string | game-2048:best | 最高分独立键 | | freshStart | boolean | false | 忽略已有存档开新局 | | autofocus | boolean | true | mount 后自动 focus 让键盘立刻可用 | | enableAI | boolean | false | 是否渲染 AI 按钮(API 一直可用) | | aiDepth | number | 3 | expectimax 搜索深度 | | title | string | '2048' | 传空串隐藏 header |

事件

move(dir, gained) / won() / lost()

Ref 命令式方法

<script setup> 里 const g = ref<Game2048Instance>(); 后:

  • g.value?.move(dir)
  • g.value?.newGame() / undo() / continuePlaying()
  • g.value?.suggestMove(): Direction | null — 只查询建议
  • g.value?.aiMove(): Direction | null — 让 AI 走一步

Composable(想自己画 UI)

import { useGame } from '@my-games/2048-vue';

const { state, move, suggestMove } = useGame({ size: 4 });

state 是 ShallowRef<GameState>,模板里 auto-unwrap 直接用。


完整玩法、引擎 API、设计取舍见仓库根 README: https://github.com/my-gam/2048#readme

License

MIT.