-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-local.html
More file actions
262 lines (237 loc) · 9.07 KB
/
Copy pathtest-local.html
File metadata and controls
262 lines (237 loc) · 9.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teste Local - Módulos Perchance</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
color: #e2e8f0;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
text-align: center;
padding: 20px;
border-bottom: 1px solid #333;
margin-bottom: 20px;
}
header h1 { color: #4ade80; margin-bottom: 8px; }
header p { color: #94a3b8; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 20px;
}
.card {
background: rgba(30, 30, 50, 0.8);
border: 1px solid #444;
border-radius: 12px;
padding: 16px;
}
.card h3 {
color: #4ade80;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.log-panel {
background: #0a0a12;
border: 1px solid #333;
border-radius: 8px;
padding: 12px;
font-family: monospace;
font-size: 12px;
max-height: 300px;
overflow-y: auto;
white-space: pre-wrap;
}
.btn {
background: #4ade80;
color: #0f0f1a;
border: none;
padding: 10px 20px;
border-radius: 6px;
font-weight: 600;
cursor: pointer;
transition: transform 0.1s, background 0.2s;
}
.btn:hover { background: #22c55e; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { background: #666; cursor: not-allowed; }
#three-container {
width: 100%;
height: 200px;
background: #000;
border-radius: 8px;
margin-top: 12px;
}
.status {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 20px;
font-size: 12px;
margin-left: 8px;
}
.status.ok { background: rgba(74, 222, 128, 0.2); color: #4ade80; }
.status.err { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status.wait { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
footer {
text-align: center;
padding: 20px;
color: #666;
font-size: 13px;
border-top: 1px solid #333;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>🧪 Teste Local - Módulos Perchance</h1>
<p>Teste os módulos sem depender do Perchance. Use o Console (F12) para ver logs detalhados.</p>
</header>
<div class="grid">
<!-- Three.js Test -->
<div class="card">
<h3>🎨 Three.js Test <span id="status-three" class="status wait">Aguardando</span></h3>
<p style="color:#94a3b8;font-size:13px;margin-bottom:12px">
Importa Three.js via esm.sh e renderiza um cubo animado.
</p>
<button id="btn-three" class="btn">▶️ Executar Teste</button>
<div id="three-container"></div>
</div>
<!-- Perchance Bridge Test -->
<div class="card">
<h3>🧪 Perchance Bridge <span id="status-bridge" class="status wait">Aguardando</span></h3>
<p style="color:#94a3b8;font-size:13px;margin-bottom:12px">
Simula acesso a root, listas e plugins (mock para teste local).
</p>
<button id="btn-bridge" class="btn">▶️ Executar Teste</button>
<div id="bridge-result" style="margin-top:12px;font-family:monospace;font-size:12px;color:#4ade80"></div>
</div>
<!-- Async Test -->
<div class="card">
<h3>⏳ Async/Await Test <span id="status-async" class="status wait">Aguardando</span></h3>
<p style="color:#94a3b8;font-size:13px;margin-bottom:12px">
Demonstra padrões assíncronos similares ao plugin de imagem.
</p>
<button id="btn-async" class="btn">▶️ Executar Teste</button>
<div id="async-result" style="margin-top:12px;font-family:monospace;font-size:12px;color:#4ade80"></div>
</div>
</div>
<!-- Log Panel -->
<div class="card">
<h3>📋 Console Log (Espelhado)</h3>
<div id="log-panel" class="log-panel">Aguardando execução dos testes...</div>
</div>
<footer>
<p>💡 Dica: Este teste local usa um mock do `root` do Perchance. Para testar com dados reais, use o preview no perchance.org.</p>
<p style="margin-top:8px">Versão: 1.0.0-test | <a href="https://perchance.org" target="_blank" style="color:#4ade80">perchance.org</a></p>
</footer>
</div>
<script type="module">
// Mock do root do Perchance para teste local
window.root = {
GAME_SEED: 38776,
test_items: {
selectOne: () => ['espada mágica', 'poção de cura', 'mapa antigo'][Math.floor(Math.random() * 3)],
selectMany: (n) => Array.from({length: n}, () => window.root.test_items.selectOne())
},
art_styles: {
selectOne: () => ['papercraft', 'pixel art', 'aquarela'][Math.floor(Math.random() * 3)]
},
image: async (prompt, opts) => {
console.log(`[Mock Image] Prompt: "${prompt}", Options:`, opts);
// Simula delay de API
await new Promise(r => setTimeout(r, 1000));
// Retorna URL placeholder
return `https://via.placeholder.com/${opts?.resolution || '512x512'}?text=${encodeURIComponent(prompt.slice(0,20))}`;
}
};
// Espelhar console.log para o painel de logs
const originalLog = console.log;
const logPanel = document.getElementById('log-panel');
function mirrorLog(...args) {
originalLog(...args);
const timestamp = new Date().toLocaleTimeString();
const message = args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ');
const entry = document.createElement('div');
entry.style.margin = '2px 0';
entry.innerHTML = `<span style="color:#666">[${timestamp}]</span> ${message}`;
logPanel.appendChild(entry);
logPanel.scrollTop = logPanel.scrollHeight;
}
console.log = mirrorLog;
console.warn = (...args) => { mirrorLog('⚠️', ...args); originalLog('⚠️', ...args); };
console.error = (...args) => { mirrorLog('❌', ...args); originalLog('❌', ...args); };
// Helper para atualizar status
function setStatus(id, state, text) {
const el = document.getElementById(id);
if (!el) return;
el.className = `status ${state}`;
el.textContent = text;
}
// Teste Three.js
document.getElementById('btn-three').addEventListener('click', async () => {
setStatus('status-three', 'wait', 'Carregando...');
try {
const { initThreeTest } = await import('./src/modules/three-test.js');
const container = document.getElementById('three-container');
container.style.display = 'block';
const success = initThreeTest(container);
setStatus('status-three', success ? 'ok' : 'err', success ? '✅ Sucesso' : '❌ Falha');
} catch (error) {
console.error('Erro no teste Three.js:', error);
setStatus('status-three', 'err', '❌ Erro');
}
});
// Teste Perchance Bridge
document.getElementById('btn-bridge').addEventListener('click', async () => {
setStatus('status-bridge', 'wait', 'Testando...');
try {
const { initPerchanceFeaturesTest } = await import('./src/modules/perchance-features-test.js');
const tester = initPerchanceFeaturesTest();
const results = tester.getResults();
document.getElementById('bridge-result').innerHTML =
`Seed: ${results.seed}<br>` +
`Lista: ${results.listAccess}<br>` +
`Plugin: ${results.pluginCheck ? '✅' : '❌'}`;
setStatus('status-bridge', 'ok', '✅ Concluído');
} catch (error) {
console.error('Erro no teste Bridge:', error);
setStatus('status-bridge', 'err', '❌ Erro');
}
});
// Teste Async
document.getElementById('btn-async').addEventListener('click', async () => {
setStatus('status-async', 'wait', 'Executando...');
try {
const { initPerchanceFeaturesTest } = await import('./src/modules/perchance-features-test.js');
const tester = initPerchanceFeaturesTest();
const result = await tester.runAsyncTest();
document.getElementById('async-result').textContent =
`Status: ${result.success}\nDados: ${result.data}\nTimestamp: ${new Date(result.timestamp).toLocaleTimeString()}`;
setStatus('status-async', 'ok', '✅ Concluído');
} catch (error) {
console.error('Erro no teste Async:', error);
setStatus('status-async', 'err', '❌ Erro');
}
});
console.log('🔧 Ambiente de teste local inicializado.');
console.log('💡 Clique nos botões para executar os módulos.');
</script>
</body>
</html>