@elurjs/universal 0.1.12 → 0.1.14

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 CHANGED
@@ -1,103 +1,111 @@
1
1
  # Elur Universal — framework
2
2
 
3
- Un solo framework: **un IR, un reconciler, backends puros**. Documento maestro:
4
- `../Elur-Universal-Documento-Arquitectura-v6.0.pdf` (la propuesta v5 vive en
3
+ A single framework: **one IR, one reconciler, pure backends**. Master document:
4
+ `../Elur-Universal-Documento-Arquitectura-v6.0.pdf` (the v5 proposal lives in
5
5
  `../planes/PROPUESTA-DOCUMENTO-MAESTRO-v5.md`).
6
6
 
7
- Estado vigente: `docs/ESTADO.md` (fuente viva por commit) · pendientes y
8
- diferidos: `docs/PENDIENTES.md` · implementación nativa consolidada:
9
- `docs/IMPLEMENTACION-NATIVA-v5.md` · auditoría SOTA y hoja de ruta:
7
+ Current status: `docs/ESTADO.md` (living source per commit) · pending and
8
+ deferred work: `docs/PENDIENTES.md` · consolidated native implementation:
9
+ `docs/IMPLEMENTACION-NATIVA-v5.md` · SOTA audit and roadmap:
10
10
  `docs/AUDITORIA-STATE-OF-THE-ART-2026-11.md`.
11
11
 
12
- ## Estructura
12
+ ## Structure
13
13
 
14
14
  ```text
15
15
  src/
16
- ir/ IRNode/IRDocument, irVersion, builder ui``, semantics.ts
16
+ ir/ IRNode/IRDocument, irVersion, ui`` builder, semantics.ts
17
17
  reconciler/ IR + signals → DisplayOps (DOM-free, engine-agnostic)
18
- transport/ Display List binario (runtime) + JSON (debug)
19
- router/ Router universal — core DOM-free + adapters
20
- adapters/ Integración con Kit (bridge, SSR, request, history, nav)
21
- ssr/ Aplicador SSR (createHtmlApplicator) + render-page
22
- hydration/ Reservado (data-elur / hydrate() pendiente de consumidor)
23
- backends/ Capa JS de los aplicadores: web/ (DOM) + android/
24
- (marshaling a ElurBridge) + textInputProtocol.ts
25
- native/ Contrato de módulos nativos: def/manifest, registry wire,
18
+ transport/ Binary Display List (runtime) + JSON (debug)
19
+ router/ Universal router — DOM-free core + adapters
20
+ adapters/ Kit integration (bridge, SSR, request, history, nav)
21
+ ssr/ SSR applicator (createHtmlApplicator) + render-page
22
+ hydration/ Reserved (data-elur / hydrate() pending consumer)
23
+ sdui/ Server-driven UI: envelope, lowering, A2UI renderer
24
+ (v0.9 + v1.0), gateway live (/serve + /publish + MCP)
25
+ backends/ JS side of the applicators: web/ (DOM) + native/
26
+ (marshaling to the ElurBridge host object)
27
+ native/ Native module contract: def/manifest, wire registry,
26
28
  codegen (TS/Kotlin/mock), sharedMemory (CESM facade +
27
29
  ring), binaryCodec, platformView, trace, tck, webModule
28
- animations/ Worklets: runner main-thread + UIThreadRunner, gestos,
29
- scroll, binds compositor, capture check
30
- app/ mountApp/mountEmbeddedApp, host embebido, snapshot de estado
30
+ animations/ Worklets: main-thread + UIThreadRunner, gestures,
31
+ scroll, compositor binds, capture check
32
+ app/ mountApp/mountEmbeddedApp, embedded host, state snapshot
31
33
  platform.ts Escape hatch: platform({ web, native, default })
32
- layout/ Reservado (la instancia Yoga vive en el target)
34
+ layout/ Reserved (the Yoga instance lives in the target)
33
35
 
34
36
  cli/ Toolchain: elur build/dev/doctor/create/debug/engines,
35
- plugin manifest|check|sync|codegen|create|add, gen-es5
36
- (Babel ie11), gen-hbc (hermesc HBC 99), gen-bundle,
37
- gen-host-integration, layout-oracle, run-tck/run-parity
37
+ sdui (gateway/mcp/sign), plugin manifest|check|sync|codegen|
38
+ create|add, gen-es5 (Babel ie11), gen-hbc (hermesc HBC 99),
39
+ gen-qjsc, gen-bundle, gen-host-integration, layout-oracle,
40
+ run-tck/run-parity
38
41
 
39
42
  targets/
40
- android/ Shell Kotlin + JNI/C++ (bridges QuickJS/Hermes, renderers
41
- Platform Views, Yoga 3.2.1 vendored, CESM glue)
42
- ios/ Futuro — spec lista (ADR-0010, requiere Mac)
43
- web/ Vite/SSR server de referencia
44
-
45
- native/ C++ host compartido, platform+engine agnóstico:
46
- cesm/ (core+adapters qjs/hermes, tests host) y
47
- layout-oracle/ (binario contra el Yoga vendored)
48
-
49
- packages/ Librerías de dominio sobre el contrato de módulos:
43
+ android/ Kotlin shell + JNI/C++ (QuickJS/Hermes bridges, Platform
44
+ Views renderers, vendored Yoga 3.2.1, CESM glue)
45
+ linux/ Native GTK4 host (GtkFixed applicator, Pango measure,
46
+ AT-SPI a11y, platform views, packaging appimage/deb/rpm)
47
+ windows/ Native WinUI 3 host (C++/WinRT, UIA a11y, unpackaged
48
+ self-contained)
49
+ ios/ Future — spec ready (ADR-0010, requires Mac)
50
+ web/ Reference Vite/SSR server
51
+
52
+ native/ Shared host C++, platform+engine agnostic:
53
+ cesm/ (core + qjs/hermes adapters, host tests) and
54
+ layout-oracle/ (binary against vendored Yoga)
55
+
56
+ packages/ Domain libraries on the module contract:
50
57
  @elurjs/i18n, @elurjs/kv, @elurjs/location
51
58
 
52
- tests/ unit (vitest+jsdom) · parity (mismos tests en QuickJS-ng y
53
- Hermes reales) · stress · e2e (Playwright) · tck ·
59
+ tests/ unit (vitest+jsdom) · parity (same tests on QuickJS-ng and
60
+ real Hermes) · stress · e2e (Playwright) · tck ·
54
61
  wire corpus · layout corpus · i18n corpus · bench
55
62
 
56
- docs/adr/ ADR-0013 … ADR-0110 (índice en docs/adr/README.md)
63
+ docs/adr/ ADR-0013 … ADR-0222 (index in docs/adr/README.md)
57
64
  ```
58
65
 
59
- ## Reglas de oro (de los ADRs / A.7)
66
+ ## Golden rules (from the ADRs / A.7)
60
67
 
61
- - `src/reconciler`, `src/router`, `src/ir`, `src/transport`: **cero imports
62
- de DOM/plataforma**. Deben transpilar a ES5 y correr igual en V8,
63
- QuickJS-ng y Hermes — verificado por los lanes de paridad.
64
- - No `TextEncoder`/`TextDecoder`/`SharedArrayBuffer`/class fields en código
65
- embebido → encode binario va en `src/transport/` con encoder nativo en
68
+ - `src/reconciler`, `src/router`, `src/ir`, `src/transport`: **zero
69
+ DOM/platform imports**. They must transpile to ES5 and run identically on
70
+ V8, QuickJS-ng and Hermes — enforced by the parity lanes.
71
+ - No `TextEncoder`/`TextDecoder`/`SharedArrayBuffer`/class fields in embedded
72
+ code → binary encoding lives in `src/transport/` with a native encoder in
66
73
  targets.
67
- - `effect()` corre síncrono al registrarse: render pass ≠ update pass; el
68
- flush es del reconciler/backend, nunca del effect.
69
- - `remove-child` = detach (conserva nodo/estado); `delete-node` = destroy
70
- (libera recursos e índices auxiliares).
71
- - El árbol del reconciler es la única fuente de verdad del orden de hijos.
72
- - Logging por frame prohibido en benchmarks.
74
+ - `effect()` runs synchronously on registration: render pass ≠ update pass;
75
+ the flush belongs to the reconciler/backend, never to the effect.
76
+ - `remove-child` = detach (keeps node/state); `delete-node` = destroy
77
+ (frees resources and auxiliary indexes).
78
+ - The reconciler's tree is the single source of truth for child order.
79
+ - Per-frame logging is forbidden in benchmarks.
73
80
 
74
- ## Construir tu app
81
+ ## Build your app
75
82
 
76
83
  ```bash
77
- bun cli/elur.mjs create mi-app # scaffold consumidor
78
- bun cli/elur.mjs build --target android --app path/to/entry.ts [--apk|--aab]
79
- bun cli/elur.mjs build --target web --app path/to/entry.ts
80
- bun cli/elur.mjs dev --target android # watch → rebuild → push assets
81
- bun cli/elur.mjs doctor # sanidad del entorno
84
+ bunx @elurjs/universal create mi-app # consumer scaffold
85
+ elur build --target android --app src/entry.ts [--apk|--aab]
86
+ elur build --target web --app src/entry.ts
87
+ elur build --target linux --app src/entry.ts # JS + elur-linux (cmake)
88
+ elur build --target windows --app src/entry.ts # JS + elur-windows.exe (msbuild, on Windows)
89
+ elur dev --target <web|android|linux|windows> # watch → rebuild → relaunch/push
90
+ elur doctor # environment check (all targets)
82
91
  ```
83
92
 
84
- `--app` es el composition root: `mountApp()` resuelve a
85
- `mount.<plataforma>.ts` en build (ADR-0101). Plugins nativos:
86
- `bun add @elurjs/x` + `import { createX }` — el import auto-declara el
87
- módulo (ADR-0099/0100); `elur build` genera `ElurModuleRegistrar.kt`, el
88
- merge de permisos y los sourceSets (ADR-0102/0103).
93
+ `--app` is the composition root: `mountApp()` resolves to
94
+ `mount.<platform>.ts` at build time (ADR-0101). Native plugins:
95
+ `bun add @elurjs/x` + `import { createX }` — the import auto-declares the
96
+ module (ADR-0099/0100); `elur build` generates `ElurModuleRegistrar.kt`,
97
+ the permission merge and the sourceSets (ADR-0102/0103).
89
98
 
90
- ## Licencia
99
+ ## License
91
100
 
92
- Código (framework, hosts, CLI, paquetes y TCK): **Apache-2.0** —
93
- ver `LICENSE`, `NOTICE` y `THIRD_PARTY_NOTICES.md` (ADR-0173).
101
+ Code (framework, hosts, CLI, packages and TCK): **Apache-2.0** —
102
+ see `LICENSE`, `NOTICE` and `THIRD_PARTY_NOTICES.md` (ADR-0173).
94
103
 
95
- La **especificación** (Documento Maestro de Arquitectura) se publica
96
- bajo **CC-BY-4.0**, con el **OWFa 1.0** del titular para quien
97
- implementa hosts — ver `LICENSE-SPEC.md` y
98
- `OWFA-1.0-Elur-Universal.md`.
104
+ The **specification** (Master Architecture Document) is published under
105
+ **CC-BY-4.0**, with the owner's **OWFa 1.0** for host implementers —
106
+ see `LICENSE-SPEC.md` and `OWFA-1.0-Elur-Universal.md`.
99
107
 
100
- "Elur" no se licencia: uso de la marca en `TRADEMARKS.md` — declararse
101
- "compatible con Elur" exige un reporte `run-tck` público en verde.
108
+ "Elur" is not licensed: trademark usage in `TRADEMARKS.md` — claiming to
109
+ be "Elur compatible" requires a public green `run-tck` report.
102
110
 
103
- Contribuciones: `CONTRIBUTING.md` (DCO 1.1 — `git commit -s`).
111
+ Contributions: `CONTRIBUTING.md` (DCO 1.1 — `git commit -s`).
@@ -102,9 +102,11 @@ Prerequisitos por plataforma:
102
102
  device online el bundle queda generado sin push.
103
103
  - linux — \`libgtk-4-dev\`, \`libsoup-3.0\` dev, \`fontconfig\`,
104
104
  \`cmake\`, \`pkg-config\`, compilador C++20, X11/Wayland. El host se
105
- compila aparte: \`cmake -B targets/linux/build && cmake --build
106
- targets/linux/build\` (el scaffold no copia \`targets/linux\` — el
107
- source está en \`node_modules/@elurjs/universal/targets/linux\`).
105
+ compila aparte dentro del paquete: \`cmake -B node_modules/@elurjs/
106
+ universal/targets/linux/build -S node_modules/@elurjs/universal/
107
+ targets/linux && cmake --build node_modules/@elurjs/universal/
108
+ targets/linux/build -j4\` → \`…/targets/linux/build/elur-linux\`
109
+ (o simplemente \`bun run build:linux\`, que lo hace solo).
108
110
  - windows — nativo: VS Build Tools 2022 (VCTools + MSBuild + Windows
109
111
  11 SDK) + clone de \`quickjs-ng\` (el host enlaza \`qjs.lib\`);
110
112
  \`msbuild node_modules/@elurjs/universal/targets/windows/
package/cli/dev.mjs CHANGED
@@ -17,6 +17,7 @@
17
17
  // — el refresh del navegador es del usuario.
18
18
 
19
19
  import { execFileSync, spawn } from "node:child_process";
20
+ import { createServer as netCreateServer } from "node:net";
20
21
  import {
21
22
  existsSync, readdirSync, readFileSync, statSync, watch,
22
23
  } from "node:fs";
@@ -44,11 +45,26 @@ const devFast = args.includes("--dev-fast");
44
45
  // ADR-0142: --ssr en web sirve el SSR real en dev — rebuild del bundle
45
46
  // server+client y restart del proceso bun por cambio.
46
47
  const ssr = target === "web" && args.includes("--ssr");
48
+ // Puerto fijo solo con --strict-port; si no, se avanza hasta uno libre.
49
+ const strictPort = args.includes("--strict-port");
47
50
  const ssrPort = opt("--port") ?? "3418";
51
+ let ssrPortResolved = Number(ssrPort);
48
52
  // ADR-0214 — servidor estático dev con SSE de reload (SPA). `--no-serve`
49
53
  // conserva el comportamiento anterior (solo rebuild de dist/).
50
54
  const noServe = args.includes("--no-serve");
51
55
  const webPort = opt("--port") ?? "3419";
56
+ const webEncoder = new TextEncoder();
57
+ function pickFreePort(start, span = 20) {
58
+ return new Promise((done) => {
59
+ const probe = (p) => {
60
+ if (p >= start + span) return done(null);
61
+ const s = netCreateServer();
62
+ s.once("error", () => probe(p + 1));
63
+ s.listen(p, () => s.close(() => done(p)));
64
+ };
65
+ probe(start);
66
+ });
67
+ }
52
68
  let webServer = null;
53
69
  const webClients = new Set();
54
70
  let ssrProc = null;
@@ -61,7 +77,7 @@ function restartSsrServer() {
61
77
  const serverJs = join(ssrOutDir(), "server.js");
62
78
  ssrProc = spawn("bun", [serverJs], {
63
79
  cwd: process.cwd(),
64
- env: { ...process.env, PORT: ssrPort },
80
+ env: { ...process.env, PORT: String(ssrPortResolved) },
65
81
  stdio: jsonLogs ? ["ignore", 2, 2] : "inherit",
66
82
  });
67
83
  ssrProc.on("exit", () => { /* el restart del próximo rebuild cubre */ });
@@ -190,85 +206,95 @@ function withReloadScript(html) {
190
206
  ? html.replace("</body>", script + "</body>")
191
207
  : html + script;
192
208
  }
193
- function startWebServer() {
194
- if (ssr || target !== "web" || noServe || webServer) return;
209
+ async function webFetch(req) {
195
210
  const dist = WEB_DIST();
196
- if (!existsSync(dist)) return;
197
- const encoder = new TextEncoder();
198
- try {
199
- webServer = Bun.serve({
200
- port: Number(webPort),
201
- async fetch(req) {
202
- const url = new URL(req.url);
203
- if (url.pathname === "/__elur_dev") {
204
- let entry = null;
205
- const stream = new ReadableStream({
206
- start(controller) {
207
- entry = {
208
- send(msg) {
209
- try {
210
- controller.enqueue(
211
- encoder.encode(`data: ${msg}\n\n`));
212
- } catch { /* cliente cerrado */ }
213
- },
214
- close() {
215
- try { controller.close(); } catch { }
216
- },
217
- };
218
- webClients.add(entry);
219
- entry.send("connected");
220
- req.signal?.addEventListener("abort", () => {
221
- if (entry) webClients.delete(entry);
222
- entry?.close();
223
- });
224
- },
225
- cancel() {
226
- if (entry) webClients.delete(entry);
227
- },
228
- });
229
- return new Response(stream, {
230
- headers: {
231
- "content-type": "text/event-stream",
232
- "cache-control": "no-cache",
233
- "connection": "keep-alive",
234
- },
235
- });
236
- }
237
- let pathname = decodeURIComponent(url.pathname);
238
- if (pathname === "/" || pathname.endsWith("/")) {
239
- pathname += "index.html";
240
- }
241
- const targetFile = resolve(dist, "." + pathname);
242
- if (targetFile !== dist &&
243
- !targetFile.startsWith(dist + sep)) {
244
- return new Response("forbidden", { status: 403 });
245
- }
246
- const fallback = join(dist, "index.html");
247
- const file = existsSync(targetFile) ? targetFile : fallback;
248
- if (!existsSync(file)) {
249
- return new Response("not found", { status: 404 });
250
- }
251
- if (file.endsWith(".html")) {
252
- return new Response(
253
- withReloadScript(readFileSync(file, "utf8")),
254
- { headers: { "content-type": WEB_MIME[".html"] } });
255
- }
256
- const ext = file.slice(file.lastIndexOf("."));
257
- return new Response(Bun.file(file), {
258
- headers: {
259
- "content-type": WEB_MIME[ext] ?? "application/octet-stream",
211
+ const url = new URL(req.url);
212
+ if (url.pathname === "/__elur_dev") {
213
+ let entry = null;
214
+ const stream = new ReadableStream({
215
+ start(controller) {
216
+ entry = {
217
+ send(msg) {
218
+ try {
219
+ controller.enqueue(
220
+ webEncoder.encode(`data: ${msg}\n\n`));
221
+ } catch { /* cliente cerrado */ }
222
+ },
223
+ close() {
224
+ try { controller.close(); } catch { }
260
225
  },
226
+ };
227
+ webClients.add(entry);
228
+ entry.send("connected");
229
+ req.signal?.addEventListener("abort", () => {
230
+ if (entry) webClients.delete(entry);
231
+ entry?.close();
261
232
  });
262
233
  },
234
+ cancel() {
235
+ if (entry) webClients.delete(entry);
236
+ },
237
+ });
238
+ return new Response(stream, {
239
+ headers: {
240
+ "content-type": "text/event-stream",
241
+ "cache-control": "no-cache",
242
+ "connection": "keep-alive",
243
+ },
263
244
  });
245
+ }
246
+ let pathname = decodeURIComponent(url.pathname);
247
+ if (pathname === "/" || pathname.endsWith("/")) {
248
+ pathname += "index.html";
249
+ }
250
+ const targetFile = resolve(dist, "." + pathname);
251
+ if (targetFile !== dist &&
252
+ !targetFile.startsWith(dist + sep)) {
253
+ return new Response("forbidden", { status: 403 });
254
+ }
255
+ const fallback = join(dist, "index.html");
256
+ const file = existsSync(targetFile) ? targetFile : fallback;
257
+ if (!existsSync(file)) {
258
+ return new Response("not found", { status: 404 });
259
+ }
260
+ if (file.endsWith(".html")) {
261
+ return new Response(
262
+ withReloadScript(readFileSync(file, "utf8")),
263
+ { headers: { "content-type": WEB_MIME[".html"] } });
264
+ }
265
+ const ext = file.slice(file.lastIndexOf("."));
266
+ return new Response(Bun.file(file), {
267
+ headers: {
268
+ "content-type": WEB_MIME[ext] ?? "application/octet-stream",
269
+ },
270
+ });
271
+ }
272
+ let webPortResolved = Number(webPort);
273
+ function startWebServer() {
274
+ if (ssr || target !== "web" || noServe || webServer) return;
275
+ const dist = WEB_DIST();
276
+ if (!existsSync(dist)) return;
277
+ const base = Number(webPort);
278
+ const span = strictPort ? 1 : 20;
279
+ let lastErr = null;
280
+ for (let p = base; p < base + span; p++) {
281
+ try {
282
+ webServer = Bun.serve({ port: p, fetch: webFetch });
283
+ webPortResolved = p;
284
+ break;
285
+ } catch (e) { lastErr = e; }
286
+ }
287
+ if (webServer) {
264
288
  log("dev.web", {
265
- url: `http://localhost:${webPort}`,
266
- msg: `sirviendo dist/ con reload en :${webPort}`,
289
+ url: `http://localhost:${webPortResolved}`,
290
+ msg: `sirviendo dist/ con reload en :${webPortResolved}` +
291
+ (webPortResolved !== base ? ` (:${base} ocupado)` : ""),
267
292
  });
268
- } catch (e) {
293
+ } else {
269
294
  log("dev.web", {
270
- ok: false, error: String(e?.message ?? e),
271
- msg: `no se pudo abrir :${webPort} (¿ocupado?) — sigue el rebuild`,
295
+ ok: false, error: String(lastErr?.message ?? lastErr),
296
+ msg: `ningún puerto libre en ${base}..${base + span - 1}` +
297
+ ` — sigue el rebuild`,
272
298
  });
273
299
  }
274
300
  }
@@ -387,8 +413,8 @@ function rebuild() {
387
413
  restartSsrServer();
388
414
  log("dev.build.end", {
389
415
  ok: true, ms: Date.now() - t0,
390
- port: ssrPort,
391
- msg: `SSR rebuild + server reiniciado (:${ssrPort})`
416
+ port: ssrPortResolved,
417
+ msg: `SSR rebuild + server reiniciado (:${ssrPortResolved})`
392
418
  });
393
419
  return;
394
420
  }
@@ -398,9 +424,9 @@ function rebuild() {
398
424
  broadcastReload();
399
425
  log("dev.build.end", {
400
426
  ok: true, ms: Date.now() - t0,
401
- port: webServer ? webPort : null,
427
+ port: webServer ? webPortResolved : null,
402
428
  msg: webServer
403
- ? `dist/ actualizado + reload (:${webPort})`
429
+ ? `dist/ actualizado + reload (:${webPortResolved})`
404
430
  : "dist/ actualizado — refresca el navegador",
405
431
  });
406
432
  return;
@@ -543,6 +569,10 @@ log("dev.start", {
543
569
  msg: `target=${target} app=${appEntry}${full ? " (full)" : ""}` +
544
570
  `${devFast ? " (fast)" : ""}`
545
571
  });
572
+ if (ssr && !strictPort) {
573
+ const free = await pickFreePort(Number(ssrPort));
574
+ if (free != null) ssrPortResolved = free;
575
+ }
546
576
  rebuild();
547
577
 
548
578
  let timer = null;
package/cli/inspect.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  // elur inspect — overlay de inspección en dev (docs §3.16): cajas con
3
3
  // el id del Display List sobre cada nodo + avisos strict.
4
4
  //
5
- // bun cli/elur.mjs inspect --target web --url http://localhost:3418/
5
+ // bun cli/elur.mjs inspect --target web [--url http://localhost:3419/]
6
+ // (3419 = dev SPA; para el servidor SSR pasa --url …:3418)
6
7
  // → imprime la URL con ?__inspect=1 (con --open la abre en Chrome)
7
8
  // bun cli/elur.mjs inspect --target android [--serial id] \
8
9
  // [--config examples/mareas/elur.app.json | --package <id.dev>] \
@@ -17,7 +18,7 @@ const opt = (n, d) => { const i = args.indexOf(`--${n}`); return i >= 0 && i + 1
17
18
  const flag = (n) => args.includes(`--${n}`);
18
19
 
19
20
  const target = opt("target", "web");
20
- const url = opt("url", "http://localhost:3418/");
21
+ const url = opt("url", "http://localhost:3419/");
21
22
  const serial = opt("serial", null);
22
23
  // Mismo convenio que visual-parity: el dev host instala con
23
24
  // <applicationId>.dev — --config evita lanzar el paquete de otra app.
package/cli/sdui.mjs CHANGED
@@ -549,6 +549,8 @@ if (sub === "gateway") {
549
549
  // POST /action → registra acciones de vuelta desde la app (a2ui.action / intents)
550
550
  // GET /actions → devuelve cola reciente de acciones para inspección del agente
551
551
  const port = Number(flag("port") ?? "8471");
552
+ // --strict-port fija el puerto; si no, se avanza hasta uno libre.
553
+ const strictPort = args.includes("--strict-port");
552
554
  const docsDir = flag("dir");
553
555
  const keyFile = flag("key");
554
556
  const defaultKid = flag("kid") ?? "app";
@@ -886,11 +888,23 @@ if (sub === "gateway") {
886
888
  });
887
889
  }
888
890
  });
889
- srv.listen(port, () => {
890
- console.error(`[sdui] gateway :${port} — POST /serve + /publish + GET /stream + /poll ` +
891
- `${requireSig ? "(firma exigida)" : "(sin firma)"}` +
892
- (docsDir ? ` almacén=${resolve(docsDir)}` : " (sin --dir: memoria/inline)"));
893
- });
891
+ const tryListen = (p, left) => {
892
+ srv.once("error", (e) => {
893
+ if (e?.code === "EADDRINUSE" && left > 0) {
894
+ console.error(`[sdui] :${p} ocupado — probando :${p + 1}`);
895
+ tryListen(p + 1, left - 1);
896
+ return;
897
+ }
898
+ throw e;
899
+ });
900
+ srv.listen(p, () => {
901
+ console.error(`[sdui] gateway :${p} — POST /serve + /publish + GET /stream + /poll ` +
902
+ `${requireSig ? "(firma exigida)" : "(sin firma)"}` +
903
+ (docsDir ? ` almacén=${resolve(docsDir)}` : " (sin --dir: memoria/inline)") +
904
+ (p !== port ? ` (auto — :${port} ocupado)` : ""));
905
+ });
906
+ };
907
+ tryListen(port, strictPort ? 0 : 20);
894
908
  }
895
909
 
896
910
  if (sub === "mcp") {
@@ -87,7 +87,9 @@ Scripts del scaffold (`create-app.mjs`):
87
87
  `http://localhost:3419` con SSE de auto-reload (ADR-0214) — cada
88
88
  rebuild empuja `reload` a los navegadores conectados. `--ssr` cambia
89
89
  al servidor SSR real en `:3418` (rebuild server+client y restart del
90
- proceso bun).
90
+ proceso bun). Si el puerto está ocupado el dev busca el siguiente
91
+ libre (`3419→3420…`, hasta +20) — `--strict-port` lo fija y falla.
92
+ Igual en el gateway SDUI (`8471→8472…`).
91
93
  - `bun run dev:android` → `elur dev --target android --app src/entry.ts`
92
94
  (sin `--dev-fast`: cada ciclo genera además HBC/QJSC y los bundles de
93
95
  verificación). Path caliente: `elur build --target android` →
@@ -144,9 +146,11 @@ Scripts del scaffold (`create-app.mjs`):
144
146
  `--splits` (APK por ABI + universal), `--minify` (R8 +
145
147
  shrinkResources). Sin credenciales release firma debug.
146
148
  - **linux** → `generated/elurApp.js` + `elurApp.es5.qjsc` +
147
- `targets/linux/generated/` (registrar/sources de módulos). El host se
148
- compila con `cmake -B targets/linux/build && cmake --build
149
- targets/linux/build` → `targets/linux/build/elur-linux`.
149
+ `targets/linux/generated/` (registrar/sources de módulos) **+ el
150
+ binario del host**: en Linux `build:linux` corre `cmake -B
151
+ node_modules/@elurjs/universal/targets/linux/build -S …/targets/linux`
152
+ `+` `cmake --build … -j4` → `node_modules/@elurjs/universal/targets/
153
+ linux/build/elur-linux`.
150
154
  Distribución (ADR-0186): `bun cli/package-linux.mjs --format
151
155
  appimage|deb|rpm|flatpak|all --app <bundle.js> --name n --title T
152
156
  --version X.Y.Z` → AppDir autocontenido (pila GTK4 por `ldd`, loaders
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elurjs/universal",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",