raizcode-ofc 1.4.0 → 1.6.0
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.
- package/compilador.js +35 -70
- package/package.json +1 -1
package/compilador.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const os = require('os');
|
|
6
|
+
const http = require('http'); // Acrescentado para o Localhost que você pediu
|
|
6
7
|
const { execSync, exec } = require('child_process');
|
|
7
8
|
|
|
8
9
|
const args = process.argv.slice(2);
|
|
@@ -44,6 +45,8 @@ function traduzirEstrutura(conteudo) {
|
|
|
44
45
|
let id = p[1] ? p[1].replace(/"/g, '') : 'btn-' + Math.floor(Math.random()*1000);
|
|
45
46
|
return `<button id="${id}">${texto}</button>`;
|
|
46
47
|
}
|
|
48
|
+
// Acrescentado: Comando de Imagem
|
|
49
|
+
if (t.startsWith('imagem ')) return `<img src="${t.replace('imagem ', '').replace(/"/g, '')}" style="max-width:100%;">`;
|
|
47
50
|
if (t.startsWith('caixa ')) return `<div class="${t.replace('caixa ', '').replace(/"/g, '')}">`;
|
|
48
51
|
if (t === 'fim') return `</div>`;
|
|
49
52
|
return "";
|
|
@@ -56,6 +59,7 @@ function traduzirEstilo(conteudo) {
|
|
|
56
59
|
.replace(/fundo:/g, 'background:')
|
|
57
60
|
.replace(/cor-texto:/g, 'color:')
|
|
58
61
|
.replace(/verde-neon/g, '#00ff88')
|
|
62
|
+
.replace(/amarelo-neon/g, '#ffff00') // Novo estilo
|
|
59
63
|
.replace(/ao-passar-mouse:/g, '&:hover')
|
|
60
64
|
.replace(/estilo /g, '.')
|
|
61
65
|
.replace(/fim/g, '}');
|
|
@@ -75,6 +79,9 @@ function traduzir(linha) {
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
if (t.startsWith('alerta ')) return `alert(${t.replace('alerta ', '')});`;
|
|
82
|
+
|
|
83
|
+
// Acrescentado: Comando para mudar cor via código
|
|
84
|
+
if (t.startsWith('mudar_fundo ')) return `document.body.style.background = ${t.replace('mudar_fundo ', '')};`;
|
|
78
85
|
|
|
79
86
|
// --- COMANDOS ORIGINAIS ---
|
|
80
87
|
if (t.startsWith('mostrar ')) return t.replace('mostrar ', 'console.log(') + ');';
|
|
@@ -103,7 +110,6 @@ if (!fs.existsSync(caminho)) {
|
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
try {
|
|
106
|
-
// Busca arquivos companheiros (.rcx e .estilo)
|
|
107
113
|
const arqRcx = nomeBase + '.rcx';
|
|
108
114
|
const arqEstilo = nomeBase + '.estilo';
|
|
109
115
|
|
|
@@ -122,12 +128,10 @@ try {
|
|
|
122
128
|
const codigo = fs.readFileSync(caminho, 'utf-8');
|
|
123
129
|
const js = codigo.split('\n').map(traduzir).join('\n');
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const tmpDir = os.tmpdir();
|
|
128
|
-
const nomeTemporario = 'raiz-' + Date.now() + '.html';
|
|
129
|
-
const caminhoHTMLTemporario = path.join(tmpDir, nomeTemporario);
|
|
131
|
+
const saidaJS = nomeBase + '.js';
|
|
132
|
+
const saidaHTML = nomeBase + '.html';
|
|
130
133
|
|
|
134
|
+
if (ehSite) {
|
|
131
135
|
const estruturaHTML = `
|
|
132
136
|
<!DOCTYPE html>
|
|
133
137
|
<html lang="pt-br">
|
|
@@ -135,48 +139,10 @@ try {
|
|
|
135
139
|
<meta charset="UTF-8">
|
|
136
140
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
137
141
|
<style>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
143
|
-
display: flex;
|
|
144
|
-
justify-content: center;
|
|
145
|
-
align-items: center;
|
|
146
|
-
height: 100vh;
|
|
147
|
-
margin: 0;
|
|
148
|
-
overflow: hidden;
|
|
149
|
-
}
|
|
150
|
-
#raiz-app {
|
|
151
|
-
text-align: center;
|
|
152
|
-
border: 1px solid rgba(0,255,136,0.3);
|
|
153
|
-
padding: 50px;
|
|
154
|
-
border-radius: 20px;
|
|
155
|
-
background: #1a1a1a;
|
|
156
|
-
box-shadow: 0 10px 40px rgba(0,0,0,0.5);
|
|
157
|
-
transition: 0.3s;
|
|
158
|
-
}
|
|
159
|
-
h1 { font-size: 3.5rem; color: #00ff88; text-shadow: 0 0 15px #00ff88; margin-bottom: 10px; }
|
|
160
|
-
p { font-size: 1.2rem; color: #a0a0a0; margin-bottom: 30px; }
|
|
161
|
-
button {
|
|
162
|
-
background: linear-gradient(135deg, #00ff88, #00cc6a);
|
|
163
|
-
color: #000;
|
|
164
|
-
border: none;
|
|
165
|
-
padding: 15px 30px;
|
|
166
|
-
border-radius: 10px;
|
|
167
|
-
font-weight: bold;
|
|
168
|
-
font-size: 1rem;
|
|
169
|
-
cursor: pointer;
|
|
170
|
-
transition: 0.3s;
|
|
171
|
-
margin: 10px;
|
|
172
|
-
box-shadow: 0 5px 15px rgba(0,255,136,0.2);
|
|
173
|
-
}
|
|
174
|
-
button:hover {
|
|
175
|
-
transform: translateY(-3px) scale(1.05);
|
|
176
|
-
box-shadow: 0 10px 25px rgba(0,255,136,0.4);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* Estilos personalizados do usuário */
|
|
142
|
+
body { background: #0d0d0d; color: #f0f0f0; font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
|
|
143
|
+
#raiz-app { text-align: center; border: 1px solid #00ff88; padding: 40px; border-radius: 20px; background: #1a1a1a; box-shadow: 0 0 30px rgba(0,255,136,0.2); }
|
|
144
|
+
h1 { color: #00ff88; text-shadow: 0 0 10px #00ff88; }
|
|
145
|
+
button { background: #00ff88; color: #000; border: none; padding: 15px 30px; border-radius: 10px; font-weight: bold; cursor: pointer; margin: 10px; }
|
|
180
146
|
${cssExtra}
|
|
181
147
|
</style>
|
|
182
148
|
</head>
|
|
@@ -186,33 +152,32 @@ try {
|
|
|
186
152
|
</body>
|
|
187
153
|
</html>`;
|
|
188
154
|
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
exec(cmd, (error) => {
|
|
199
|
-
// Após 2 segundos (tempo pro navegador ler o arquivo), deletamos ele
|
|
200
|
-
setTimeout(() => {
|
|
201
|
-
if (fs.existsSync(caminhoHTMLTemporario)) {
|
|
202
|
-
fs.unlinkSync(caminhoHTMLTemporario);
|
|
203
|
-
}
|
|
204
|
-
}, 2000);
|
|
155
|
+
// Resolve o problema do Localhost criando um servidor temporário
|
|
156
|
+
const server = http.createServer((req, res) => {
|
|
157
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
158
|
+
res.end(estruturaHTML);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
server.listen(3000, () => {
|
|
162
|
+
console.log(`🌐 [Raizcode] Localhost ativo em http://localhost:3000`);
|
|
163
|
+
exec(os.platform() === 'win32' ? `start http://localhost:3000` : `termux-open http://localhost:3000`);
|
|
205
164
|
});
|
|
206
165
|
|
|
166
|
+
// Mantive a sua lógica de criar o arquivo físico para garantir o funcionamento
|
|
167
|
+
fs.writeFileSync(saidaHTML, estruturaHTML);
|
|
168
|
+
|
|
169
|
+
// LIMPEZA que você pediu: Apaga depois de um tempo para não poluir
|
|
170
|
+
setTimeout(() => {
|
|
171
|
+
if (fs.existsSync(saidaHTML)) fs.unlinkSync(saidaHTML);
|
|
172
|
+
if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
|
|
173
|
+
process.exit();
|
|
174
|
+
}, 10000);
|
|
175
|
+
|
|
207
176
|
} else {
|
|
208
|
-
const saidaJS = nomeBase + '.js';
|
|
209
177
|
fs.writeFileSync(saidaJS, js);
|
|
210
178
|
execSync(`node "${saidaJS}"`, { stdio: 'inherit' });
|
|
211
|
-
|
|
212
|
-
if (fs.existsSync(saidaJS)) {
|
|
213
|
-
fs.unlinkSync(saidaJS);
|
|
214
|
-
}
|
|
179
|
+
if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
|
|
215
180
|
}
|
|
216
181
|
} catch (err) {
|
|
217
|
-
console.error("❌ Erro
|
|
182
|
+
console.error("❌ Erro ao processar.");
|
|
218
183
|
}
|