@elurjs/universal 0.1.13 → 0.1.15

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`).
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 */ });
@@ -185,90 +201,101 @@ const WEB_MIME = {
185
201
  };
186
202
  function withReloadScript(html) {
187
203
  const script = `<script>(()=>{const es=new EventSource("/__elur_dev");` +
188
- `es.onmessage=e=>{if(e.data==="reload")location.reload();};})();</script>`;
204
+ `es.onmessage=e=>{if(e.data==="reload")location.reload();};` +
205
+ `addEventListener("beforeunload",()=>es.close());})();</script>`;
189
206
  return html.includes("</body>")
190
207
  ? html.replace("</body>", script + "</body>")
191
208
  : html + script;
192
209
  }
193
- function startWebServer() {
194
- if (ssr || target !== "web" || noServe || webServer) return;
210
+ async function webFetch(req) {
195
211
  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",
212
+ const url = new URL(req.url);
213
+ if (url.pathname === "/__elur_dev") {
214
+ let entry = null;
215
+ const stream = new ReadableStream({
216
+ start(controller) {
217
+ entry = {
218
+ send(msg) {
219
+ try {
220
+ controller.enqueue(
221
+ webEncoder.encode(`data: ${msg}\n\n`));
222
+ } catch { /* cliente cerrado */ }
223
+ },
224
+ close() {
225
+ try { controller.close(); } catch { }
260
226
  },
227
+ };
228
+ webClients.add(entry);
229
+ entry.send("connected");
230
+ req.signal?.addEventListener("abort", () => {
231
+ if (entry) webClients.delete(entry);
232
+ entry?.close();
261
233
  });
262
234
  },
235
+ cancel() {
236
+ if (entry) webClients.delete(entry);
237
+ },
238
+ });
239
+ return new Response(stream, {
240
+ headers: {
241
+ "content-type": "text/event-stream",
242
+ "cache-control": "no-cache",
243
+ "connection": "keep-alive",
244
+ },
263
245
  });
246
+ }
247
+ let pathname = decodeURIComponent(url.pathname);
248
+ if (pathname === "/" || pathname.endsWith("/")) {
249
+ pathname += "index.html";
250
+ }
251
+ const targetFile = resolve(dist, "." + pathname);
252
+ if (targetFile !== dist &&
253
+ !targetFile.startsWith(dist + sep)) {
254
+ return new Response("forbidden", { status: 403 });
255
+ }
256
+ const fallback = join(dist, "index.html");
257
+ const file = existsSync(targetFile) ? targetFile : fallback;
258
+ if (!existsSync(file)) {
259
+ return new Response("not found", { status: 404 });
260
+ }
261
+ if (file.endsWith(".html")) {
262
+ return new Response(
263
+ withReloadScript(readFileSync(file, "utf8")),
264
+ { headers: { "content-type": WEB_MIME[".html"] } });
265
+ }
266
+ const ext = file.slice(file.lastIndexOf("."));
267
+ return new Response(Bun.file(file), {
268
+ headers: {
269
+ "content-type": WEB_MIME[ext] ?? "application/octet-stream",
270
+ },
271
+ });
272
+ }
273
+ let webPortResolved = Number(webPort);
274
+ function startWebServer() {
275
+ if (ssr || target !== "web" || noServe || webServer) return;
276
+ const dist = WEB_DIST();
277
+ if (!existsSync(dist)) return;
278
+ const base = Number(webPort);
279
+ const span = strictPort ? 1 : 20;
280
+ let lastErr = null;
281
+ for (let p = base; p < base + span; p++) {
282
+ try {
283
+ webServer = Bun.serve({ port: p, fetch: webFetch });
284
+ webPortResolved = p;
285
+ break;
286
+ } catch (e) { lastErr = e; }
287
+ }
288
+ if (webServer) {
264
289
  log("dev.web", {
265
- url: `http://localhost:${webPort}`,
266
- msg: `sirviendo dist/ con reload en :${webPort}`,
290
+ url: `http://localhost:${webPortResolved}`,
291
+ msg: `sirviendo dist/ con reload en :${webPortResolved}` +
292
+ (webPortResolved !== base ? ` (:${base} ocupado)` : ""),
267
293
  });
268
- } catch (e) {
294
+ } else {
269
295
  log("dev.web", {
270
- ok: false, error: String(e?.message ?? e),
271
- msg: `no se pudo abrir :${webPort} (¿ocupado?) — sigue el rebuild`,
296
+ ok: false, error: String(lastErr?.message ?? lastErr),
297
+ msg: `ningún puerto libre en ${base}..${base + span - 1}` +
298
+ ` — sigue el rebuild`,
272
299
  });
273
300
  }
274
301
  }
@@ -387,8 +414,8 @@ function rebuild() {
387
414
  restartSsrServer();
388
415
  log("dev.build.end", {
389
416
  ok: true, ms: Date.now() - t0,
390
- port: ssrPort,
391
- msg: `SSR rebuild + server reiniciado (:${ssrPort})`
417
+ port: ssrPortResolved,
418
+ msg: `SSR rebuild + server reiniciado (:${ssrPortResolved})`
392
419
  });
393
420
  return;
394
421
  }
@@ -398,9 +425,9 @@ function rebuild() {
398
425
  broadcastReload();
399
426
  log("dev.build.end", {
400
427
  ok: true, ms: Date.now() - t0,
401
- port: webServer ? webPort : null,
428
+ port: webServer ? webPortResolved : null,
402
429
  msg: webServer
403
- ? `dist/ actualizado + reload (:${webPort})`
430
+ ? `dist/ actualizado + reload (:${webPortResolved})`
404
431
  : "dist/ actualizado — refresca el navegador",
405
432
  });
406
433
  return;
@@ -543,6 +570,10 @@ log("dev.start", {
543
570
  msg: `target=${target} app=${appEntry}${full ? " (full)" : ""}` +
544
571
  `${devFast ? " (fast)" : ""}`
545
572
  });
573
+ if (ssr && !strictPort) {
574
+ const free = await pickFreePort(Number(ssrPort));
575
+ if (free != null) ssrPortResolved = free;
576
+ }
546
577
  rebuild();
547
578
 
548
579
  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";
@@ -633,6 +635,15 @@ if (sub === "gateway") {
633
635
  const urlObj = new URL(req.url ?? "/", "http://127.0.0.1");
634
636
  const pathname = urlObj.pathname;
635
637
 
638
+ if (req.method === "GET" &&
639
+ (pathname === "/" || pathname === "/favicon.ico")) {
640
+ return send(200, {
641
+ ok: true, rev,
642
+ rutas: "POST /serve | POST /publish | GET /poll | " +
643
+ "GET /stream | POST /action | GET /actions",
644
+ });
645
+ }
646
+
636
647
  if (req.method === "GET" && pathname === "/poll") {
637
648
  const since = Number(urlObj.searchParams.get("since") ?? "0");
638
649
  if (rev > since && liveItem) {
@@ -886,11 +897,23 @@ if (sub === "gateway") {
886
897
  });
887
898
  }
888
899
  });
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
- });
900
+ const tryListen = (p, left) => {
901
+ srv.once("error", (e) => {
902
+ if (e?.code === "EADDRINUSE" && left > 0) {
903
+ console.error(`[sdui] :${p} ocupado — probando :${p + 1}`);
904
+ tryListen(p + 1, left - 1);
905
+ return;
906
+ }
907
+ throw e;
908
+ });
909
+ srv.listen(p, () => {
910
+ console.error(`[sdui] gateway :${p} — POST /serve + /publish + GET /stream + /poll ` +
911
+ `${requireSig ? "(firma exigida)" : "(sin firma)"}` +
912
+ (docsDir ? ` almacén=${resolve(docsDir)}` : " (sin --dir: memoria/inline)") +
913
+ (p !== port ? ` (auto — :${port} ocupado)` : ""));
914
+ });
915
+ };
916
+ tryListen(port, strictPort ? 0 : 20);
894
917
  }
895
918
 
896
919
  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` →
@@ -147,7 +149,7 @@ Scripts del scaffold (`create-app.mjs`):
147
149
  `targets/linux/generated/` (registrar/sources de módulos) **+ el
148
150
  binario del host**: en Linux `build:linux` corre `cmake -B
149
151
  node_modules/@elurjs/universal/targets/linux/build -S …/targets/linux`
150
- + `cmake --build … -j4` → `node_modules/@elurjs/universal/targets/
152
+ `+` `cmake --build … -j4` → `node_modules/@elurjs/universal/targets/
151
153
  linux/build/elur-linux`.
152
154
  Distribución (ADR-0186): `bun cli/package-linux.mjs --format
153
155
  appimage|deb|rpm|flatpak|all --app <bundle.js> --name n --title T
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elurjs/universal",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",