@elurjs/universal 0.1.2 → 0.1.4

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 (37) hide show
  1. package/cli/commands.mjs +3 -3
  2. package/cli/create-app.mjs +211 -14
  3. package/cli/dev.mjs +50 -0
  4. package/cli/tck-platform-windows.mjs +450 -0
  5. package/cli/tck-windows-uia.ps1 +312 -0
  6. package/cli/vm-agent.ps1 +25 -0
  7. package/cli/vm-job-server.py +97 -0
  8. package/cli/vm-job.py +46 -0
  9. package/docs/ESTADO.md +5 -1
  10. package/docs/INSTALACION-Y-DEV.md +162 -0
  11. package/docs/PENDIENTES.md +173 -12
  12. package/docs/adr/0218-sdui-gateway-live-mcp-y-scaffold.md +1 -0
  13. package/docs/adr/0220-target-windows-winui3.md +331 -0
  14. package/docs/adr/0221-shell-tabs-desktop-normativa.md +45 -0
  15. package/docs/adr/README.md +11 -10
  16. package/docs/doc-data.json +395 -104
  17. package/docs/propuestas/demo-google-devfest-a2ui-sdui.md +206 -54
  18. package/docs/skills/elur-sdui-mcp/SKILL.md +107 -0
  19. package/examples/natprobe/entry-a11y.ts +52 -0
  20. package/examples/natprobe/entry-tinput.ts +73 -0
  21. package/examples/natprobe/entry-tml.ts +46 -0
  22. package/examples/natprobe/entry.ts +89 -0
  23. package/examples/uiprops/elur.app.json +8 -0
  24. package/examples/uiprops/entry.ts +65 -0
  25. package/native/ed25519/tweetnacl.c +809 -0
  26. package/native/ed25519/tweetnacl.h +272 -0
  27. package/package.json +2 -2
  28. package/src/app/state.ts +1 -1
  29. package/src/backends/web/index.ts +55 -2
  30. package/src/ir/catalog.ts +17 -3
  31. package/src/ir/schema.ts +245 -94
  32. package/src/native/http.ts +1 -1
  33. package/src/runtime/environment.ts +1 -1
  34. package/src/sdui/cryptoModule.ts +1 -1
  35. package/src/sdui/oracle.ts +5 -0
  36. package/src/sdui/profile.ts +3 -2
  37. package/targets/android/app/src/main/java/com/elur/universal/ElurRenderer.kt +55 -3
@@ -0,0 +1,312 @@
1
+ # cli/tck-windows-uia.ps1 — probe UIA del harness T6 Windows (ADR-0220).
2
+ # Observa el host por la API de accesibilidad real de la plataforma
3
+ # (equivalente al uiautomator dump de Android y al AT-SPI de Linux):
4
+ # árbol, ControlType, nombres, BoundingRectangle (pantalla) y patrones.
5
+ #
6
+ # Uso (corre DENTRO del guest Windows — el orquestador lo invoca por el
7
+ # job server):
8
+ # tck-windows-uia.ps1 dump <pid> → JSON [{name,role,x,y,w,h,text}]
9
+ # tck-windows-uia.ps1 focus <pid> <name> → SetFocus/click al centro
10
+ # tck-windows-uia.ps1 type <pid> <name> <s> → foco + SendKeys del texto
11
+ # tck-windows-uia.ps1 click <x> <y> → mouse_event b1 en (x,y)
12
+ # tck-windows-uia.ps1 wheel <x> <y> <n> → n notches MOUSEEVENTF_WHEEL
13
+ # tck-windows-uia.ps1 shot <x> <y> <w> <h> <out.png>
14
+ # tck-windows-uia.ps1 resize <pid> <w> <h> → MoveWindow en la ventana
15
+ # tck-windows-uia.ps1 keys <combo> → SendKeys ("^s", "{ENTER}"…)
16
+ # tck-windows-uia.ps1 longpress <x> <y> <ms>
17
+ # tck-windows-uia.ps1 drag <x1> <y1> <x2> <y2> <pasos>
18
+ #
19
+ # Todo emite JSON por stdout; errores a stderr + exit 1.
20
+
21
+ param([Parameter(Mandatory=$true)][string]$Cmd,
22
+ [Parameter(ValueFromRemainingArguments=$true)][string[]]$Rest)
23
+
24
+ # El agente captura esta stdout decodificando UTF-8; con el codepage OEM
25
+ # por defecto (CP850) un '→' sale como byte 0x1A y llega como U+001A.
26
+ [Console]::OutputEncoding = [Text.Encoding]::UTF8
27
+
28
+ Add-Type -AssemblyName UIAutomationClient
29
+ Add-Type -AssemblyName UIAutomationTypes
30
+ Add-Type -AssemblyName System.Windows.Forms
31
+ Add-Type -AssemblyName System.Drawing
32
+
33
+ $sig = @'
34
+ using System;
35
+ using System.Runtime.InteropServices;
36
+ public class U32T {
37
+ [DllImport("user32.dll")] public static extern bool SetCursorPos(int x,int y);
38
+ [DllImport("user32.dll")] public static extern void mouse_event(uint f,int x,int y,int d,int e);
39
+ [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
40
+ [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr h,int c);
41
+ [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h,IntPtr i,int x,int y,int cx,int cy,uint f);
42
+ [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr h,int x,int y,int w,int hh,bool r);
43
+ [DllImport("user32.dll")] public static extern IntPtr WindowFromPoint(System.Drawing.Point p);
44
+ [DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr h,out int p);
45
+ [StructLayout(LayoutKind.Sequential)] public struct MI { public int dx,dy,d,du; public int dwF,time; public IntPtr ex; }
46
+ [StructLayout(LayoutKind.Sequential)] public struct INP { public int type; public MI mi; }
47
+ [DllImport("user32.dll")] public static extern uint SendInput(uint n, INP[] p, int cb);
48
+ public const uint LD=0x02, LU=0x04, WHEEL=0x0800;
49
+ }
50
+ '@
51
+ Add-Type -TypeDefinition $sig -ReferencedAssemblies @(
52
+ 'System.Windows.Forms','System.Drawing','UIAutomationClient','UIAutomationTypes')
53
+
54
+ function Fail($m) { [Console]::Error.WriteLine($m); exit 1 }
55
+
56
+ $auto = [System.Windows.Automation.AutomationElement]
57
+ $pt = [System.Windows.Automation.PropertyCondition]
58
+
59
+ function AppWindow([int]$pid_) {
60
+ $w = $auto::RootElement.FindFirst(
61
+ [System.Windows.Automation.TreeScope]::Children,
62
+ (New-Object $pt($auto::ProcessIdProperty, $pid_)))
63
+ if (-not $w) { Fail "ventana no encontrada: pid $pid_" }
64
+ return $w
65
+ }
66
+
67
+ function NodeInfo($el, [int]$depth) {
68
+ $c = $el.Current
69
+ $o = [ordered]@{
70
+ name = [string]$c.Name
71
+ role = ($c.ControlType.ProgrammaticName -replace '^ControlType\.','')
72
+ depth = $depth
73
+ }
74
+ try { $o.lct = [string]$c.LocalizedControlType } catch {}
75
+ try {
76
+ $r = $c.BoundingRectangle
77
+ $o.x = [int]$r.X; $o.y = [int]$r.Y; $o.w = [int]$r.Width; $o.h = [int]$r.Height
78
+ } catch {}
79
+ try {
80
+ $vp = $el.GetCurrentPattern([System.Windows.Automation.ValuePattern]::Pattern)
81
+ if ($vp) { $o.value = [string]$vp.Current.Value }
82
+ } catch {}
83
+ try {
84
+ if ($el.GetCurrentPattern([System.Windows.Automation.TextPattern]::Pattern)) {
85
+ $o.text = $el.GetCurrentPattern([System.Windows.Automation.TextPattern]::Pattern).DocumentRange.GetText(-1)
86
+ } else {
87
+ $o.text = [string]$c.Name
88
+ }
89
+ } catch { $o.text = [string]$c.Name }
90
+ return $o
91
+ }
92
+
93
+ $tw = [System.Windows.Automation.TreeWalker]::ControlViewWalker
94
+ function Walk($el, [int]$depth, $acc) {
95
+ if ($depth -gt 24 -or $null -eq $el) { return }
96
+ try {
97
+ [void]$acc.Add((NodeInfo $el $depth))
98
+ # ControlViewWalker: la vista real de a11y — salta wrappers
99
+ # no-control y poda accessible=false (misma semántica que AT-SPI /
100
+ # uiautomator importantForA11y). FindAll(Children, cond) NO sirve:
101
+ # no desciende por hijos que no matchean la condición.
102
+ $k = $tw.GetFirstChild($el)
103
+ while ($k) { Walk $k ($depth + 1) $acc; $k = $tw.GetNextSibling($k) }
104
+ } catch { }
105
+ }
106
+
107
+ function FindNamed($win, [string]$name) {
108
+ return $win.FindFirst([System.Windows.Automation.TreeScope]::Descendants,
109
+ (New-Object $pt($auto::NameProperty, $name)))
110
+ }
111
+
112
+ function FocusTarget($el) {
113
+ # El `label` vive en el wrapper Custom; el control interactivo real
114
+ # (Edit, Button…) es el primer descendiente con un patrón de entrada.
115
+ foreach ($patt in @(
116
+ [System.Windows.Automation.ValuePattern]::Pattern,
117
+ [System.Windows.Automation.InvokePattern]::Pattern,
118
+ [System.Windows.Automation.TogglePattern]::Pattern,
119
+ [System.Windows.Automation.SelectionItemPattern]::Pattern)) {
120
+ try {
121
+ if ($el.GetCurrentPattern($patt)) { return $el }
122
+ } catch {}
123
+ }
124
+ try {
125
+ $d = $el.FindFirst([System.Windows.Automation.TreeScope]::Descendants,
126
+ (New-Object $pt($auto::IsEnabledProperty, $true)))
127
+ if ($d) {
128
+ foreach ($patt in @(
129
+ [System.Windows.Automation.ValuePattern]::Pattern,
130
+ [System.Windows.Automation.InvokePattern]::Pattern,
131
+ [System.Windows.Automation.TogglePattern]::Pattern,
132
+ [System.Windows.Automation.SelectionItemPattern]::Pattern)) {
133
+ try { if ($d.GetCurrentPattern($patt)) { return $d } } catch {}
134
+ }
135
+ return $d
136
+ }
137
+ } catch {}
138
+ return $el
139
+ }
140
+
141
+ function ClickXY([int]$x, [int]$y) {
142
+ [U32T]::SetCursorPos($x, $y) | Out-Null
143
+ [U32T]::mouse_event([U32T]::LD, 0, 0, 0, 0)
144
+ Start-Sleep -Milliseconds 60
145
+ [U32T]::mouse_event([U32T]::LU, 0, 0, 0, 0)
146
+ }
147
+
148
+ function RaiseApp($win) {
149
+ # Los pixels/SendKeys/clicks del harness leen la pantalla real; una
150
+ # consola encima convierte todo en [12,12,12]. El exe es subsystem
151
+ # console: al lanzarlo sin consola heredable Windows 11 abre su
152
+ # terminal por defecto (WindowsTerminal) encima de la app — hay que
153
+ # ocultarlo. SetForegroundWindow se bloquea desde procesos en
154
+ # background: solo HWND_TOPMOST deja la app por encima.
155
+ Get-Process WindowsTerminal -ErrorAction SilentlyContinue |
156
+ ForEach-Object { [U32T]::ShowWindow($_.MainWindowHandle, 0) | Out-Null }
157
+ $h = [IntPtr]$win.Current.NativeWindowHandle
158
+ # El raise fija la posición para que los px del harness sean
159
+ # deterministas — la ventana debe quedar ENTERA dentro de la pantalla
160
+ # (los nodos a x>ScreenWidth no existen en el framebuffer: px=negro).
161
+ $sw = [Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width
162
+ $sh = [Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height
163
+ $wr = $win.Current.BoundingRectangle
164
+ $x = [Math]::Max(0, [Math]::Min(40, $sw - $wr.Width - 10))
165
+ $y = [Math]::Max(0, [Math]::Min(40, $sh - $wr.Height - 60))
166
+ [U32T]::ShowWindow($h, 9) | Out-Null
167
+ [U32T]::SetWindowPos($h, [IntPtr](-1), $x, $y, 0, 0, 1) | Out-Null
168
+ [U32T]::SetForegroundWindow($h) | Out-Null
169
+ }
170
+
171
+ function ClickCenter($el) {
172
+ $r = $el.Current.BoundingRectangle
173
+ ClickXY ([int]($r.X + $r.Width / 2)) ([int]($r.Y + $r.Height / 2))
174
+ }
175
+
176
+ switch ($Cmd) {
177
+ 'dump' {
178
+ $win = AppWindow ([int]$Rest[0])
179
+ $acc = New-Object System.Collections.ArrayList
180
+ Walk $win 0 $acc
181
+ # ArrayList → JSON plano
182
+ $arr = @($acc)
183
+ ConvertTo-Json -Compress -Depth 4 @(if ($arr.Count -eq 1) { ,$arr[0] } else { $arr })
184
+ }
185
+ 'focus' {
186
+ $win = AppWindow ([int]$Rest[0])
187
+ RaiseApp $win
188
+ $el = FindNamed $win $Rest[1]
189
+ if (-not $el) { Fail "nodo no encontrado: $($Rest[1])" }
190
+ $el = FocusTarget $el
191
+ try { $el.SetFocus(); ConvertTo-Json -Compress @{focused=$Rest[1]}; break } catch {}
192
+ ClickCenter $el
193
+ ConvertTo-Json -Compress @{focused=$Rest[1]}
194
+ }
195
+ 'type' {
196
+ $win = AppWindow ([int]$Rest[0])
197
+ RaiseApp $win
198
+ $el = FindNamed $win $Rest[1]
199
+ if (-not $el) { Fail "nodo no encontrado: $($Rest[1])" }
200
+ $el = FocusTarget $el
201
+ # SendKeys va al foco OS, no al foco UIA — un click real lleva las
202
+ # dos cosas al control (además de caret), igual que un usuario.
203
+ ClickCenter $el
204
+ Start-Sleep -Milliseconds 300
205
+ try { $el.SetFocus() } catch {}
206
+ $txt = $Rest[2] -replace '([+^%~(){}\[\]])', '{$1}'
207
+ [System.Windows.Forms.SendKeys]::SendWait($txt)
208
+ ConvertTo-Json -Compress @{typed=$Rest[2]}
209
+ }
210
+ 'click' { ClickXY ([int]$Rest[0]) ([int]$Rest[1])
211
+ ConvertTo-Json -Compress @{clicked=@([int]$Rest[0],[int]$Rest[1])} }
212
+ 'raise' {
213
+ $win = AppWindow ([int]$Rest[0])
214
+ RaiseApp $win
215
+ ConvertTo-Json -Compress @{raised=$Rest[0]; hwnd=[int64]$win.Current.NativeWindowHandle}
216
+ }
217
+ 'at' {
218
+ # qué ventana está realmente en (x,y) — diagnóstico de z-order.
219
+ $h = [U32T]::WindowFromPoint((New-Object System.Drawing.Point([int]$Rest[0],[int]$Rest[1])))
220
+ $wp = 0
221
+ [U32T]::GetWindowThreadProcessId($h, [ref]$wp) | Out-Null
222
+ $pn = (Get-Process -Id $wp -ErrorAction SilentlyContinue).ProcessName
223
+ ConvertTo-Json -Compress @{x=[int]$Rest[0]; y=[int]$Rest[1]; hwnd=[int64]$h; pid=$wp; proc=$pn}
224
+ }
225
+ 'props' {
226
+ $win = AppWindow ([int]$Rest[0])
227
+ $el = FindNamed $win $Rest[1]
228
+ if (-not $el) { Fail "nodo no encontrado: $($Rest[1])" }
229
+ $c = $el.Current
230
+ $r = $c.BoundingRectangle
231
+ ConvertTo-Json -Compress ([ordered]@{
232
+ name=$c.Name; ct=$c.ControlType.ProgrammaticName; cls=$c.ClassName;
233
+ off=$c.IsOffscreen; en=$c.IsEnabled; rect="$($r.X),$($r.Y),$($r.Width)x$($r.Height)" })
234
+ }
235
+ 'wheel' {
236
+ [U32T]::SetCursorPos([int]$Rest[0], [int]$Rest[1]) | Out-Null
237
+ $n = [int]$Rest[2]
238
+ for ($i = 0; $i -lt [Math]::Abs($n); $i++) {
239
+ [U32T]::mouse_event([U32T]::WHEEL, 0, 0, $(if ($n -gt 0) { 120 } else { -120 }), 0)
240
+ Start-Sleep -Milliseconds 120
241
+ }
242
+ ConvertTo-Json -Compress @{wheeled=@([int]$Rest[0],[int]$Rest[1],$n)}
243
+ }
244
+ 'px' {
245
+ # Pixel de pantalla en (x,y) — evidencia sin mover PNGs al host.
246
+ $bmp = New-Object System.Drawing.Bitmap 1, 1
247
+ $g = [System.Drawing.Graphics]::FromImage($bmp)
248
+ $g.CopyFromScreen([int]$Rest[0], [int]$Rest[1], 0, 0,
249
+ (New-Object System.Drawing.Size 1, 1))
250
+ $c = $bmp.GetPixel(0, 0)
251
+ $g.Dispose(); $bmp.Dispose()
252
+ ConvertTo-Json -Compress @{rgb=@($c.R,$c.G,$c.B)}
253
+ }
254
+ 'shot' {
255
+ $x=[int]$Rest[0]; $y=[int]$Rest[1]; $w=[int]$Rest[2]; $h=[int]$Rest[3]
256
+ $bmp = New-Object System.Drawing.Bitmap $w, $h
257
+ $g = [System.Drawing.Graphics]::FromImage($bmp)
258
+ $g.CopyFromScreen($x, $y, 0, 0, (New-Object System.Drawing.Size $w, $h))
259
+ $bmp.Save($Rest[4], [System.Drawing.Imaging.ImageFormat]::Png)
260
+ $g.Dispose(); $bmp.Dispose()
261
+ ConvertTo-Json -Compress @{shot=$Rest[4]; size=@($w,$h)}
262
+ }
263
+ 'resize' {
264
+ $p = Get-Process -Id ([int]$Rest[0]) -ErrorAction SilentlyContinue
265
+ if (-not $p) { Fail "proceso no encontrado: $($Rest[0])" }
266
+ [U32T]::MoveWindow($p.MainWindowHandle, 40, 40, [int]$Rest[1], [int]$Rest[2], $true) | Out-Null
267
+ ConvertTo-Json -Compress @{resized=@([int]$Rest[1],[int]$Rest[2])}
268
+ }
269
+ 'keys' {
270
+ [System.Windows.Forms.SendKeys]::SendWait($Rest[0])
271
+ ConvertTo-Json -Compress @{keys=$Rest[0]}
272
+ }
273
+ 'longpress' {
274
+ $x=[int]$Rest[0]; $y=[int]$Rest[1]
275
+ [U32T]::SetCursorPos($x, $y) | Out-Null
276
+ [U32T]::mouse_event([U32T]::LD, 0, 0, 0, 0)
277
+ Start-Sleep -Milliseconds ([int]$Rest[2])
278
+ [U32T]::mouse_event([U32T]::LU, 0, 0, 0, 0)
279
+ ConvertTo-Json -Compress @{longpress=@($x,$y,[int]$Rest[2])}
280
+ }
281
+ 'drag' {
282
+ $x1=[int]$Rest[0]; $y1=[int]$Rest[1]; $x2=[int]$Rest[2]; $y2=[int]$Rest[3]
283
+ $steps = [Math]::Max(1, [int]$Rest[4])
284
+ # SendInput (MOVE|ABSOLUTE): SetCursorPos no genera PointerMoved en
285
+ # el stack de punteros de WinUI 3 (los clicks sí pasan por
286
+ # WM_LBUTTON* — el move sintético solo WM_MOUSEMOVE, que la isla
287
+ # no traduce a pointer).
288
+ $sw=[Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width
289
+ $sh=[Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height
290
+ $mi = { param($x,$y,$f)
291
+ $i = New-Object U32T+INP
292
+ $i.type = 0
293
+ $i.mi.dx = [int]($x * 65535 / ($sw - 1))
294
+ $i.mi.dy = [int]($y * 65535 / ($sh - 1))
295
+ $i.mi.dwF = $f -bor 0x8000
296
+ return ,@($i)
297
+ }
298
+ [U32T]::SendInput(1, (& $mi $x1 $y1 0x0001), 40) | Out-Null
299
+ Start-Sleep -Milliseconds 50
300
+ [U32T]::mouse_event([U32T]::LD, 0, 0, 0, 0)
301
+ Start-Sleep -Milliseconds 50
302
+ for ($i = 1; $i -le $steps; $i++) {
303
+ $px = $x1 + ($x2-$x1)*$i/$steps
304
+ $py = $y1 + ($y2-$y1)*$i/$steps
305
+ [U32T]::SendInput(1, (& $mi $px $py 0x0001), 40) | Out-Null
306
+ Start-Sleep -Milliseconds 20
307
+ }
308
+ [U32T]::mouse_event([U32T]::LU, 0, 0, 0, 0)
309
+ ConvertTo-Json -Compress @{drag=@($x1,$y1,$x2,$y2,$steps)}
310
+ }
311
+ default { Fail "cmd desconocido: $Cmd" }
312
+ }
@@ -0,0 +1,25 @@
1
+ # cli/vm-agent.ps1 — agente guest del job server (cli/vm-job-server.py).
2
+ # Corre dentro de la VM Windows: pollea /poll cada 400ms, ejecuta el cmd
3
+ # recibido por cmd /c y POSTea la salida a /result. La plantilla se
4
+ # sirve con __VM__/__PORT__ sustituidos por el server.
5
+ $h='http://10.0.2.2:__PORT__'
6
+ $vm='__VM__'
7
+ # PS decodifica la stdout de procesos hijo con [Console]::OutputEncoding;
8
+ # sin UTF-8 un '→' emitido por el probe llega mojibake ('ÔåÆ').
9
+ [Console]::OutputEncoding = [Text.Encoding]::UTF8
10
+ while($true){
11
+ try{
12
+ $j=irm "$h/poll?vm=$vm" -TimeoutSec 5
13
+ if($j.id){
14
+ try{ $o=& cmd /c ($j.cmd+' 2>&1') | Out-String }
15
+ catch{ $o=$_.Exception.Message }
16
+ try{
17
+ # out como UTF8→base64: un cuerpo crudo con tildes/JSON grande
18
+ # pierde el POST entero en algunos guests (job <pending> eterno).
19
+ $b64=[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes([string]$o))
20
+ irm -Method Post -Uri "$h/result" -ContentType 'application/json' -Body (@{vm=$vm;id=$j.id;out_b64=$b64}|ConvertTo-Json -Compress) | Out-Null
21
+ }catch{}
22
+ }
23
+ }catch{}
24
+ sleep -Milliseconds 400
25
+ }
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env python3
2
+ # cli/vm-job-server.py — job server del host dev para VMs Windows
3
+ # (VirtualBox NAT). El agente guest (cli/vm-agent.ps1) pollea
4
+ # /poll/<vm>, ejecuta el cmd recibido y POSTea el resultado a /result.
5
+ # El cliente sube por /submit y lee por /fetch/<vm>/<id>.
6
+ # /agent/<vm> sirve el agente con el nombre de VM incrustado (el guest
7
+ # lo baja una vez con iex(irm http://10.0.2.2:8899/agent/<VM>)).
8
+ # /files/<p> sirve archivos del framework — el guest sincroniza
9
+ # bundles/fuentes con Invoke-WebRequest contra 10.0.2.2:8899.
10
+ #
11
+ # python3 cli/vm-job-server.py [puerto]
12
+ import http.server, json, threading, urllib.parse, os, collections, sys
13
+
14
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15
+ PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8899
16
+ queues = collections.defaultdict(collections.deque) # vm -> deque of (id,cmd)
17
+ results = {} # "vm/id" -> out
18
+ counter = [0]
19
+ lock = threading.Lock()
20
+
21
+ class H(http.server.BaseHTTPRequestHandler):
22
+ def log_message(self, *a): pass
23
+ def _j(self, obj, code=200):
24
+ b = json.dumps(obj).encode()
25
+ self.send_response(code)
26
+ self.send_header("Content-Type", "application/json")
27
+ self.send_header("Content-Length", str(len(b)))
28
+ self.end_headers(); self.wfile.write(b)
29
+ def _t(self, txt, code=200, ct="text/plain"):
30
+ b = txt.encode("utf-8", "replace")
31
+ self.send_response(code)
32
+ self.send_header("Content-Type", ct)
33
+ self.send_header("Content-Length", str(len(b)))
34
+ self.end_headers(); self.wfile.write(b)
35
+ def do_GET(self):
36
+ u = urllib.parse.urlparse(self.path)
37
+ if u.path.startswith("/agent/"):
38
+ vmname = u.path[len("/agent/"):]
39
+ tpl = open(os.path.join(ROOT, "cli", "vm-agent.ps1")).read()
40
+ self._t(tpl.replace("__VM__", vmname).replace("__PORT__", str(PORT)),
41
+ ct="text/plain")
42
+ return
43
+ if u.path == "/poll":
44
+ vm = urllib.parse.parse_qs(u.query).get("vm", [""])[0]
45
+ elif u.path.startswith("/poll/"):
46
+ vm = u.path.split("/", 2)[2]
47
+ else:
48
+ vm = None
49
+ if vm is not None:
50
+ with lock:
51
+ job = queues[vm].popleft() if queues[vm] else None
52
+ self._j(job if job else {})
53
+ return
54
+ if u.path.startswith("/fetch/"):
55
+ key = u.path[len("/fetch/"):]
56
+ with lock:
57
+ r = results.get(key)
58
+ self._t(r if r is not None else "<pending>")
59
+ return
60
+ if u.path.startswith("/files/"):
61
+ rel = urllib.parse.unquote(u.path[len("/files/"):])
62
+ p = os.path.normpath(os.path.join(ROOT, rel))
63
+ if not p.startswith(ROOT) or not os.path.isfile(p):
64
+ self._t("nf", 404); return
65
+ self.send_response(200)
66
+ self.send_header("Content-Length", str(os.path.getsize(p)))
67
+ self.end_headers()
68
+ with open(p, "rb") as f: self.wfile.write(f.read())
69
+ return
70
+ self._t("ok")
71
+ def do_POST(self):
72
+ ln = int(self.headers.get("Content-Length", 0))
73
+ body = self.rfile.read(ln) if ln else b"{}"
74
+ try: d = json.loads(body)
75
+ except Exception: d = {}
76
+ u = urllib.parse.urlparse(self.path)
77
+ if u.path == "/submit":
78
+ with lock:
79
+ counter[0] += 1
80
+ jid = str(counter[0])
81
+ queues[d.get("vm", "")].append({"id": jid, "cmd": d.get("cmd", "")})
82
+ self._j({"id": jid})
83
+ return
84
+ if u.path == "/result":
85
+ out = d.get("out", "")
86
+ if "out_b64" in d:
87
+ import base64
88
+ try: out = base64.b64decode(d["out_b64"]).decode("utf-8", "replace")
89
+ except Exception: out = d["out_b64"]
90
+ with lock:
91
+ results[d.get("vm", "") + "/" + str(d.get("id", ""))] = out
92
+ self._j({"ok": True})
93
+ return
94
+ self._t("nf", 404)
95
+
96
+ print(f"[vm-job-server] :{PORT} root={ROOT}", flush=True)
97
+ http.server.ThreadingHTTPServer(("0.0.0.0", PORT), H).serve_forever()
package/cli/vm-job.py ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env python3
2
+ # cli/vm-job.py — cliente del job server (cli/vm-job-server.py).
3
+ # vm-job.py <vm> "<cmd>" [timeout] → imprime la salida del job
4
+ # vm-job.py <vm> <archivo.ps1> [timeout] → sube el .ps1 por base64 y
5
+ # lo ejecuta con -file (evita quoting de cmd y patrones
6
+ # iex/irm bloqueados por ASR en algunos guests)
7
+ import sys, os, base64, json, urllib.request, time
8
+
9
+ JOB = os.environ.get("ELUR_VM_JOB", "http://localhost:8899")
10
+
11
+ def submit(vm, cmd):
12
+ req = urllib.request.Request(JOB + "/submit",
13
+ data=json.dumps({"vm": vm, "cmd": cmd}).encode(),
14
+ headers={"Content-Type": "application/json"})
15
+ return json.loads(urllib.request.urlopen(req, timeout=10).read())["id"]
16
+
17
+ def fetch(key, timeout=90):
18
+ t = time.time()
19
+ while time.time() - t < timeout:
20
+ r = urllib.request.urlopen(JOB + "/fetch/" + key,
21
+ timeout=10).read().decode()
22
+ if r != "<pending>":
23
+ return r
24
+ time.sleep(0.6)
25
+ return "<timeout>"
26
+
27
+ def run(vm, cmd, timeout):
28
+ jid = submit(vm, cmd)
29
+ return fetch(f"{vm}/{jid}", timeout)
30
+
31
+ def main():
32
+ vm, arg = sys.argv[1], sys.argv[2]
33
+ timeout = float(sys.argv[3]) if len(sys.argv) > 3 else 90
34
+ if os.path.isfile(arg):
35
+ data = open(arg, "rb").read()
36
+ b64 = base64.b64encode(data).decode()
37
+ dst = rf"C:\Users\elur\job{os.getpid()}.ps1"
38
+ wr = (f"powershell -c \"[IO.File]::WriteAllText('{dst}',"
39
+ f"[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('{b64}')))\"")
40
+ run(vm, wr, 30)
41
+ print(run(vm, f"powershell -ep bypass -file {dst}", timeout))
42
+ else:
43
+ print(run(vm, arg, timeout))
44
+
45
+ if __name__ == "__main__":
46
+ main()
package/docs/ESTADO.md CHANGED
@@ -582,7 +582,11 @@ release ADR-0104 (elur.app.json, signing/AAB/splits, keep-rules,
582
582
  (R7.3 cerrado 2026-09-30: el host loguea `dlAbi`/`moduleAbi`/
583
583
  engine/fp del manifiesto al init — `MainActivity.kt`).
584
584
  - **Plataformas**: Linux nativo implementado (GTK4, TCK 36/36 — incl. platform views + gaps certificados, ADR-0181);
585
- Windows = siguiente target desktop; macOS y ChromeOS
585
+ Windows nativo implementado (WinUI 3, ADR-0220 — `text-input`
586
+ incluida: resuelto 2026-11-19 con `IXamlMetadataProvider`
587
+ code-only + merge en `OnLaunched`; verificado con typing real
588
+ y eventos en Win10 22H2 unpackaged y Win11 empaquetado);
589
+ macOS y ChromeOS
586
590
  pendientes (ADR-0180 — Tauri descartado); iOS pendiente
587
591
  (ADR-0010, requiere Mac); SDUI y 120 Hz diferidos por scope.
588
592
  - Heap JS en métricas: sin API de engine (ausencia aceptada).
@@ -0,0 +1,162 @@
1
+ # Instalación y desarrollo — app consumidora
2
+
3
+ Cómo se instala `@elurjs/universal`, qué exige cada plataforma y qué
4
+ hacen exactamente `elur dev` / `elur build` sobre un proyecto creado
5
+ con `elur create`. Todo lo verificado contra `cli/elur.mjs`,
6
+ `cli/dev.mjs`, `cli/create-app.mjs`, `cli/doctor.mjs`,
7
+ `cli/package-linux.mjs` y los `targets/`.
8
+
9
+ ## 1. Instalación
10
+
11
+ El paquete publica un único binario `elur` (`bin: cli/elur.mjs`,
12
+ shebang `#!/usr/bin/env bun`) — aterriza en `node_modules/.bin` y lo
13
+ invocan los scripts del proyecto o `bunx`.
14
+
15
+ ```bash
16
+ # Scaffold desde npm (no hace falta tener el repo del framework):
17
+ bunx @elurjs/universal create mi-app --name "Mi App" --id com.acme.miapp --scheme miapp
18
+ cd mi-app && bun install
19
+ # En un proyecto ya creado, el paquete entra como dependencia normal:
20
+ bun add @elurjs/universal
21
+ ```
22
+
23
+ `elur create <dir> [--name N] [--id com.x.app] [--scheme s]
24
+ [--template default|sdui] [--local]` (ADR-0103) materializa:
25
+
26
+ - `package.json` — dep `@elurjs/universal` (semver publicado; `--local`
27
+ enlaza el checkout del framework) + scripts `doctor`, `dev`,
28
+ `dev:android`, `dev:linux`, `build:web`, `build:android`,
29
+ `build:linux`, `gen:routes`.
30
+ - `elur.app.json` — identidad T-2: `name`, `applicationId`, `bundleId`,
31
+ `scheme`, `engine` (`hermes` por defecto), `versionName`/`versionCode`.
32
+ - `src/entry.ts` — composition root único (`mountApp`, ADR-0101) y
33
+ `src/app.ts` — pantalla raíz con el tag `` ui` ``.
34
+ - `targets/android/` — copia propia del proyecto Gradle (applicationId,
35
+ scheme y marcadores `BEGIN/END ELUR MODULE *` sustituidos; sin outputs
36
+ ni `local.properties`, que se genera si hay SDK detectable).
37
+ - `AGENTS.md` + `docs/INSTALACION-Y-DEV.md` — contexto para agentes:
38
+ prerequisitos por plataforma, qué hace cada script dev/build y las
39
+ reglas del proyecto (en `sdui` además el contrato MCP completo).
40
+ - `--template sdui` añade llaves Ed25519, `docs/home.envelope.json`
41
+ firmado, `.mcp.json`/`.agents/mcp_config.json`/`.cursor/mcp.json`/
42
+ `opencode.json` apuntando
43
+ al MCP del paquete, `docs/skills/elur-sdui-mcp/` y el cliente live
44
+ (ADR-0218).
45
+
46
+ `elur doctor` verifica el entorno tras instalar (exit ≠ 0 si falta algo
47
+ requerido): bun, JDK, `ANDROID_HOME`/SDK (+`ndk/`, `cmake/` del SDK,
48
+ `adb`), `hermesc`, alineación 16 KB de los `.so` y credenciales de
49
+ firma release (`targets/android/keystore/release.properties` o env
50
+ `ELUR_STORE_FILE`/`ELUR_STORE_PASSWORD`/`ELUR_KEY_ALIAS`/`ELUR_KEY_PASSWORD`).
51
+
52
+ ## 2. Prerequisitos por plataforma
53
+
54
+ | Plataforma | Requerido | Opcional / notas |
55
+ |---|---|---|
56
+ | web | bun + navegador | node solo para vitest/playwright |
57
+ | android | JDK 17+, Android SDK (`ANDROID_HOME`/`ANDROID_SDK_ROOT` o `local.properties sdk.dir`), `cmake` del SDK (externalNativeBuild), Gradle via wrapper (nada que instalar), device/emulador + `adb` para el loop dev | NDK (C++/CESM), `hermesc` (npm `hermes-compiler`, HBC 99), credenciales release |
58
+ | linux | `libgtk-4-dev`, `libsoup-3.0` dev, `fontconfig`, `cmake`, `pkg-config`, compilador C++20, X11/Wayland | `libcrypto` (módulo `crypto` Ed25519; sin él negocia `unavailable`), `libskia.a` en `targets/linux/skia-libs` (renderer opt-in), `freetype2`/`epoxy` con Skia |
59
+ | windows | Windows 10 1809+/11 x64, VS Build Tools 2022 (workloads `VCTools` + `MSBuildTools`, componente `Windows11SDK.22621`), WindowsAppSDK 1.6+ + CppWinRT 2.0+ (NuGet vía `msbuild /restore` de `packages.config`), runtime WindowsAppSDK (host framework-dependent), clone `quickjs-ng` compilado con `cmake -B build -DQJS_ENABLE_LIBC=ON` | `msbuild /p:ElurQjsDir=<ruta>` (default `C:\elur\src\quickjs-ng` — de allí salen includes y `build\Release\{qjs,qjs-libc}.lib`) |
60
+
61
+ Linux: QuickJS-ng se toma del clone `../../../quickjs-ng` (pin BC 28,
62
+ ADR-0156); `-DELUR_QJS_DIR=` apunta a otro clone o cae a FetchContent
63
+ del tarball pineado. `elur doctor` solo comprueba web/android — los
64
+ checks de linux/windows no existen aún en `cli/doctor.mjs`.
65
+
66
+ ## 3. Desarrollo diario — `elur dev`
67
+
68
+ `elur dev --target <p>` (cli/dev.mjs): build inicial + `fs.watch` por
69
+ directorio sobre `src/` del framework, `packages/`, el dir del entry y
70
+ `src/` del proyecto (debounce 400 ms, re-escaneo para dirs nuevos).
71
+ Antes de cada rebuild regenera `routes.gen.ts` si el entry tiene
72
+ `app/` con algún `page.ts` (ADR-0213). Flags comunes: `--json` (logs
73
+ NDJSON, ADR-0106), `--dev-fast` (omite ES5/HBC/QJSC y los bundles de
74
+ verificación on-device; el host cae a source JS — incompatible con
75
+ `--release`/`--require-hbc`/`--require-qjsc`, ADR-0213), `--no-serve`
76
+ (sin relanzado de host/servidor), `--full` (fuerza rebuild del host).
77
+
78
+ Scripts del scaffold (`create-app.mjs`):
79
+
80
+ - `bun run dev` → `elur dev --target web --app src/entry.ts --dev-fast`:
81
+ rebuja `targets/web/dist/` y levanta servidor estático en
82
+ `http://localhost:3419` con SSE de auto-reload (ADR-0214) — cada
83
+ rebuild empuja `reload` a los navegadores conectados. `--ssr` cambia
84
+ al servidor SSR real en `:3418` (rebuild server+client y restart del
85
+ proceso bun).
86
+ - `bun run dev:android` → `elur dev --target android --app src/entry.ts`
87
+ (sin `--dev-fast`: cada ciclo genera además HBC/QJSC y los bundles de
88
+ verificación). Path caliente: `elur build --target android` →
89
+ `adb push generated/elurApp.js /data/local/tmp/elurApp.dev.js` →
90
+ `am start -n <applicationId>.dev/com.elur.universal.MainActivity
91
+ -e appAsset elurApp.dev.js -e devSeq <ms>` — sin Gradle ni reinstall:
92
+ el host lee el asset de `/data/local/tmp` primero y `devSeq` dispara
93
+ hot reload con el snapshot nav+app preservado (ADR-0111). Exige el
94
+ APK `.dev` instalado una vez (`bun run build:android` +
95
+ `adb install`, o `elur dev --target android --full` que compila el
96
+ APK, instala y lanza); sin device online el bundle queda generado y
97
+ no hay push.
98
+ - `bun run dev:linux` → `elur dev --target linux --app src/entry.ts
99
+ --dev-fast`: emite solo `generated/elurApp.js` (dev-fast borra el
100
+ `.qjsc` stale) y relanza `targets/linux/build/elur-linux --dir
101
+ generated --app elurApp.js` — con display (DISPLAY/WAYLAND_DISPLAY) y
102
+ binario presente. El binario se busca en
103
+ `<proyecto>/targets/linux/build/elur-linux` y luego en el paquete
104
+ instalado; el scaffold **no** copia `targets/linux` — el host se
105
+ compila aparte (§4). Sin binario/display el bundle queda en
106
+ `generated/` sin lanzar. `--full` además corre `cmake --build
107
+ targets/linux/build -j4`. Sin dev-fast el host carga
108
+ `elurApp.es5.qjsc` (bytecode) si existe.
109
+ - `elur dev --target windows` (ADR-0220): el host corre en otra
110
+ máquina/VM vía SSH — `ELUR_WIN_SSH=user@host[:port]` habilita el
111
+ relanzado: `scp` de `elurSignals.js`+bundle a `ELUR_WIN_DIR`
112
+ (default `C:/elur/generated`) y `schtasks /run /tn ELUR_WIN_TASK`
113
+ (default `elur-app-dev`; la tarea debe existir y lanzar
114
+ `elur-windows.exe`).
115
+
116
+ ## 4. Build y distribución
117
+
118
+ `elur build --target <p> [--app src/entry.ts]` (cli/elur.mjs; sin
119
+ `--app` cae a `src/entry.ts` si existe):
120
+
121
+ - **web** → `targets/web/dist/` (`app.js` IIFE + `index.html`; plugin
122
+ `X.web.ts` + `__ELUR_PLATFORM__="web"`, ADR-0101). `--ssr` →
123
+ `dist/ssr/` autocontenido (`server.js` Bun, ADR-0142); `--ssg` →
124
+ sitio estático con `generateStaticParams` (ADR-0137).
125
+ - **android** → integración de host (`gen-host-integration`: merge de
126
+ permisos, `ElurModuleRegistrar.kt`, keep-rules, fuentes), bundles
127
+ `elurSignals.js`/`elurApp.js` (+`elurEncParity`/`elurStress` salvo
128
+ dev-fast), ES5→`.hbc` (HBC 99) y `.qjsc` (BC 28) staging atómico en
129
+ `targets/android/app/src/main/assets/` + manifiesto sha256.
130
+ `--apk`→`assembleDebug`, `--aab`→`bundle*`; `--release` exige
131
+ `--engine hermes|quickjs` e implica `--require-*` del engine;
132
+ `--splits` (APK por ABI + universal), `--minify` (R8 +
133
+ shrinkResources). Sin credenciales release firma debug.
134
+ - **linux** → `generated/elurApp.js` + `elurApp.es5.qjsc` +
135
+ `targets/linux/generated/` (registrar/sources de módulos). El host se
136
+ compila con `cmake -B targets/linux/build && cmake --build
137
+ targets/linux/build` → `targets/linux/build/elur-linux`.
138
+ Distribución (ADR-0186): `bun cli/package-linux.mjs --format
139
+ appimage|deb|rpm|flatpak|all --app <bundle.js> --name n --title T
140
+ --version X.Y.Z` → AppDir autocontenido (pila GTK4 por `ldd`, loaders
141
+ gdk-pixbuf, módulos GIO, fuentes, `.desktop`) → `dist/`: AppImage
142
+ (o tarball+install.sh sin appimagetool), `.deb` real por `dpkg-deb`,
143
+ receta `.spec`+staging para `rpmbuild`, manifest Flatpak+metainfo.
144
+ - **windows** → `generated/elurApp.{js,es5.qjsc}`; el host:
145
+ `msbuild elur-windows.vcxproj /p:Configuration=Release
146
+ /p:Platform=x64 /restore` → `x64/Release/elur-windows.exe`
147
+ unpackaged framework-dependent (`WindowsPackageType=None`,
148
+ `WindowsAppSDKSelfContained=false` — exige el runtime WASDK
149
+ instalado). `Package.appxmanifest` está presente pero el pipeline
150
+ MSIX (firma + dev-register) queda declarado pendiente
151
+ (ADR-0180/0220, PENDIENTES T-10).
152
+ - **ios** → solo el bundle `generated/elurApp.*` (host futuro,
153
+ ADR-0010).
154
+
155
+ ## 5. Referencia
156
+
157
+ - Toolchain completo: `cli/commands.mjs` (catálogo ADR-0178) +
158
+ `AGENTS.md` §Comandos.
159
+ - Loop dev y hot reload: ADR-0111 (devSeq/snapshot), ADR-0213
160
+ (dev-fast + auto gen-routes), ADR-0214 (SSE reload web).
161
+ - Packaging Linux: `targets/linux/README.md` + ADR-0177/0186.
162
+ - Host Windows: `targets/windows/README.md` + ADR-0220.