import {createServer} from 'vite'; import vue from '@vitejs/plugin-vue'; import {mkdirSync,mkdtempSync,readFileSync,writeFileSync} from 'node:fs'; import {resolve,join} from 'node:path'; import {tmpdir} from 'node:os'; import {fileURLToPath} from 'node:url'; const target=resolve(fileURLToPath(new URL('..',import.meta.url))), source=process.env.OPENMAUS_REFERENCE_ROOT || resolve(target,'../OpenMausBot'), root=mkdtempSync(join(tmpdir(),'yaoyao-avatar-reference-')); mkdirSync(root+'/reference',{recursive:true});mkdirSync(root+'/ported',{recursive:true}); const shapes=['circle','ellipse','square','capsule','triangle','hexagon','cloud','droplet']; const bodies=['cursor','blob','circle','squircle','capsule','drop','shield','hexagon','diamond','star']; const expressions=['idle','happy','curious','drowsy','working','thinking','listening','sleeping','suspicious','proud']; const cases=[...shapes.map(shape=>({id:'shape-'+shape,shape,color:'green',hex:'#00c875',expression:'idle'})),...bodies.map(bodyId=>({id:'body-'+bodyId,shape:'circle',bodyId,color:'blue',hex:'#1488ff',expression:'happy'})),...expressions.map(expression=>({id:'face-'+expression,shape:'circle',color:'pink',hex:'#f52ba5',expression}))]; const html='
'; for(const sub of ['reference','ported'])writeFileSync(root+'/'+sub+'/index.html',html); let cursor=readFileSync(source+'/src/components/CursorAvatar.tsx','utf8'); cursor=cursor.replace('"../../shared/mascot-bodies"',JSON.stringify(source+'/shared/mascot-bodies.ts')).replace('"./cursor-face-data"',JSON.stringify(source+'/src/components/cursor-face-data.ts')); // Canonical resting-frame capture: settle the spring and hold elapsed time at 0. // This only controls the test clock; all original geometry/drawing code is unchanged. cursor=cursor.replace('if (p.paused) {','if (p.paused) { e.morph = 1; e.stateStart = now;'); writeFileSync(root+'/reference/CursorAvatar.tsx',cursor); let avatar=readFileSync(source+'/src/components/Avatar.tsx','utf8').replace('"../../shared/bot-avatar"',JSON.stringify(source+'/shared/bot-avatar.ts')).replace('"../../shared/mascot-bodies"',JSON.stringify(source+'/shared/mascot-bodies.ts')); writeFileSync(root+'/reference/Avatar.tsx',avatar); writeFileSync(root+'/reference/main.tsx',`import React from 'react';import{createRoot}from'react-dom/client';import{MausAvatar}from'./Avatar';const cases=${JSON.stringify(cases)};createRoot(document.getElementById('app')!).render(