Back to Powder Tool V600Billion
SOURCE / PINNED RELEASE

Made of little things.

Powder Tool V600Billion

Release
142767edcab8…
Author-recorded commit
6d92971effd0…
License
LICENSE
Author’s source reference
nostr://npub1fllw8kw0thjj55wds0uugcnp5kej2nfxd36eruq39d56wwz8r44q5q78wj/wss%3A%2F%2Fgit.napplet.soy%2F/powder-toy

Archive hash verified: ed7d6a8ea7083197…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

source/scripts/soy-preview.mjs
/**
 * napplet.soy's listing picture: the built napplet in their player
 * (scripts/harness.mjs), dark, at 960 x 600 like their own screenshots, with
 * a scene running and the game's information hidden. It is saved as
 * preview.png in the project folder `npm run soy` wrote, and napplet.json
 * names it (preview.image), which soyli then publishes instead of taking a
 * picture of the empty sandbox itself.
 *
 *   node scripts/soy-preview.mjs <project folder> [scene id] [seconds]
 */
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

import { startHarness } from './harness.mjs';

const [folder, scene = 'fireworks', seconds = '5'] = process.argv.slice(2);
if (!folder) throw new Error('usage: node scripts/soy-preview.mjs <project folder> [scene id] [seconds]');
const projectFile = join(folder, 'napplet.json');
const project = JSON.parse(readFileSync(projectFile, 'utf8'));

const harness = await startHarness({ player: 'soy', viewport: { width: 960, height: 600 } });
await harness.tab.emulateMedia({ colorScheme: 'dark' });
try {
  await harness.waitForGame();
  const frame = harness.frame();
  await frame.waitForFunction(() => window.powderUi, null, { timeout: 10000 });
  const found = await frame.evaluate((id) => {
    const wanted = window.powderUi.scenes.find((s) => s.id === id);
    if (wanted) window.powderUi.loadScene(wanted);
    return Boolean(wanted);
  }, scene);
  if (!found) throw new Error(`no scene ${scene} in the built page`);
  await harness.tab.waitForTimeout(Number(seconds) * 1000);
  await frame.evaluate(() => window.powderUi.lua('ren.hud(false)'));
  await harness.tab.waitForTimeout(60);
  await harness.tab.screenshot({ path: join(folder, 'preview.png') });
  if (harness.errors.length) throw new Error(`page errors: ${harness.errors.join(' | ')}`);
} finally {
  await harness.close();
}
project.preview = { ...project.preview, image: 'preview.png' };
writeFileSync(projectFile, `${JSON.stringify(project, null, 2)}\n`);
console.log(`${join(folder, 'preview.png')}: ${scene} after ${seconds} s, named in napplet.json`);