@vibechain/os 0.2.1 → 0.4.1

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 (47) hide show
  1. package/AGENTS.md +110 -201
  2. package/README.md +78 -7
  3. package/SECURITY.md +22 -3
  4. package/dist/app-runtime.d.ts +1 -1
  5. package/dist/app-runtime.js +11 -3
  6. package/dist/bundle.js +10 -0
  7. package/dist/canvas.d.ts +40 -0
  8. package/dist/canvas.js +41 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/listing.d.ts +35 -0
  11. package/dist/listing.js +56 -0
  12. package/dist/loop.d.ts +34 -0
  13. package/dist/loop.js +47 -0
  14. package/dist/manifest.d.ts +70 -1
  15. package/dist/manifest.js +117 -9
  16. package/dist/preview-ui.js +1 -1
  17. package/dist/scaffold.js +20 -7
  18. package/dist/testing.d.ts +29 -0
  19. package/dist/testing.js +49 -0
  20. package/examples/paw-beat/README.md +50 -0
  21. package/examples/paw-beat/cat.ts +129 -0
  22. package/examples/paw-beat/game.ts +151 -0
  23. package/examples/paw-beat/index.html +65 -0
  24. package/examples/paw-beat/main.ts +243 -0
  25. package/examples/paw-beat/music.ts +123 -0
  26. package/examples/paw-beat/store/icon.png +0 -0
  27. package/examples/paw-beat/store/screenshot-1.webp +0 -0
  28. package/examples/paw-beat/store/screenshot-2.webp +0 -0
  29. package/examples/paw-beat/vibemarket.json +21 -0
  30. package/examples/vibexp-app/README.md +19 -3
  31. package/examples/vibexp-app/store/icon.png +0 -0
  32. package/examples/vibexp-app/store/screenshot-1.png +0 -0
  33. package/examples/vibexp-app/vibemarket.json +21 -1
  34. package/package.json +19 -2
  35. package/examples/chonk-stack/card-slice.ts +0 -17
  36. package/examples/chonk-stack/cat3d.ts +0 -57
  37. package/examples/chonk-stack/game.css +0 -174
  38. package/examples/chonk-stack/index.html +0 -32
  39. package/examples/chonk-stack/main.ts +0 -149
  40. package/examples/chonk-stack/model.ts +0 -40
  41. package/examples/chonk-stack/renderer.ts +0 -263
  42. package/examples/chonk-stack/skins.ts +0 -47
  43. package/examples/chonk-stack/vibemarket.json +0 -21
  44. package/examples/collection-room/index.html +0 -3
  45. package/examples/collection-room/main.ts +0 -31
  46. package/examples/collection-room/vibemarket.json +0 -12
  47. package/examples/tsconfig.json +0 -4
@@ -0,0 +1,243 @@
1
+ import * as THREE from "three";
2
+ import { connectVibeMarketApp, type AppValue, type VibeMarketAppSdk } from "@vibechain/os";
3
+ import { createLoop } from "@vibechain/os/loop";
4
+ import { fitCanvas } from "@vibechain/os/canvas";
5
+ import { createCat } from "./cat";
6
+ import { BEAT_SECONDS, createGame, LANES, SONG_SECONDS, type DanceGame, type Judgement, type Lane } from "./game";
7
+ import { createMusic } from "./music";
8
+
9
+ function element<T extends HTMLElement>(id: string): T {
10
+ const node = document.getElementById(id);
11
+ if (!node) throw Error(`Missing element: ${id}`);
12
+ return node as T;
13
+ }
14
+ const canvas = element<HTMLCanvasElement>("scene"), hud = element("hud"), pads = element("pads"), call = element("call");
15
+ const intro = element("intro"), done = element("done"), bestLine = element("best");
16
+ const startButton = element<HTMLButtonElement>("start"), againButton = element<HTMLButtonElement>("again");
17
+ const scoreText = element("score"), comboText = element("combo"), timeText = element("time");
18
+
19
+ // ---- Stage layout. Two lanes run past each side of the cat toward the targets. ----
20
+ const LANE_X: Readonly<Record<Lane, number>> = { left: -3.1, down: -1.75, up: 1.75, right: 3.1 };
21
+ const LANE_COLOR: Readonly<Record<Lane, string>> = { left: "#ff5c8a", down: "#4cc9f0", up: "#ffd166", right: "#7bd88f" };
22
+ /** Which way each arrow points when lying on the floor (rotation about the vertical axis). */
23
+ const LANE_TURN: Readonly<Record<Lane, number>> = { up: 0, left: Math.PI / 2, down: Math.PI, right: -Math.PI / 2 };
24
+ const HIT_Z = 1.6, SPEED = 7.5, LOOKAHEAD = 2.2;
25
+
26
+ const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, powerPreference: "low-power" });
27
+ renderer.setPixelRatio(1); // fitCanvas already sizes the backing store in device pixels.
28
+ const scene = new THREE.Scene();
29
+ scene.background = new THREE.Color("#150f24");
30
+ scene.fog = new THREE.Fog("#150f24", 12, 24);
31
+ const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 60);
32
+ scene.add(new THREE.HemisphereLight("#fff1dc", "#2a1d44", 1.2));
33
+ const spot = new THREE.DirectionalLight("#ffe2b8", 1.5);
34
+ spot.position.set(2, 6, 5);
35
+ scene.add(spot);
36
+
37
+ const floor = new THREE.Mesh(new THREE.PlaneGeometry(40, 60), new THREE.MeshStandardMaterial({ color: "#1d1533", roughness: 1 }));
38
+ floor.rotation.x = -Math.PI / 2;
39
+ floor.position.z = -12;
40
+ scene.add(floor);
41
+ const stageGlow = new THREE.MeshStandardMaterial({ color: "#3a2a66", emissive: "#8f6bff", emissiveIntensity: 0.2, roughness: 0.8 });
42
+ const stage = new THREE.Mesh(new THREE.CylinderGeometry(1.25, 1.35, 0.18, 40), stageGlow);
43
+ stage.position.y = 0.09;
44
+ scene.add(stage);
45
+
46
+ // One flat arrow shape, reused for every note and target.
47
+ const arrowShape = new THREE.Shape();
48
+ for (const [x, y] of [[0, 0.55], [0.5, 0.02], [0.2, 0.02], [0.2, -0.5], [-0.2, -0.5], [-0.2, 0.02], [-0.5, 0.02]] as const) {
49
+ if (x === 0 && y === 0.55) arrowShape.moveTo(x, y);
50
+ else arrowShape.lineTo(x, y);
51
+ }
52
+ const arrowGeometry = new THREE.ExtrudeGeometry(arrowShape, { depth: 0.1, bevelEnabled: false });
53
+ arrowGeometry.rotateX(-Math.PI / 2); // lie flat, pointing away from the camera
54
+
55
+ const targets = {} as Record<Lane, THREE.MeshStandardMaterial>;
56
+ const noteMaterial = {} as Record<Lane, THREE.MeshStandardMaterial>;
57
+ for (const lane of LANES) {
58
+ const strip = new THREE.Mesh(new THREE.PlaneGeometry(1.15, 30), new THREE.MeshBasicMaterial({ color: LANE_COLOR[lane], transparent: true, opacity: 0.07 }));
59
+ strip.rotation.x = -Math.PI / 2;
60
+ strip.position.set(LANE_X[lane], 0.01, HIT_Z - 14);
61
+ scene.add(strip);
62
+ targets[lane] = new THREE.MeshStandardMaterial({ color: "#2b2147", emissive: LANE_COLOR[lane], emissiveIntensity: 0.25, roughness: 0.6, side: THREE.DoubleSide });
63
+ const target = new THREE.Mesh(arrowGeometry, targets[lane]);
64
+ target.position.set(LANE_X[lane], 0.02, HIT_Z);
65
+ target.rotation.y = LANE_TURN[lane];
66
+ target.scale.setScalar(1.12);
67
+ scene.add(target);
68
+ noteMaterial[lane] = new THREE.MeshStandardMaterial({ color: LANE_COLOR[lane], emissive: LANE_COLOR[lane], emissiveIntensity: 0.9, roughness: 0.4, side: THREE.DoubleSide });
69
+ }
70
+ // A fixed pool is enough: only a couple of seconds of notes are ever on screen.
71
+ const pool = Array.from({ length: 28 }, () => {
72
+ const mesh = new THREE.Mesh(arrowGeometry, noteMaterial.left);
73
+ mesh.scale.setScalar(1.2);
74
+ mesh.visible = false;
75
+ scene.add(mesh);
76
+ return mesh;
77
+ });
78
+
79
+ const cat = createCat();
80
+ cat.root.position.y = 0.18;
81
+ scene.add(cat.root);
82
+
83
+ // ---- Round state ----
84
+ interface Saved { best: number; rounds: number }
85
+ function parseSaved(value: AppValue): Saved {
86
+ if (!value || typeof value !== "object" || Array.isArray(value)) return { best: 0, rounds: 0 };
87
+ const count = (input: AppValue | undefined) => (typeof input === "number" && Number.isFinite(input) && input >= 0 ? Math.floor(input) : 0);
88
+ return { best: count(value.best), rounds: count(value.rounds) };
89
+ }
90
+
91
+ let app: VibeMarketAppSdk | undefined;
92
+ let game: DanceGame = createGame();
93
+ let saved: Saved = { best: 0, rounds: 0 };
94
+ let running = false, silentClock = 0, shownScore = -1, shownCombo = -1, shownTime = -1;
95
+ const flash: Record<Lane, number> = { left: 0, down: 0, up: 0, right: 0 };
96
+ const music = createMusic();
97
+
98
+ function announce(kind: Judgement) {
99
+ call.dataset.kind = kind;
100
+ call.textContent = kind === "miss" ? "Miss" : kind === "perfect" ? "Perfect!" : kind === "great" ? "Great" : "Good";
101
+ call.classList.remove("show");
102
+ void call.offsetWidth; // restart the CSS animation
103
+ call.classList.add("show");
104
+ }
105
+
106
+ function press(lane: Lane) {
107
+ if (!running) return;
108
+ flash[lane] = 1;
109
+ const hit = game.press(lane);
110
+ if (!hit?.judged) return; // a stray press costs nothing
111
+ cat.dance(lane);
112
+ announce(hit.judged);
113
+ }
114
+
115
+ function begin() {
116
+ const seed = saved.rounds + 1;
117
+ game = createGame(seed);
118
+ silentClock = 0;
119
+ music.start(seed);
120
+ running = true;
121
+ intro.hidden = done.hidden = true;
122
+ hud.hidden = pads.hidden = false;
123
+ canvas.focus();
124
+ }
125
+
126
+ function end() {
127
+ running = false;
128
+ music.stop();
129
+ const { score, bestCombo, counts } = game.state;
130
+ saved = { best: Math.max(saved.best, score), rounds: saved.rounds + 1 };
131
+ // A failed write only loses the personal best; the result still goes to the host.
132
+ void app?.checkpoint.write({ best: saved.best, rounds: saved.rounds }).catch(() => {});
133
+ hud.hidden = pads.hidden = true;
134
+ element("done-score").textContent = String(score);
135
+ element("done-note").textContent = `${counts.perfect} perfect · ${counts.great} great · ${counts.good} good · ${counts.miss} missed. Best run of steps: ${bestCombo}.`;
136
+ done.hidden = false;
137
+ // The host owns the results screen and normally replaces this frame. If it declines
138
+ // (it accepts one score per open window), the card above stays as the result.
139
+ void app?.game.finish({ score }).catch(() => {});
140
+ }
141
+
142
+ // ---- Input: arrow keys, WASD, or the on-screen pads. ----
143
+ const KEY_LANE: Readonly<Record<string, Lane>> = {
144
+ ArrowLeft: "left", ArrowDown: "down", ArrowUp: "up", ArrowRight: "right", KeyA: "left", KeyS: "down", KeyW: "up", KeyD: "right",
145
+ };
146
+ window.addEventListener("keydown", event => {
147
+ const lane = KEY_LANE[event.code];
148
+ if (!lane) return;
149
+ event.preventDefault(); // arrow keys must not scroll the frame
150
+ if (!event.repeat) press(lane);
151
+ });
152
+ for (const pad of Array.from(pads.querySelectorAll<HTMLButtonElement>("button[data-lane]"))) {
153
+ const lane = pad.dataset.lane as Lane;
154
+ pad.addEventListener("pointerdown", event => {
155
+ event.preventDefault();
156
+ press(lane);
157
+ });
158
+ }
159
+
160
+ function drawHud(score: number, combo: number, secondsLeft: number) {
161
+ // Touch the DOM only when a number actually changed.
162
+ if (score !== shownScore) scoreText.textContent = String((shownScore = score));
163
+ if (combo !== shownCombo) comboText.textContent = String((shownCombo = combo));
164
+ if (secondsLeft !== shownTime) timeText.textContent = String((shownTime = secondsLeft));
165
+ }
166
+
167
+ // ---- Boot: connect, restore, then let the host know the first frame is up. ----
168
+ async function boot() {
169
+ try {
170
+ app = await connectVibeMarketApp();
171
+ } catch {
172
+ startButton.textContent = "Open in VibeMarket OS";
173
+ return;
174
+ }
175
+ const host = app;
176
+ fitCanvas(host, canvas, {
177
+ onResize({ width, height }) {
178
+ renderer.setSize(width, height, false);
179
+ camera.aspect = width / height;
180
+ // Pull back on tall, narrow windows so all four lanes stay in frame.
181
+ const pull = Math.max(1, 1.25 / camera.aspect);
182
+ camera.position.set(0, 5.4 * pull, 10.5 * pull);
183
+ camera.lookAt(0, 0.9, -1.5);
184
+ camera.updateProjectionMatrix();
185
+ },
186
+ onContextLost: () => { running = false; },
187
+ });
188
+ createLoop(host, {
189
+ update(stepMs) {
190
+ const seconds = stepMs / 1000;
191
+ silentClock += running ? seconds : 0;
192
+ // The audio clock is the truth while there is sound; otherwise the loop keeps time.
193
+ const now = running ? music.time() ?? silentClock : 0;
194
+ if (running) {
195
+ music.pump();
196
+ if (game.advance(now).length > 0) {
197
+ cat.stumble();
198
+ announce("miss");
199
+ }
200
+ const state = game.state;
201
+ drawHud(state.score, state.combo, Math.max(0, Math.ceil(SONG_SECONDS - state.time)));
202
+ if (state.finished) end();
203
+ }
204
+ const beatPhase = ((now / BEAT_SECONDS) % 1 + 1) % 1, pulse = Math.pow(1 - beatPhase, 3);
205
+ cat.animate(seconds, beatPhase);
206
+ stageGlow.emissiveIntensity = 0.2 + pulse * 0.7;
207
+ for (const lane of LANES) {
208
+ flash[lane] = Math.max(0, flash[lane] - seconds * 5);
209
+ targets[lane].emissiveIntensity = 0.25 + pulse * 0.2 + flash[lane] * 1.4;
210
+ }
211
+ // Lay out the notes that are on screen right now.
212
+ let used = 0;
213
+ if (running) {
214
+ game.each(now - 0.35, now + LOOKAHEAD, (note, judged) => {
215
+ // A step that was hit disappears; a missed one slides on past the target.
216
+ const mesh = judged && judged !== "miss" ? undefined : pool[used];
217
+ if (!mesh) return;
218
+ used += 1;
219
+ mesh.material = noteMaterial[note.lane];
220
+ mesh.position.set(LANE_X[note.lane], 0.06, HIT_Z - (note.time - now) * SPEED);
221
+ mesh.rotation.y = LANE_TURN[note.lane];
222
+ mesh.visible = true;
223
+ });
224
+ }
225
+ for (let index = used; index < pool.length; index++) pool[index]!.visible = false;
226
+ },
227
+ render() {
228
+ renderer.render(scene, camera);
229
+ },
230
+ });
231
+ host.lifecycle.onChanged(state => music.setActive(state.active));
232
+
233
+ saved = parseSaved(await host.checkpoint.read().catch(() => null));
234
+ bestLine.textContent = saved.rounds > 0 ? `Best: ${saved.best} over ${saved.rounds} song${saved.rounds === 1 ? "" : "s"}.` : "One song is about a minute.";
235
+ startButton.textContent = "Start dancing";
236
+ startButton.disabled = false;
237
+ startButton.addEventListener("click", begin);
238
+ againButton.addEventListener("click", begin);
239
+ await host.ready();
240
+ window.addEventListener("pagehide", () => { music.dispose(); cat.dispose(); host.destroy(); }, { once: true });
241
+ }
242
+ canvas.tabIndex = 0;
243
+ void boot();
@@ -0,0 +1,123 @@
1
+ import { BEAT_SECONDS, COUNT_IN_BEATS, SONG_BEATS } from "./game";
2
+
3
+ /**
4
+ * The song, synthesized with Web Audio. Nothing is downloaded or sampled: a kick, a
5
+ * clap, a hat, a bass line and a lead are built from oscillators and noise, scheduled a
6
+ * little ahead of the audio clock. That same clock times the steps, so what you hear
7
+ * and what you hit stay together.
8
+ */
9
+ export interface Music {
10
+ /** Start the song from the top. Call from a user gesture. */
11
+ start(seed: number): void;
12
+ /** Seconds into the song by the audio clock, or null when there is no audio. */
13
+ time(): number | null;
14
+ /** Schedule the next few beats. Call every frame while the song plays. */
15
+ pump(): void;
16
+ /** Pause or resume with the app's lifecycle. */
17
+ setActive(active: boolean): void;
18
+ stop(): void;
19
+ dispose(): void;
20
+ }
21
+
22
+ // A minor, F, C, G: one chord per four-beat bar. Bass roots in Hz.
23
+ const ROOTS = [55, 43.65, 65.41, 49];
24
+ // A minor pentatonic across two octaves, for the lead.
25
+ const SCALE = [220, 261.63, 293.66, 329.63, 392, 440, 523.25, 587.33, 659.25];
26
+ const LOOKAHEAD = 0.4;
27
+
28
+ export function createMusic(): Music {
29
+ let context: AudioContext | undefined, master: GainNode | undefined, noise: AudioBuffer | undefined;
30
+ let startAt = 0, nextBeat = 0, playing = false, melody: number[] = [];
31
+
32
+ const tone = (type: OscillatorType, from: number, to: number, at: number, length: number, volume: number) => {
33
+ if (!context || !master) return;
34
+ const voice = context.createOscillator(), envelope = context.createGain();
35
+ voice.type = type;
36
+ voice.frequency.setValueAtTime(from, at);
37
+ if (to !== from) voice.frequency.exponentialRampToValueAtTime(to, at + length);
38
+ envelope.gain.setValueAtTime(volume, at);
39
+ envelope.gain.exponentialRampToValueAtTime(0.0001, at + length);
40
+ voice.connect(envelope).connect(master);
41
+ voice.start(at);
42
+ voice.stop(at + length + 0.02);
43
+ };
44
+ const hiss = (filter: BiquadFilterType, frequency: number, at: number, length: number, volume: number) => {
45
+ if (!context || !master || !noise) return;
46
+ const source = context.createBufferSource(), shape = context.createBiquadFilter(), envelope = context.createGain();
47
+ source.buffer = noise;
48
+ shape.type = filter;
49
+ shape.frequency.value = frequency;
50
+ envelope.gain.setValueAtTime(volume, at);
51
+ envelope.gain.exponentialRampToValueAtTime(0.0001, at + length);
52
+ source.connect(shape).connect(envelope).connect(master);
53
+ source.start(at);
54
+ source.stop(at + length + 0.02);
55
+ };
56
+
57
+ const beat = (index: number) => {
58
+ const at = startAt + index * BEAT_SECONDS, half = at + BEAT_SECONDS / 2;
59
+ if (index < COUNT_IN_BEATS) {
60
+ tone("square", 1320, 1320, at, 0.05, 0.12); // count-in tick
61
+ return;
62
+ }
63
+ const inBar = index % 4, root = ROOTS[Math.floor(index / 4) % ROOTS.length] ?? 55;
64
+ tone("sine", 150, 45, at, 0.14, 0.7); // kick
65
+ if (inBar === 1 || inBar === 3) hiss("bandpass", 1800, at, 0.12, 0.35); // clap
66
+ hiss("highpass", 7000, half, 0.04, 0.16); // off-beat hat
67
+ tone("triangle", root, root, at, 0.2, 0.4); // bass
68
+ tone("triangle", root * 2, root * 2, half, 0.14, 0.26);
69
+ // Two lead notes per beat; a zero in the pattern is a rest.
70
+ for (const [slot, when] of [[index * 2, at], [index * 2 + 1, half]] as const) {
71
+ const pitch = melody[slot % melody.length] ?? 0;
72
+ if (pitch > 0) tone("square", pitch, pitch, when, 0.16, 0.07);
73
+ }
74
+ };
75
+
76
+ return {
77
+ start(seed) {
78
+ try {
79
+ context ??= new AudioContext();
80
+ } catch {
81
+ return; // No audio: the game falls back to its own clock and plays silent.
82
+ }
83
+ void context.resume().catch(() => {});
84
+ if (!master) {
85
+ master = context.createGain();
86
+ master.gain.value = 0.35;
87
+ master.connect(context.destination);
88
+ noise = context.createBuffer(1, context.sampleRate / 2, context.sampleRate);
89
+ const samples = noise.getChannelData(0);
90
+ for (let i = 0; i < samples.length; i++) samples[i] = Math.random() * 2 - 1;
91
+ }
92
+ // A 32-step lead pattern that depends on the seed, so each round sounds a little different.
93
+ let state = (seed >>> 0) || 1;
94
+ melody = Array.from({ length: 32 }, () => {
95
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
96
+ return state % 5 < 2 ? 0 : SCALE[state % SCALE.length] ?? 0;
97
+ });
98
+ startAt = context.currentTime + 0.12;
99
+ nextBeat = 0;
100
+ playing = true;
101
+ },
102
+ time() {
103
+ return context && playing && context.state === "running" ? context.currentTime - startAt : null;
104
+ },
105
+ pump() {
106
+ if (!context || !playing) return;
107
+ while (nextBeat < SONG_BEATS && startAt + nextBeat * BEAT_SECONDS < context.currentTime + LOOKAHEAD) beat(nextBeat++);
108
+ },
109
+ setActive(active) {
110
+ if (!context) return;
111
+ void (active ? context.resume() : context.suspend()).catch(() => {});
112
+ },
113
+ stop() {
114
+ playing = false;
115
+ },
116
+ dispose() {
117
+ playing = false;
118
+ void context?.close().catch(() => {});
119
+ context = undefined;
120
+ master = undefined;
121
+ },
122
+ };
123
+ }
Binary file
@@ -0,0 +1,21 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "sdkVersion": 1,
4
+ "id": "paw-beat",
5
+ "version": "1.0.0",
6
+ "name": "Paw Beat",
7
+ "tagline": "A 3D cat, four arrows and a beat. Hit the steps, keep the combo.",
8
+ "category": "vibexp-app",
9
+ "entry": "index.html",
10
+ "permissions": [],
11
+ "collectionId": null,
12
+ "window": { "width": 960, "height": 600, "resizable": true },
13
+ "store": {
14
+ "icon": "store/icon.png",
15
+ "screenshots": ["store/screenshot-1.webp", "store/screenshot-2.webp"],
16
+ "description": "Biscuit the cat dances to a one-minute song made entirely in code. Arrows slide down four lanes toward their targets: press the matching arrow key or WASD, or tap the on-screen pads, as each one lands, and Biscuit dances the step.\n\nTiming is judged perfect, great or good, and every ten steps in a row adds 10% to each step, up to double. The steps change a little every round. Your best score is kept while the window stays open.",
17
+ "category": "game",
18
+ "rating": { "violence": "none", "language": "none", "mature": false },
19
+ "support": "https://vibechain.com/os/docs"
20
+ }
21
+ }
@@ -1,9 +1,25 @@
1
1
  # Stamp Club
2
2
 
3
- Stamp Club is a small VibeMarket OS app built with TypeScript. Use it to try your own intro, checkpoints, window lifecycle events and a host-owned final score screen, then replace the stamp counter with your own idea.
3
+ Stamp Club is a small VibeMarket OS app built with TypeScript, and the starting point `os init` gives you. Use it to try your own intro, checkpoints, window lifecycle events and a host-owned final score screen, then replace the stamp counter with your own idea.
4
4
 
5
5
  Run `npm install`, `npm run build`, then `npm run dev`. Open the printed **127.0.0.1** URL. Start a round, add stamps, minimize the window and restore it: the host restores only this app's host-accepted JSON into a fresh isolated frame. Finish the round to see the reported score. Play again creates a new controller and clears the old round. Rebuild and restart the preview after source changes.
6
6
 
7
- `npm run pack` produces `app.zip` for the existing development publisher. Production app publishing remains disabled; installing the SDK does not provide a public app-store listing.
8
-
9
7
  The app API has `ready()`, `checkpoint.read()/write()`, lifecycle notifications and `game.finish({score})`. Your app owns its intro/loading UI; the host owns final results. The preview awards no Cash. Checkpoints are at most 32 KiB, remain in host memory only while this window is open, and carry no account, inventory, wallet, Cash, Steam or reward authority. Native shells are unsupported. See the SDK security documentation before accepting untrusted code.
8
+
9
+ ## Before you submit to VibeStore
10
+
11
+ `vibemarket.json` is already a complete VibeStore listing (manifest schema version 2), so `npm run build` and `npm run pack` produce an `app.zip` that passes the submission checks. Its listing is placeholder text and pictures of this starter, though, and **a submission of the unchanged starter will be rejected at review.** Change these first:
12
+
13
+ | Field | Change it to |
14
+ |---|---|
15
+ | `id` | Your own app ID: lowercase letters, digits and single hyphens, at most 60 characters. The first accepted submission claims an ID for its publisher. |
16
+ | `version` | Your version number. Each version can be submitted once; use a new one for every change. |
17
+ | `name` and `tagline` | Your app's name and one line about it. |
18
+ | `store.description` | 40 to 2,000 characters of plain text about your app. |
19
+ | `store.category` and `store.rating` | `game`, `tool` or `toy`, and an honest content rating. |
20
+ | `store.support` | Your own `https://` support page or email address. Players and reviewers see it. |
21
+ | `store/icon.png` | Your icon: a PNG of exactly 256 x 256 pixels, at most 256 KiB. |
22
+ | `store/screenshot-1.png` | 1 to 4 screenshots of your app (PNG, JPEG or WebP, at most 1 MiB each). List every file in `store.screenshots`. |
23
+ | `window` | The size your app's window opens at: 320 to 1600 by 200 to 1200 pixels, and whether it can be resized. |
24
+
25
+ `npm run build` copies `index.html`, `vibemarket.json` and the listed store images into `dist/`. `os preview` and `os pack` check the manifest and images, so a listing mistake shows up locally. Submit `app.zip` from the **Submit** tab of VibeStore in VibeMarket OS. A person reviews every version, and an approved version is copied to public IPFS, so approval is publication: never put anything secret in a bundle.
@@ -1 +1,21 @@
1
- {"schemaVersion":1,"sdkVersion":1,"id":"stamp-club","version":"1.0.0","name":"Stamp Club","tagline":"A tiny VibeMarket OS app with restorable state.","category":"vibexp-app","entry":"index.html","permissions":[],"collectionId":null}
1
+ {
2
+ "schemaVersion": 2,
3
+ "sdkVersion": 1,
4
+ "id": "stamp-club",
5
+ "version": "1.0.0",
6
+ "name": "Stamp Club",
7
+ "tagline": "A tiny VibeMarket OS app with restorable state.",
8
+ "category": "vibexp-app",
9
+ "entry": "index.html",
10
+ "permissions": [],
11
+ "collectionId": null,
12
+ "window": { "width": 640, "height": 480, "resizable": true },
13
+ "store": {
14
+ "icon": "store/icon.png",
15
+ "screenshots": ["store/screenshot-1.png"],
16
+ "description": "Replace this description before you submit. It is the placeholder text of the VibeMarket OS starter app, Stamp Club: start a round, add stamps, minimize and restore the window to see them come back, then finish to report a score. Describe your own app here in plain text.",
17
+ "category": "toy",
18
+ "rating": { "violence": "none", "language": "none", "mature": false },
19
+ "support": "https://example.com/replace-with-your-support-page"
20
+ }
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibechain/os",
3
- "version": "0.2.1",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -18,7 +18,8 @@
18
18
  "AGENTS.md",
19
19
  "SECURITY.md",
20
20
  "LICENSE",
21
- "examples"
21
+ "examples/paw-beat",
22
+ "examples/vibexp-app"
22
23
  ],
23
24
  "exports": {
24
25
  ".": {
@@ -28,6 +29,22 @@
28
29
  "./manifest": {
29
30
  "types": "./dist/manifest.d.ts",
30
31
  "import": "./dist/manifest.js"
32
+ },
33
+ "./listing": {
34
+ "types": "./dist/listing.d.ts",
35
+ "import": "./dist/listing.js"
36
+ },
37
+ "./loop": {
38
+ "types": "./dist/loop.d.ts",
39
+ "import": "./dist/loop.js"
40
+ },
41
+ "./canvas": {
42
+ "types": "./dist/canvas.d.ts",
43
+ "import": "./dist/canvas.js"
44
+ },
45
+ "./testing": {
46
+ "types": "./dist/testing.d.ts",
47
+ "import": "./dist/testing.js"
31
48
  }
32
49
  },
33
50
  "bin": {
@@ -1,17 +0,0 @@
1
- import { START_WIDTH, type CardLayer } from './model';
2
-
3
- export interface CardSlice { left: number; right: number }
4
- /** UV width follows physical width, so the card's print never gets squeezed. */
5
- export function centeredCardSlice(width: number): CardSlice {
6
- if (!Number.isFinite(width) || width <= 0 || width > START_WIDTH) throw new Error('Invalid card slice width');
7
- const span = width / START_WIDTH;
8
- return { left: (1 - span) / 2, right: (1 + span) / 2 };
9
- }
10
- /** A landed piece and its falling offcut retain complementary parts of the incoming print. */
11
- export function cutCardSlice(card: Pick<CardLayer, 'x' | 'width'>, piece: Pick<CardLayer, 'x' | 'width'>): CardSlice {
12
- const source = centeredCardSlice(card.width);
13
- if (![card.x, piece.x, piece.width].every(Number.isFinite) || piece.width <= 0
14
- || piece.x < card.x - 1e-7 || piece.x + piece.width > card.x + card.width + 1e-7) throw new Error('Piece is outside the card');
15
- const left = source.left + (piece.x - card.x) / START_WIDTH;
16
- return { left: Math.max(0, left), right: Math.min(1, left + piece.width / START_WIDTH) };
17
- }
@@ -1,57 +0,0 @@
1
- import * as THREE from "three";
2
- import { SKINS } from "./skins";
3
-
4
- /** Procedural author-owned character: no host renderer or remote model. */
5
- export function createChonk() {
6
- const root = new THREE.Group();
7
- const fur = new THREE.MeshPhysicalMaterial({ color: SKINS[0].fur, roughness: 0.4, clearcoat: 0.45 });
8
- const belly = new THREE.MeshStandardMaterial({ color: SKINS[0].belly, roughness: 0.55 });
9
- const pink = new THREE.MeshStandardMaterial({ color: "#ff94bd", roughness: 0.4 });
10
- const black = new THREE.MeshPhysicalMaterial({ color: "#100e29", roughness: 0.25, clearcoat: 0.4, envMapIntensity: 0.2 });
11
- const white = new THREE.MeshBasicMaterial({ color: "#ffffff" });
12
- const gold = new THREE.MeshStandardMaterial({ color: "#ffc54f", metalness: 0.8, roughness: 0.19 });
13
- const stripe = new THREE.MeshStandardMaterial({ color: "#96623d", roughness: 0.55 });
14
- const ball = new THREE.SphereGeometry(1, 24, 16);
15
- const mesh = (geometry: THREE.BufferGeometry, material: THREE.Material, position: number[], scale = [1, 1, 1]) => {
16
- const item = new THREE.Mesh(geometry, material); item.position.set(position[0], position[1], position[2]); item.scale.set(scale[0], scale[1], scale[2]); item.castShadow = true; root.add(item); return item;
17
- };
18
- mesh(ball, fur, [0, 0.68, 0], [0.91, 0.67, 0.71]);
19
- mesh(ball, belly, [0, 0.6, 0.54], [0.61, 0.44, 0.25]);
20
- mesh(ball, fur, [0, 1.36, 0.08], [1.03, 0.75, 0.76]);
21
- const ear = new THREE.ConeGeometry(0.39, 0.8, 3);
22
- for (const side of [-1, 1]) {
23
- const outer = mesh(ear, fur, [side * 0.67, 1.99, 0.07]); outer.rotation.z = side * -0.24; outer.rotation.y = Math.PI;
24
- const inner = mesh(ear, pink, [side * 0.67, 2.02, 0.18], [0.58, 0.66, 0.58]); inner.rotation.copy(outer.rotation);
25
- mesh(ball, fur, [side * 0.56, 0.12, 0.39], [0.35, 0.16, 0.35]);
26
- mesh(ball, belly, [side * 0.24, 1.11, 0.75], [0.35, 0.23, 0.13]);
27
- mesh(ball, pink, [side * 0.59, 1.2, 0.65], [0.17, 0.085, 0.05]);
28
- mesh(ball, black, [side * 0.38, 1.45, 0.745], [0.12, 0.17, 0.075]);
29
- mesh(ball, white, [side * 0.38 - 0.035, 1.5, 0.81], [0.037, 0.05, 0.015]);
30
- for (let i = 0; i < 3; i++) {
31
- const line = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(side * 0.58, 1.04 + i * 0.09, 0.7), new THREE.Vector3(side * 1.13, 0.98 + i * 0.15, 0.65)]), new THREE.LineBasicMaterial({ color: "#fff7eb" })); root.add(line);
32
- }
33
- }
34
- mesh(ball, pink, [0, 1.18, 0.865], [0.09, 0.065, 0.055]);
35
- for (const side of [-1, 1]) {
36
- const smile = new THREE.Mesh(new THREE.TorusGeometry(0.115, 0.013, 5, 12, Math.PI), black); smile.rotation.z = Math.PI; smile.position.set(side * 0.106, 1.052, 0.873); root.add(smile);
37
- }
38
- const tailCurve = new THREE.CatmullRomCurve3([new THREE.Vector3(0.5, 0.35, -0.4), new THREE.Vector3(1.1, 0.4, -0.65), new THREE.Vector3(1.35, 0.9, -0.4), new THREE.Vector3(1.1, 1.05, -0.28)]);
39
- mesh(new THREE.TubeGeometry(tailCurve, 16, 0.17, 8, false), fur, [0, 0, 0]);
40
- const glasses = new THREE.Group(), shades = new THREE.Group(), jewelry = new THREE.Group(), stripes = new THREE.Group(), bracelets = new THREE.Group();
41
- root.add(glasses, shades, jewelry, stripes, bracelets);
42
- for (const side of [-1, 1]) {
43
- const lens = new THREE.Mesh(new THREE.TorusGeometry(0.24, 0.028, 6, 24), black); lens.position.set(side * 0.37, 1.45, 0.85); glasses.add(lens);
44
- const shade = new THREE.Mesh(new THREE.BoxGeometry(0.48, 0.29, 0.06), black); shade.position.set(side * 0.37, 1.44, 0.855); shade.rotation.z = side * 0.07; shades.add(shade);
45
- const bracelet = new THREE.Mesh(new THREE.TorusGeometry(0.23, 0.055, 6, 16), pink); bracelet.rotation.x = Math.PI / 2; bracelet.position.set(side * 0.56, 0.17, 0.39); bracelets.add(bracelet);
46
- }
47
- const bridge = new THREE.Mesh(new THREE.BoxGeometry(0.25, 0.03, 0.04), black); bridge.position.set(0, 1.47, 0.86); glasses.add(bridge); shades.add(bridge.clone());
48
- const chain = new THREE.Mesh(new THREE.TorusGeometry(0.6, 0.055, 7, 28), gold); chain.rotation.x = Math.PI / 2.8; chain.position.set(0, 0.92, 0.25); jewelry.add(chain);
49
- const charm = new THREE.Mesh(new THREE.OctahedronGeometry(0.14), gold); charm.position.set(0, 0.49, 0.77); jewelry.add(charm);
50
- for (const x of [-0.23, 0, 0.23]) { const mark = new THREE.Mesh(new THREE.CapsuleGeometry(0.047, 0.18, 3, 6), stripe); mark.position.set(x, 1.89, 0.49); mark.rotation.x = -0.65; stripes.add(mark); }
51
- return { root, skin(index: number) {
52
- const look = SKINS[index] ?? SKINS[0]; fur.color.set(look.fur); belly.color.set(look.belly);
53
- fur.metalness = index === 5 ? 0.45 : 0; fur.roughness = index === 5 ? 0.22 : 0.4;
54
- glasses.visible = index === 3; shades.visible = index === 4; jewelry.visible = index === 5; stripes.visible = index === 1 || index === 5; bracelets.visible = index === 2;
55
- stripe.color.set(index === 5 ? "#b68c28" : "#96623d");
56
- } };
57
- }