raizcode-ofc 1.5.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.
Files changed (2) hide show
  1. package/compilador.js +22 -10
  2. 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(') + ');';
@@ -121,7 +128,6 @@ try {
121
128
  const codigo = fs.readFileSync(caminho, 'utf-8');
122
129
  const js = codigo.split('\n').map(traduzir).join('\n');
123
130
 
124
- // Nomes dos arquivos que vamos "esconder"
125
131
  const saidaJS = nomeBase + '.js';
126
132
  const saidaHTML = nomeBase + '.html';
127
133
 
@@ -146,20 +152,26 @@ try {
146
152
  </body>
147
153
  </html>`;
148
154
 
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`);
164
+ });
165
+
166
+ // Mantive a sua lógica de criar o arquivo físico para garantir o funcionamento
149
167
  fs.writeFileSync(saidaHTML, estruturaHTML);
150
- console.log(`🌐 [Raizcode] Abrindo pré-visualização...`);
151
-
152
- const cmd = os.platform() === 'win32' ? `start ${saidaHTML}` :
153
- (os.platform() === 'darwin' ? `open ${saidaHTML}` :
154
- `termux-open ${saidaHTML}`);
155
168
 
156
- exec(cmd);
157
-
158
- // LIMPEZA: Apaga o HTML depois de 5 segundos (tempo de abrir)
169
+ // LIMPEZA que você pediu: Apaga depois de um tempo para não poluir
159
170
  setTimeout(() => {
160
171
  if (fs.existsSync(saidaHTML)) fs.unlinkSync(saidaHTML);
161
172
  if (fs.existsSync(saidaJS)) fs.unlinkSync(saidaJS);
162
- }, 5000);
173
+ process.exit();
174
+ }, 10000);
163
175
 
164
176
  } else {
165
177
  fs.writeFileSync(saidaJS, js);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raizcode-ofc",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Linguagem de programação Brasileira focada em simplicidade e performance.",
5
5
  "main": "compilador.js",
6
6
  "bin": {