@designliquido/delegua-node 1.16.1 → 1.17.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/README.md +54 -0
- package/avaliador-sintatico/avaliador-sintatico-com-importacao.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-com-importacao.js +1 -1
- package/avaliador-sintatico/avaliador-sintatico-com-importacao.js.map +1 -1
- package/bibliotecas/dialetos/portugol-studio/arquivos.d.ts.map +1 -1
- package/bibliotecas/dialetos/portugol-studio/arquivos.js +29 -26
- package/bibliotecas/dialetos/portugol-studio/arquivos.js.map +1 -1
- package/bibliotecas/dialetos/portugol-studio/graficos.d.ts +87 -0
- package/bibliotecas/dialetos/portugol-studio/graficos.d.ts.map +1 -0
- package/bibliotecas/dialetos/portugol-studio/graficos.js +642 -0
- package/bibliotecas/dialetos/portugol-studio/graficos.js.map +1 -0
- package/bibliotecas/dialetos/portugol-studio/util.js +1 -1
- package/bibliotecas/dialetos/portugol-studio/util.js.map +1 -1
- package/bin/package.json +9 -7
- package/infraestruturas/host-windows/infraestrutura-host-windows.d.ts +17 -0
- package/infraestruturas/host-windows/infraestrutura-host-windows.d.ts.map +1 -0
- package/infraestruturas/host-windows/infraestrutura-host-windows.js +260 -0
- package/infraestruturas/host-windows/infraestrutura-host-windows.js.map +1 -0
- package/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.d.ts +48 -0
- package/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.d.ts.map +1 -0
- package/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.js +530 -0
- package/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.js.map +1 -0
- package/interpretador/dialetos/interpretador-pitugues-com-importacao.d.ts +2 -2
- package/interpretador/dialetos/portugol-studio-comum.d.ts.map +1 -1
- package/interpretador/dialetos/portugol-studio-comum.js +54 -0
- package/interpretador/dialetos/portugol-studio-comum.js.map +1 -1
- package/interpretador/interpretador-com-importacao.d.ts +2 -2
- package/mecanismo-importacao-bibliotecas/index.d.ts +19 -0
- package/mecanismo-importacao-bibliotecas/index.d.ts.map +1 -1
- package/mecanismo-importacao-bibliotecas/index.js +78 -3
- package/mecanismo-importacao-bibliotecas/index.js.map +1 -1
- package/package.json +9 -7
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.InfraestruturaInvocacaoElectron = void 0;
|
|
37
|
+
exports.localizarElectron = localizarElectron;
|
|
38
|
+
const child_process = __importStar(require("child_process"));
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const net = __importStar(require("net"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const readline = __importStar(require("readline"));
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
// Conteúdo dos arquivos estáticos gravados no diretório temporário
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
const ELECTRON_MAIN_JS = `
|
|
48
|
+
'use strict';
|
|
49
|
+
const { app, BrowserWindow, ipcMain } = require('electron');
|
|
50
|
+
const net = require('net');
|
|
51
|
+
const path = require('path');
|
|
52
|
+
const readline = require('readline');
|
|
53
|
+
|
|
54
|
+
let mainWindow = null;
|
|
55
|
+
const pendentes = [];
|
|
56
|
+
let carregou = false;
|
|
57
|
+
|
|
58
|
+
// Socket de IPC com o processo Node.js pai
|
|
59
|
+
let socketHost = null;
|
|
60
|
+
const filaTcp = []; // mensagens enviadas antes da conexão estar pronta
|
|
61
|
+
|
|
62
|
+
process.on('uncaughtException', (err) => {
|
|
63
|
+
process.stderr.write('[InterfaceGrafica] Erro não tratado: ' + err.stack + '\\n');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function enviarAoHost(msg) {
|
|
67
|
+
const linha = JSON.stringify(msg) + '\\n';
|
|
68
|
+
if (socketHost) {
|
|
69
|
+
socketHost.write(linha);
|
|
70
|
+
} else {
|
|
71
|
+
filaTcp.push(linha);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function enviarAoRenderer(msg) {
|
|
76
|
+
if (carregou && mainWindow) {
|
|
77
|
+
mainWindow.webContents.send('mensagem', msg);
|
|
78
|
+
} else {
|
|
79
|
+
pendentes.push(msg);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
app.whenReady().then(() => {
|
|
84
|
+
const rendererPath = process.argv[2];
|
|
85
|
+
const porta = parseInt(process.argv[3], 10);
|
|
86
|
+
if (!rendererPath || isNaN(porta)) {
|
|
87
|
+
process.stderr.write('[InterfaceGrafica] Argumentos inválidos\\n');
|
|
88
|
+
app.quit();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ── Conexão TCP de volta ao servidor do processo pai ──────────────────────
|
|
93
|
+
const cliente = net.createConnection(porta, '127.0.0.1');
|
|
94
|
+
|
|
95
|
+
cliente.on('error', (err) => {
|
|
96
|
+
process.stderr.write('[InterfaceGrafica] Erro de conexão TCP: ' + err.message + '\\n');
|
|
97
|
+
app.quit();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
cliente.on('connect', () => {
|
|
101
|
+
socketHost = cliente;
|
|
102
|
+
for (const msg of filaTcp) socketHost.write(msg);
|
|
103
|
+
filaTcp.length = 0;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const rl = readline.createInterface({ input: cliente, terminal: false });
|
|
107
|
+
|
|
108
|
+
rl.on('close', () => app.quit());
|
|
109
|
+
|
|
110
|
+
rl.on('line', (linha) => {
|
|
111
|
+
if (!linha.trim()) return;
|
|
112
|
+
try {
|
|
113
|
+
const msg = JSON.parse(linha);
|
|
114
|
+
if (msg.tipo === 'criar-janela' && !mainWindow) {
|
|
115
|
+
mainWindow = new BrowserWindow({
|
|
116
|
+
width: msg.largura || 800,
|
|
117
|
+
height: (msg.altura || 400) + 40,
|
|
118
|
+
title: msg.titulo || 'Delégua',
|
|
119
|
+
show: false,
|
|
120
|
+
webPreferences: {
|
|
121
|
+
preload: path.join(__dirname, 'preload.js'),
|
|
122
|
+
contextIsolation: true,
|
|
123
|
+
nodeIntegration: false,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
mainWindow.loadFile(rendererPath);
|
|
128
|
+
|
|
129
|
+
mainWindow.webContents.on('did-finish-load', () => {
|
|
130
|
+
carregou = true;
|
|
131
|
+
for (const m of pendentes) {
|
|
132
|
+
mainWindow.webContents.send('mensagem', m);
|
|
133
|
+
}
|
|
134
|
+
pendentes.length = 0;
|
|
135
|
+
mainWindow.show();
|
|
136
|
+
// No Windows, setAlwaysOnTop contorna a proteção contra roubo de foco.
|
|
137
|
+
if (process.platform === 'win32') {
|
|
138
|
+
mainWindow.setAlwaysOnTop(true, 'screen-saver');
|
|
139
|
+
mainWindow.setAlwaysOnTop(false);
|
|
140
|
+
}
|
|
141
|
+
mainWindow.focus();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
mainWindow.webContents.on('did-fail-load', (_e, errCode, errDesc) => {
|
|
145
|
+
process.stderr.write('[InterfaceGrafica] Falha ao carregar renderer: ' + errCode + ' ' + errDesc + '\\n');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
mainWindow.on('closed', () => {
|
|
149
|
+
enviarAoHost({ tipo: 'fechado' });
|
|
150
|
+
mainWindow = null;
|
|
151
|
+
app.quit();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
enviarAoRenderer(msg);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
process.stderr.write('[InterfaceGrafica] Erro ao processar mensagem: ' + e.message + '\\n');
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// Eventos do renderer (cliques, texto alterado, etc.) → socket TCP
|
|
161
|
+
ipcMain.on('mensagem', (_event, msg) => {
|
|
162
|
+
enviarAoHost(msg);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
app.on('window-all-closed', () => app.quit());
|
|
167
|
+
`;
|
|
168
|
+
const PRELOAD_JS = `
|
|
169
|
+
'use strict';
|
|
170
|
+
const { contextBridge, ipcRenderer } = require('electron');
|
|
171
|
+
|
|
172
|
+
contextBridge.exposeInMainWorld('electronAPI', {
|
|
173
|
+
enviar: (msg) => ipcRenderer.send('mensagem', msg),
|
|
174
|
+
receber: (callback) => ipcRenderer.on('mensagem', (_, msg) => callback(msg)),
|
|
175
|
+
});
|
|
176
|
+
`;
|
|
177
|
+
const RENDERER_HTML = `<!DOCTYPE html>
|
|
178
|
+
<html lang="pt-BR">
|
|
179
|
+
<head>
|
|
180
|
+
<meta charset="UTF-8">
|
|
181
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
182
|
+
<title>Interface Gráfica – Delégua</title>
|
|
183
|
+
<style>
|
|
184
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
185
|
+
body {
|
|
186
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
187
|
+
background: #f0f0f0;
|
|
188
|
+
padding: 10px;
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
gap: 8px;
|
|
192
|
+
}
|
|
193
|
+
.delegua-caixa-vertical { display: flex; flex-direction: column; gap: 8px; }
|
|
194
|
+
.delegua-caixa-horizontal { display: flex; flex-direction: row; gap: 8px; align-items: center; }
|
|
195
|
+
.delegua-botao {
|
|
196
|
+
padding: 6px 16px; font-size: 13px; cursor: pointer;
|
|
197
|
+
border: 1px solid #999; border-radius: 3px; background: #e8e8e8;
|
|
198
|
+
align-self: flex-start;
|
|
199
|
+
}
|
|
200
|
+
.delegua-rotulo { font-size: 13px; color: #222; }
|
|
201
|
+
.delegua-caixa-texto {
|
|
202
|
+
font-size: 13px; padding: 5px 8px;
|
|
203
|
+
border: 1px solid #999; border-radius: 3px;
|
|
204
|
+
}
|
|
205
|
+
</style>
|
|
206
|
+
</head>
|
|
207
|
+
<body>
|
|
208
|
+
<div id="delegua-raiz"></div>
|
|
209
|
+
<script>
|
|
210
|
+
const elementos = {};
|
|
211
|
+
|
|
212
|
+
window.electronAPI.receber((msg) => {
|
|
213
|
+
switch (msg.tipo) {
|
|
214
|
+
case 'criar-janela': {
|
|
215
|
+
// A janela já foi criada pelo processo principal; apenas registramos
|
|
216
|
+
// a área de conteúdo (o próprio body) como componente raiz.
|
|
217
|
+
elementos[msg.id] = document.getElementById('delegua-raiz');
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
case 'criar-botao': {
|
|
221
|
+
const btn = document.createElement('button');
|
|
222
|
+
btn.className = 'delegua-botao';
|
|
223
|
+
btn.textContent = msg.rotulo;
|
|
224
|
+
btn.onclick = () => window.electronAPI.enviar({
|
|
225
|
+
tipo: 'evento', componenteId: msg.id, evento: 'clique'
|
|
226
|
+
});
|
|
227
|
+
elementos[msg.paiId].appendChild(btn);
|
|
228
|
+
elementos[msg.id] = btn;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 'criar-rotulo': {
|
|
232
|
+
const lbl = document.createElement('label');
|
|
233
|
+
lbl.className = 'delegua-rotulo';
|
|
234
|
+
lbl.textContent = msg.texto;
|
|
235
|
+
elementos[msg.paiId].appendChild(lbl);
|
|
236
|
+
elementos[msg.id] = lbl;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case 'criar-caixa-texto': {
|
|
240
|
+
const inp = document.createElement('input');
|
|
241
|
+
inp.className = 'delegua-caixa-texto';
|
|
242
|
+
inp.type = 'text';
|
|
243
|
+
inp.value = msg.textoInicial || '';
|
|
244
|
+
inp.addEventListener('input', () => {
|
|
245
|
+
window.electronAPI.enviar({ tipo: 'valor-atualizado', id: msg.id, valor: inp.value });
|
|
246
|
+
window.electronAPI.enviar({
|
|
247
|
+
tipo: 'evento', componenteId: msg.id, evento: 'alterado', valor: inp.value
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
elementos[msg.paiId].appendChild(inp);
|
|
251
|
+
elementos[msg.id] = inp;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case 'criar-caixa-vertical': {
|
|
255
|
+
const div = document.createElement('div');
|
|
256
|
+
div.className = 'delegua-caixa-vertical';
|
|
257
|
+
elementos[msg.paiId].appendChild(div);
|
|
258
|
+
elementos[msg.id] = div;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case 'criar-caixa-horizontal': {
|
|
262
|
+
const div = document.createElement('div');
|
|
263
|
+
div.className = 'delegua-caixa-horizontal';
|
|
264
|
+
elementos[msg.paiId].appendChild(div);
|
|
265
|
+
elementos[msg.id] = div;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
case 'definir-texto': {
|
|
269
|
+
const el = elementos[msg.id];
|
|
270
|
+
if (el) {
|
|
271
|
+
if (el.tagName === 'INPUT') el.value = msg.texto;
|
|
272
|
+
else el.textContent = msg.texto;
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
case 'encerrar': {
|
|
277
|
+
document.getElementById('delegua-raiz').innerHTML = '';
|
|
278
|
+
window.close();
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
</script>
|
|
284
|
+
</body>
|
|
285
|
+
</html>`;
|
|
286
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
287
|
+
// InfraestruturaInvocacaoElectron
|
|
288
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
289
|
+
/**
|
|
290
|
+
* Infraestrutura de interface gráfica que spawna um processo Electron filho.
|
|
291
|
+
*
|
|
292
|
+
* Usada quando o programa Delégua roda na linha de comando (Node.js puro),
|
|
293
|
+
* sem DOM e sem WebView do VS Code. Requer que o pacote `electron` esteja
|
|
294
|
+
* instalado local ou globalmente.
|
|
295
|
+
*
|
|
296
|
+
* Protocolo de comunicação: servidor TCP local (127.0.0.1, porta aleatória).
|
|
297
|
+
* O processo pai cria o servidor; o Electron conecta de volta como cliente.
|
|
298
|
+
* Mensagens trocadas como JSON delimitadas por `\n` — idêntico ao protocolo
|
|
299
|
+
* de `InfraestruturaWebView`, porém via socket em vez de stdin/stdout
|
|
300
|
+
* (stdin é consumido pelo Chromium durante a inicialização no Windows).
|
|
301
|
+
*/
|
|
302
|
+
class InfraestruturaInvocacaoElectron {
|
|
303
|
+
constructor(caminhoBinario) {
|
|
304
|
+
this.contadorIds = 0;
|
|
305
|
+
this.textosComponentes = new Map();
|
|
306
|
+
this.resolverLaco = null;
|
|
307
|
+
this.processoFinalizou = false;
|
|
308
|
+
this.tratadoresEventos = new Map();
|
|
309
|
+
this.processo = null;
|
|
310
|
+
this.socket = null;
|
|
311
|
+
this.filaEnvio = [];
|
|
312
|
+
const dirTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'delegua-gui-'));
|
|
313
|
+
const caminhoMain = path.join(dirTemp, 'electron-main.js');
|
|
314
|
+
const caminhoPreload = path.join(dirTemp, 'preload.js');
|
|
315
|
+
const caminhoRenderer = path.join(dirTemp, 'renderer.html');
|
|
316
|
+
fs.writeFileSync(caminhoMain, ELECTRON_MAIN_JS, 'utf-8');
|
|
317
|
+
fs.writeFileSync(caminhoPreload, PRELOAD_JS, 'utf-8');
|
|
318
|
+
fs.writeFileSync(caminhoRenderer, RENDERER_HTML, 'utf-8');
|
|
319
|
+
// Servidor TCP local: Electron conecta de volta depois de iniciar.
|
|
320
|
+
// Usamos TCP em vez de stdin/stdout porque o Chromium consome fd 0
|
|
321
|
+
// durante a inicialização no Windows, descartando os dados do pipe.
|
|
322
|
+
this.servidor = net.createServer();
|
|
323
|
+
this.servidor.once('connection', (socket) => {
|
|
324
|
+
this.servidor.close();
|
|
325
|
+
this.socket = socket;
|
|
326
|
+
socket.on('error', () => this._encerrarInterno());
|
|
327
|
+
socket.on('close', () => this._encerrarInterno());
|
|
328
|
+
const leitor = readline.createInterface({ input: socket });
|
|
329
|
+
leitor.on('line', (linha) => {
|
|
330
|
+
try {
|
|
331
|
+
this._processarMensagem(JSON.parse(linha));
|
|
332
|
+
}
|
|
333
|
+
catch (_) { }
|
|
334
|
+
});
|
|
335
|
+
// Descarrega mensagens enviadas antes da conexão estar pronta
|
|
336
|
+
for (const msg of this.filaEnvio)
|
|
337
|
+
socket.write(msg);
|
|
338
|
+
this.filaEnvio.length = 0;
|
|
339
|
+
});
|
|
340
|
+
this.servidor.listen(0, '127.0.0.1', () => {
|
|
341
|
+
var _a;
|
|
342
|
+
const porta = this.servidor.address().port;
|
|
343
|
+
this.processo = child_process.spawn(caminhoBinario, [caminhoMain, caminhoRenderer, String(porta)], { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
344
|
+
(_a = this.processo.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (dados) => process.stderr.write(dados));
|
|
345
|
+
this.processo.on('error', (err) => {
|
|
346
|
+
process.stderr.write('[InterfaceGrafica] Erro ao iniciar Electron: ' + err.message + '\n');
|
|
347
|
+
this._encerrarInterno();
|
|
348
|
+
});
|
|
349
|
+
this.processo.on('close', () => this._encerrarInterno());
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
353
|
+
// Helpers internos
|
|
354
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
355
|
+
proximoId() {
|
|
356
|
+
return `delegua-gui-${++this.contadorIds}`;
|
|
357
|
+
}
|
|
358
|
+
_enviar(msg) {
|
|
359
|
+
const linha = JSON.stringify(msg) + '\n';
|
|
360
|
+
if (this.socket) {
|
|
361
|
+
this.socket.write(linha);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.filaEnvio.push(linha);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
_encerrarInterno() {
|
|
368
|
+
if (this.resolverLaco) {
|
|
369
|
+
this.resolverLaco();
|
|
370
|
+
this.resolverLaco = null;
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.processoFinalizou = true;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
_processarMensagem(msg) {
|
|
377
|
+
if (msg.tipo === 'evento') {
|
|
378
|
+
const tratadores = this.tratadoresEventos.get(msg.componenteId);
|
|
379
|
+
if (tratadores) {
|
|
380
|
+
const cb = tratadores.get(msg.evento);
|
|
381
|
+
if (cb) {
|
|
382
|
+
const args = msg.valor !== undefined ? [msg.valor] : [];
|
|
383
|
+
cb(...args).catch(console.error);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else if (msg.tipo === 'valor-atualizado') {
|
|
388
|
+
this.textosComponentes.set(msg.id, msg.valor);
|
|
389
|
+
}
|
|
390
|
+
else if (msg.tipo === 'fechado') {
|
|
391
|
+
this._encerrarInterno();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
395
|
+
// Criação de componentes
|
|
396
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
397
|
+
criarJanela(largura, altura, titulo) {
|
|
398
|
+
const idComponente = this.proximoId();
|
|
399
|
+
this._enviar({ tipo: 'criar-janela', id: idComponente, largura, altura, titulo });
|
|
400
|
+
return { idComponente };
|
|
401
|
+
}
|
|
402
|
+
criarBotao(pai, rotulo) {
|
|
403
|
+
const idComponente = this.proximoId();
|
|
404
|
+
this._enviar({ tipo: 'criar-botao', id: idComponente, paiId: pai.idComponente, rotulo });
|
|
405
|
+
return { idComponente };
|
|
406
|
+
}
|
|
407
|
+
criarRotulo(pai, texto) {
|
|
408
|
+
const idComponente = this.proximoId();
|
|
409
|
+
this.textosComponentes.set(idComponente, texto);
|
|
410
|
+
this._enviar({ tipo: 'criar-rotulo', id: idComponente, paiId: pai.idComponente, texto });
|
|
411
|
+
return { idComponente };
|
|
412
|
+
}
|
|
413
|
+
criarCaixaTexto(pai, textoInicial) {
|
|
414
|
+
const idComponente = this.proximoId();
|
|
415
|
+
this.textosComponentes.set(idComponente, textoInicial);
|
|
416
|
+
this._enviar({ tipo: 'criar-caixa-texto', id: idComponente, paiId: pai.idComponente, textoInicial });
|
|
417
|
+
return { idComponente };
|
|
418
|
+
}
|
|
419
|
+
criarCaixaVertical(pai) {
|
|
420
|
+
const idComponente = this.proximoId();
|
|
421
|
+
this._enviar({ tipo: 'criar-caixa-vertical', id: idComponente, paiId: pai.idComponente });
|
|
422
|
+
return { idComponente };
|
|
423
|
+
}
|
|
424
|
+
criarCaixaHorizontal(pai) {
|
|
425
|
+
const idComponente = this.proximoId();
|
|
426
|
+
this._enviar({ tipo: 'criar-caixa-horizontal', id: idComponente, paiId: pai.idComponente });
|
|
427
|
+
return { idComponente };
|
|
428
|
+
}
|
|
429
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
430
|
+
// Leitura e escrita de propriedades
|
|
431
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
432
|
+
definirTexto(componente, texto) {
|
|
433
|
+
this.textosComponentes.set(componente.idComponente, texto);
|
|
434
|
+
this._enviar({ tipo: 'definir-texto', id: componente.idComponente, texto });
|
|
435
|
+
}
|
|
436
|
+
obterTexto(componente) {
|
|
437
|
+
var _a;
|
|
438
|
+
return (_a = this.textosComponentes.get(componente.idComponente)) !== null && _a !== void 0 ? _a : '';
|
|
439
|
+
}
|
|
440
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
441
|
+
// Eventos
|
|
442
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
443
|
+
conectarEvento(componente, evento, callback) {
|
|
444
|
+
if (!this.tratadoresEventos.has(componente.idComponente)) {
|
|
445
|
+
this.tratadoresEventos.set(componente.idComponente, new Map());
|
|
446
|
+
}
|
|
447
|
+
this.tratadoresEventos.get(componente.idComponente).set(evento, callback);
|
|
448
|
+
}
|
|
449
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
450
|
+
// Ciclo de vida
|
|
451
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
452
|
+
async iniciarLaco() {
|
|
453
|
+
if (this.processoFinalizou)
|
|
454
|
+
return;
|
|
455
|
+
return new Promise((resolve) => {
|
|
456
|
+
this.resolverLaco = resolve;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
encerrar() {
|
|
460
|
+
var _a, _b;
|
|
461
|
+
this._enviar({ tipo: 'encerrar' });
|
|
462
|
+
this._encerrarInterno();
|
|
463
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
464
|
+
this.servidor.close();
|
|
465
|
+
try {
|
|
466
|
+
(_b = this.processo) === null || _b === void 0 ? void 0 : _b.kill();
|
|
467
|
+
}
|
|
468
|
+
catch (_) { }
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
exports.InfraestruturaInvocacaoElectron = InfraestruturaInvocacaoElectron;
|
|
472
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
473
|
+
// Utilitário: localizar o binário do Electron
|
|
474
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
475
|
+
/**
|
|
476
|
+
* Tenta localizar o binário do Electron instalado como pacote npm.
|
|
477
|
+
* Verifica primeiro nas dependências locais e depois no diretório global do npm.
|
|
478
|
+
* Retorna `null` se o Electron não estiver disponível.
|
|
479
|
+
*/
|
|
480
|
+
/**
|
|
481
|
+
* Tenta obter o binário do Electron a partir do `index.js` do pacote, usando
|
|
482
|
+
* `require`. O `index.js` do pacote Electron já resolve `path.txt` corretamente
|
|
483
|
+
* (inclusive quando o executável está em uma subpasta como `dist/`).
|
|
484
|
+
*
|
|
485
|
+
* @param diretorioPacote Caminho absoluto para o diretório do pacote `electron`.
|
|
486
|
+
*/
|
|
487
|
+
function resolverBinarioDoIndexJs(diretorioPacote) {
|
|
488
|
+
try {
|
|
489
|
+
const indexJs = path.join(diretorioPacote, 'index.js');
|
|
490
|
+
if (!fs.existsSync(indexJs))
|
|
491
|
+
return null;
|
|
492
|
+
const caminho = require(indexJs);
|
|
493
|
+
if (typeof caminho === 'string' && fs.existsSync(caminho))
|
|
494
|
+
return caminho;
|
|
495
|
+
}
|
|
496
|
+
catch (_) { }
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Tenta localizar o binário do Electron instalado como pacote npm.
|
|
501
|
+
* Verifica primeiro nas dependências locais e depois no diretório global do npm.
|
|
502
|
+
* Retorna `null` se o Electron não estiver disponível.
|
|
503
|
+
*/
|
|
504
|
+
function localizarElectron() {
|
|
505
|
+
// 1. Dependência local do projeto atual (require resolve normal)
|
|
506
|
+
try {
|
|
507
|
+
const caminho = require('electron');
|
|
508
|
+
if (typeof caminho === 'string' && fs.existsSync(caminho))
|
|
509
|
+
return caminho;
|
|
510
|
+
}
|
|
511
|
+
catch (_) { }
|
|
512
|
+
// 2. Instalação global do npm — requer o index.js do pacote diretamente
|
|
513
|
+
try {
|
|
514
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
515
|
+
const globalRoot = child_process
|
|
516
|
+
.execSync(`${npm} root -g`, { encoding: 'utf-8' })
|
|
517
|
+
.trim();
|
|
518
|
+
// 2a. global/electron
|
|
519
|
+
const resultado = resolverBinarioDoIndexJs(path.join(globalRoot, 'electron'));
|
|
520
|
+
if (resultado)
|
|
521
|
+
return resultado;
|
|
522
|
+
// 2b. global/delegua/node_modules/electron
|
|
523
|
+
const resultadoDelegua = resolverBinarioDoIndexJs(path.join(globalRoot, 'delegua', 'node_modules', 'electron'));
|
|
524
|
+
if (resultadoDelegua)
|
|
525
|
+
return resultadoDelegua;
|
|
526
|
+
}
|
|
527
|
+
catch (_) { }
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
//# sourceMappingURL=infraestrutura-invocacao-electron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infraestrutura-invocacao-electron.js","sourceRoot":"","sources":["../../../fontes/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0fA,8CA0BC;AAphBD,6DAA+C;AAC/C,uCAAyB;AACzB,yCAA2B;AAC3B,uCAAyB;AACzB,2CAA6B;AAC7B,mDAAqC;AAIrC,g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adorInterface<SimboloInterface>;
|
|
13
13
|
constructor(importador: ImportadorInterface<SimboloInterface>, diretorioBase: string, performance?: boolean, funcaoDeRetorno?: Function, funcaoDeRetornoMesmaLinha?: Function);
|
|
14
14
|
executar(declaracao: Declaracao, mostrarResultado?: boolean): Promise<any>;
|
|
15
|
-
visitarConstrutoImportarBiblioteca(importarBiblioteca: ImportarBiblioteca): Promise<import("@designliquido/delegua
|
|
15
|
+
visitarConstrutoImportarBiblioteca(importarBiblioteca: ImportarBiblioteca): Promise<import("@designliquido/delegua").DeleguaModulo>;
|
|
16
16
|
visitarDeclaracaoConst(declaracao: Const): Promise<any>;
|
|
17
17
|
visitarDeclaracaoDefinicaoFuncao(funcaoDeclaracao: FuncaoDeclaracao): Promise<any>;
|
|
18
|
-
visitarDeclaracaoModuloDeclaracoes(declaracao: ModuloDeclaracoes): Promise<import("@designliquido/delegua
|
|
18
|
+
visitarDeclaracaoModuloDeclaracoes(declaracao: ModuloDeclaracoes): Promise<import("@designliquido/delegua").DeleguaModulo>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=interpretador-pitugues-com-importacao.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portugol-studio-comum.d.ts","sourceRoot":"","sources":["../../../fontes/interpretador/dialetos/portugol-studio-comum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAgB,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"portugol-studio-comum.d.ts","sourceRoot":"","sources":["../../../fontes/interpretador/dialetos/portugol-studio-comum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAgB,MAAM,iDAAiD,CAAC;AAW9F,wBAAsB,8BAA8B,CAAC,UAAU,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAEjG;AAED,wBAAsB,6BAA6B,CAAC,SAAS,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,CAG5G"}
|
|
@@ -41,6 +41,7 @@ exports.visitarExpressaoImportarComum = visitarExpressaoImportarComum;
|
|
|
41
41
|
const estruturas_1 = require("@designliquido/delegua/interpretador/estruturas");
|
|
42
42
|
const comum_1 = __importDefault(require("@designliquido/portugol-studio/interpretador/comum"));
|
|
43
43
|
const arquivos = __importStar(require("../../bibliotecas/dialetos/portugol-studio/arquivos"));
|
|
44
|
+
const graficos = __importStar(require("../../bibliotecas/dialetos/portugol-studio/graficos"));
|
|
44
45
|
const internet = __importStar(require("../../bibliotecas/dialetos/portugol-studio/internet"));
|
|
45
46
|
const teclado = __importStar(require("../../bibliotecas/dialetos/portugol-studio/teclado"));
|
|
46
47
|
const util = __importStar(require("../../bibliotecas/dialetos/portugol-studio/util"));
|
|
@@ -56,6 +57,8 @@ function logicaComumImportacao(caminho) {
|
|
|
56
57
|
switch (caminho) {
|
|
57
58
|
case 'Arquivos':
|
|
58
59
|
return carregarBibliotecaArquivos();
|
|
60
|
+
case 'Graficos':
|
|
61
|
+
return carregarBibliotecaGraficos();
|
|
59
62
|
case 'Internet':
|
|
60
63
|
return carregarBibliotecaInternet();
|
|
61
64
|
case 'Teclado':
|
|
@@ -87,6 +90,57 @@ function carregarBibliotecaArquivos() {
|
|
|
87
90
|
objetoArquivos.componentes = metodos;
|
|
88
91
|
return objetoArquivos;
|
|
89
92
|
}
|
|
93
|
+
function carregarBibliotecaGraficos() {
|
|
94
|
+
const objetoClasseGraficos = new graficos.Graficos();
|
|
95
|
+
const metodos = {
|
|
96
|
+
iniciar_modo_grafico: new estruturas_1.FuncaoPadrao(0, objetoClasseGraficos.iniciar_modo_grafico.bind(objetoClasseGraficos)),
|
|
97
|
+
definir_dimensoes_janela: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.definir_dimensoes_janela.bind(objetoClasseGraficos)),
|
|
98
|
+
limpar: new estruturas_1.FuncaoPadrao(0, objetoClasseGraficos.limpar.bind(objetoClasseGraficos)),
|
|
99
|
+
renderizar: new estruturas_1.FuncaoPadrao(0, objetoClasseGraficos.renderizar.bind(objetoClasseGraficos)),
|
|
100
|
+
renderizar_imagem: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.renderizar_imagem.bind(objetoClasseGraficos)),
|
|
101
|
+
desenhar_retangulo: new estruturas_1.FuncaoPadrao(6, objetoClasseGraficos.desenhar_retangulo.bind(objetoClasseGraficos)),
|
|
102
|
+
desenhar_poligono: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.desenhar_poligono.bind(objetoClasseGraficos)),
|
|
103
|
+
desenhar_elipse: new estruturas_1.FuncaoPadrao(5, objetoClasseGraficos.desenhar_elipse.bind(objetoClasseGraficos)),
|
|
104
|
+
desenhar_ponto: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.desenhar_ponto.bind(objetoClasseGraficos)),
|
|
105
|
+
desenhar_linha: new estruturas_1.FuncaoPadrao(4, objetoClasseGraficos.desenhar_linha.bind(objetoClasseGraficos)),
|
|
106
|
+
carregar_imagem: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.carregar_imagem.bind(objetoClasseGraficos)),
|
|
107
|
+
proximo_frame_gif: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.proximo_frame_gif.bind(objetoClasseGraficos)),
|
|
108
|
+
transformar_imagem: new estruturas_1.FuncaoPadrao(5, objetoClasseGraficos.transformar_imagem.bind(objetoClasseGraficos)),
|
|
109
|
+
redimensionar_imagem: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.redimensionar_imagem.bind(objetoClasseGraficos)),
|
|
110
|
+
obter_cor_pixel: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.obter_cor_pixel.bind(objetoClasseGraficos)),
|
|
111
|
+
obter_RGB: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.obter_RGB.bind(objetoClasseGraficos)),
|
|
112
|
+
transformar_porcao_imagem: new estruturas_1.FuncaoPadrao(9, objetoClasseGraficos.transformar_porcao_imagem.bind(objetoClasseGraficos)),
|
|
113
|
+
desenhar_imagem: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.desenhar_imagem.bind(objetoClasseGraficos)),
|
|
114
|
+
salvar_imagem: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.salvar_imagem.bind(objetoClasseGraficos)),
|
|
115
|
+
desenhar_quadro_atual_gif: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.desenhar_quadro_atual_gif.bind(objetoClasseGraficos)),
|
|
116
|
+
desenhar_porcao_imagem: new estruturas_1.FuncaoPadrao(7, objetoClasseGraficos.desenhar_porcao_imagem.bind(objetoClasseGraficos)),
|
|
117
|
+
obter_intervalo_gif: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.obter_intervalo_gif.bind(objetoClasseGraficos)),
|
|
118
|
+
obter_numero_quadros_gif: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.obter_numero_quadros_gif.bind(objetoClasseGraficos)),
|
|
119
|
+
obter_numero_quadro_atual_gif: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.obter_numero_quadro_atual_gif.bind(objetoClasseGraficos)),
|
|
120
|
+
obter_quadro_gif: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.obter_quadro_gif.bind(objetoClasseGraficos)),
|
|
121
|
+
definir_quadro_gif: new estruturas_1.FuncaoPadrao(2, objetoClasseGraficos.definir_quadro_gif.bind(objetoClasseGraficos)),
|
|
122
|
+
liberar_imagem: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.liberar_imagem.bind(objetoClasseGraficos)),
|
|
123
|
+
desenhar_texto: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.desenhar_texto.bind(objetoClasseGraficos)),
|
|
124
|
+
definir_cor: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.definir_cor.bind(objetoClasseGraficos)),
|
|
125
|
+
definir_gradiente: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.definir_gradiente.bind(objetoClasseGraficos)),
|
|
126
|
+
definir_fonte_texto: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.definir_fonte_texto.bind(objetoClasseGraficos)),
|
|
127
|
+
definir_tamanho_texto: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.definir_tamanho_texto.bind(objetoClasseGraficos)),
|
|
128
|
+
definir_estilo_texto: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.definir_estilo_texto.bind(objetoClasseGraficos)),
|
|
129
|
+
largura_texto: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.largura_texto.bind(objetoClasseGraficos)),
|
|
130
|
+
altura_texto: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.altura_texto.bind(objetoClasseGraficos)),
|
|
131
|
+
largura_imagem: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.largura_imagem.bind(objetoClasseGraficos)),
|
|
132
|
+
altura_imagem: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.altura_imagem.bind(objetoClasseGraficos)),
|
|
133
|
+
criar_cor: new estruturas_1.FuncaoPadrao(3, objetoClasseGraficos.criar_cor.bind(objetoClasseGraficos)),
|
|
134
|
+
carregar_fonte: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.carregar_fonte.bind(objetoClasseGraficos)),
|
|
135
|
+
definir_opacidade: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.definir_opacidade.bind(objetoClasseGraficos)),
|
|
136
|
+
definir_rotacao: new estruturas_1.FuncaoPadrao(1, objetoClasseGraficos.definir_rotacao.bind(objetoClasseGraficos)),
|
|
137
|
+
largura_janela: new estruturas_1.FuncaoPadrao(0, objetoClasseGraficos.largura_janela.bind(objetoClasseGraficos)),
|
|
138
|
+
altura_janela: new estruturas_1.FuncaoPadrao(0, objetoClasseGraficos.altura_janela.bind(objetoClasseGraficos)),
|
|
139
|
+
};
|
|
140
|
+
const objetoGraficos = new estruturas_1.DeleguaModulo('Graficos');
|
|
141
|
+
objetoGraficos.componentes = metodos;
|
|
142
|
+
return objetoGraficos;
|
|
143
|
+
}
|
|
90
144
|
function carregarBibliotecaInternet() {
|
|
91
145
|
const metodos = {
|
|
92
146
|
definir_tempo_limite: new estruturas_1.FuncaoPadrao(1, internet.definir_tempo_limite),
|