@elurjs/universal 0.1.9 → 0.1.10

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.
@@ -105,9 +105,12 @@ Prerequisitos por plataforma:
105
105
  compila aparte: \`cmake -B targets/linux/build && cmake --build
106
106
  targets/linux/build\` (el scaffold no copia \`targets/linux\` — el
107
107
  source está en \`node_modules/@elurjs/universal/targets/linux\`).
108
- - windows — host remoto por SSH: \`ELUR_WIN_SSH=user@host[:port]\`
109
- habilita el relanzado (scp a \`ELUR_WIN_DIR\` + \`schtasks /run
110
- /tn ELUR_WIN_TASK\`, ADR-0220).
108
+ - windows — nativo: VS Build Tools 2022 (VCTools + MSBuild + Windows
109
+ 11 SDK); NuGet resuelve WindowsAppSDK/CppWinRT con \`msbuild
110
+ targets/windows/elur-windows.vcxproj /restore\`. El loop dev es
111
+ local — \`dev:windows\` relanza \`elur-windows.exe\`. Desde
112
+ Linux/macOS hacia un host remoto: \`ELUR_WIN_SSH=user@host[:port]\`
113
+ habilita scp + relanzado por \`schtasks\` (ADR-0220).
111
114
 
112
115
  Qué hace cada script:
113
116
  - \`bun run dev\` — web: \`targets/web/dist\` + servidor en
@@ -122,10 +125,11 @@ Qué hace cada script:
122
125
  - \`bun run dev:linux\` — \`generated/elurApp.js\` + relanza
123
126
  \`targets/linux/build/elur-linux\` si hay binario + display;
124
127
  \`--full\` además corre \`cmake --build\` del host.
125
- - \`bun run dev:windows\` — bundle a \`generated/\` + push remoto:
126
- con \`ELUR_WIN_SSH\` hace scp a \`ELUR_WIN_DIR\` y relanza por
127
- \`schtasks /tn elur-app-dev\` (ADR-0220); sin la var, solo deja
128
- el bundle (el host WinUI 3 corre en la máquina Windows).
128
+ - \`bun run dev:windows\` — en Windows relanza
129
+ \`elur-windows.exe\` compilado (loop local nativo); desde
130
+ Linux/macOS con \`ELUR_WIN_SSH\` hace scp a \`ELUR_WIN_DIR\` y
131
+ relanza remoto por \`schtasks\` (ADR-0220); sin host disponible
132
+ solo deja el bundle en \`generated/\`.
129
133
  - \`bun run gen:routes\` — regenera \`src/routes.gen.ts\` cuando hay
130
134
  \`app/\` con \`page.ts\` (\`elur dev\` lo corre solo al detectarlo).
131
135
  - Builds — \`build:web\` → \`targets/web/dist\` (app.js IIFE +
@@ -444,7 +448,8 @@ ${agentsDev}
444
448
  - Prerequisitos: \`bun run gateway\` corriendo + un cliente abierto
445
449
  (\`bun run dev\`, \`dev:android\` con APK instalado, \`dev:linux\`
446
450
  con el binario en \`targets/linux/build/elur-linux\`, o
447
- \`dev:windows\` con \`ELUR_WIN_SSH\` + el host remoto).
451
+ \`dev:windows\` con el host compilado en Windows o remoto por
452
+ \`ELUR_WIN_SSH\`).
448
453
  - Guía detallada del flujo y anti-patrones:
449
454
  \`docs/skills/elur-sdui-mcp/SKILL.md\`
450
455
  - Arquitectura código+superficie y modelo responsive:
package/cli/dev.mjs CHANGED
@@ -93,11 +93,23 @@ function restartLinuxHost() {
93
93
  linuxProc.on("exit", () => { /* el próximo rebuild relanza */ });
94
94
  return true;
95
95
  }
96
- // ADR-0220: el host Windows corre fuera (VM/otra máquina) — se alcanza
97
- // por SSH. ELUR_WIN_SSH=user@host[:port] habilita el relanzado; el
98
- // bundle viaja por scp a ELUR_WIN_DIR y la app se levanta en la sesión
99
- // interactiva con la scheduled task ELUR_WIN_TASK (debe existir en el
100
- // host y ejecutar elur-windows.exe sin --shot).
96
+ // ADR-0220: en Windows nativo el loop es local (rebuild → relaunch de
97
+ // elur-windows.exe, igual que Linux). Desde Linux/macOS el host corre
98
+ // remoto (VM/otra máquina) alcanzado por SSH — ELUR_WIN_SSH=user@host
99
+ // [:port] habilita scp a ELUR_WIN_DIR + relanzado por la scheduled task
100
+ // ELUR_WIN_TASK (debe existir y ejecutar elur-windows.exe sin --shot).
101
+ let winProc = null;
102
+ function findWindowsHostBin() {
103
+ for (const p of [
104
+ join(process.cwd(), "targets/windows/x64/Release/elur-windows.exe"),
105
+ join(process.cwd(), "targets/windows/x64/Debug/elur-windows.exe"),
106
+ join(root, "targets/windows/x64/Release/elur-windows.exe"),
107
+ join(root, "targets/windows/x64/Debug/elur-windows.exe"),
108
+ ]) {
109
+ if (existsSync(p)) return p;
110
+ }
111
+ return null;
112
+ }
101
113
  function winSshTarget() {
102
114
  const raw = process.env.ELUR_WIN_SSH;
103
115
  if (!raw) return null;
@@ -108,14 +120,26 @@ function winSshTarget() {
108
120
  return { dest: raw, port: "22" };
109
121
  }
110
122
  function restartWindowsHost() {
111
- const sshT = winSshTarget();
112
- if (!sshT || noServe) return false;
113
- const winDir = process.env.ELUR_WIN_DIR ?? "C:/elur/generated";
114
- const task = process.env.ELUR_WIN_TASK ?? "elur-app-dev";
123
+ if (noServe) return false;
115
124
  const genDir = join(process.cwd(), "generated");
116
125
  const appName = !devFast && existsSync(join(genDir, "elurApp.es5.qjsc"))
117
126
  ? "elurApp.es5.qjsc"
118
127
  : "elurApp.js";
128
+ if (process.platform === "win32") {
129
+ const bin = findWindowsHostBin();
130
+ if (!bin) return false;
131
+ try { winProc?.kill(); } catch { }
132
+ winProc = spawn(bin, ["--dir", genDir, "--app", appName], {
133
+ cwd: process.cwd(),
134
+ stdio: jsonLogs ? ["ignore", 2, 2] : "inherit",
135
+ });
136
+ winProc.on("exit", () => { /* el próximo rebuild relanza */ });
137
+ return "local";
138
+ }
139
+ const sshT = winSshTarget();
140
+ if (!sshT) return false;
141
+ const winDir = process.env.ELUR_WIN_DIR ?? "C:/elur/generated";
142
+ const task = process.env.ELUR_WIN_TASK ?? "elur-app-dev";
119
143
  const scpArgs = ["-P", sshT.port];
120
144
  try {
121
145
  run("scp", ...scpArgs, join(genDir, "elurSignals.js"),
@@ -124,22 +148,23 @@ function restartWindowsHost() {
124
148
  `${sshT.dest}:${winDir}/`);
125
149
  run("ssh", "-p", sshT.port, sshT.dest,
126
150
  `taskkill /f /im elur-windows.exe 2>nul & schtasks /run /tn ${task}`);
127
- return true;
151
+ return "ssh";
128
152
  } catch {
129
153
  return false;
130
154
  }
131
155
  }
132
156
  const killSsr = () => { try { ssrProc?.kill("SIGKILL"); } catch { } };
133
157
  const killLinux = () => { try { linuxProc?.kill("SIGTERM"); } catch { } };
158
+ const killWin = () => { try { winProc?.kill(); } catch { } };
134
159
  const stopWeb = () => {
135
160
  for (const c of webClients) c.close();
136
161
  webClients.clear();
137
162
  try { webServer?.stop(true); } catch { }
138
163
  webServer = null;
139
164
  };
140
- process.on("exit", () => { killSsr(); killLinux(); stopWeb(); });
141
- process.on("SIGINT", () => { killSsr(); killLinux(); stopWeb(); process.exit(130); });
142
- process.on("SIGTERM", () => { killSsr(); killLinux(); stopWeb(); process.exit(143); });
165
+ process.on("exit", () => { killSsr(); killLinux(); killWin(); stopWeb(); });
166
+ process.on("SIGINT", () => { killSsr(); killLinux(); killWin(); stopWeb(); process.exit(130); });
167
+ process.on("SIGTERM", () => { killSsr(); killLinux(); killWin(); stopWeb(); process.exit(143); });
143
168
 
144
169
  const WEB_DIST = () => join(process.cwd(), "targets/web/dist");
145
170
  const WEB_MIME = {
@@ -410,9 +435,13 @@ function rebuild() {
410
435
  log("dev.build.end", {
411
436
  ok: true, ms: Date.now() - t0,
412
437
  launch: launched,
413
- msg: launched
414
- ? "bundle Windows copiado + app relanzada (SSH)"
415
- : "bundle Windows en generated/ (ELUR_WIN_SSH no definido)",
438
+ msg: launched === "local"
439
+ ? "bundle Windows + elur-windows.exe relanzado"
440
+ : launched === "ssh"
441
+ ? "bundle Windows copiado + app relanzada (SSH)"
442
+ : process.platform === "win32"
443
+ ? "bundle Windows en generated/ (host sin compilar: msbuild elur-windows.vcxproj /restore)"
444
+ : "bundle Windows en generated/ (ELUR_WIN_SSH no definido)",
416
445
  });
417
446
  return;
418
447
  }
package/cli/doctor.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
9
9
  import { join, relative } from "node:path";
10
- import { execFileSync } from "node:child_process";
10
+ import { execFileSync, spawnSync } from "node:child_process";
11
11
 
12
12
  const args = process.argv.slice(2);
13
13
  const target = args.includes("--target")
@@ -25,6 +25,18 @@ function cmdVersion(cmd, argv = ["--version"]) {
25
25
  } catch { return null; }
26
26
  }
27
27
 
28
+ // Binarios cuya versión sale por stderr (ssh -V, scp -V) o cuyo éxito es
29
+ // simplemente resolver — devuelve la primera línea de cualquier stream.
30
+ function cmdProbe(cmd, argv) {
31
+ try {
32
+ const r = spawnSync(cmd, argv, { stdio: ["ignore", "pipe", "pipe"] });
33
+ if (r.error) return null;
34
+ const out = (r.stdout?.toString() || r.stderr?.toString() || "")
35
+ .split("\n")[0].trim();
36
+ return out || "presente";
37
+ } catch { return null; }
38
+ }
39
+
28
40
  // T-6 — Google Play exige alineación 16KB en .so (nov 2025). Se leen
29
41
  // los program headers ELF sin depender de readelf: PT_LOAD debe tener
30
42
  // p_align ≥ 0x4000. Devuelve { align } o null si no es ELF válido.
@@ -200,19 +212,33 @@ if (target === "linux" || !target) {
200
212
 
201
213
  if (target === "windows" || !target) {
202
214
  console.log("[doctor] windows");
203
- // El host WinUI 3 corre remoto (ADR-0220): lo que se verifica aquí
204
- // es el lado cliente del loop dev.
205
- process.env.ELUR_WIN_SSH
206
- ? ok(`ELUR_WIN_SSH=${process.env.ELUR_WIN_SSH} — push+relaunch remoto`)
207
- : warn("ELUR_WIN_SSH sin definir — dev:windows solo emite el bundle");
208
- const ssh = cmdVersion("ssh", ["-V"]);
209
- ssh ? ok(`ssh presente (${ssh})`)
210
- : warn("ssh ausente — scp/relaunch remoto no disponible");
211
- const scp = cmdVersion("scp", ["-V"]);
212
- scp ? ok("scp presente") : warn("scp ausente — el bundle no viaja");
213
- cmdVersion("msbuild", ["-version"])
214
- ? ok("msbuild presente — build del host local")
215
- : warn("msbuild no resoluble aquí (normal: el host se compila en la máquina Windows)");
215
+ if (process.platform === "win32") {
216
+ // Desarrollo nativo (ADR-0220): VS Build Tools 2022 —
217
+ // VCTools + MSBuild + Windows 11 SDK; NuGet resuelve
218
+ // WindowsAppSDK/CppWinRT con msbuild /restore.
219
+ const msbuild = cmdVersion("msbuild", ["-version"])
220
+ ?? cmdVersion("vswhere", ["-latest", "-property", "installationVersion"]);
221
+ msbuild ? ok(`msbuild/vswhere ${msbuild}`)
222
+ : fail("VS Build Tools 2022 ausente — msbuild no resoluble en PATH");
223
+ const cmakeW = cmdVersion("cmake");
224
+ cmakeW ? ok(`${cmakeW}`)
225
+ : warn("cmake ausente — solo se usa para quickjs.lib (prebuilt ya enlazado)");
226
+ const exe = existsSync("targets/windows/x64/Release/elur-windows.exe")
227
+ || existsSync("targets/windows/x64/Debug/elur-windows.exe");
228
+ exe ? ok("elur-windows.exe compilado — dev:windows lo relanza")
229
+ : warn("host sin compilar: msbuild targets/windows/elur-windows.vcxproj /restore");
230
+ } else {
231
+ // Desarrollo hacia un host remoto (VM/otra máquina): el loop por
232
+ // SSH es opción, no requisito — en Windows el loop es local.
233
+ process.env.ELUR_WIN_SSH
234
+ ? ok(`ELUR_WIN_SSH=${process.env.ELUR_WIN_SSH} — push+relaunch remoto`)
235
+ : warn("ELUR_WIN_SSH sin definir — dev:windows solo emite el bundle (loop remoto opcional)");
236
+ const ssh = cmdProbe("ssh", ["-V"]);
237
+ ssh ? ok(`ssh presente (${ssh})`)
238
+ : warn("ssh ausente — scp/relaunch remoto no disponible");
239
+ const scp = cmdProbe("scp", ["-V"]);
240
+ scp ? ok("scp presente") : warn("scp ausente — el bundle no viaja");
241
+ }
216
242
  }
217
243
 
218
244
  // ── Firma de release (T-6/3.4): qué fuente resuelve el signingConfig
@@ -111,12 +111,16 @@ Scripts del scaffold (`create-app.mjs`):
111
111
  `generated/` sin lanzar. `--full` además corre `cmake --build
112
112
  targets/linux/build -j4`. Sin dev-fast el host carga
113
113
  `elurApp.es5.qjsc` (bytecode) si existe.
114
- - `bun run dev:windows` → `elur dev --target windows` (ADR-0220): el host corre en otra
115
- máquina/VM vía SSH — `ELUR_WIN_SSH=user@host[:port]` habilita el
116
- relanzado: `scp` de `elurSignals.js`+bundle a `ELUR_WIN_DIR`
117
- (default `C:/elur/generated`) y `schtasks /run /tn ELUR_WIN_TASK`
118
- (default `elur-app-dev`; la tarea debe existir y lanzar
119
- `elur-windows.exe`).
114
+ - `bun run dev:windows` → `elur dev --target windows` (ADR-0220): en
115
+ Windows el loop es **nativo local** — relanza `elur-windows.exe`
116
+ (`targets/windows/x64/{Release,Debug}/` o el del paquete) igual que
117
+ el loop GTK en Linux. Toolchain: VS Build Tools 2022 (VCTools +
118
+ MSBuild + Windows 11 SDK); `msbuild elur-windows.vcxproj /restore`
119
+ resuelve los NuGet (WindowsAppSDK 1.6+, CppWinRT 2.0+). Desde
120
+ Linux/macOS el host corre remoto: `ELUR_WIN_SSH=user@host[:port]`
121
+ habilita `scp` de `elurSignals.js`+bundle a `ELUR_WIN_DIR` (default
122
+ `C:/elur/generated`) + `schtasks /run /tn ELUR_WIN_TASK` (default
123
+ `elur-app-dev`; la tarea debe existir y lanzar `elur-windows.exe`).
120
124
 
121
125
  ## 4. Build y distribución
122
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elurjs/universal",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",