Skip to documentation
CranberryClock.Ideas / Systems / Design

INDEPENDENT TOOL / v0.1.0

KeepsakeIntegration guide

Install Keepsake, connect it to your project, and understand the integration boundaries.

Start with the package archive.

Download Keepsake v0.1.0 ↓, then follow the installation instructions below. Commands that pack source files run from the public repository checkout.

Install

bash
npm pack ./dist/packages/keepsake
npm install /path/to/cranberry-forge-keepsake-0.1.0.tgz

Source/archive distribution; not published to npm. Node 22+ or a modern browser.

Example

javascript
import { createSave, migrateSave } from "@cranberry-forge/keepsake";
const old = createSave("my-game", 0, { coins: 12 });
const result = migrateSave(old, {
  format: "my-game",
  targetVersion: 1,
  migrations: { 0: (p) => ({ gold: p.coins }) },
  validators: {
    0: (p) => Number.isFinite(p?.coins),
    1: (p) => Number.isFinite(p?.gold),
  },
});
if (result.ok) console.log(result.save.payload); // { gold: 12 }

Tutorial · Runnable example

View versioned source on GitHub ↗