@designliquido/delegua-node 1.16.0 → 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/mouse.d.ts +21 -0
- package/bibliotecas/dialetos/portugol-studio/mouse.d.ts.map +1 -0
- package/bibliotecas/dialetos/portugol-studio/mouse.js +127 -0
- package/bibliotecas/dialetos/portugol-studio/mouse.js.map +1 -0
- package/bibliotecas/dialetos/portugol-studio/sons.d.ts +92 -0
- package/bibliotecas/dialetos/portugol-studio/sons.d.ts.map +1 -0
- package/bibliotecas/dialetos/portugol-studio/sons.js +324 -0
- package/bibliotecas/dialetos/portugol-studio/sons.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/excecoes/erro-execucao-biblioteca.d.ts +5 -0
- package/excecoes/erro-execucao-biblioteca.d.ts.map +1 -0
- package/excecoes/erro-execucao-biblioteca.js +11 -0
- package/excecoes/erro-execucao-biblioteca.js.map +1 -0
- package/excecoes/index.d.ts +1 -0
- package/excecoes/index.d.ts.map +1 -1
- package/excecoes/index.js +1 -0
- package/excecoes/index.js.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../fontes/bibliotecas/dialetos/portugol-studio/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,0DAMC;AAED,4CAEC;AAED,sCAEC;AAED,wCAEC;AAED,0BAUC;AAED,0BAEC;AAED,0CAGC;AA3CD,uCAAyB;AAEzB,MAAM,WAAW,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;AAEhC,KAAK,UAAU,uBAAuB;IACzC,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+CAA+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,MAAe;IACtF,OAAO,MAAM,CAAC,MAAM,CAAC;AACzB,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,aAAqC,EAAE,MAAe;IACvF,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5B,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,aAAqC,EAAE,MAAc,EAAE,MAAc;IAC/F,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,oCAAoC,MAAM,GAAG,CAAC,CAAC;IAC5F,CAAC;IAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;AACtE,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,aAAqC,EAAE,SAAiB;IAClF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AACnE,CAAC;AAEM,KAAK,UAAU,eAAe;IACjC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC;AAChD,CAAC"}
|
package/bin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designliquido/delegua-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Linguagem Delégua com capacidades para ecossistema Node.js.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"empacotar": "yarn rimraf ./dist && tsc && yarn copyfiles -V ./bin/delegua ./bin/delegua.cmd ./dist && yarn copyfiles -V ./package.json ./dist/bin && yarn copyfiles -V ./README.md ./dist && yarn copyfiles -V ./LICENSE ./dist",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"testes:servidor-depuracao": "yarn ts-node ./fontes/depuracao/servidor-depuracao.ts"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@designliquido/birl": "^0.5.
|
|
16
|
-
"@designliquido/delegua": "^1.
|
|
17
|
-
"@designliquido/mapler": "^0.6.
|
|
18
|
-
"@designliquido/portugol-studio": "^0.
|
|
19
|
-
"@designliquido/potigol": "^0.
|
|
20
|
-
"@designliquido/visualg": "^0.8.
|
|
15
|
+
"@designliquido/birl": "^0.5.19",
|
|
16
|
+
"@designliquido/delegua": "^1.15.3",
|
|
17
|
+
"@designliquido/mapler": "^0.6.19",
|
|
18
|
+
"@designliquido/portugol-studio": "^0.10.0",
|
|
19
|
+
"@designliquido/potigol": "^0.9.0",
|
|
20
|
+
"@designliquido/visualg": "^0.8.19",
|
|
21
|
+
"canvas": "^3.2.1",
|
|
21
22
|
"chalk": "4.1.2",
|
|
22
23
|
"commander": "^14.0.0",
|
|
23
24
|
"json-colorizer": "^3.0.1",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"@designliquido/delegua-estatistica": "^0.1.0",
|
|
32
33
|
"@designliquido/delegua-fisica": "^0.1.0",
|
|
33
34
|
"@designliquido/delegua-http": "^0.1.2",
|
|
35
|
+
"@designliquido/delegua-interface-grafica": "^0.0.1",
|
|
34
36
|
"@designliquido/delegua-json": "^0.2.1",
|
|
35
37
|
"@designliquido/delegua-matematica": "^0.3.0",
|
|
36
38
|
"@designliquido/delegua-tempo": "^1.0.1",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erro-execucao-biblioteca.d.ts","sourceRoot":"","sources":["../../fontes/excecoes/erro-execucao-biblioteca.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,QAAQ,EAAE,MAAM,CAAC;gBAEL,QAAQ,EAAE,MAAM;CAI/B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErroExecucaoBiblioteca = void 0;
|
|
4
|
+
class ErroExecucaoBiblioteca extends Error {
|
|
5
|
+
constructor(mensagem) {
|
|
6
|
+
super(mensagem);
|
|
7
|
+
this.name = "ErroExecucaoBiblioteca";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ErroExecucaoBiblioteca = ErroExecucaoBiblioteca;
|
|
11
|
+
//# sourceMappingURL=erro-execucao-biblioteca.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erro-execucao-biblioteca.js","sourceRoot":"","sources":["../../fontes/excecoes/erro-execucao-biblioteca.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAG7C,YAAY,QAAgB;QACxB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACzC,CAAC;CACJ;AAPD,wDAOC"}
|
package/excecoes/index.d.ts
CHANGED
package/excecoes/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fontes/excecoes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fontes/excecoes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC"}
|
package/excecoes/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./erro-importacao"), exports);
|
|
18
|
+
__exportStar(require("./erro-execucao-biblioteca"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/excecoes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fontes/excecoes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fontes/excecoes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,6DAA2C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InfraestruturaWindows } from '@designliquido/delegua-interface-grafica';
|
|
2
|
+
/**
|
|
3
|
+
* Cria uma instância de `InfraestruturaWindows` apontando para um processo
|
|
4
|
+
* PowerShell filho que exibe a janela com WinForms.
|
|
5
|
+
*
|
|
6
|
+
* Compatível com o protocolo `InfraestruturaProcessoExterno`: o script envia
|
|
7
|
+
* `{"tipo":"pronto"}` antes de entrar no laço de eventos, garantindo que as
|
|
8
|
+
* mensagens (criar-janela, criar-botao, …) só cheguem depois que o WinForms
|
|
9
|
+
* já está inicializado.
|
|
10
|
+
*/
|
|
11
|
+
export declare function criarHostWindows(): InfraestruturaWindows;
|
|
12
|
+
/**
|
|
13
|
+
* Retorna `true` se estamos no Windows, onde PowerShell e WinForms
|
|
14
|
+
* estão disponíveis sem instalação adicional.
|
|
15
|
+
*/
|
|
16
|
+
export declare function podeUsarHostWindows(): boolean;
|
|
17
|
+
//# sourceMappingURL=infraestrutura-host-windows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infraestrutura-host-windows.d.ts","sourceRoot":"","sources":["../../../fontes/infraestruturas/host-windows/infraestrutura-host-windows.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAiMjF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAcxD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
|
|
@@ -0,0 +1,260 @@
|
|
|
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.criarHostWindows = criarHostWindows;
|
|
37
|
+
exports.podeUsarHostWindows = podeUsarHostWindows;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const delegua_interface_grafica_1 = require("@designliquido/delegua-interface-grafica");
|
|
42
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
// Script PowerShell gravado no diretório temporário
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
/**
|
|
46
|
+
* Script PowerShell que implementa o host de interface gráfica com WinForms.
|
|
47
|
+
*
|
|
48
|
+
* Protocolo (mesmo de InfraestruturaProcessoExterno):
|
|
49
|
+
* - Envia `{"tipo":"pronto"}` ao stdout assim que estiver pronto para receber mensagens.
|
|
50
|
+
* - Lê mensagens JSON (linha por linha) do stdin e cria/atualiza controles WinForms.
|
|
51
|
+
* - Emite eventos de volta ao Node.js via stdout JSON lines.
|
|
52
|
+
*
|
|
53
|
+
* Notas de implementação PowerShell:
|
|
54
|
+
* - Funções são declaradas com `function global:` para ficarem acessíveis dentro
|
|
55
|
+
* de handlers de eventos WinForms (Add_Tick, Add_Click etc.), que executam em
|
|
56
|
+
* escopo global no PowerShell 5.1, não no escopo do script.
|
|
57
|
+
* - A leitura do stdin é feita por uma classe C# compilada com `Add-Type`, que
|
|
58
|
+
* roda em thread .NET puro sem precisar de runspace PowerShell.
|
|
59
|
+
* - O timer WinForms (30 ms) drena a fila de mensagens na thread de UI.
|
|
60
|
+
*/
|
|
61
|
+
const SCRIPT_POWERSHELL = `
|
|
62
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
63
|
+
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
|
64
|
+
|
|
65
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
66
|
+
Add-Type -AssemblyName System.Drawing
|
|
67
|
+
[System.Windows.Forms.Application]::EnableVisualStyles()
|
|
68
|
+
|
|
69
|
+
# Leitor de stdin em C# puro: thread .NET sem runspace PowerShell
|
|
70
|
+
Add-Type @"
|
|
71
|
+
using System;
|
|
72
|
+
using System.Collections.Concurrent;
|
|
73
|
+
using System.Threading;
|
|
74
|
+
public class DguaStdinLeitor {
|
|
75
|
+
public static void Iniciar(ConcurrentQueue<string> fila) {
|
|
76
|
+
var t = new Thread(() => {
|
|
77
|
+
try {
|
|
78
|
+
string linha;
|
|
79
|
+
while ((linha = Console.In.ReadLine()) != null) {
|
|
80
|
+
var l = linha.Trim();
|
|
81
|
+
if (l.Length > 0) fila.Enqueue(l);
|
|
82
|
+
}
|
|
83
|
+
} catch {}
|
|
84
|
+
fila.Enqueue("{\\"tipo\\":\\"encerrar\\"}");
|
|
85
|
+
});
|
|
86
|
+
t.IsBackground = true;
|
|
87
|
+
t.Start();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
"@
|
|
91
|
+
|
|
92
|
+
$script:fila = [System.Collections.Concurrent.ConcurrentQueue[string]]::new()
|
|
93
|
+
$script:elementos = [System.Collections.Hashtable]::new()
|
|
94
|
+
$script:textosComponentes = [System.Collections.Hashtable]::new()
|
|
95
|
+
|
|
96
|
+
# ── Funções globais ─────────────────────────────────────────────────────────
|
|
97
|
+
# Devem ser "global:" para ficarem acessíveis em handlers de eventos WinForms.
|
|
98
|
+
|
|
99
|
+
function global:DguaEnviar([hashtable]$obj) {
|
|
100
|
+
$json = ($obj | ConvertTo-Json -Compress -Depth 3)
|
|
101
|
+
[Console]::Out.WriteLine($json)
|
|
102
|
+
[Console]::Out.Flush()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function global:DguaCriarPainel([string]$paiId, [string]$id, $dir) {
|
|
106
|
+
$p = New-Object System.Windows.Forms.FlowLayoutPanel
|
|
107
|
+
$p.FlowDirection = $dir
|
|
108
|
+
$p.WrapContents = $false
|
|
109
|
+
$p.AutoSize = $true
|
|
110
|
+
$p.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink
|
|
111
|
+
$script:elementos[$paiId].Controls.Add($p)
|
|
112
|
+
$script:elementos[$id] = $p
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function global:DguaProcessar([string]$linha) {
|
|
116
|
+
try {
|
|
117
|
+
$msg = $linha | ConvertFrom-Json
|
|
118
|
+
} catch {
|
|
119
|
+
[Console]::Error.WriteLine('[DG] JSON invalido: ' + $linha)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
switch ($msg.tipo) {
|
|
123
|
+
'criar-janela' {
|
|
124
|
+
$script:mainForm.Text = if ($msg.titulo) { $msg.titulo } else { 'Delegua' }
|
|
125
|
+
$script:mainForm.Width = if ($msg.largura) { [int]$msg.largura } else { 800 }
|
|
126
|
+
$script:mainForm.Height = if ($msg.altura) { [int]$msg.altura + 40 } else { 440 }
|
|
127
|
+
$script:elementos[$msg.id] = $script:painelRaiz
|
|
128
|
+
$script:mainForm.Visible = $true
|
|
129
|
+
$script:mainForm.BringToFront()
|
|
130
|
+
$script:mainForm.Activate()
|
|
131
|
+
}
|
|
132
|
+
'criar-botao' {
|
|
133
|
+
$id = $msg.id
|
|
134
|
+
$btn = New-Object System.Windows.Forms.Button
|
|
135
|
+
$btn.Text = $msg.rotulo
|
|
136
|
+
$btn.AutoSize = $true
|
|
137
|
+
$btn.Margin = New-Object System.Windows.Forms.Padding(4)
|
|
138
|
+
$btn.Add_Click({ DguaEnviar @{ tipo='evento'; componenteId=$id; evento='clique' } }.GetNewClosure())
|
|
139
|
+
$script:elementos[$msg.paiId].Controls.Add($btn)
|
|
140
|
+
$script:elementos[$id] = $btn
|
|
141
|
+
}
|
|
142
|
+
'criar-rotulo' {
|
|
143
|
+
$lbl = New-Object System.Windows.Forms.Label
|
|
144
|
+
$lbl.Text = $msg.texto
|
|
145
|
+
$lbl.AutoSize = $true
|
|
146
|
+
$lbl.Margin = New-Object System.Windows.Forms.Padding(4)
|
|
147
|
+
$script:elementos[$msg.paiId].Controls.Add($lbl)
|
|
148
|
+
$script:elementos[$msg.id] = $lbl
|
|
149
|
+
$script:textosComponentes[$msg.id] = $msg.texto
|
|
150
|
+
}
|
|
151
|
+
'criar-caixa-texto' {
|
|
152
|
+
$id = $msg.id
|
|
153
|
+
$inp = New-Object System.Windows.Forms.TextBox
|
|
154
|
+
$inp.Text = if ($msg.textoInicial) { $msg.textoInicial } else { '' }
|
|
155
|
+
$inp.Width = 200
|
|
156
|
+
$inp.Margin = New-Object System.Windows.Forms.Padding(4)
|
|
157
|
+
$inp.Add_TextChanged({
|
|
158
|
+
$script:textosComponentes[$id] = $inp.Text
|
|
159
|
+
DguaEnviar @{ tipo='valor-atualizado'; id=$id; valor=$inp.Text }
|
|
160
|
+
DguaEnviar @{ tipo='evento'; componenteId=$id; evento='alterado'; valor=$inp.Text }
|
|
161
|
+
}.GetNewClosure())
|
|
162
|
+
$script:elementos[$msg.paiId].Controls.Add($inp)
|
|
163
|
+
$script:elementos[$id] = $inp
|
|
164
|
+
$script:textosComponentes[$id] = $inp.Text
|
|
165
|
+
}
|
|
166
|
+
'criar-caixa-vertical' {
|
|
167
|
+
DguaCriarPainel $msg.paiId $msg.id ([System.Windows.Forms.FlowDirection]::TopDown)
|
|
168
|
+
}
|
|
169
|
+
'criar-caixa-horizontal' {
|
|
170
|
+
DguaCriarPainel $msg.paiId $msg.id ([System.Windows.Forms.FlowDirection]::LeftToRight)
|
|
171
|
+
}
|
|
172
|
+
'definir-texto' {
|
|
173
|
+
$el = $script:elementos[$msg.id]
|
|
174
|
+
if ($null -ne $el) { $el.Text = $msg.texto }
|
|
175
|
+
$script:textosComponentes[$msg.id] = $msg.texto
|
|
176
|
+
}
|
|
177
|
+
'encerrar' { $script:mainForm.Close() }
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# ── Formulário principal ─────────────────────────────────────────────────────
|
|
182
|
+
|
|
183
|
+
$script:mainForm = New-Object System.Windows.Forms.Form
|
|
184
|
+
$script:mainForm.Visible = $false
|
|
185
|
+
$script:mainForm.AutoScroll = $true
|
|
186
|
+
|
|
187
|
+
# Painel raiz: preenche o formulário sem AutoSize (conflita com Dock=Fill)
|
|
188
|
+
$script:painelRaiz = New-Object System.Windows.Forms.FlowLayoutPanel
|
|
189
|
+
$script:painelRaiz.FlowDirection = [System.Windows.Forms.FlowDirection]::TopDown
|
|
190
|
+
$script:painelRaiz.WrapContents = $false
|
|
191
|
+
$script:painelRaiz.Dock = [System.Windows.Forms.DockStyle]::Fill
|
|
192
|
+
$script:mainForm.Controls.Add($script:painelRaiz)
|
|
193
|
+
|
|
194
|
+
# Força criação do handle (necessário para que Invoke funcione antes do Show)
|
|
195
|
+
$null = $script:mainForm.Handle
|
|
196
|
+
|
|
197
|
+
$script:mainForm.Add_FormClosed({
|
|
198
|
+
DguaEnviar @{ tipo='fechado' }
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
# ── Timer que drena a fila na thread de UI ───────────────────────────────────
|
|
202
|
+
|
|
203
|
+
$timer = New-Object System.Windows.Forms.Timer
|
|
204
|
+
$timer.Interval = 30
|
|
205
|
+
$timer.Add_Tick({
|
|
206
|
+
try {
|
|
207
|
+
$item = [string]$null
|
|
208
|
+
while ($script:fila.TryDequeue([ref]$item)) {
|
|
209
|
+
DguaProcessar $item
|
|
210
|
+
}
|
|
211
|
+
} catch {
|
|
212
|
+
[Console]::Error.WriteLine('[DG] Erro no timer: ' + $_.Exception.Message)
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
$timer.Start()
|
|
216
|
+
|
|
217
|
+
# ── Inicia leitor de stdin (thread C#) ──────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
[DguaStdinLeitor]::Iniciar($script:fila)
|
|
220
|
+
|
|
221
|
+
# Sinaliza que está pronto para receber mensagens (protocolo InfraestruturaProcessoExterno)
|
|
222
|
+
[Console]::Out.WriteLine('{"tipo":"pronto"}')
|
|
223
|
+
[Console]::Out.Flush()
|
|
224
|
+
|
|
225
|
+
[System.Windows.Forms.Application]::Run($script:mainForm)
|
|
226
|
+
`;
|
|
227
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
228
|
+
// Fábrica pública
|
|
229
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
230
|
+
/**
|
|
231
|
+
* Cria uma instância de `InfraestruturaWindows` apontando para um processo
|
|
232
|
+
* PowerShell filho que exibe a janela com WinForms.
|
|
233
|
+
*
|
|
234
|
+
* Compatível com o protocolo `InfraestruturaProcessoExterno`: o script envia
|
|
235
|
+
* `{"tipo":"pronto"}` antes de entrar no laço de eventos, garantindo que as
|
|
236
|
+
* mensagens (criar-janela, criar-botao, …) só cheguem depois que o WinForms
|
|
237
|
+
* já está inicializado.
|
|
238
|
+
*/
|
|
239
|
+
function criarHostWindows() {
|
|
240
|
+
const dirTemp = fs.mkdtempSync(path.join(os.tmpdir(), 'delegua-gui-'));
|
|
241
|
+
const caminhoScript = path.join(dirTemp, 'delegua-gui.ps1');
|
|
242
|
+
fs.writeFileSync(caminhoScript, SCRIPT_POWERSHELL, 'utf-8');
|
|
243
|
+
return new delegua_interface_grafica_1.InfraestruturaWindows({
|
|
244
|
+
comando: 'powershell.exe',
|
|
245
|
+
argumentos: [
|
|
246
|
+
'-NoProfile',
|
|
247
|
+
'-NonInteractive',
|
|
248
|
+
'-ExecutionPolicy', 'Bypass',
|
|
249
|
+
'-File', caminhoScript,
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Retorna `true` se estamos no Windows, onde PowerShell e WinForms
|
|
255
|
+
* estão disponíveis sem instalação adicional.
|
|
256
|
+
*/
|
|
257
|
+
function podeUsarHostWindows() {
|
|
258
|
+
return process.platform === 'win32';
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=infraestrutura-host-windows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infraestrutura-host-windows.js","sourceRoot":"","sources":["../../../fontes/infraestruturas/host-windows/infraestrutura-host-windows.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8MA,4CAcC;AAMD,kDAEC;AApOD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,wFAAiF;AAEjF,gFAAgF;AAChF,oDAAoD;AACpD,gFAAgF;AAEhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKzB,CAAC;AAEF,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;;;;GAQG;AACH,SAAgB,gBAAgB;IAC5B,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAC5D,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5D,OAAO,IAAI,iDAAqB,CAAC;QAC7B,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE;YACR,YAAY;YACZ,iBAAiB;YACjB,kBAAkB,EAAE,QAAQ;YAC5B,OAAO,EAAE,aAAa;SACzB;KACJ,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB;IAC/B,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { InfraestruturaGraficaInterface, ComponenteInterfaceGraficaInterface } from '@designliquido/delegua-interface-grafica';
|
|
2
|
+
/**
|
|
3
|
+
* Infraestrutura de interface gráfica que spawna um processo Electron filho.
|
|
4
|
+
*
|
|
5
|
+
* Usada quando o programa Delégua roda na linha de comando (Node.js puro),
|
|
6
|
+
* sem DOM e sem WebView do VS Code. Requer que o pacote `electron` esteja
|
|
7
|
+
* instalado local ou globalmente.
|
|
8
|
+
*
|
|
9
|
+
* Protocolo de comunicação: servidor TCP local (127.0.0.1, porta aleatória).
|
|
10
|
+
* O processo pai cria o servidor; o Electron conecta de volta como cliente.
|
|
11
|
+
* Mensagens trocadas como JSON delimitadas por `\n` — idêntico ao protocolo
|
|
12
|
+
* de `InfraestruturaWebView`, porém via socket em vez de stdin/stdout
|
|
13
|
+
* (stdin é consumido pelo Chromium durante a inicialização no Windows).
|
|
14
|
+
*/
|
|
15
|
+
export declare class InfraestruturaInvocacaoElectron implements InfraestruturaGraficaInterface {
|
|
16
|
+
private contadorIds;
|
|
17
|
+
private readonly textosComponentes;
|
|
18
|
+
private resolverLaco;
|
|
19
|
+
private processoFinalizou;
|
|
20
|
+
private readonly tratadoresEventos;
|
|
21
|
+
private processo;
|
|
22
|
+
private readonly servidor;
|
|
23
|
+
private socket;
|
|
24
|
+
private readonly filaEnvio;
|
|
25
|
+
constructor(caminhoBinario: string);
|
|
26
|
+
private proximoId;
|
|
27
|
+
private _enviar;
|
|
28
|
+
private _encerrarInterno;
|
|
29
|
+
private _processarMensagem;
|
|
30
|
+
criarJanela(largura: number, altura: number, titulo: string): ComponenteInterfaceGraficaInterface;
|
|
31
|
+
criarBotao(pai: ComponenteInterfaceGraficaInterface, rotulo: string): ComponenteInterfaceGraficaInterface;
|
|
32
|
+
criarRotulo(pai: ComponenteInterfaceGraficaInterface, texto: string): ComponenteInterfaceGraficaInterface;
|
|
33
|
+
criarCaixaTexto(pai: ComponenteInterfaceGraficaInterface, textoInicial: string): ComponenteInterfaceGraficaInterface;
|
|
34
|
+
criarCaixaVertical(pai: ComponenteInterfaceGraficaInterface): ComponenteInterfaceGraficaInterface;
|
|
35
|
+
criarCaixaHorizontal(pai: ComponenteInterfaceGraficaInterface): ComponenteInterfaceGraficaInterface;
|
|
36
|
+
definirTexto(componente: ComponenteInterfaceGraficaInterface, texto: string): void;
|
|
37
|
+
obterTexto(componente: ComponenteInterfaceGraficaInterface): string;
|
|
38
|
+
conectarEvento(componente: ComponenteInterfaceGraficaInterface, evento: string, callback: (...argumentos: any[]) => Promise<void>): void;
|
|
39
|
+
iniciarLaco(): Promise<void>;
|
|
40
|
+
encerrar(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tenta localizar o binário do Electron instalado como pacote npm.
|
|
44
|
+
* Verifica primeiro nas dependências locais e depois no diretório global do npm.
|
|
45
|
+
* Retorna `null` se o Electron não estiver disponível.
|
|
46
|
+
*/
|
|
47
|
+
export declare function localizarElectron(): string | null;
|
|
48
|
+
//# sourceMappingURL=infraestrutura-invocacao-electron.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infraestrutura-invocacao-electron.d.ts","sourceRoot":"","sources":["../../../fontes/infraestruturas/invocacao-electron/infraestrutura-invocacao-electron.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AA4P/H;;;;;;;;;;;;GAYG;AACH,qBAAa,+BAAgC,YAAW,8BAA8B;IAClF,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAC/D,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;IAEJ,OAAO,CAAC,QAAQ,CAA2C;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,cAAc,EAAE,MAAM;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