@vibechain/os 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/AGENTS.md +139 -208
  2. package/README.md +131 -54
  3. package/SECURITY.md +45 -20
  4. package/dist/app-client.d.ts +4 -1
  5. package/dist/app-client.js +4 -1
  6. package/dist/app-host.d.ts +111 -9
  7. package/dist/app-host.js +339 -58
  8. package/dist/app-protocol.d.ts +2 -0
  9. package/dist/app-runtime.d.ts +18 -2
  10. package/dist/app-runtime.js +75 -11
  11. package/dist/app-wire.d.ts +194 -0
  12. package/dist/app-wire.js +253 -0
  13. package/dist/browser.d.ts +2 -0
  14. package/dist/browser.js +2 -0
  15. package/dist/bundle.js +6 -6
  16. package/dist/canvas.d.ts +2 -2
  17. package/dist/canvas.js +3 -1
  18. package/dist/check.d.ts +12 -0
  19. package/dist/check.js +167 -0
  20. package/dist/cli-publish.d.ts +24 -0
  21. package/dist/cli-publish.js +288 -0
  22. package/dist/cli-session.d.ts +108 -0
  23. package/dist/cli-session.js +245 -0
  24. package/dist/cli.d.ts +10 -0
  25. package/dist/cli.js +46 -10
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.js +3 -0
  28. package/dist/listing.d.ts +3 -3
  29. package/dist/listing.js +1 -1
  30. package/dist/loop.d.ts +18 -2
  31. package/dist/loop.js +13 -1
  32. package/dist/manifest.d.ts +90 -4
  33. package/dist/manifest.js +340 -5
  34. package/dist/os.d.ts +56 -0
  35. package/dist/os.js +354 -0
  36. package/dist/preview-parent.d.ts +36 -0
  37. package/dist/preview-parent.js +122 -11
  38. package/dist/preview-ui.js +1 -1
  39. package/dist/preview.js +25 -7
  40. package/dist/redact.d.ts +6 -0
  41. package/dist/redact.js +16 -0
  42. package/dist/runtime-policy.d.ts +20 -0
  43. package/dist/runtime-policy.js +45 -0
  44. package/dist/scaffold.d.ts +13 -2
  45. package/dist/scaffold.js +99 -29
  46. package/dist/submit-notice.d.ts +26 -0
  47. package/dist/submit-notice.js +34 -0
  48. package/dist/templates/plain/game.js +18 -0
  49. package/dist/testing.d.ts +63 -0
  50. package/dist/testing.js +157 -1
  51. package/dist/transport.d.ts +20 -0
  52. package/dist/transport.js +71 -19
  53. package/dist/vibemarket-os.js +1 -0
  54. package/dist/worker.d.ts +18 -0
  55. package/dist/worker.js +34 -0
  56. package/examples/paw-beat/README.md +20 -8
  57. package/examples/paw-beat/cat.ts +665 -89
  58. package/examples/paw-beat/game.ts +162 -28
  59. package/examples/paw-beat/index.html +114 -40
  60. package/examples/paw-beat/main.ts +264 -149
  61. package/examples/paw-beat/music.ts +314 -65
  62. package/examples/paw-beat/stage.ts +560 -0
  63. package/examples/paw-beat/store/icon.png +0 -0
  64. package/examples/paw-beat/store/screenshot-1.webp +0 -0
  65. package/examples/paw-beat/store/screenshot-2.webp +0 -0
  66. package/examples/paw-beat/vibemarket.json +2 -2
  67. package/examples/vibexp-app/README.md +20 -4
  68. package/examples/vibexp-app/index.html +3 -2
  69. package/examples/vibexp-app/plain/game.ts +20 -0
  70. package/examples/vibexp-app/plain/index.html +6 -0
  71. package/examples/vibexp-app/plain/vibemarket.json +17 -0
  72. package/examples/vibexp-app/src/main.ts +46 -31
  73. package/examples/vibexp-app/store/icon.png +0 -0
  74. package/examples/vibexp-app/store/screenshot-1.png +0 -0
  75. package/examples/vibexp-app/three/README.md +21 -0
  76. package/examples/vibexp-app/three/index.html +4 -0
  77. package/examples/vibexp-app/three/src/main.ts +45 -0
  78. package/examples/vibexp-app/three/vibemarket.json +19 -0
  79. package/examples/vibexp-app/vibemarket.json +27 -1
  80. package/package.json +8 -3
  81. package/examples/chonk-stack/card-slice.ts +0 -17
  82. package/examples/chonk-stack/cat3d.ts +0 -57
  83. package/examples/chonk-stack/game.css +0 -174
  84. package/examples/chonk-stack/index.html +0 -32
  85. package/examples/chonk-stack/main.ts +0 -149
  86. package/examples/chonk-stack/model.ts +0 -40
  87. package/examples/chonk-stack/renderer.ts +0 -263
  88. package/examples/chonk-stack/skins.ts +0 -47
  89. package/examples/chonk-stack/vibemarket.json +0 -21
  90. package/examples/collection-room/index.html +0 -3
  91. package/examples/collection-room/main.ts +0 -31
  92. package/examples/collection-room/vibemarket.json +0 -12
  93. package/examples/tsconfig.json +0 -4
@@ -1,149 +0,0 @@
1
- import { connectGameSdk, watchInventory, type GameSdk } from "@vibechain/os";
2
- import { StackRenderer } from "./renderer";
3
- import { START_WIDTH } from "./model";
4
- import { drawCat, ownedSkins, SKINS } from "./skins";
5
- import "./game.css";
6
-
7
- function element<T extends HTMLElement>(id: string): T {
8
- const node = document.getElementById(id);
9
- if (!node) throw Error(`Missing game element: ${id}`);
10
- return node as T;
11
- }
12
- const root = element("stack"), board = element<HTMLCanvasElement>("board");
13
- const intro = element("intro"), result = element("result"), paused = element("paused");
14
- const collection = element<HTMLDialogElement>("collection"), error = element("error");
15
- const dropButton = element<HTMLButtonElement>("drop"), pauseButton = element<HTMLButtonElement>("pause");
16
- const abort = new AbortController();
17
- let sdk: GameSdk | undefined;
18
- let inventory: ReturnType<typeof watchInventory> | undefined;
19
- let selected = 0, owned = new Set([0]), best = 0;
20
- let playing = false, isPaused = false, disposed = false;
21
- let calloutTimer = 0, previousWidth = START_WIDTH;
22
- const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
23
-
24
- // HUD work happens on accepted drops, never inside the render loop.
25
- function syncHud() {
26
- const { score, combo, layers, ended } = renderer.state;
27
- const percent = ended ? 0 : Math.round(layers[layers.length - 1].width / START_WIDTH * 100);
28
- element("score").textContent = String(score);
29
- element("width-value").textContent = `${percent}%`;
30
- element("width-meter").setAttribute("aria-valuenow", String(percent));
31
- element("width-meter").dataset.narrow = String(percent < 30);
32
- element("width-fill").style.transform = `scaleX(${percent / 100})`;
33
- element("combo").textContent = `×${combo}`;
34
- element("streak-pips").querySelectorAll("i").forEach((pip, index) => { pip.dataset.lit = String(combo > index); });
35
- element("streak-help").textContent = combo >= 3 ? "WIDTH BOOST ACTIVE" : "3 IN A ROW → WIDER CARD";
36
- }
37
-
38
- function showError(message: string) { error.textContent = message; error.hidden = !message; }
39
- const renderer = new StackRenderer(board, (score, combo, ended) => {
40
- syncHud();
41
- const currentWidth = renderer.state.layers[renderer.state.layers.length - 1].width;
42
- const restoredWidth = currentWidth > previousWidth; previousWidth = currentWidth;
43
- window.clearTimeout(calloutTimer);
44
- const callout = element("callout");
45
- callout.textContent = ended ? "" : restoredWidth ? "Perfect. Wider card!" : combo >= 2 ? `Perfect ×${combo}` : combo ? "Perfect." : "";
46
- if (!ended && !reduceMotion.matches) {
47
- element("score").animate([{ transform: "translateY(4px)", opacity: .5 }, { transform: "translateY(0)", opacity: 1 }], { duration: 200, easing: "ease-out" });
48
- if (combo) callout.animate([{ opacity: 0, transform: "translateY(10px) scale(.94)" }, { opacity: 1, transform: "translateY(0) scale(1)" }], { duration: 200, easing: "ease-out" });
49
- }
50
- calloutTimer = window.setTimeout(() => { callout.textContent = ""; }, 950);
51
- if (ended) {
52
- const newBest = score > best;
53
- playing = false; best = Math.max(best, score);
54
- element("best").textContent = String(best);
55
- root.className = "is-ended"; result.hidden = false; dropButton.hidden = true; pauseButton.hidden = true;
56
- element("result-label").textContent = newBest ? "NEW SESSION BEST" : "RUN COMPLETE";
57
- element("result-title").textContent = score === 0 ? "One more try?" : score >= 20 ? "Above the clouds." : "Nice stack.";
58
- element("result-score").textContent = String(score);
59
- element("result-streak").textContent = `×${renderer.state.bestCombo}`;
60
- element("result-best").textContent = String(best);
61
- element<HTMLButtonElement>("again").focus({ preventScroll: true });
62
- }
63
- });
64
-
65
- function pause(value: boolean) {
66
- if (!playing) return;
67
- isPaused = value; renderer.pause(value); paused.hidden = !value;
68
- dropButton.hidden = value; pauseButton.hidden = value;
69
- root.className = value ? "is-paused" : "is-playing";
70
- if (value) element("resume").focus({ preventScroll: true });
71
- }
72
- function start() {
73
- intro.hidden = true; result.hidden = true; paused.hidden = true;
74
- root.className = "is-playing"; playing = true; isPaused = false;
75
- dropButton.hidden = false; pauseButton.hidden = false;
76
- window.clearTimeout(calloutTimer); element("callout").textContent = "";
77
- previousWidth = START_WIDTH; renderer.start(); syncHud(); dropButton.focus({ preventScroll: true });
78
- }
79
- function drawAvatar(canvas: HTMLCanvasElement, skin: number) {
80
- const c = canvas.getContext("2d");
81
- if (!c) return;
82
- c.clearRect(0, 0, canvas.width, canvas.height);
83
- drawCat(c, canvas.width / 2, canvas.height - 5, Math.min(canvas.width * 0.9, canvas.height), skin);
84
- }
85
- function renderCollection() {
86
- if (!owned.has(selected)) selected = 0;
87
- renderer.setSkin(selected);
88
- element("cat-name").textContent = SKINS[selected].name;
89
- element("wardrobe-count").textContent = `${owned.size}/${SKINS.length}`;
90
- element("owned-count").textContent = `${owned.size} / ${SKINS.length} available`;
91
- element("wardrobe").setAttribute("aria-label", `Choose chonk, ${SKINS[selected].name} equipped, ${owned.size} of ${SKINS.length} available`);
92
- drawAvatar(element<HTMLCanvasElement>("avatar"), selected);
93
- const grid = element("skins"); grid.replaceChildren();
94
- SKINS.forEach((skin, index) => {
95
- const button = document.createElement("button"); button.type = "button";
96
- button.setAttribute("aria-label", `${owned.has(index) ? "Equip" : "Locked"} ${skin.name}`);
97
- button.setAttribute("aria-pressed", String(selected === index)); button.disabled = !owned.has(index);
98
- button.style.setProperty("--skin-color", skin.accent);
99
- const rarity = document.createElement("span"); rarity.className = "skin-rarity"; rarity.textContent = skin.label;
100
- const avatar = document.createElement("canvas"); avatar.width = 180; avatar.height = 170; avatar.setAttribute("aria-hidden", "true");
101
- drawAvatar(avatar, index);
102
- const name = document.createElement("b"); name.textContent = skin.name;
103
- const label = document.createElement("small"); label.textContent = selected === index ? "✓ EQUIPPED" : owned.has(index) ? "EQUIP ↗" : "LOCKED";
104
- button.append(rarity, avatar, name, label);
105
- button.onclick = () => { if (!owned.has(index)) return; selected = index; renderCollection(); collection.close(); element("wardrobe").focus({ preventScroll: true }); };
106
- grid.append(button);
107
- });
108
- }
109
- element("play").onclick = start; element("again").onclick = start;
110
- dropButton.onclick = () => renderer.input(); board.onclick = () => renderer.input();
111
- pauseButton.onclick = () => pause(true); element("resume").onclick = () => { pause(false); dropButton.focus({ preventScroll: true }); };
112
- element("wardrobe").onclick = () => { pause(true); collection.showModal(); };
113
- element("close-collection").onclick = () => collection.close();
114
- const shop = async () => {
115
- pause(true); if (collection.open) collection.close();
116
- if (!sdk) { showError("The collection is connecting. You can keep playing."); return; }
117
- try { await sdk.showShop(); } catch (reason) { showError(reason instanceof Error ? reason.message : "Reopen the game to reconnect the collection."); }
118
- };
119
- element("shop").onclick = () => { void shop(); }; element("collection-shop").onclick = () => { void shop(); };
120
- window.addEventListener("keydown", event => {
121
- if (collection.open || event.repeat) return;
122
- if (event.key === "Escape" && playing) { event.preventDefault(); pause(!isPaused); return; }
123
- if (event.code !== "Space") return;
124
- // Buttons already translate Space into one click; never double-drop.
125
- if (event.target instanceof HTMLElement && event.target.closest("button,a,input")) return;
126
- event.preventDefault(); if (!playing) start(); else if (isPaused) pause(false); else renderer.input();
127
- }, { signal: abort.signal });
128
- document.addEventListener("visibilitychange", () => { if (document.hidden) pause(true); }, { signal: abort.signal });
129
- window.addEventListener("blur", () => pause(true), { signal: abort.signal });
130
-
131
- renderCollection(); root.className = "is-intro";
132
- performance.mark("chonk-stack-first-frame");
133
- void connectGameSdk(abort.signal).then(async connection => {
134
- if (disposed) { connection.destroy(); return; }
135
- sdk = connection;
136
- await sdk.ready(); // Free play doesn't wait for catalog or paginated inventory.
137
- if (disposed) return;
138
- inventory = watchInventory(sdk, {
139
- onChange(value) { owned = ownedSkins(value.cards); renderCollection(); showError(""); },
140
- onError() {
141
- // Cosmetic authority fails closed. Never retain an unverified entitlement.
142
- owned = new Set([0]); renderCollection(); showError("Collection refresh failed. Starter is available.");
143
- const retry = document.createElement("button"); retry.textContent = "Retry"; retry.onclick = () => { void inventory?.refresh(); }; error.append(retry);
144
- },
145
- });
146
- }).catch(() => { if (!disposed) showError("Playing offline. Open through VibeMarket to use your collection."); });
147
- window.addEventListener("pagehide", () => {
148
- disposed = true; inventory?.destroy(); sdk?.destroy(); renderer.destroy(); abort.abort(); window.clearTimeout(calloutTimer);
149
- }, { once: true });
@@ -1,40 +0,0 @@
1
- export interface CardLayer { x: number; width: number; level: number; perfect: boolean }
2
- export interface StackState {
3
- layers: CardLayer[]; moving: CardLayer; direction: 1 | -1;
4
- score: number; combo: number; bestCombo: number; ended: boolean;
5
- }
6
- export const BOARD_WIDTH = 480;
7
- export const START_WIDTH = 228;
8
- export const RETAINED_LAYERS = 36;
9
- export function newStack(): StackState {
10
- return { layers: [{ x: 126, width: START_WIDTH, level: 0, perfect: false }],
11
- moving: { x: 18, width: START_WIDTH, level: 1, perfect: false },
12
- direction: 1, score: 0, combo: 0, bestCombo: 0, ended: false };
13
- }
14
- export function advance(state: StackState, seconds: number) {
15
- if (state.ended) return;
16
- const distance = Math.max(0, Math.min(seconds, 0.05)) * Math.min(220, 105 + state.score * 3.2);
17
- const min = 16, max = BOARD_WIDTH - 16 - state.moving.width;
18
- state.moving.x += distance * state.direction;
19
- if (state.moving.x > max) { state.moving.x = 2 * max - state.moving.x; state.direction = -1; }
20
- if (state.moving.x < min) { state.moving.x = 2 * min - state.moving.x; state.direction = 1; }
21
- }
22
- export function drop(state: StackState): { perfect: boolean; offcut: CardLayer | null } {
23
- if (state.ended) return { perfect: false, offcut: null };
24
- const top = state.layers[state.layers.length - 1], moving = state.moving;
25
- const delta = moving.x - top.x;
26
- const perfect = Math.abs(delta) <= Math.min(5, top.width * 0.08);
27
- const left = Math.max(moving.x, top.x), right = Math.min(moving.x + moving.width, top.x + top.width);
28
- if (right - left < 5) { state.ended = true; return { perfect: false, offcut: { ...moving } }; }
29
- const offcut = perfect ? null : { x: delta > 0 ? right : moving.x, width: Math.abs(delta), level: moving.level, perfect: false };
30
- state.combo = perfect ? state.combo + 1 : 0;
31
- state.bestCombo = Math.max(state.bestCombo, state.combo);
32
- const width = perfect ? Math.min(START_WIDTH, top.width + (state.combo >= 3 ? 8 : 0)) : right - left;
33
- const x = perfect ? top.x - (width - top.width) / 2 : left;
34
- state.score++;
35
- state.layers.push({ x, width, level: state.score, perfect });
36
- if (state.layers.length > RETAINED_LAYERS) state.layers.shift();
37
- state.direction = state.score % 2 ? -1 : 1;
38
- state.moving = { x: state.direction === 1 ? 16 : BOARD_WIDTH - 16 - width, width, level: state.score + 1, perfect: false };
39
- return { perfect, offcut };
40
- }
@@ -1,263 +0,0 @@
1
- import * as THREE from "three";
2
- import { RoundedBoxGeometry } from "three/examples/jsm/geometries/RoundedBoxGeometry.js";
3
- import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
4
- import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
5
- import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
6
- import { UnrealBloomPass } from "three/examples/jsm/postprocessing/UnrealBloomPass.js";
7
- import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
8
- import { advance, drop, newStack, START_WIDTH, type CardLayer } from "./model";
9
- import { centeredCardSlice, cutCardSlice, type CardSlice } from './card-slice';
10
- import { createChonk } from "./cat3d";
11
- const UNIT = 0.02, STEP = 0.34;
12
- const COLORS = ["#ff65c9", "#78fff0", "#ffcd67", "#a993ff", "#fa8379", "#85aaff"];
13
- interface Piece { mesh: THREE.Group; velocity: THREE.Vector3; age: number; spin: number }
14
- interface Particle { position: THREE.Vector3; velocity: THREE.Vector3; age: number }
15
- function foil(color: string, index: number) {
16
- const canvas = document.createElement("canvas"); canvas.width = 512; canvas.height = 256;
17
- const c = canvas.getContext("2d")!;
18
- const gradient = c.createLinearGradient(0, 0, 512, 256); gradient.addColorStop(0, color); gradient.addColorStop(0.3, "#f6edff"); gradient.addColorStop(0.52, color); gradient.addColorStop(0.77, "#695af2"); gradient.addColorStop(1, color);
19
- c.fillStyle = gradient; c.fillRect(0, 0, 512, 256);
20
- c.strokeStyle = "#ffffffaf"; c.lineWidth = 3; c.strokeRect(16, 16, 480, 224); c.strokeRect(22, 22, 468, 212);
21
- c.fillStyle = "#15132e"; c.font = "bold 19px monospace"; c.fillText("CHONK / AFTER HOURS", 39, 61);
22
- c.font = "900 70px Arial"; c.fillText("STACK", 34, 152); c.font = "12px monospace"; c.fillText("COLLECTOR SERIES / 00" + (index + 1), 39, 215);
23
- c.save(); c.translate(410, 123); c.rotate(Math.PI / 4); c.strokeStyle = "#ffffffd0";
24
- for (let i = 0; i < 5; i++) c.strokeRect(-45 + i * 7, -45 + i * 7, 90 - i * 14, 90 - i * 14); c.restore();
25
- const texture = new THREE.CanvasTexture(canvas); texture.colorSpace = THREE.SRGBColorSpace; return texture;
26
- }
27
- export class StackRenderer {
28
- readonly state = newStack();
29
- private renderer: THREE.WebGLRenderer;
30
- private scene = new THREE.Scene();
31
- private lights = new THREE.Group();
32
- private camera = new THREE.PerspectiveCamera(38, 1, 0.1, 140);
33
- private composer: EffectComposer;
34
- private bloom: UnrealBloomPass;
35
- private environment: THREE.WebGLRenderTarget;
36
- private cat = createChonk();
37
- private tower = new Map<number, { mesh: THREE.Group; born: number }>();
38
- private moving: THREE.Group;
39
- private introCards: THREE.Group[] = [];
40
- private fragments: Piece[] = [];
41
- private particles: Particle[] = [];
42
- private sparks = new THREE.InstancedMesh(new THREE.OctahedronGeometry(0.055), new THREE.MeshBasicMaterial({ color: "#fff4cb", toneMapped: false }), 80);
43
- private dummy = new THREE.Object3D();
44
- private platform = new THREE.Group();
45
- private rings = new THREE.Group();
46
- private stars: THREE.Points;
47
- private textures = COLORS.map(foil);
48
- private faces = COLORS.map((color, index) => new THREE.MeshPhysicalMaterial({ map: this.textures[index], metalness: 0.6, roughness: 0.23, clearcoat: 1, iridescence: 0.8, iridescenceIOR: 1.4, emissive: color, emissiveIntensity: 0.09, side: THREE.DoubleSide }));
49
- private edges = COLORS.map(color => new THREE.MeshStandardMaterial({ color, metalness: 0.65, roughness: 0.22 }));
50
- private cardGeometry = new RoundedBoxGeometry(1, 0.18, 2.75, 2, 0.035);
51
- private faceGeometry = new THREE.PlaneGeometry(0.97, 2.67);
52
- private lineGeometry = new THREE.BoxGeometry(1.005, 0.025, 2.73);
53
- private lineMaterial = new THREE.MeshBasicMaterial({ color: "#c9faff", toneMapped: false });
54
- private guides: THREE.LineSegments;
55
- private frame = 0; private previous = 0; private elapsed = 0; private lastInput = -10; private landed = -10; private cameraY = 0;
56
- private mode: "intro" | "playing" | "ended" = "intro";
57
- private paused = false; private destroyed = false; private width = 480; private height = 640;
58
- private cardDepth = 2.75;
59
- private artworkOrder = COLORS.map((_, index) => index);
60
- private suppliedArtwork = false;
61
- private nextArtwork: readonly HTMLImageElement[] | null = null;
62
- private layerSlices = new Map<number, CardSlice>();
63
- private croppedFaces = new Map<THREE.Group, THREE.BufferGeometry>();
64
- private reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
65
- private resizeObserver: ResizeObserver;
66
- private pointer = new THREE.Vector2();
67
- private aim = new THREE.Vector3();
68
- private onPointer = (event: PointerEvent) => { this.pointer.set(event.offsetX / this.width - 0.5, event.offsetY / this.height - 0.5); };
69
- private onVisibility = () => { if (document.hidden) this.cancel(); else this.schedule(); };
70
- constructor(private canvas: HTMLCanvasElement, private onDrop: (score: number, combo: number, ended: boolean) => void) {
71
- this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: false, powerPreference: "high-performance" });
72
- this.renderer.setClearColor("#090519"); this.renderer.toneMapping = THREE.ACESFilmicToneMapping; this.renderer.toneMappingExposure = 0.95;
73
- this.renderer.shadowMap.enabled = true; this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
74
- this.scene.background = new THREE.Color("#090519"); this.scene.environmentIntensity = 0.35;
75
- this.scene.fog = new THREE.FogExp2("#090519", 0.018);
76
- const room = new RoomEnvironment(), pmrem = new THREE.PMREMGenerator(this.renderer);
77
- this.environment = pmrem.fromScene(room, 0.04); this.scene.environment = this.environment.texture; room.dispose(); pmrem.dispose();
78
- this.scene.add(new THREE.HemisphereLight("#b5aaff", "#26112e", 1.2));
79
- const key = new THREE.DirectionalLight("#fff1d5", 2.6); key.position.set(-4, 12, 8); key.castShadow = true; key.shadow.mapSize.set(1024, 1024); key.shadow.camera.left = -8; key.shadow.camera.right = 8; key.shadow.camera.top = 10; key.shadow.camera.bottom = -6; key.shadow.bias = -0.001; this.lights.add(key, key.target);
80
- const cyan = new THREE.PointLight("#4df5ff", 35, 30); cyan.position.set(-6, 5, 3); this.lights.add(cyan);
81
- const pink = new THREE.PointLight("#ff48c4", 45, 30); pink.position.set(5, 6, -4); this.lights.add(pink); this.scene.add(this.lights);
82
- const base = new THREE.Mesh(new THREE.CylinderGeometry(3.3, 2.9, 0.35, 64), new THREE.MeshStandardMaterial({ color: "#251741", metalness: 0.8, roughness: 0.25 })); base.position.y = -0.35; base.receiveShadow = true; this.platform.add(base);
83
- for (let i = 0; i < 3; i++) { const ring = new THREE.Mesh(new THREE.TorusGeometry(3.25 + i * 0.16, 0.025, 6, 80), new THREE.MeshBasicMaterial({ color: i === 1 ? "#ff63d9" : "#65fff2", toneMapped: false })); ring.rotation.x = Math.PI / 2; ring.position.y = -0.23 - i * 0.12; this.platform.add(ring); }
84
- this.scene.add(this.platform, this.cat.root, this.rings, this.sparks); this.sparks.count = 0; this.sparks.frustumCulled = false;
85
- for (let i = 0; i < 4; i++) {
86
- const ring = new THREE.Mesh(new THREE.TorusGeometry(6.1 + i * 1.8, 0.012, 5, 128), new THREE.MeshBasicMaterial({ color: i % 2 ? "#653ae1" : "#ff4698", transparent: true, opacity: 0.45, toneMapped: false }));
87
- ring.position.set(0, 3, -6); ring.rotation.set(0.3 + i * 0.22, 0.4, i * 0.4); this.rings.add(ring);
88
- }
89
- const positions = new Float32Array(900 * 3);
90
- for (let i = 0; i < 900; i++) { const a = i * 2.39996, radius = 15 + (i % 53) * 0.5; positions[i * 3] = Math.cos(a) * radius; positions[i * 3 + 1] = (i % 71) - 20; positions[i * 3 + 2] = Math.sin(a) * radius - 8; }
91
- const geometry = new THREE.BufferGeometry(); geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
92
- this.stars = new THREE.Points(geometry, new THREE.PointsMaterial({ color: "#a6c9ff", size: 0.06, transparent: true, opacity: 0.8, sizeAttenuation: true })); this.scene.add(this.stars);
93
- const guideGeometry = new THREE.BufferGeometry(); guideGeometry.setAttribute("position", new THREE.Float32BufferAttribute(new Float32Array(12), 3));
94
- this.guides = new THREE.LineSegments(guideGeometry, new THREE.LineBasicMaterial({ color: "#7bffe2", transparent: true, opacity: 0.32 })); this.guides.frustumCulled = false; this.scene.add(this.guides);
95
- this.moving = this.makeCard(0); this.scene.add(this.moving);
96
- for (let i = 0; i < 7; i++) { const card = this.makeCard(i); card.scale.x = 4.55; card.position.y = i * 0.36; this.introCards.push(card); this.scene.add(card); }
97
- this.composer = new EffectComposer(this.renderer); this.composer.addPass(new RenderPass(this.scene, this.camera));
98
- this.bloom = new UnrealBloomPass(new THREE.Vector2(480, 640), 0.25, 0.3, 1.8); this.composer.addPass(this.bloom); this.composer.addPass(new OutputPass());
99
- this.cat.skin(0); this.resizeObserver = new ResizeObserver(() => this.resize()); this.resizeObserver.observe(canvas);
100
- canvas.addEventListener("pointermove", this.onPointer); document.addEventListener("visibilitychange", this.onVisibility);
101
- this.resize(); this.schedule();
102
- }
103
- private makeCard(level: number, slice = centeredCardSlice(START_WIDTH)) {
104
- const group = new THREE.Group(); const index = this.artworkOrder[level % this.artworkOrder.length];
105
- const body = new THREE.Mesh(this.cardGeometry, this.edges[index % this.edges.length]); body.receiveShadow = true; group.add(body);
106
- const geometry = slice.left === 0 && slice.right === 1 ? this.faceGeometry : this.faceGeometry.clone();
107
- if (geometry !== this.faceGeometry) {
108
- const uv = geometry.getAttribute('uv');
109
- for (let i = 0; i < uv.count; i++) uv.setX(i, slice.left + uv.getX(i) * (slice.right - slice.left));
110
- uv.needsUpdate = true; this.croppedFaces.set(group, geometry);
111
- }
112
- const face = new THREE.Mesh(geometry, this.faces[index]); face.rotation.x = -Math.PI / 2; face.position.y = 0.094; face.receiveShadow = true; group.add(face);
113
- const line = new THREE.Mesh(this.lineGeometry, this.lineMaterial); line.position.y = -0.01; group.add(line); return group;
114
- }
115
- private removeCard(mesh: THREE.Group): void {
116
- this.scene.remove(mesh); this.croppedFaces.get(mesh)?.dispose(); this.croppedFaces.delete(mesh);
117
- }
118
- private resize() {
119
- if (this.destroyed) return; const bounds = this.canvas.getBoundingClientRect(); if (!bounds.width || !bounds.height) return;
120
- this.width = bounds.width; this.height = bounds.height;
121
- const ratio = Math.min(devicePixelRatio || 1, this.width < 600 ? 1.25 : 1.5);
122
- this.renderer.setPixelRatio(ratio); this.renderer.setSize(this.width, this.height, false); this.composer.setPixelRatio(ratio); this.composer.setSize(this.width, this.height);
123
- this.bloom.enabled = this.width >= 600 && !this.reduced;
124
- this.camera.aspect = this.width / this.height; this.camera.updateProjectionMatrix(); this.draw();
125
- }
126
- setSkin(index: number) { this.cat.skin(index); this.draw(); }
127
- /** Background artwork can change the intro, or wait for the next fresh run. */
128
- setNextCardArtwork(images: readonly HTMLImageElement[]): void {
129
- if (this.destroyed) return;
130
- if (this.mode === 'intro') { this.setCardArtwork(images); return; }
131
- if (images.length < 1 || images.length > 12 || images.some(image => !image.complete || image.naturalWidth < 1 || image.naturalHeight < 1 || image.naturalWidth > 2048 || image.naturalHeight > 2048))
132
- throw new Error('Supply one to twelve decoded card faces');
133
- this.nextArtwork = [...images];
134
- }
135
- /** First-party hosts can supply decoded, origin-clean full slabs. This performs no network or inventory work. */
136
- setCardArtwork(images: readonly HTMLImageElement[]): void {
137
- if (this.destroyed) return;
138
- if (this.mode !== 'intro') throw new Error('Load card artwork before play');
139
- if (images.length < 1 || images.length > 12) throw new Error('Supply one to twelve card faces');
140
- const prepared = images.map(image => {
141
- if (!image.complete || image.naturalWidth < 1 || image.naturalHeight < 1 || image.naturalWidth > 2048 || image.naturalHeight > 2048)
142
- throw new Error('Card artwork is not decoded or exceeds its size limit');
143
- const canvas = document.createElement('canvas'); canvas.width = 512; canvas.height = 806;
144
- const context = canvas.getContext('2d'); if (!context) throw new Error('Card artwork canvas unavailable');
145
- context.fillStyle = '#16161a'; context.fillRect(0, 0, 512, 806);
146
- const scale = Math.min(512 / image.naturalWidth, 806 / image.naturalHeight);
147
- const width = image.naturalWidth * scale, height = image.naturalHeight * scale;
148
- context.drawImage(image, (512 - width) / 2, (806 - height) / 2, width, height);
149
- // Refuse a tainted source before replacing any texture used by recording.
150
- context.getImageData(0, 0, 1, 1); return canvas;
151
- });
152
- // The intro has already uploaded the procedural textures. WebGL's immutable
153
- // storage cannot be resized from those landscape faces to portrait slabs.
154
- const previousTextures = this.textures;
155
- this.textures = prepared.map(canvas => { const texture = new THREE.CanvasTexture(canvas); texture.colorSpace = THREE.SRGBColorSpace; return texture; });
156
- while (this.faces.length < prepared.length) this.faces.push(this.faces[0].clone());
157
- this.faces.forEach((face, index) => { face.map = this.textures[index % this.textures.length]; });
158
- previousTextures.forEach(texture => texture.dispose());
159
- this.faces.forEach(face => { face.metalness = 0; face.roughness = 0.6; face.iridescence = 0; face.clearcoat = 0.25; face.emissiveIntensity = 0; face.needsUpdate = true; });
160
- this.edges.forEach(edge => { edge.color.set('#50535c'); edge.metalness = 0.1; edge.roughness = 0.25; });
161
- this.artworkOrder = prepared.map((_, index) => index); this.suppliedArtwork = true;
162
- const replace = <T extends THREE.BufferGeometry>(previous: T, next: T): T => {
163
- this.scene.traverse(object => { if (object instanceof THREE.Mesh && object.geometry === previous) object.geometry = next; });
164
- previous.dispose(); return next;
165
- };
166
- this.cardDepth = 7.15;
167
- this.cardGeometry = replace(this.cardGeometry, new RoundedBoxGeometry(1, 0.18, this.cardDepth, 2, 0.035));
168
- this.faceGeometry = replace(this.faceGeometry, new THREE.PlaneGeometry(0.97, this.cardDepth - 0.08));
169
- this.lineGeometry = replace(this.lineGeometry, new THREE.BoxGeometry(1.005, 0.025, this.cardDepth - 0.02));
170
- this.draw();
171
- }
172
- start() {
173
- for (const entry of this.tower.values()) this.removeCard(entry.mesh); this.tower.clear(); this.layerSlices.clear();
174
- for (const piece of this.fragments) this.removeCard(piece.mesh); this.fragments = []; this.particles = [];
175
- if (this.nextArtwork) {
176
- const images = this.nextArtwork; this.nextArtwork = null; this.mode = 'intro'; this.setCardArtwork(images);
177
- }
178
- if (this.suppliedArtwork) for (let i = this.artworkOrder.length - 1; i > 0; i--) {
179
- const j = Math.floor(crypto.getRandomValues(new Uint32Array(1))[0] / 0x1_0000_0000 * (i + 1));
180
- [this.artworkOrder[i], this.artworkOrder[j]] = [this.artworkOrder[j], this.artworkOrder[i]];
181
- }
182
- Object.assign(this.state, newStack()); this.mode = "playing"; this.paused = false; this.cameraY = 0; this.elapsed = 0; this.landed = -10; this.lastInput = -10;
183
- this.syncCards(); this.draw(); this.schedule();
184
- }
185
- private syncCards() {
186
- const keep = new Set(this.state.layers.map(layer => layer.level));
187
- for (const [level, entry] of this.tower) if (!keep.has(level)) { this.removeCard(entry.mesh); this.tower.delete(level); this.layerSlices.delete(level); }
188
- for (const layer of this.state.layers) if (!this.tower.has(layer.level)) {
189
- const mesh = this.makeCard(layer.level, this.layerSlices.get(layer.level) ?? centeredCardSlice(layer.width)); mesh.scale.x = layer.width * UNIT; mesh.position.x = (layer.x + layer.width / 2 - 240) * UNIT;
190
- this.scene.add(mesh); this.tower.set(layer.level, { mesh, born: layer.level ? this.elapsed : -10 });
191
- }
192
- this.removeCard(this.moving); this.moving = this.makeCard(this.state.moving.level, centeredCardSlice(this.state.moving.width)); this.scene.add(this.moving);
193
- }
194
- input() {
195
- if (this.mode !== "playing" || this.paused || this.elapsed - this.lastInput < 0.2) return;
196
- this.lastInput = this.elapsed; const incoming = { ...this.state.moving }, result = drop(this.state); this.landed = this.elapsed;
197
- if (!this.state.ended) {
198
- const landed = this.state.layers[this.state.layers.length - 1];
199
- this.layerSlices.set(landed.level, result.perfect ? centeredCardSlice(landed.width) : cutCardSlice(incoming, landed));
200
- }
201
- if (result.offcut && !this.reduced) this.fall(result.offcut, cutCardSlice(incoming, result.offcut));
202
- const top = this.state.layers[this.state.layers.length - 1];
203
- if (!this.reduced) for (let i = 0; i < (result.perfect ? 24 : 8); i++) this.particles.push({ position: new THREE.Vector3((top.x + top.width / 2 - 240) * UNIT, top.level * STEP + 0.2, 0), velocity: new THREE.Vector3(Math.sin(i * 2.4) * 3.2, 2 + (i % 3), Math.cos(i * 2.4) * 3.2), age: 0 });
204
- this.particles = this.particles.slice(-80); this.syncCards();
205
- if (this.state.ended) this.mode = "ended";
206
- this.onDrop(this.state.score, this.state.combo, this.state.ended); this.draw();
207
- }
208
- private fall(card: CardLayer, slice: CardSlice) {
209
- const mesh = this.makeCard(card.level, slice); mesh.scale.x = card.width * UNIT; mesh.position.set((card.x + card.width / 2 - 240) * UNIT, card.level * STEP + 2.1, 0); this.scene.add(mesh);
210
- this.fragments.push({ mesh, velocity: new THREE.Vector3(card.x > 240 ? 2 : -2, 0.3, 0.2), age: 0, spin: card.x > 240 ? -1 : 1 });
211
- while (this.fragments.length > 8) this.removeCard(this.fragments.shift()!.mesh);
212
- }
213
- pause(value: boolean) { this.paused = value; this.previous = 0; if (value) this.cancel(); else this.schedule(); this.draw(); }
214
- private schedule() { if (!this.frame && !this.paused && !this.destroyed && !document.hidden && !(this.reduced && this.mode !== "playing")) this.frame = requestAnimationFrame(time => this.tick(time)); }
215
- private cancel() { cancelAnimationFrame(this.frame); this.frame = 0; this.previous = 0; }
216
- private tick(time: number) {
217
- this.frame = 0; if (this.paused || this.destroyed || document.hidden) return;
218
- if (this.mode === "intro" && this.previous && time - this.previous < 32) { this.schedule(); return; }
219
- const dt = this.previous ? Math.min(0.05, (time - this.previous) / 1000) : 0; this.previous = time; this.elapsed += dt;
220
- if (this.mode === "playing") advance(this.state, dt);
221
- this.cameraY += (Math.max(0, this.state.score - 2) * STEP - this.cameraY) * Math.min(1, dt * 5);
222
- for (const piece of this.fragments) { piece.age += dt; piece.velocity.y -= 10 * dt; piece.mesh.position.addScaledVector(piece.velocity, dt); piece.mesh.rotation.z += dt * piece.spin * 2; piece.mesh.rotation.x += dt; }
223
- this.fragments = this.fragments.filter(piece => { if (piece.age < 1.8) return true; this.removeCard(piece.mesh); return false; });
224
- for (const particle of this.particles) { particle.age += dt; particle.velocity.y -= 6 * dt; particle.position.addScaledVector(particle.velocity, dt); }
225
- this.particles = this.particles.filter(particle => particle.age < 1.2); this.draw();
226
- if (this.mode !== "ended" || this.elapsed - this.landed < 1.8) this.schedule();
227
- }
228
- private draw() {
229
- if (this.destroyed) return;
230
- const intro = this.mode === "intro", t = this.elapsed, top = this.state.layers[this.state.layers.length - 1];
231
- this.platform.position.y = -Math.max(0, this.cameraY * 0.1); this.platform.visible = this.cameraY < 7;
232
- this.introCards.forEach((mesh, index) => { mesh.visible = intro; mesh.rotation.y = this.reduced ? index * 0.05 : Math.sin(t * 0.35 + index * 0.4) * 0.2; mesh.position.y = index * 0.36 + (this.reduced ? 0 : Math.sin(t * 0.8 + index) * 0.035); });
233
- for (const [level, entry] of this.tower) { const progress = this.reduced ? 1 : Math.min(1, (t - entry.born) / 0.18); entry.mesh.position.y = level * STEP + (1 - progress) ** 3 * 2.1; }
234
- this.moving.visible = this.mode === "playing"; this.moving.scale.x = this.state.moving.width * UNIT;
235
- this.moving.position.set((this.state.moving.x + this.state.moving.width / 2 - 240) * UNIT, this.state.moving.level * STEP + 2.1, 0);
236
- const bounce = this.reduced ? 0 : Math.max(0, 1 - (t - this.landed) / 0.5);
237
- this.cat.root.position.set(intro ? 0 : (top.x + top.width / 2 - 240) * UNIT, (intro ? 6 * 0.36 : top.level * STEP) + 0.11 + Math.sin(bounce * Math.PI) * 0.65, 0);
238
- this.cat.root.scale.set(0.85 + bounce * 0.05, 0.85 - bounce * 0.07, 0.85 + bounce * 0.05);
239
- this.cat.root.rotation.y = 0.38 + (!this.reduced && intro ? Math.sin(t * 0.5) * 0.1 : 0); this.cat.root.rotation.z = Math.sin(bounce * Math.PI * 2) * 0.08;
240
- this.lights.position.y = this.cameraY; this.rings.position.y = this.cameraY; if (!this.reduced) this.rings.rotation.z = t * 0.018; this.stars.position.y = this.cameraY * 0.7;
241
- this.particles.forEach((particle, index) => { this.dummy.position.copy(particle.position); this.dummy.rotation.set(particle.age * 3, particle.age * 5, 0); this.dummy.scale.setScalar((1 - particle.age / 1.2) * 1.8); this.dummy.updateMatrix(); this.sparks.setMatrixAt(index, this.dummy.matrix); }); this.sparks.count = this.particles.length; this.sparks.instanceMatrix.needsUpdate = true;
242
- const array = this.guides.geometry.attributes.position.array;
243
- const x1 = (top.x - 240) * UNIT, x2 = (top.x + top.width - 240) * UNIT, y1 = top.level * STEP + 0.15, y2 = this.state.moving.level * STEP + 2.0;
244
- const guideZ = this.cardDepth / 2 + 0.025;
245
- array.set([x1, y1, guideZ, x1, y2, guideZ, x2, y1, guideZ, x2, y2, guideZ]); this.guides.geometry.attributes.position.needsUpdate = true; this.guides.visible = this.mode === "playing";
246
- const distance = Math.max(14, Math.min(25, 15 / Math.pow(this.camera.aspect, 0.55))) * (intro && this.width <= 650 ? 1.12 : 1);
247
- const orbit = 0.44 + (this.reduced ? 0 : this.pointer.x * 0.1);
248
- this.aim.set(intro && this.width > 650 ? -1.9 : 0, this.cameraY + (intro ? 1.65 : 1.0), 0);
249
- const impact = !this.reduced && this.state.combo >= 3 ? Math.sin(bounce * 28) * bounce * 0.035 : 0;
250
- this.camera.position.set(Math.sin(orbit) * distance + impact, this.cameraY + distance * 0.57, Math.cos(orbit) * distance);
251
- this.camera.lookAt(this.aim); this.composer.render();
252
- }
253
- destroy() {
254
- if (this.destroyed) return;
255
- this.destroyed = true; this.cancel(); this.resizeObserver.disconnect(); this.canvas.removeEventListener("pointermove", this.onPointer); document.removeEventListener("visibilitychange", this.onVisibility);
256
- const geometries = new Set<THREE.BufferGeometry>(), materials = new Set<THREE.Material>();
257
- this.scene.traverse(object => { if (object instanceof THREE.DirectionalLight) object.shadow.dispose(); if (object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points) { geometries.add(object.geometry); for (const material of Array.isArray(object.material) ? object.material : [object.material]) materials.add(material); } });
258
- this.faces.forEach(material => materials.add(material)); this.edges.forEach(material => materials.add(material));
259
- geometries.forEach(geometry => geometry.dispose()); materials.forEach(material => material.dispose()); this.textures.forEach(texture => texture.dispose());
260
- this.croppedFaces.clear(); this.layerSlices.clear(); this.nextArtwork = null;
261
- this.environment.dispose(); for (const pass of this.composer.passes) pass.dispose(); this.composer.dispose(); this.renderer.dispose(); this.renderer.forceContextLoss();
262
- }
263
- }
@@ -1,47 +0,0 @@
1
- import type { GameCard } from "@vibechain/os";
2
-
3
- export const COLLECTION = "4663:0x733f92170fa7d42bdb6f35fb7d37af97208ff124:6";
4
- export const SKINS = [
5
- { name: "Cloud", fur: "#f7f0dc", belly: "#fffbee", accent: "#c3d4d7", eyes: "#324b55", label: "STARTER" },
6
- { name: "Ginger", fur: "#df9859", belly: "#ffe1ad", accent: "#eaae72", eyes: "#4d6154", label: "COMMON" },
7
- { name: "Bubblegum", fur: "#e7a5c7", belly: "#ffe3ef", accent: "#edb8d0", eyes: "#665281", label: "RARE" },
8
- { name: "Mint Condition", fur: "#7fcbb2", belly: "#dcffec", accent: "#8ed3b7", eyes: "#29534d", label: "EPIC" },
9
- { name: "Midnight", fur: "#515066", belly: "#e9e5ff", accent: "#b3aedc", eyes: "#dbd5fc", label: "LEGENDARY" },
10
- { name: "Solar Gold", fur: "#e4b546", belly: "#fff3c2", accent: "#f3cf76", eyes: "#6b5735", label: "MYTHIC" },
11
- ] as const;
12
- export function ownedSkins(cards: readonly GameCard[]): Set<number> {
13
- return new Set([0, ...cards.filter(card => card.packId === COLLECTION && card.state === "collected" && Number.isInteger(card.rarity) && card.rarity >= 0 && card.rarity < 5).map(card => card.rarity + 1)]);
14
- }
15
-
16
- /** The same cosmetic characters, drawn locally; no remote art or wallet code. */
17
- export function drawCat(c: CanvasRenderingContext2D, x: number, y: number, size: number, skin: number, squash = 0) {
18
- const look = SKINS[skin] ?? SKINS[0];
19
- c.save(); c.translate(x, y); c.scale(size / 100 * (1 + squash * 0.12), size / 100 * (1 - squash * 0.12));
20
- c.lineCap = "round"; c.lineJoin = "round";
21
- // Tail, haunches and the oversized head are the silhouette at small sizes.
22
- c.strokeStyle = look.fur; c.lineWidth = 13; c.beginPath(); c.moveTo(30, -17); c.bezierCurveTo(62, -3, 57, -43, 42, -38); c.stroke();
23
- c.fillStyle = look.fur; c.beginPath(); c.ellipse(0, -24, 37, 26, 0, 0, Math.PI * 2); c.fill();
24
- c.beginPath(); c.moveTo(-31, -55); c.lineTo(-34, -88); c.quadraticCurveTo(-27, -94, -12, -72); c.lineTo(14, -72); c.quadraticCurveTo(30, -94, 35, -88); c.lineTo(32, -52); c.closePath(); c.fill();
25
- c.fillStyle = "#eab8b0"; c.beginPath(); c.moveTo(-28, -65); c.lineTo(-28, -80); c.lineTo(-17, -69); c.moveTo(27, -65); c.lineTo(28, -80); c.lineTo(17, -69); c.fill();
26
- c.fillStyle = look.fur; c.beginPath(); c.ellipse(0, -54, 40, 29, 0, 0, Math.PI * 2); c.fill();
27
- c.fillStyle = look.belly; c.beginPath(); c.ellipse(0, -15, 22, 12, 0, 0, Math.PI * 2); c.fill();
28
- c.beginPath(); c.ellipse(-12, -43, 16, 11, 0, 0, Math.PI * 2); c.ellipse(12, -43, 16, 11, 0, 0, Math.PI * 2); c.fill();
29
- c.fillStyle = look.eyes; for (const side of [-1, 1]) { c.beginPath(); c.ellipse(side * 17, -56, 4, 6, 0, 0, Math.PI * 2); c.fill(); }
30
- c.fillStyle = "#fff"; for (const side of [-1, 1]) { c.beginPath(); c.arc(side * 17 - 1, -58, 1.4, 0, Math.PI * 2); c.fill(); }
31
- c.fillStyle = "#b97c79"; c.beginPath(); c.moveTo(-4, -45); c.lineTo(4, -45); c.lineTo(0, -41); c.fill();
32
- c.strokeStyle = "#6b6261"; c.lineWidth = 1.5; c.beginPath(); c.moveTo(-6, -38); c.quadraticCurveTo(-2, -35, 0, -40); c.quadraticCurveTo(2, -35, 6, -38); c.stroke();
33
- c.strokeStyle = look.belly; c.lineWidth = 3; c.beginPath(); c.moveTo(-27, -41); c.lineTo(-43, -43); c.moveTo(27, -41); c.lineTo(43, -43); c.stroke();
34
- c.fillStyle = look.fur; for (const side of [-1, 1]) { c.beginPath(); c.ellipse(side * 22, -3, 12, 6, 0, 0, Math.PI * 2); c.fill(); }
35
- if (skin === 1 || skin === 5) {
36
- c.strokeStyle = skin === 5 ? "#b48836" : "#ad713c"; c.lineWidth = 3;
37
- for (const dx of [-9, 0, 9]) { c.beginPath(); c.moveTo(dx, -80); c.lineTo(dx * 0.7, -70); c.stroke(); }
38
- }
39
- if (skin === 3 || skin === 4) {
40
- c.strokeStyle = "#303940"; c.lineWidth = 3;
41
- for (const side of [-1, 1]) { c.beginPath(); c.roundRect(side * 17 - 11, -65, 22, 17, 5); if (skin === 4) { c.fillStyle = "#273341"; c.fill(); } c.stroke(); }
42
- c.beginPath(); c.moveTo(-6, -57); c.lineTo(6, -57); c.stroke();
43
- }
44
- if (skin === 5) { c.strokeStyle = "#fff1a1"; c.lineWidth = 4; c.beginPath(); c.arc(0, -28, 17, 0.15, Math.PI - 0.15); c.stroke(); }
45
- if (skin === 2) { c.fillStyle = "#cb88b4"; c.beginPath(); c.roundRect(-32, -8, 20, 6, 3); c.roundRect(12, -8, 20, 6, 3); c.fill(); }
46
- c.restore();
47
- }
@@ -1,21 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "sdkVersion": 1,
4
- "id": "chonk-stack-lab",
5
- "version": "2.1.0",
6
- "name": "Chonk Stack Lab",
7
- "tagline": "Stack the impossible. Your cards. Your cat. No ceiling.",
8
- "category": "3D arcade \u00b7 collect \u00b7 stack",
9
- "entry": "index.html",
10
- "permissions": [
11
- "inventory.get",
12
- "catalog.list",
13
- "packs.buy",
14
- "packs.sell",
15
- "packs.open",
16
- "cards.reveal",
17
- "cards.sell",
18
- "cards.collect"
19
- ],
20
- "collectionId": "4663:0x733f92170fa7d42bdb6f35fb7d37af97208ff124:6"
21
- }
@@ -1,3 +0,0 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Collection Room</title><style>
2
- *{box-sizing:border-box}body{margin:0;background:#14191b;color:#f5f0dc;font:16px system-ui;min-height:100vh;display:grid;place-items:center}main{text-align:center;padding:32px 20px;width:min(100%,720px)}small{color:#afc48f;letter-spacing:.2em;font:11px monospace}h1{font-size:clamp(30px,6vw,60px);letter-spacing:-.05em;margin:14px 0}#status{font:12px monospace;color:#a8aaa1;line-height:1.6}#cat{display:block;margin:28px auto 12px;background:#ecdcaf;color:#191919;font-size:100px;width:200px;height:200px;border-radius:50%;border:0;cursor:pointer;box-shadow:0 0 0 12px #ecdcaf0c}button{cursor:pointer;padding:12px 20px;border:1px solid #677362;background:transparent;color:inherit;border-radius:4px}#count{color:#d0e5ad;font-size:18px}#inventory{font:12px monospace;color:#a8aaa1;margin:24px 0}#inventory button{margin:4px}footer{margin-top:30px;font:10px monospace;color:#758072}
3
- </style></head><body><main><small>VIBEMARKET DEVELOPER EXAMPLE</small><h1>Collection Room</h1><p id="status">Connecting to VibeMarket…</p><button id="cat" aria-label="Pat the cat">🐈</button><p id="count">Give your cat a pat.</p><div id="inventory"></div><button id="shop">MY PACKS ↗</button><footer>STANDALONE BUNDLE · SCOPED SDK · FREE PLAY</footer></main><script type="module" src="./game.js"></script></body></html>
@@ -1,31 +0,0 @@
1
- import { connectGameSdk } from "@vibechain/os";
2
- const status = document.querySelector<HTMLElement>("#status")!;
3
- const count = document.querySelector<HTMLElement>("#count")!;
4
- const cat = document.querySelector<HTMLButtonElement>("#cat")!;
5
- const inventory = document.querySelector<HTMLElement>("#inventory")!;
6
- const abort = new AbortController();
7
- let taps = 0;
8
- cat.onclick = () => { taps += 1; count.textContent = `${taps} happy pats`; cat.animate([{ transform: "scale(1) rotate(0deg)" }, { transform: "scale(1.15) rotate(-5deg)" }, { transform: "scale(1) rotate(0deg)" }], { duration: 220 }); };
9
- async function boot() {
10
- const sdk = await connectGameSdk(abort.signal);
11
- const refresh = async () => {
12
- try {
13
- const [profile, catalog, own] = await Promise.all([sdk.profile.get(), sdk.catalog.list(), sdk.inventory.get()]);
14
- status.textContent = profile ? `Welcome, ${profile.name}` : "Guest play · connect in VibeMarket for your collection";
15
- inventory.replaceChildren();
16
- const label = document.createElement("p");
17
- label.textContent = `${catalog.length} linked collections · ${own.packs.reduce((sum, pack) => sum + pack.quantity, 0)} packs · ${own.cards.length} cards on this page`;
18
- inventory.append(label);
19
- for (const card of own.cards.filter(card => card.state === "collected")) {
20
- const button = document.createElement("button"); button.textContent = `Equip ${card.name}`;
21
- button.onclick = () => { cat.style.filter = `hue-rotate(${card.rarity * 55}deg)`; }; inventory.append(button);
22
- }
23
- } catch (error) { status.textContent = error instanceof Error ? error.message : "Inventory unavailable"; }
24
- };
25
- const unsubscribe = sdk.inventory.onChanged(() => void refresh());
26
- document.querySelector<HTMLButtonElement>("#shop")!.onclick = () => { void sdk.showShop().catch(error => { status.textContent = String(error); }); };
27
- window.addEventListener("pagehide", () => { unsubscribe(); sdk.destroy(); abort.abort(); }, { once: true });
28
- await sdk.ready();
29
- await refresh();
30
- }
31
- void boot().catch(error => { status.textContent = `Open this game through VibeMarket. ${String(error)}`; });
@@ -1,12 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "sdkVersion": 1,
4
- "id": "collection-room",
5
- "version": "1.0.0",
6
- "name": "Collection Room",
7
- "tagline": "Your cards. Your cozy corner.",
8
- "category": "Collect · customize · play",
9
- "entry": "index.html",
10
- "permissions": ["profile.get", "catalog.list", "inventory.get"],
11
- "collectionId": null
12
- }
@@ -1,4 +0,0 @@
1
- {
2
- "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "Bundler", "lib": ["ES2022", "DOM"], "strict": true, "skipLibCheck": true, "noEmit": true, "allowImportingTsExtensions": true, "paths": { "@vibechain/os": ["../src/index.ts"], "@vibechain/os/loop": ["../src/loop.ts"], "@vibechain/os/canvas": ["../src/canvas.ts"], "@vibechain/os/testing": ["../src/testing.ts"] } },
3
- "include": ["../tools/*.ts", "../tools/*.mts", "collection-room/main.ts", "chonk-stack/*.ts", "paw-beat/*.ts", "vibexp-app/src/*.ts", "../tests/**/*.ts", "../vitest.config.ts"]
4
- }