Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/thatstupidcomputer / scripts/sync-rive-wasm.mjs |
| Date | Not specified in source |
| Repository | Janady13/thatstupidcomputer |
| Revision | 57555cde46910102dd25d6c1c1fb2c359e9655bd |
| Branch | main |
| Path or archive member | scripts/sync-rive-wasm.mjs |
| Original SHA-256 | a180ea024d5d2bbc9b7e95ab2cf7fdd17f3d1ee10095752cb2a05bfca1f4d44a |
| Git blob SHA | 5acdd7fd2c5a85a24ee810d73cd549355d6dba5c |
| Reading-copy SHA-256 | a180ea024d5d2bbc9b7e95ab2cf7fdd17f3d1ee10095752cb2a05bfca1f4d44a |
Recovered source transcript
Download complete source text ↓24 lines · 1.7 KB
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { existsSync, readFileSync, copyFileSync, mkdirSync, writeFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
import { fileURLToPath } from 'node:url';
process.chdir(fileURLToPath(new URL('..', import.meta.url)));
const require=createRequire(import.meta.url);
try {
const reactEntry=require.resolve('@rive-app/react-webgl2');
const scoped=createRequire(reactEntry); const runtimeEntry=scoped.resolve('@rive-app/webgl2');
let dir=dirname(runtimeEntry);
while(!existsSync(join(dir,'package.json'))){const parent=dirname(dir);if(parent===dir)throw new Error('Runtime package root not found');dir=parent;}
const pkg=JSON.parse(readFileSync(join(dir,'package.json'),'utf8'));
if(pkg.name!=='@rive-app/webgl2')throw new Error('Unexpected runtime package');
const wasm=join(dir,'rive.wasm'); const js=join(dir,'rive.js');
if(!existsSync(wasm)||!existsSync(js))throw new Error('Installed runtime layout changed; inspect the version-matched package before adapting this script');
const out='apps/web/public/animation/runtime';mkdirSync(out,{recursive:true});
copyFileSync(wasm,join(out,'rive.wasm'));
// The native verification harness uses the same official browser bundle as the React wrapper.
copyFileSync(js,join(out,'rive.js'));
writeFileSync(join(out,'version.json'),JSON.stringify({name:pkg.name,version:pkg.version,wasmSHA256:createHash('sha256').update(readFileSync(wasm)).digest('hex')},null,2));
console.log(`Self-hosted official Rive runtime ${pkg.version}; no mismatched CDN WASM.`);
} catch(error) { console.error('BLOCKED: Install package.json dependencies before preparing Rive WASM.',error.message);process.exit(2); }