@elurjs/universal 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (757) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +24 -0
  3. package/README.md +102 -2
  4. package/THIRD_PARTY_NOTICES.md +153 -0
  5. package/cli/.gitkeep +0 -0
  6. package/cli/build-spec.mjs +46 -0
  7. package/cli/build-ssg.mjs +145 -0
  8. package/cli/build-ssr.mjs +276 -0
  9. package/cli/check-divergences.mjs +135 -0
  10. package/cli/check-doc-sync.mjs +282 -0
  11. package/cli/commands.d.mts +8 -0
  12. package/cli/commands.mjs +124 -0
  13. package/cli/commit-present.py +157 -0
  14. package/cli/create-app.mjs +768 -0
  15. package/cli/debug.mjs +45 -0
  16. package/cli/dev.mjs +488 -0
  17. package/cli/doctor.mjs +197 -0
  18. package/cli/elur.mjs +394 -0
  19. package/cli/font-license.mjs +24 -0
  20. package/cli/gen-bundle.mjs +195 -0
  21. package/cli/gen-doc-data.mjs +274 -0
  22. package/cli/gen-es5.mjs +60 -0
  23. package/cli/gen-hbc.mjs +87 -0
  24. package/cli/gen-host-integration.mjs +386 -0
  25. package/cli/gen-i18n-corpus.mjs +47 -0
  26. package/cli/gen-manifest.mjs +95 -0
  27. package/cli/gen-qjsc.mjs +77 -0
  28. package/cli/gen-route-types.mjs +65 -0
  29. package/cli/gen-routes.mjs +129 -0
  30. package/cli/gen-signals.mjs +151 -0
  31. package/cli/gen-ssr-client.mjs +119 -0
  32. package/cli/gen-wire-codec.mjs +214 -0
  33. package/cli/gen-wire-corpus.mjs +318 -0
  34. package/cli/gen-worklet-src.mjs +200 -0
  35. package/cli/gen-zones.mjs +197 -0
  36. package/cli/hermes-pair.mjs +61 -0
  37. package/cli/inspect.mjs +55 -0
  38. package/cli/layout-oracle-web.mjs +213 -0
  39. package/cli/layout-oracle.mjs +80 -0
  40. package/cli/lib-vlq.mjs +84 -0
  41. package/cli/measure-engines.mjs +206 -0
  42. package/cli/measure-shared.mjs +143 -0
  43. package/cli/package-linux.mjs +440 -0
  44. package/cli/parity-align.mjs +66 -0
  45. package/cli/platform-plugin.ts +97 -0
  46. package/cli/plugin-manifest.mjs +573 -0
  47. package/cli/run-bench.mjs +291 -0
  48. package/cli/run-commit-present.sh +91 -0
  49. package/cli/run-device-ab-surface.sh +94 -0
  50. package/cli/run-device-ab.sh +107 -0
  51. package/cli/run-energy.sh +44 -0
  52. package/cli/run-parity.mjs +164 -0
  53. package/cli/run-semantics.mjs +111 -0
  54. package/cli/run-tck.mjs +243 -0
  55. package/cli/sdui.mjs +1211 -0
  56. package/cli/symbolicate.mjs +90 -0
  57. package/cli/tck-android.sh +21 -0
  58. package/cli/tck-events-android.mjs +101 -0
  59. package/cli/tck-linux-atspi.py +389 -0
  60. package/cli/tck-platform-linux.mjs +638 -0
  61. package/cli/tck-platform.mjs +510 -0
  62. package/cli/visual-parity.mjs +691 -0
  63. package/docs/AUDITORIA-STATE-OF-THE-ART-2026-11.md +981 -0
  64. package/docs/ESTADO.md +679 -0
  65. package/docs/IMPLEMENTACION-NATIVA-v5.md +507 -0
  66. package/docs/PENDIENTES.md +1306 -0
  67. package/docs/adr/0013-transiciones-navegacion.md +169 -0
  68. package/docs/adr/0014-list-renderitem-factory.md +41 -0
  69. package/docs/adr/0015-dl-header-versionado.md +57 -0
  70. package/docs/adr/0016-hermes-v1-runtime.md +78 -0
  71. package/docs/adr/0017-encoder-nativo-dl.md +62 -0
  72. package/docs/adr/0018-yoga-tree-nativo.md +78 -0
  73. package/docs/adr/0019-ssr-universal-hidratacion.md +245 -0
  74. package/docs/adr/0020-canvas-draw-list.md +65 -0
  75. package/docs/adr/0021-text-input-props.md +55 -0
  76. package/docs/adr/0022-deep-links.md +49 -0
  77. package/docs/adr/0023-animacion-declarativa.md +130 -0
  78. package/docs/adr/0024-estilos-reactivos-vocabulario.md +100 -0
  79. package/docs/adr/0025-worklets-contrato-runner.md +181 -0
  80. package/docs/adr/0026-threading-js-dedicado.md +94 -0
  81. package/docs/adr/0027-ui-array-children-y-scope-por-fila.md +58 -0
  82. package/docs/adr/0028-commit-por-frame-en-host-embebido.md +93 -0
  83. package/docs/adr/0029-render-commit-latest-wins-screenhost.md +62 -0
  84. package/docs/adr/0030-destruccion-recursiva-ids-monotonicos.md +79 -0
  85. package/docs/adr/0031-scopes-formales-pool-filas.md +76 -0
  86. package/docs/adr/0032-nav-commit-autoritativo.md +64 -0
  87. package/docs/adr/0033-lista-virtual-ventana.md +80 -0
  88. package/docs/adr/0034-attach-event-class-strict-styles.md +89 -0
  89. package/docs/adr/0035-pipeline-imagenes-acotado.md +133 -0
  90. package/docs/adr/0036-data-por-entry-spa.md +91 -0
  91. package/docs/adr/0037-ir-serializable-factories-por-id.md +73 -0
  92. package/docs/adr/0038-transform-keys-compositor.md +79 -0
  93. package/docs/adr/0039-destroy-postorder-scope-ownership.md +86 -0
  94. package/docs/adr/0040-outbound-barriers-overflow-ack.md +60 -0
  95. package/docs/adr/0041-diff-treap-ir-version-strict.md +65 -0
  96. package/docs/adr/0042-data-endpoint-seguridad-hasloader.md +67 -0
  97. package/docs/adr/0043-aplicador-dom-unico.md +70 -0
  98. package/docs/adr/0044-descriptor-runtime-explicito.md +80 -0
  99. package/docs/adr/0045-navstate-versionado-scroll-settle.md +72 -0
  100. package/docs/adr/0046-harness-build-fail-closed.md +99 -0
  101. package/docs/adr/0047-envelope-evento-normalizado.md +110 -0
  102. package/docs/adr/0048-sesion-embebida-estados.md +91 -0
  103. package/docs/adr/0049-strict-styles-valores-portables.md +78 -0
  104. package/docs/adr/0050-update-style-tipado-abi-v5.md +66 -0
  105. package/docs/adr/0051-plugin-sdk-comandos.md +65 -0
  106. package/docs/adr/0052-benchmarks-reproducibles.md +50 -0
  107. package/docs/adr/0053-fling-target-pool-estructural.md +105 -0
  108. package/docs/adr/0054-lista-nativa-render-policy.md +130 -0
  109. package/docs/adr/0055-cesm-core.md +143 -0
  110. package/docs/adr/0056-dos-ejes-superficie-vs-propietario-de-ventana.md +112 -0
  111. package/docs/adr/0057-reset-node-y-firma-de-reciclaje.md +95 -0
  112. package/docs/adr/0058-rollback-de-montaje.md +83 -0
  113. package/docs/adr/0059-traza-on-device-u01-y-scroll-unico-productor.md +89 -0
  114. package/docs/adr/0060-list-update-patch-por-campo.md +73 -0
  115. package/docs/adr/0061-elegibilidad-de-plantilla-nativa.md +70 -0
  116. package/docs/adr/0062-invalidacion-adapter-lista-nativa.md +77 -0
  117. package/docs/adr/0063-autoridad-eventos-y-scroll.md +66 -0
  118. package/docs/adr/0064-admision-unica-de-commits.md +66 -0
  119. package/docs/adr/0065-runtime-de-sesion-u11.md +97 -0
  120. package/docs/adr/0066-perfil-layout-y-safe-area.md +78 -0
  121. package/docs/adr/0067-sesion-robusta-y-procedencia-de-build.md +121 -0
  122. package/docs/adr/0068-metodologia-de-benchmark-y-carril-verificable.md +94 -0
  123. package/docs/adr/0069-schema-de-wire-y-corpus-comun-de-codecs.md +126 -0
  124. package/docs/adr/0070-modelo-publico-de-aplicacion-y-mount.md +91 -0
  125. package/docs/adr/0071-image-service-y-tck-de-plataforma.md +133 -0
  126. package/docs/adr/0072-par-compilador-runtime-hermes.md +62 -0
  127. package/docs/adr/0073-corpus-de-semantica-y-lowering-por-motor.md +67 -0
  128. package/docs/adr/0074-perfil-i18n-formateo-dom-free.md +85 -0
  129. package/docs/adr/0075-back-predictivo-restore-y-layout-adaptativo.md +126 -0
  130. package/docs/adr/0076-contrato-de-modulos-capa-1.md +159 -0
  131. package/docs/adr/0077-manifest-de-plugin-y-plugin-sync.md +109 -0
  132. package/docs/adr/0078-extraccion-de-i18n-a-paquete-propio.md +114 -0
  133. package/docs/adr/0079-handles-de-host-objects-por-epoch.md +96 -0
  134. package/docs/adr/0080-platform-views-por-contrato.md +93 -0
  135. package/docs/adr/0081-codegen-del-dsl-de-modulos.md +118 -0
  136. package/docs/adr/0082-variante-web-de-modulos-nativos.md +126 -0
  137. package/docs/adr/0083-perfiles-dev-release.md +92 -0
  138. package/docs/adr/0084-instrumentacion-acotada-exportable.md +126 -0
  139. package/docs/adr/0085-medicion-agrupada-en-main.md +125 -0
  140. package/docs/adr/0086-matriz-capacidades-props-eventos.md +75 -0
  141. package/docs/adr/0087-uithread-runner-android.md +271 -0
  142. package/docs/adr/0088-worklet-src-estatico.md +82 -0
  143. package/docs/adr/0089-composicion-animaciones-settle-drag.md +122 -0
  144. package/docs/adr/0090-linter-capturas-build.md +94 -0
  145. package/docs/adr/0091-router-core-vs-universal.md +74 -0
  146. package/docs/adr/0092-sharedregion-type-strings.md +59 -0
  147. package/docs/adr/0093-permission-request-estandar.md +52 -0
  148. package/docs/adr/0094-dispatch-worker-timeoutms.md +51 -0
  149. package/docs/adr/0095-tck-modulos.md +65 -0
  150. package/docs/adr/0096-cesm-ring-deferral.md +47 -0
  151. package/docs/adr/0097-tooling-diferido.md +51 -0
  152. package/docs/adr/0098-handshake-moduleabi.md +46 -0
  153. package/docs/adr/0099-modulos-ambient.md +58 -0
  154. package/docs/adr/0100-auto-declaracion-modulos.md +43 -0
  155. package/docs/adr/0101-plataforma-build.md +49 -0
  156. package/docs/adr/0102-permisos-manifest-build.md +38 -0
  157. package/docs/adr/0103-registrant-ownership.md +45 -0
  158. package/docs/adr/0104-toolchain-release.md +125 -0
  159. package/docs/adr/0105-cesm-ring-mode.md +71 -0
  160. package/docs/adr/0106-module-observabilidad.md +100 -0
  161. package/docs/adr/0107-layout-l1-oraculo.md +67 -0
  162. package/docs/adr/0108-semantica-como-ops.md +69 -0
  163. package/docs/adr/0109-text-input-composition.md +64 -0
  164. package/docs/adr/0110-yoga-3-2.md +63 -0
  165. package/docs/adr/0111-hot-reload-con-estado.md +92 -0
  166. package/docs/adr/0112-metricas-nativas-reales.md +65 -0
  167. package/docs/adr/0113-cesm-proyeccion-ampliada.md +80 -0
  168. package/docs/adr/0114-androidx-deps.md +72 -0
  169. package/docs/adr/0115-coil-imagenes.md +57 -0
  170. package/docs/adr/0116-precomputed-text-off-ui.md +49 -0
  171. package/docs/adr/0117-a11y-state-hint-foco.md +54 -0
  172. package/docs/adr/0118-yoga-3-2-vocabulario.md +98 -0
  173. package/docs/adr/0119-codecs-wire-desde-esquema.md +86 -0
  174. package/docs/adr/0120-unidades-logicas-pointscalefactor.md +73 -0
  175. package/docs/adr/0121-yoga-filas-lista.md +100 -0
  176. package/docs/adr/0122-delegado-layout-subarbol.md +140 -0
  177. package/docs/adr/0123-canvas-sobre-skia-raster.md +101 -0
  178. package/docs/adr/0124-evaluacion-taffy-css-grid.md +52 -0
  179. package/docs/adr/0125-paridad-visual-android.md +89 -0
  180. package/docs/adr/0126-documento-web-metadata-enlaces.md +52 -0
  181. package/docs/adr/0127-perfil-l1-shorthand-flex-herencia-texto.md +70 -0
  182. package/docs/adr/0128-pantalla-llena-fragmentos-transparentes.md +56 -0
  183. package/docs/adr/0129-content-visibility-canvas-unidades-logicas.md +37 -0
  184. package/docs/adr/0130-expresiones-reactivas-ui.md +55 -0
  185. package/docs/adr/0131-state-style.md +59 -0
  186. package/docs/adr/0132-create-theme-system-color-scheme.md +58 -0
  187. package/docs/adr/0133-navegacion-rutas-href-chrome.md +59 -0
  188. package/docs/adr/0134-servicios-ambient-modulos-timers.md +63 -0
  189. package/docs/adr/0135-registro-fuentes.md +67 -0
  190. package/docs/adr/0136-i18n-zonas-dst-locale-reactivo.md +70 -0
  191. package/docs/adr/0137-ssg-universal.md +78 -0
  192. package/docs/adr/0138-plantillas-fila-ui-rowref.md +54 -0
  193. package/docs/adr/0139-paridad-geometrica-e-inspector.md +63 -0
  194. package/docs/adr/0140-medida-line-height-css.md +78 -0
  195. package/docs/adr/0141-build-ssr-autocontenido.md +37 -0
  196. package/docs/adr/0142-tema-ssr-cookie-client-hint.md +42 -0
  197. package/docs/adr/0143-paridad-visual-ci.md +51 -0
  198. package/docs/adr/0144-oraculo-layout-chromium.md +45 -0
  199. package/docs/adr/0145-admision-opcodes-wire.md +89 -0
  200. package/docs/adr/0146-presupuesto-divergencias.md +82 -0
  201. package/docs/adr/0147-spans-texto-enriquecido.md +113 -0
  202. package/docs/adr/0148-scroll-restore.md +92 -0
  203. package/docs/adr/0149-gestion-foco.md +94 -0
  204. package/docs/adr/0150-sticky.md +89 -0
  205. package/docs/adr/0151-politica-migracion-snapshots.md +83 -0
  206. package/docs/adr/0152-vocabulario-semantico-v3.md +112 -0
  207. package/docs/adr/0153-puerta-doc-codigo.md +59 -0
  208. package/docs/adr/0154-matriz-paridad.md +79 -0
  209. package/docs/adr/0155-rtl-ambiente.md +73 -0
  210. package/docs/adr/0156-quickjs-ng-0170.md +55 -0
  211. package/docs/adr/0157-qjsc-bytecode-android.md +73 -0
  212. package/docs/adr/0158-abi-host-explicita.md +62 -0
  213. package/docs/adr/0159-entrada-desktop.md +59 -0
  214. package/docs/adr/0160-port-linux-hallazgos-plataforma.md +91 -0
  215. package/docs/adr/0161-paridad-deeplink-alineacion-estructural.md +76 -0
  216. package/docs/adr/0162-fontscale-linux-fuentes.md +63 -0
  217. package/docs/adr/0163-overflow-hidden-linux-clip.md +67 -0
  218. package/docs/adr/0164-nav-transitions-linux.md +126 -0
  219. package/docs/adr/0165-transiciones-declarativas.md +147 -0
  220. package/docs/adr/0166-ime-composition-linux.md +68 -0
  221. package/docs/adr/0167-spans-pango-linux.md +80 -0
  222. package/docs/adr/0168-statestyle-linux.md +65 -0
  223. package/docs/adr/0169-animate-linux.md +114 -0
  224. package/docs/adr/0170-image-service-linux.md +54 -0
  225. package/docs/adr/0171-semantics-atspi-linux.md +80 -0
  226. package/docs/adr/0172-conformidad-de-host-por-terceros.md +159 -0
  227. package/docs/adr/0173-licencias-espec-y-codigo.md +95 -0
  228. package/docs/adr/0174-tabla-estilo-yoga-compartida.md +67 -0
  229. package/docs/adr/0175-easings-normativos-cubic-bezier.md +68 -0
  230. package/docs/adr/0176-harness-plataforma-linux-y-locale-decimal.md +80 -0
  231. package/docs/adr/0177-gaps-linux-dir-as-navstate.md +84 -0
  232. package/docs/adr/0178-matriz-linux-y-tablas-normativas-generadas.md +104 -0
  233. package/docs/adr/0179-eventos-gesto-y-teclado.md +132 -0
  234. package/docs/adr/0180-desktop-nativo-linux-windows-macos-chromeos.md +58 -0
  235. package/docs/adr/0181-linux-platform-views-uiworklet-y-gaps-certificados.md +101 -0
  236. package/docs/adr/0182-sdui-envelope-dialecto-rico-y-lowering.md +452 -0
  237. package/docs/adr/0183-hermes-es6-block-scoping-en-source-eval.md +99 -0
  238. package/docs/adr/0184-sdui-consumidor-de-referencia-y-modulo-http.md +72 -0
  239. package/docs/adr/0185-sdui-modelo-de-seguridad-del-envelope.md +160 -0
  240. package/docs/adr/0186-linux-packaging-deb-rpm-flatpak.md +61 -0
  241. package/docs/adr/0187-modelo-de-hilos-ejecutores-logicos.md +163 -0
  242. package/docs/adr/0188-sdui-seguridad-hardening.md +214 -0
  243. package/docs/adr/0189-worklets-web-worker-y-egreso-pinning.md +235 -0
  244. package/docs/adr/0190-semantics-actions-linux-via-gaction-muxer.md +102 -0
  245. package/docs/adr/0191-reporte-de-errores-en-produccion.md +126 -0
  246. package/docs/adr/0192-source-maps-y-simbolizacion-de-stacks.md +107 -0
  247. package/docs/adr/0193-renderer-skia-opt-in-en-linux.md +143 -0
  248. package/docs/adr/0194-superficie-declarada-y-carril-skia-tree.md +96 -0
  249. package/docs/adr/0195-bundles-embebidos-subpaths-core.md +66 -0
  250. package/docs/adr/0196-matriz-capacidades-verdad.md +84 -0
  251. package/docs/adr/0197-entorno-reactivo-cableado.md +67 -0
  252. package/docs/adr/0198-csprng-host-wintertc.md +57 -0
  253. package/docs/adr/0199-testing-harness-dom-free.md +59 -0
  254. package/docs/adr/0200-overlays-back-foco.md +84 -0
  255. package/docs/adr/0201-paridad-nativa-props-texto-fase1.md +79 -0
  256. package/docs/adr/0202-node-ref-measure-web.md +61 -0
  257. package/docs/adr/0203-primitivas-headless.md +54 -0
  258. package/docs/adr/0204-imagen-load-error-fallback.md +123 -0
  259. package/docs/adr/0205-primitivas-controls-fase2.md +79 -0
  260. package/docs/adr/0206-a2ui-catalogo-tabs-modal-choicepicker-icon.md +110 -0
  261. package/docs/adr/0207-a2ui-superficie-viva.md +104 -0
  262. package/docs/adr/0208-a2ui-checks-validacion.md +94 -0
  263. package/docs/adr/0209-loaddata-nativo-default.md +56 -0
  264. package/docs/adr/0210-primitivas-navegacion-fase3.md +69 -0
  265. package/docs/adr/0211-a2ui-formato-localizado.md +113 -0
  266. package/docs/adr/0212-red-fuera-del-core.md +67 -0
  267. package/docs/adr/0213-dev-fast-y-rutas-automaticas.md +68 -0
  268. package/docs/adr/0214-dev-web-server-reload.md +55 -0
  269. package/docs/adr/0215-ui-host-noderef-back-http-linux.md +77 -0
  270. package/docs/adr/0216-paridad-nativa-switch-scroll-lista.md +53 -0
  271. package/docs/adr/0217-overlays-drag-y-popover-anclado.md +64 -0
  272. package/docs/adr/0218-sdui-gateway-live-mcp-y-scaffold.md +31 -0
  273. package/docs/adr/README.md +228 -0
  274. package/docs/deuda/i18n-libreria-separada.md +50 -0
  275. package/docs/doc-data.json +2784 -0
  276. package/docs/propuestas/demo-google-devfest-a2ui-sdui.md +374 -0
  277. package/docs/propuestas/dx-y-paridad.md +684 -0
  278. package/docs/propuestas/investigacion-apps-completas/PENDIENTES-CORE-APPS-COMPLETAS.md +226 -0
  279. package/docs/propuestas/investigacion-apps-completas/arquitectura-motor-videojuegos-elur.md +254 -0
  280. package/docs/propuestas/investigacion-apps-completas/auditoria-paridad-frameworks-y-sdui.md +295 -0
  281. package/docs/propuestas/investigacion-apps-completas/ciclo-de-vida-dx-y-apps-completas.md +394 -0
  282. package/docs/propuestas/investigacion-apps-completas/crear-proyecto-desde-npm-y-agentes.md +477 -0
  283. package/docs/propuestas/investigacion-apps-completas/especificacion-arquitectura-capacidades-faltantes.md +407 -0
  284. package/docs/propuestas/investigacion-apps-completas/identidad-y-nombre-elur-universal.md +133 -0
  285. package/docs/propuestas/investigacion-apps-completas/migracion-elur-core-4.md +266 -0
  286. package/docs/propuestas/investigacion-apps-completas/sdui-a2ui-aplicaciones-completas.md +255 -0
  287. package/docs/propuestas/investigacion-apps-completas/verificacion-mejoras-y-brechas-nuevas.md +228 -0
  288. package/docs/propuestas/modelo-de-consumo.md +287 -0
  289. package/docs/propuestas/modulos-nativos.md +1062 -0
  290. package/docs/propuestas/palabras-clave-normativas.md +69 -0
  291. package/docs/propuestas/sdui-seguridad-hardening.md +322 -0
  292. package/docs/propuestas/skia-graphite.md +167 -0
  293. package/docs/propuestas/skia-renderer-arbol.md +603 -0
  294. package/docs/propuestas/targets-nativos-nuevos.md +359 -0
  295. package/docs/propuestas/toolchain-y-distribucion.md +311 -0
  296. package/docs/propuestas/ui-worklet-capacidades-exclusivas.md +114 -0
  297. package/examples/a11ylive/elur.app.json +8 -0
  298. package/examples/a11ylive/entry.ts +22 -0
  299. package/examples/a11ysem/elur.app.json +8 -0
  300. package/examples/a11ysem/entry.ts +24 -0
  301. package/examples/anim/elur.app.json +8 -0
  302. package/examples/anim/entry.ts +50 -0
  303. package/examples/app.ts +10 -0
  304. package/examples/cliprad/elur.app.json +8 -0
  305. package/examples/cliprad/entry.ts +16 -0
  306. package/examples/controls/app.ts +32 -0
  307. package/examples/controls/elur.app.json +8 -0
  308. package/examples/counter/app.ts +21 -0
  309. package/examples/counter/elur.app.json +8 -0
  310. package/examples/counter/entry.ts +7 -0
  311. package/examples/entry.ts +11 -0
  312. package/examples/feedstress/app.ts +334 -0
  313. package/examples/feedstress/elur.app.json +8 -0
  314. package/examples/feedstress/entry.ts +7 -0
  315. package/examples/i18n/app.ts +86 -0
  316. package/examples/i18n/elur.app.json +8 -0
  317. package/examples/i18n/entry.ts +22 -0
  318. package/examples/imecomp/elur.app.json +8 -0
  319. package/examples/imecomp/entry.ts +41 -0
  320. package/examples/imgtest/elur.app.json +8 -0
  321. package/examples/imgtest/entry.ts +18 -0
  322. package/examples/mareas/app/ajustes/page.ts +54 -0
  323. package/examples/mareas/app/page.ts +91 -0
  324. package/examples/mareas/app/puerto/[id]/page.ts +106 -0
  325. package/examples/mareas/app.ts +12 -0
  326. package/examples/mareas/elur.app.json +35 -0
  327. package/examples/mareas/entry.ts +11 -0
  328. package/examples/mareas/fonts/DejaVuSansMono-Bold.ttf +0 -0
  329. package/examples/mareas/fonts/DejaVuSansMono.ttf +0 -0
  330. package/examples/mareas/fonts/DejaVuSerif-Bold.ttf +0 -0
  331. package/examples/mareas/fonts/DejaVuSerif-Italic.ttf +0 -0
  332. package/examples/mareas/fonts/DejaVuSerif.ttf +0 -0
  333. package/examples/mareas/fonts/LICENSE-DejaVu.txt +187 -0
  334. package/examples/mareas/fonts.ts +6 -0
  335. package/examples/mareas/head.ts +12 -0
  336. package/examples/mareas/i18n.ts +163 -0
  337. package/examples/mareas/ports.ts +131 -0
  338. package/examples/mareas/routes.gen.ts +44 -0
  339. package/examples/mareas/serve.ts +70 -0
  340. package/examples/mareas/services.ts +5 -0
  341. package/examples/mareas/services.web.ts +6 -0
  342. package/examples/mareas/state.ts +64 -0
  343. package/examples/mareas/theme.ts +56 -0
  344. package/examples/mareas/ui/controls.ts +42 -0
  345. package/examples/mareas/ui/frame.ts +63 -0
  346. package/examples/mareas/ui/marigram.ts +52 -0
  347. package/examples/masonry/app.ts +32 -0
  348. package/examples/masonry/elur.app.json +8 -0
  349. package/examples/masonry/entry.ts +4 -0
  350. package/examples/natprobe/elur.app.json +8 -0
  351. package/examples/natprobe/entry.ts +196 -0
  352. package/examples/navdemo/app.ts +109 -0
  353. package/examples/navdemo/elur.app.json +8 -0
  354. package/examples/navdemo/entry.ts +7 -0
  355. package/examples/navtrans/elur.app.json +8 -0
  356. package/examples/navtrans/entry.ts +53 -0
  357. package/examples/platformview/app.ts +26 -0
  358. package/examples/platformview/elur.app.json +8 -0
  359. package/examples/sdui-demo/docs/home.envelope.json +588 -0
  360. package/examples/sdui-demo/docs/home.iife.json +582 -0
  361. package/examples/sdui-demo/elur.app.json +8 -0
  362. package/examples/sdui-demo/entry.ts +346 -0
  363. package/examples/select/elur.app.json +8 -0
  364. package/examples/select/entry.ts +20 -0
  365. package/examples/skiacanvas/app.ts +34 -0
  366. package/examples/skiacanvas/elur.app.json +8 -0
  367. package/examples/skiacanvas/entry.ts +4 -0
  368. package/examples/spans/elur.app.json +8 -0
  369. package/examples/spans/entry.ts +28 -0
  370. package/examples/ssr/app/about/page.ts +18 -0
  371. package/examples/ssr/app/items/[id]/page.ts +16 -0
  372. package/examples/ssr/app/layout.ts +21 -0
  373. package/examples/ssr/app/page.action.ts +10 -0
  374. package/examples/ssr/app/page.data.ts +5 -0
  375. package/examples/ssr/app/page.ts +95 -0
  376. package/examples/ssr/app/slow/loading.ts +10 -0
  377. package/examples/ssr/app/slow/page.data.ts +4 -0
  378. package/examples/ssr/app/slow/page.ts +16 -0
  379. package/examples/ssr/app/store.ts +3 -0
  380. package/examples/ssr/serve.ts +53 -0
  381. package/examples/statestyle/elur.app.json +8 -0
  382. package/examples/statestyle/entry.ts +25 -0
  383. package/examples/swipe/elur.app.json +8 -0
  384. package/examples/swipe/entry.ts +39 -0
  385. package/examples/tasks/app.ts +145 -0
  386. package/examples/tasks/elur.app.json +8 -0
  387. package/examples/uiwk/app.ts +288 -0
  388. package/examples/uiwk/elur.app.json +8 -0
  389. package/examples/uiwk/entry.ts +7 -0
  390. package/examples/vertical/app.ts +275 -0
  391. package/examples/vertical/elur.app.json +8 -0
  392. package/examples/vertical/entry.ts +31 -0
  393. package/examples/yogafeatures/app.ts +55 -0
  394. package/examples/yogafeatures/elur.app.json +8 -0
  395. package/examples/yogafeatures/entry.ts +4 -0
  396. package/native/cesm/README.md +94 -0
  397. package/native/cesm/adapters/hermes/HermesAdapter.h +432 -0
  398. package/native/cesm/adapters/quickjs/QuickJsAdapter.h +562 -0
  399. package/native/cesm/core/Bytes.h +236 -0
  400. package/native/cesm/core/Core.h +157 -0
  401. package/native/cesm/core/EngineAdapter.h +20 -0
  402. package/native/cesm/core/Region.h +77 -0
  403. package/native/cesm/core/Ring.h +99 -0
  404. package/native/cesm/core/Slots.h +132 -0
  405. package/native/cesm/core/Types.h +67 -0
  406. package/native/cesm/tests/CMakeLists.txt +50 -0
  407. package/native/cesm/tests/README.md +89 -0
  408. package/native/cesm/tests/compile_check_hermes.cpp +23 -0
  409. package/native/cesm/tests/test_core.cpp +101 -0
  410. package/native/cesm/tests/test_main.cpp +13 -0
  411. package/native/cesm/tests/test_quickjs_adapter.cpp +252 -0
  412. package/native/cesm/tests/test_ring.cpp +131 -0
  413. package/native/cesm/tests/test_slots.cpp +81 -0
  414. package/native/cesm/tests/test_sync.cpp +157 -0
  415. package/native/cesm/tests/test_util.h +24 -0
  416. package/native/layout/elur_layout_style.cpp +297 -0
  417. package/native/layout/elur_layout_style.h +36 -0
  418. package/native/layout-oracle/CMakeLists.txt +22 -0
  419. package/native/layout-oracle/oracle.cpp +140 -0
  420. package/native/rand/elur_random.h +43 -0
  421. package/native/skia-tree/elur_skia_tree.cpp +1293 -0
  422. package/native/skia-tree/elur_skia_tree.h +231 -0
  423. package/native/yoga/LICENSE +21 -0
  424. package/native/yoga/YGConfig.cpp +92 -0
  425. package/native/yoga/YGConfig.h +158 -0
  426. package/native/yoga/YGEnums.cpp +262 -0
  427. package/native/yoga/YGEnums.h +142 -0
  428. package/native/yoga/YGMacros.h +99 -0
  429. package/native/yoga/YGNode.cpp +366 -0
  430. package/native/yoga/YGNode.h +304 -0
  431. package/native/yoga/YGNodeLayout.cpp +92 -0
  432. package/native/yoga/YGNodeLayout.h +35 -0
  433. package/native/yoga/YGNodeStyle.cpp +405 -0
  434. package/native/yoga/YGNodeStyle.h +130 -0
  435. package/native/yoga/YGPixelGrid.cpp +22 -0
  436. package/native/yoga/YGPixelGrid.h +29 -0
  437. package/native/yoga/YGValue.cpp +20 -0
  438. package/native/yoga/YGValue.h +84 -0
  439. package/native/yoga/Yoga.h +21 -0
  440. package/native/yoga/algorithm/AbsoluteLayout.cpp +563 -0
  441. package/native/yoga/algorithm/AbsoluteLayout.h +41 -0
  442. package/native/yoga/algorithm/Align.h +72 -0
  443. package/native/yoga/algorithm/Baseline.cpp +78 -0
  444. package/native/yoga/algorithm/Baseline.h +21 -0
  445. package/native/yoga/algorithm/BoundAxis.h +79 -0
  446. package/native/yoga/algorithm/Cache.cpp +121 -0
  447. package/native/yoga/algorithm/Cache.h +30 -0
  448. package/native/yoga/algorithm/CalculateLayout.cpp +2428 -0
  449. package/native/yoga/algorithm/CalculateLayout.h +38 -0
  450. package/native/yoga/algorithm/FlexDirection.h +120 -0
  451. package/native/yoga/algorithm/FlexLine.cpp +124 -0
  452. package/native/yoga/algorithm/FlexLine.h +75 -0
  453. package/native/yoga/algorithm/PixelGrid.cpp +132 -0
  454. package/native/yoga/algorithm/PixelGrid.h +29 -0
  455. package/native/yoga/algorithm/SizingMode.h +73 -0
  456. package/native/yoga/algorithm/TrailingPosition.h +44 -0
  457. package/native/yoga/config/Config.cpp +135 -0
  458. package/native/yoga/config/Config.h +92 -0
  459. package/native/yoga/debug/AssertFatal.cpp +53 -0
  460. package/native/yoga/debug/AssertFatal.h +29 -0
  461. package/native/yoga/debug/Log.cpp +107 -0
  462. package/native/yoga/debug/Log.h +34 -0
  463. package/native/yoga/enums/Align.h +47 -0
  464. package/native/yoga/enums/BoxSizing.h +40 -0
  465. package/native/yoga/enums/Dimension.h +40 -0
  466. package/native/yoga/enums/Direction.h +41 -0
  467. package/native/yoga/enums/Display.h +41 -0
  468. package/native/yoga/enums/Edge.h +47 -0
  469. package/native/yoga/enums/Errata.h +41 -0
  470. package/native/yoga/enums/ExperimentalFeature.h +39 -0
  471. package/native/yoga/enums/FlexDirection.h +42 -0
  472. package/native/yoga/enums/Gutter.h +41 -0
  473. package/native/yoga/enums/Justify.h +44 -0
  474. package/native/yoga/enums/LogLevel.h +44 -0
  475. package/native/yoga/enums/MeasureMode.h +41 -0
  476. package/native/yoga/enums/NodeType.h +40 -0
  477. package/native/yoga/enums/Overflow.h +41 -0
  478. package/native/yoga/enums/PhysicalEdge.h +21 -0
  479. package/native/yoga/enums/PositionType.h +41 -0
  480. package/native/yoga/enums/Unit.h +42 -0
  481. package/native/yoga/enums/Wrap.h +41 -0
  482. package/native/yoga/enums/YogaEnums.h +85 -0
  483. package/native/yoga/event/event.cpp +87 -0
  484. package/native/yoga/event/event.h +130 -0
  485. package/native/yoga/node/CachedMeasurement.h +53 -0
  486. package/native/yoga/node/LayoutResults.cpp +48 -0
  487. package/native/yoga/node/LayoutResults.h +122 -0
  488. package/native/yoga/node/LayoutableChildren.h +148 -0
  489. package/native/yoga/node/Node.cpp +443 -0
  490. package/native/yoga/node/Node.h +337 -0
  491. package/native/yoga/numeric/Comparison.h +81 -0
  492. package/native/yoga/numeric/FloatOptional.h +93 -0
  493. package/native/yoga/style/SmallValueBuffer.h +133 -0
  494. package/native/yoga/style/Style.h +757 -0
  495. package/native/yoga/style/StyleLength.h +107 -0
  496. package/native/yoga/style/StyleValueHandle.h +98 -0
  497. package/native/yoga/style/StyleValuePool.h +127 -0
  498. package/package.json +111 -3
  499. package/src/adapters/kit-bridge.ts +72 -0
  500. package/src/adapters/kit-ssg.ts +219 -0
  501. package/src/adapters/kit-ssr.ts +577 -0
  502. package/src/adapters/kit-types.ts +28 -0
  503. package/src/adapters/request-adapter.ts +41 -0
  504. package/src/adapters/ssr-resolver.ts +177 -0
  505. package/src/adapters/web-history.ts +218 -0
  506. package/src/adapters/web-nav-executor.ts +72 -0
  507. package/src/animations/.gitkeep +0 -0
  508. package/src/animations/bindWorklets.ts +49 -0
  509. package/src/animations/captureCheck.ts +75 -0
  510. package/src/animations/compose.ts +127 -0
  511. package/src/animations/easing.ts +75 -0
  512. package/src/animations/gestureWorklets.ts +129 -0
  513. package/src/animations/index.ts +23 -0
  514. package/src/animations/runner.ts +404 -0
  515. package/src/animations/scrollWorklets.ts +48 -0
  516. package/src/animations/uiBindings.ts +83 -0
  517. package/src/animations/uiRunner.ts +449 -0
  518. package/src/animations/worklet.ts +157 -0
  519. package/src/animations/workletForm.ts +197 -0
  520. package/src/app/clock.ts +69 -0
  521. package/src/app/embedded.ts +232 -0
  522. package/src/app/index.ts +24 -0
  523. package/src/app/load-data.ts +36 -0
  524. package/src/app/mount.native.ts +18 -0
  525. package/src/app/mount.ts +26 -0
  526. package/src/app/mount.web.ts +21 -0
  527. package/src/app/state.ts +256 -0
  528. package/src/app/types.ts +146 -0
  529. package/src/app/web.ts +291 -0
  530. package/src/backends/native/hostAbi.ts +304 -0
  531. package/src/backends/native/index.ts +1132 -0
  532. package/src/backends/textInputProtocol.ts +111 -0
  533. package/src/backends/web/.gitkeep +0 -0
  534. package/src/backends/web/base-css.ts +148 -0
  535. package/src/backends/web/batcher.ts +162 -0
  536. package/src/backends/web/hydrate.ts +227 -0
  537. package/src/backends/web/index.ts +2231 -0
  538. package/src/backends/web/inspect.ts +80 -0
  539. package/src/backends/web/workerRunner.ts +513 -0
  540. package/src/context/index.ts +19 -0
  541. package/src/events.ts +139 -0
  542. package/src/forms/index.ts +264 -0
  543. package/src/hydration/.gitkeep +0 -0
  544. package/src/index.ts +169 -0
  545. package/src/ir/.gitkeep +0 -0
  546. package/src/ir/catalog.ts +166 -0
  547. package/src/ir/events.ts +54 -0
  548. package/src/ir/schema.ts +1103 -0
  549. package/src/ir/semantics.ts +189 -0
  550. package/src/ir/shortcut.ts +104 -0
  551. package/src/ir/signal-names.ts +27 -0
  552. package/src/ir/ui.ts +709 -0
  553. package/src/layout/.gitkeep +0 -0
  554. package/src/native/.gitkeep +0 -0
  555. package/src/native/binaryCodec.ts +230 -0
  556. package/src/native/codegen.ts +635 -0
  557. package/src/native/hostArtifacts.ts +386 -0
  558. package/src/native/http.ts +558 -0
  559. package/src/native/index.ts +54 -0
  560. package/src/native/manifest.ts +227 -0
  561. package/src/native/module.ts +1108 -0
  562. package/src/native/platformView.ts +107 -0
  563. package/src/native/pluginManifest.ts +269 -0
  564. package/src/native/sharedMemory.ts +168 -0
  565. package/src/native/specType.ts +164 -0
  566. package/src/native/tck.ts +436 -0
  567. package/src/native/trace.ts +97 -0
  568. package/src/native/webModule.ts +281 -0
  569. package/src/overlays/index.ts +579 -0
  570. package/src/platform.ts +89 -0
  571. package/src/primitives/controls.ts +725 -0
  572. package/src/primitives/index.ts +400 -0
  573. package/src/primitives/navigation.ts +407 -0
  574. package/src/reconciler/reconciler.ts +2857 -0
  575. package/src/router/guards.ts +129 -0
  576. package/src/router/index.ts +41 -0
  577. package/src/router/lifecycle.ts +133 -0
  578. package/src/router/match.ts +184 -0
  579. package/src/router/router.ts +508 -0
  580. package/src/router/screen-host.ts +918 -0
  581. package/src/router/state.ts +76 -0
  582. package/src/router/table.ts +55 -0
  583. package/src/router/transitions.ts +87 -0
  584. package/src/router/types.ts +161 -0
  585. package/src/runtime/environment.ts +332 -0
  586. package/src/runtime/wintertc-globals.ts +1067 -0
  587. package/src/sdui/a2ui.ts +1470 -0
  588. package/src/sdui/a2uiSurface.ts +214 -0
  589. package/src/sdui/client.ts +370 -0
  590. package/src/sdui/cryptoModule.ts +107 -0
  591. package/src/sdui/diagnostics.ts +39 -0
  592. package/src/sdui/downlevel.ts +375 -0
  593. package/src/sdui/envelope.ts +729 -0
  594. package/src/sdui/expr.ts +658 -0
  595. package/src/sdui/gateway.ts +223 -0
  596. package/src/sdui/httpModule.ts +29 -0
  597. package/src/sdui/index.ts +74 -0
  598. package/src/sdui/intents.ts +216 -0
  599. package/src/sdui/lower.ts +576 -0
  600. package/src/sdui/machines.ts +141 -0
  601. package/src/sdui/manifest.ts +167 -0
  602. package/src/sdui/oracle.ts +373 -0
  603. package/src/sdui/profile.ts +72 -0
  604. package/src/sdui/seqStore.ts +89 -0
  605. package/src/sdui/sign.ts +155 -0
  606. package/src/sdui/worklets.ts +164 -0
  607. package/src/ssr/html-applicator.ts +515 -0
  608. package/src/ssr/render-page.ts +264 -0
  609. package/src/store/index.ts +28 -0
  610. package/src/style/textInherit.ts +29 -0
  611. package/src/style/theme.ts +178 -0
  612. package/src/testing/index.ts +276 -0
  613. package/src/transport/.gitkeep +0 -0
  614. package/src/transport/format.ts +477 -0
  615. package/src/transport/wireSchema.ts +189 -0
  616. package/src/web.ts +31 -0
  617. package/targets/android/app/build.gradle.kts +192 -0
  618. package/targets/android/app/proguard-rules-elur.pro +12 -0
  619. package/targets/android/app/proguard-rules.pro +3 -0
  620. package/targets/android/app/src/main/AndroidManifest.xml +81 -0
  621. package/targets/android/app/src/main/cpp/CMakeLists.txt +117 -0
  622. package/targets/android/app/src/main/cpp/dlEncoder.h +117 -0
  623. package/targets/android/app/src/main/cpp/dlEncoderJsi.cpp +315 -0
  624. package/targets/android/app/src/main/cpp/dlEncoderQjs.cpp +394 -0
  625. package/targets/android/app/src/main/cpp/dlOps.inc +145 -0
  626. package/targets/android/app/src/main/cpp/elurBridge.cpp +1350 -0
  627. package/targets/android/app/src/main/cpp/elurBridgeHermes.cpp +1294 -0
  628. package/targets/android/app/src/main/cpp/elurSkia.cpp +287 -0
  629. package/targets/android/app/src/main/cpp/elurSkiaTree.cpp +448 -0
  630. package/targets/android/app/src/main/cpp/elurUiWorklet.cpp +1233 -0
  631. package/targets/android/app/src/main/cpp/elurYoga.cpp +1060 -0
  632. package/targets/android/app/src/main/cpp/elurYoga.h +82 -0
  633. package/targets/android/app/src/main/cpp/hermes-libs/LICENSE +21 -0
  634. package/targets/android/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
  635. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +276 -0
  636. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +97 -0
  637. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +502 -0
  638. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +107 -0
  639. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +145 -0
  640. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +193 -0
  641. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +211 -0
  642. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +40 -0
  643. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +14 -0
  644. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +27 -0
  645. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +141 -0
  646. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +270 -0
  647. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +64 -0
  648. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +1566 -0
  649. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +37 -0
  650. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +75 -0
  651. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +23 -0
  652. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +334 -0
  653. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +328 -0
  654. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +131 -0
  655. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +73 -0
  656. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +89 -0
  657. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +135 -0
  658. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +280 -0
  659. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +137 -0
  660. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +107 -0
  661. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +140 -0
  662. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +71 -0
  663. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +40 -0
  664. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +82 -0
  665. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +72 -0
  666. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +1279 -0
  667. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +313 -0
  668. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +38 -0
  669. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +77 -0
  670. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +127 -0
  671. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +138 -0
  672. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +24 -0
  673. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +20 -0
  674. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +23 -0
  675. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +44 -0
  676. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +123 -0
  677. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +29 -0
  678. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +24 -0
  679. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +23 -0
  680. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +30 -0
  681. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +113 -0
  682. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +242 -0
  683. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +52 -0
  684. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +295 -0
  685. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +25 -0
  686. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +642 -0
  687. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +29 -0
  688. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +41 -0
  689. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +12 -0
  690. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +8516 -0
  691. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +137 -0
  692. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +3945 -0
  693. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +119 -0
  694. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +124 -0
  695. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +66 -0
  696. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +456 -0
  697. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +26 -0
  698. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +1157 -0
  699. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +242 -0
  700. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +132 -0
  701. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +434 -0
  702. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +2266 -0
  703. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +59 -0
  704. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +79 -0
  705. package/targets/android/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +1111 -0
  706. package/targets/android/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
  707. package/targets/android/app/src/main/java/com/elur/universal/BinaryCodec.kt +121 -0
  708. package/targets/android/app/src/main/java/com/elur/universal/DlDecoder.kt +260 -0
  709. package/targets/android/app/src/main/java/com/elur/universal/DlOpsDecode.kt +158 -0
  710. package/targets/android/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +161 -0
  711. package/targets/android/app/src/main/java/com/elur/universal/ElurBridge.kt +238 -0
  712. package/targets/android/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +223 -0
  713. package/targets/android/app/src/main/java/com/elur/universal/ElurCanvasView.kt +202 -0
  714. package/targets/android/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +206 -0
  715. package/targets/android/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +185 -0
  716. package/targets/android/app/src/main/java/com/elur/universal/ElurEditText.kt +17 -0
  717. package/targets/android/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +190 -0
  718. package/targets/android/app/src/main/java/com/elur/universal/ElurHttpModule.kt +306 -0
  719. package/targets/android/app/src/main/java/com/elur/universal/ElurImageService.kt +348 -0
  720. package/targets/android/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +84 -0
  721. package/targets/android/app/src/main/java/com/elur/universal/ElurListView.kt +954 -0
  722. package/targets/android/app/src/main/java/com/elur/universal/ElurManifest.kt +117 -0
  723. package/targets/android/app/src/main/java/com/elur/universal/ElurMetrics.kt +325 -0
  724. package/targets/android/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +14 -0
  725. package/targets/android/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +36 -0
  726. package/targets/android/app/src/main/java/com/elur/universal/ElurRenderer.kt +6112 -0
  727. package/targets/android/app/src/main/java/com/elur/universal/ElurRowYoga.kt +130 -0
  728. package/targets/android/app/src/main/java/com/elur/universal/ElurScrollView.kt +240 -0
  729. package/targets/android/app/src/main/java/com/elur/universal/ElurShellView.kt +117 -0
  730. package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +162 -0
  731. package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +968 -0
  732. package/targets/android/app/src/main/java/com/elur/universal/ElurStateModule.kt +69 -0
  733. package/targets/android/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +34 -0
  734. package/targets/android/app/src/main/java/com/elur/universal/ElurTckModule.kt +99 -0
  735. package/targets/android/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +16 -0
  736. package/targets/android/app/src/main/java/com/elur/universal/ElurTrace.kt +24 -0
  737. package/targets/android/app/src/main/java/com/elur/universal/ElurUiModule.kt +48 -0
  738. package/targets/android/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +305 -0
  739. package/targets/android/app/src/main/java/com/elur/universal/JsBridge.kt +67 -0
  740. package/targets/android/app/src/main/java/com/elur/universal/JsThread.kt +189 -0
  741. package/targets/android/app/src/main/java/com/elur/universal/MainActivity.kt +844 -0
  742. package/targets/android/app/src/main/java/com/elur/universal/ModuleRegistry.kt +701 -0
  743. package/targets/android/app/src/main/java/com/elur/universal/YogaRowScope.kt +97 -0
  744. package/targets/android/app/src/main/res/values/ids.xml +10 -0
  745. package/targets/android/app/src/main/res/values/strings.xml +8 -0
  746. package/targets/android/app/src/main/res/values-es/strings.xml +5 -0
  747. package/targets/android/app/src/main/res/xml/network_security_config.xml +10 -0
  748. package/targets/android/build.gradle.kts +5 -0
  749. package/targets/android/gradle/libs.versions.toml +12 -0
  750. package/targets/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  751. package/targets/android/gradle/wrapper/gradle-wrapper.properties +8 -0
  752. package/targets/android/gradle.properties +23 -0
  753. package/targets/android/gradlew +251 -0
  754. package/targets/android/gradlew.bat +94 -0
  755. package/targets/android/settings.gradle.kts +32 -0
  756. package/targets/web/.gitkeep +0 -0
  757. package/targets/web/index.html +13 -0
@@ -0,0 +1,1132 @@
1
+ // Backend nativo compartido — lado JS del aplicador (Capa 4) para todo
2
+ // host embebido (Android hoy; iOS/desktop nativo mañana — ADR-0101).
3
+ // DOM-free: recibe DisplayOps del reconciler y los empuja al host object
4
+ // `ElurBridge` que el runtime nativo (QuickJS-ng/Hermes) registra en
5
+ // globalThis. La mitad host (aplicación a Views/Widgets) vive en
6
+ // targets/<p> — p.ej. ElurRenderer.kt en Android. El archivo no lleva
7
+ // nada Android-específico: la divergencia por plataforma entra por los
8
+ // métodos opcionales del bridge (supportsNativeList?/supportsSkia?/…)
9
+ // o por archivo `X.<plat>.ts` si el contrato no alcanza.
10
+ //
11
+ // Contrato con el lado nativo (elurBridge.cpp):
12
+ // JS → nativo: ElurBridge.flush(json) — Display List JSON por frame
13
+ // ElurBridge.flushBinary(bytes) — Display List binario (ABI v3)
14
+ // ElurBridge.flushOps(f, ops) — P1-ENC: encode nativo + apply
15
+ // ElurBridge.requestFrame() — frame source (Choreographer)
16
+ // ElurBridge.setTimer(id, ms) / clearTimer(id) — ADR-0134
17
+ // ElurBridge.openUrl(url) — href externo (ADR-0133)
18
+ // ElurBridge.colorScheme() — esquema del SO (ADR-0132)
19
+ // nativo → JS: __elurCallHandler(name) — evento discreto
20
+ // __elurCallHandlerWithString(n,v) — evento con payload (input)
21
+ // __elurFlush() — pide flush pendiente
22
+ // __elur_commit_ack (payload=frame) — ack de commit aplicado
23
+ // __elur_frame — callback de frame
24
+ // __elur_timer (payload=id) — disparo de timer
25
+ // __elur_scheme (payload=light|dark) — cambio de uiMode
26
+ // CONTRATO R3.4: el bundle embebido solo puede consultar estos nombres —
27
+ // el resto del host object no es API. Fuera de ElurBridge: Promise,
28
+ // Date.now, JSON, parseInt, console.* (warn/error). setTimeout/
29
+ // setInterval los instala este backend sobre setTimer (ADR-0134).
30
+ // Nada de DOM/URL/fetch.
31
+ // → tick del WorkletRunner (ADR-0025 MainThreadRunner).
32
+ //
33
+ // R2.3/R2.4/R2.5 — outbound lane:
34
+ // · commitId = `frame` (monotónico por host); el nativo confirma la
35
+ // aplicación con __elur_commit_ack — pendingAcks mide el lag.
36
+ // · surfaceEpoch vive en el host: los apply posteados tras destroy se
37
+ // descartan allí (ElurRenderer.destroyed) — no viaja por el wire.
38
+ // · Continuo = update-text/style/props por (op,id): latest-wins con
39
+ // merge in-place dentro del batch del frame — nunca se descartan
40
+ // estructurales ni discretos (la semántica no se puede dropear;
41
+ // el desborde se cuenta en metrics.droppedContinuous).
42
+
43
+ import type { DisplayOp } from "../../transport/format";
44
+ import { DL_ABI_VERSION, encodeDisplayList } from "../../transport/format";
45
+ import { IR_VERSION } from "../../ir/schema";
46
+ import { NAV_STATE_VERSION } from "../../router/types";
47
+ import { parseEnvelope } from "../../events";
48
+ import { createMainThreadRunner, setWorkletRunner } from "../../animations/runner";
49
+ import { createUiThreadRunner, type UiWorkletBridge } from "../../animations/uiRunner";
50
+ import { createModuleRuntime, moduleError } from "../../native/module";
51
+ import type { ModuleRuntime } from "../../native/module";
52
+ import { setSystemColorScheme } from "../../style/theme";
53
+ import { setAppState } from "../../router/lifecycle";
54
+ import { Platform } from "../../platform";
55
+ import {
56
+ disposeSharedRegions,
57
+ resolveSharedMarker,
58
+ } from "../../native/sharedMemory";
59
+ import {
60
+ ElurAbortController,
61
+ ElurAbortSignal,
62
+ ElurCustomEvent,
63
+ ElurEvent,
64
+ ElurEventTarget,
65
+ ElurTextDecoder,
66
+ ElurTextEncoder,
67
+ ElurURL,
68
+ ElurURLSearchParams,
69
+ elurGetRandomValues,
70
+ elurRandomUUID,
71
+ elurStructuredClone,
72
+ installWinterTCGlobals,
73
+ } from "../../runtime/wintertc-globals";
74
+
75
+ import {
76
+ ElurHeaders,
77
+ ElurRequest,
78
+ ElurResponse,
79
+ universalFetch,
80
+ setHttpBaseUrl,
81
+ getHttpBaseUrl,
82
+ setHttpAdapter,
83
+ setHostHttpEntry,
84
+ clearHostHttpEntry,
85
+ httpModuleDef,
86
+ resolveHttpUrl,
87
+ installFetchGlobals,
88
+ } from "../../native/http";
89
+ import {
90
+ clearNodeMeasureResolver,
91
+ setNodeMeasureResolver,
92
+ uiModuleDef,
93
+ type NodeMeasureResolver,
94
+ } from "../../runtime/environment";
95
+
96
+ export {
97
+ ElurAbortController,
98
+ ElurAbortSignal,
99
+ ElurCustomEvent,
100
+ ElurEvent,
101
+ ElurEventTarget,
102
+ ElurTextDecoder,
103
+ ElurTextEncoder,
104
+ ElurURL,
105
+ ElurURLSearchParams,
106
+ elurGetRandomValues,
107
+ elurRandomUUID,
108
+ elurStructuredClone,
109
+ installWinterTCGlobals,
110
+ ElurHeaders,
111
+ ElurRequest,
112
+ ElurResponse,
113
+ universalFetch,
114
+ setHttpBaseUrl,
115
+ getHttpBaseUrl,
116
+ setHttpAdapter,
117
+ resolveHttpUrl,
118
+ installFetchGlobals,
119
+ };
120
+
121
+ installWinterTCGlobals();
122
+ installFetchGlobals();
123
+
124
+ // Tipo del host object nativo (lo provee el .cpp — no es código nuestro)
125
+ interface NativeBridge {
126
+ flush(json: string): void;
127
+ flushBinary?(bytes: ArrayBuffer): void;
128
+ /** P1-ENC: encode en C++ + apply directo — evita el ArrayBuffer JS. */
129
+ flushOps?(frame: number, ops: DisplayOp[]): void;
130
+ /** ADR-0025: postea un frame callback nativo → __elur_frame. */
131
+ requestFrame?(): void;
132
+ /** ADR-0134: arma (o re-arma) el timer `id` → `__elur_timer` tras `ms`. */
133
+ setTimer?(id: number, ms: number): void;
134
+ clearTimer?(id: number): void;
135
+ /** ADR-0133: abre una URL externa con la app del sistema. */
136
+ openUrl?(url: string): void;
137
+ /** ADR-0132: esquema del SO "light"|"dark" (Configuration.uiMode). */
138
+ colorScheme?(): string;
139
+ /** Docs §3.16: ms fijados por `-e now` (paridad geométrica) o ≤0. */
140
+ debugNow?(): number;
141
+ /**
142
+ * ADR-0054: el host declara la cap "native-list" — entiende las ops
143
+ * set-list-template / set-list-items / list-splice / list-update /
144
+ * list-move y posee ventana+recycle+bind a nivel item. Sin el método
145
+ * el reconciler usa el path JS (ventana + pool estructural).
146
+ */
147
+ supportsNativeList?(): boolean;
148
+ /**
149
+ * ADR-0123: el host declara la cap "skia" — `canvas` con
150
+ * renderPolicy:"custom" pinta vía libelur-skia.so (raster CPU).
151
+ * Sin el método, degrada a Platform Views con warn.
152
+ */
153
+ supportsSkia?(): boolean;
154
+ /**
155
+ * ADR-0194: cap "skia-tree" — el host puede pintar el árbol de
156
+ * render completo vía `native/skia-tree` (surface "custom").
157
+ * Sin el método, esa superficie degrada a Platform Views con warn.
158
+ */
159
+ supportsSkiaTree?(): boolean;
160
+ /**
161
+ * ADR-0194 — backend del carril Skia-árbol que el host usaría
162
+ * ("raster" | "gl" | "vulkan"); "" = sin lib. Descriptor
163
+ * declarativo, no gate — la selección de superficie es del host.
164
+ */
165
+ skiaBackend?(): string;
166
+ /**
167
+ * ADR-0043/0051/0076: invoca un comando de módulo nativo. El host
168
+ * responde por `__elur_module_result` con
169
+ * `{callId,ok,data|error}` — asíncrono, nunca bloquea el hilo JS.
170
+ * module="__elur_module_ctl" es el canal de control reservado
171
+ * (handshake/subscribe/unsubscribe) — el registry del host lo
172
+ * atiende internamente.
173
+ */
174
+ callCommand?(callId: number, module: string, command: string, argsJson: string): void;
175
+ /** Petición de cancelación cooperativa (el host puede ignorarla). */
176
+ cancelCommand?(callId: number): void;
177
+ /**
178
+ * ADR-0191: canal de errores de producción JS→host. `kind` del
179
+ * vocabulario cerrado ("session-overflow" | "session-close" |
180
+ * "unhandled-rejection" | "js-stall" | "prev-exit" | "engine-init");
181
+ * `json` lleva solo contadores/ids — nunca payloads de app (sin PII
182
+ * por diseño). Opcional: sin el método la sesión corre igual, los
183
+ * eventos solo quedan en [metrics-js].
184
+ */
185
+ reportError?(kind: string, json: string): void;
186
+ /**
187
+ * ADR-0087/R6.2 — cap "ui-worklet": segundo contexto QuickJS-ng en
188
+ * el hilo de UI. Su presencia instala el UIThreadRunner; ausente
189
+ * (host legacy) el MainThreadRunner queda como fallback declarado.
190
+ * El contexto UI es QuickJS siempre — Hermes lo declara también
191
+ * vía elurBridgeHermes (el spec viaja con `__src`, ADR-0088).
192
+ * Resultados por el handler reservado "__elur_uiwk".
193
+ */
194
+ uiWorkletStart?(specJson: string): void;
195
+ uiWorkletCancel?(id: string): void;
196
+ /** Sync main→UI de un signal capturado por un worklet vivo. */
197
+ uiWorkletSyncSignal?(name: string, v: number): void;
198
+ /** Teardown de sesión del contexto UI (cancela todo lo vivo). */
199
+ uiWorkletReset?(): void;
200
+ /**
201
+ * ADR-0188 — cap "worklet-quota": el host acota la CPU del runtime
202
+ * por llamada a fn de worklet (interrupt handler en QuickJS). El
203
+ * runner arma antes de invocar y desarma en finally; un bucle del
204
+ * firmante corta por InternalError y el worklet se cancela. Ausente,
205
+ * el runner corre sin cuota (web/hosts legacy — declarado, no
206
+ * silencio: el contexto UI sí tiene cuota propia siempre).
207
+ */
208
+ workletArm?(polls?: number): void;
209
+ workletDisarm?(): void;
210
+ /**
211
+ * Identidad del motor DECLARADA por el host al registrar el bridge
212
+ * (ADR-0044): "quickjs-ng" | "hermes" | … El runtime nunca la
213
+ * infiere del global (la heurística HermesInternal informaba
214
+ * "quickjs" bajo cualquier engine sin el global — p.ej. Bun/JSC).
215
+ */
216
+ engine?: string;
217
+ /**
218
+ * Plataforma DECLARADA por el host (mismo patrón que `engine`):
219
+ * "android" | "ios" | "linux" | "windows" | "desktop". Alimenta el
220
+ * fallback de `Platform.OS` sin define (tests/dev) — en bundle el
221
+ * define gana siempre. Ausente, el fallback legacy es "android".
222
+ */
223
+ platform?: string;
224
+ /** ADR-0172: versión de la superficie que el host implementa —
225
+ * ≠ BRIDGE_ABI_VERSION → createEmbeddedHost lanza (fail-loud). */
226
+ bridgeAbi?: number;
227
+ /** ADR-0187 — topología de hilos declarada por el host:
228
+ * `"S"` = ejecutor `js` y `ui` son el mismo hilo; `"D"` = hilos
229
+ * distintos. Identidad declarada (patrón `engine`/`platform`),
230
+ * nunca inferida. */
231
+ threadModel?: string;
232
+ }
233
+
234
+ declare const ElurBridge: NativeBridge;
235
+
236
+ /** Versión de la superficie del host object `ElurBridge` (ADR-0158):
237
+ * el conjunto de métodos + firmas + semántica de hilos, tabulado en
238
+ * hostAbi.ts (Apéndice I). Distinta de los contratos de datos que
239
+ * viajan sobre ella (IR, DL ABI, eventos): el host la declara en
240
+ * `ElurBridge.bridgeAbi` y createEmbeddedHost la compara — un host de
241
+ * otra versión falla en voz alta, no en el primer flush (ADR-0172). */
242
+ export const BRIDGE_ABI_VERSION = 1;
243
+
244
+ /**
245
+ * Capacidades del host object declaradas por presencia de método —
246
+ * nunca asumidas (ADR-0044). Un host sin flushBinary solo tiene el
247
+ * carril JSON; sin requestFrame el batching cae al microtask.
248
+ */
249
+ export interface HostCapabilities {
250
+ flushJson: boolean;
251
+ flushBinary: boolean;
252
+ flushOps: boolean;
253
+ requestFrame: boolean;
254
+ /** ADR-0054 — ops de lista nativa (nivel item) soportadas. */
255
+ nativeList: boolean;
256
+ /** ADR-0087 — segundo contexto JS en el hilo UI para worklets. */
257
+ uiWorklet: boolean;
258
+ /** ADR-0123 — backend raster Skia para `canvas` renderPolicy:"custom". */
259
+ skia: boolean;
260
+ /** ADR-0194 — render-tree completo vía native/skia-tree (surface "custom"). */
261
+ skiaTree: boolean;
262
+ /** ADR-0188 — cuota CPU por llamada a worklet en el runtime principal. */
263
+ workletQuota: boolean;
264
+ /** ADR-0191 — canal de errores de producción JS→host. */
265
+ reportError: boolean;
266
+ }
267
+
268
+ /**
269
+ * Descriptor explícito del runtime embebido (ADR-0044): lo que el
270
+ * host dice ser y lo que expone. `engine` viene del bridge (o del
271
+ * opts del composition root); las caps se leen del bridge real.
272
+ */
273
+ export interface RuntimeDescriptor {
274
+ ir: number;
275
+ dlAbi: number;
276
+ nav: number;
277
+ /** ADR-0158 — versión de la ABI de host ElurBridge del bundle. */
278
+ bridgeAbi: number;
279
+ /** ADR-0172 — la que declara el host (`null` = no declara). */
280
+ hostBridgeAbi: number | null;
281
+ engine: string;
282
+ /** ADR-0101/0182 — plataforma del artefacto (define de build o
283
+ * detección por globals). Viaja en el handshake SDUI: el gateway
284
+ * baja el documento contra la columna de esta plataforma. */
285
+ platform: string;
286
+ /** ADR-0182 — versión del dialecto SDUI que el bundle baja por sí
287
+ * mismo; ausente = cliente IR plano. Lo declara el composition
288
+ * root (`opts.sdui`), nunca inferido — mismo patrón que `engine`. */
289
+ sdui?: number;
290
+ /** ADR-0187 — topología de hilos del host: `"S"` = el ejecutor `js`
291
+ * y el `ui` son el mismo hilo (perfil S — carril de reentrancia
292
+ * del TCK obligatorio); `"D"` = hilos distintos (perfil D —
293
+ * carril de orden/interleaving). Identidad declarada por el
294
+ * bridge (`ElurBridge.threadModel`), nunca inferida; ausente →
295
+ * "unknown". */
296
+ threadModel?: string;
297
+ /** ADR-0194 — backend del carril Skia-árbol que declara el host
298
+ * ("raster" | "gl" | "vulkan"); ausente = sin lib o sin
299
+ * declaración. No es un booleano de caps: es descriptor. */
300
+ skiaBackend?: string;
301
+ caps: HostCapabilities;
302
+ }
303
+
304
+ /**
305
+ * V13 — ciclo de vida de la sesión JS (el análogo DOM-free de la
306
+ * sesión nativa de JsThread). Transiciones:
307
+ *
308
+ * init → active → suspended ⇄ active → closing → closed
309
+ *
310
+ * `init`: construido, globals aún no registrados.
311
+ * `active`: recibe emit/dispatchEvent normalmente.
312
+ * `suspended`: pausa el frame source (emit acumula sin programar
313
+ * flush; resume() lo programa) — para background del host.
314
+ * `closing`/`closed`: emit y dispatchEvent son no-op contados en
315
+ * metrics.droppedAfterClose — trabajo tardío nunca toca el bridge
316
+ * ni re-enciende scheduling. close() además suelta globals y el
317
+ * worklet runner: una segunda sesión sobre el mismo globalThis no
318
+ * hereda handlers ni cbs de la anterior.
319
+ */
320
+ export type SessionState =
321
+ "init" | "active" | "suspended" | "closing" | "closed";
322
+
323
+ export interface EmbeddedHost {
324
+ emit: (op: DisplayOp) => void;
325
+ flush: () => void;
326
+ /** ADR-0133 — URL externa → app del sistema (no-op sin la cap). */
327
+ openUrl: (url: string) => void;
328
+ /** ADR-0200 — activa/desactiva la intercepción nativa de Back/Escape cuando hay overlays/guards. */
329
+ setBackIntercept: (active: boolean) => void;
330
+ dispatchEvent: (handlerName: string, payload?: string) => void;
331
+ /** Estado de sesión (V13) — ver SessionState. */
332
+ state: () => SessionState;
333
+ suspend: () => void;
334
+ resume: () => void;
335
+ /** Cierre idempotente: drop de pendientes, desinstala el runner y
336
+ * borra los globals __elur_* — nada sobrevive a la sesión. */
337
+ close: () => void;
338
+ /**
339
+ * Métricas de sesión (R2.5 + R4.1): profundidad/coalescencia/acks del
340
+ * lane outbound + tiempos del hilo JS (activo vs espera en cola),
341
+ * ops/bytes reales post-coalesce, latencia de ack, eventos de sesión
342
+ * (ring ≤64) y `screen` (contadores del reconciler vivo via
343
+ * `opts.gauges` — nodos/effects/worklets/idMap). Snapshot puro —
344
+ * el push lo hace flush()/close() por console.log("[metrics-js]").
345
+ */
346
+ metrics: () => {
347
+ depth: number;
348
+ maxDepth: number;
349
+ commits: number;
350
+ acked: number;
351
+ pendingAcks: number;
352
+ coalescedOps: number;
353
+ droppedContinuous: number;
354
+ emittedOps: number;
355
+ /** Frames cuyo flush se difirió al próximo ack (backpressure). */
356
+ deferredByAck: number;
357
+ /** Ops/eventos llegados tras close() — se descartan, se cuentan. */
358
+ droppedAfterClose: number;
359
+ /** U09: desbordes de la cota dura — sesión pasó a closing. */
360
+ overflowFailed: number;
361
+ /** Payloads JSON inválidos en canales reservados del host
362
+ * (`__elur_module_*`, `__elur_uiwk`) — bug del host: se
363
+ * descartan con console.error; el TCK exige 0. */
364
+ hostProtocolErrors: number;
365
+ /** Ops que sí viajaron al host (post-coalesce). */
366
+ opsSent: number;
367
+ /** Bytes serializados en JS (carriles json/binario; flushOps
368
+ * codifica en C++ — no cuenta bytes aquí). */
369
+ bytesSent: number;
370
+ /** ms dentro de cbs de frame + flush — "JS activo" (R4.1). */
371
+ jsActiveMs: number;
372
+ /** ms primer emit → flush por commit — espera en cola JS (R4.1). */
373
+ queueWaitMs: number;
374
+ /** ms de encode JS (encodeDisplayList/JSON.stringify). */
375
+ encodeMs: number;
376
+ ackLatencyAvgMs: number;
377
+ ackSamples: number;
378
+ /** Ring de eventos de sesión (cola ≤64): suspend/resume/close/… */
379
+ events: Array<{ t: number; ev: string }>;
380
+ /** Invocaciones de handlers de app (dispatchEvent fuera de
381
+ * __elur_*) — volumen UI→JS real de la sesión (R4.1). */
382
+ handlersInvoked: number;
383
+ /** Contadores del reconciler vivo (opts.gauges) — {} sin wiring. */
384
+ screen: Record<string, number>;
385
+ };
386
+ /**
387
+ * R7.3 — descriptor del contrato que este runtime publica: el host
388
+ * nativo lo consulta en diagnóstico (un mismatch de ABI ya falla
389
+ * ruidoso en el decoder; esto lo hace VISIBLE antes del fallo).
390
+ * `engine` lo declara el host (bridge.engine o opts) — "unknown"
391
+ * cuando ninguno lo declara (ADR-0044).
392
+ */
393
+ versions: () => RuntimeDescriptor;
394
+ /**
395
+ * ADR-0043/0051: runtime de módulos nativos del SDK. `register(def)`
396
+ * instala un plugin validado contra NATIVE_ABI_VERSION;
397
+ * `invoke()` viaja por `ElurBridge.callCommand` y el resultado
398
+ * vuelve por el handler reservado `__elur_module_result`.
399
+ */
400
+ modules: ModuleRuntime;
401
+ }
402
+
403
+ /** Cota dura del lane outbound (U09): emit() nunca publica por cuenta —
404
+ * el único punto de admisión es flush() en la frontera de frame o ack.
405
+ * Un productor que excede la cota con el consumidor detenido falla
406
+ * explícito (sesión closing): ni cola ilimitada ni descarte del estado
407
+ * final ni lotes estructurales publicados a medias por un número
408
+ * mágico. */
409
+ const HARD_PENDING = 65536;
410
+ /** Commits en vuelo sin ack tolerados (V04): por encima el lane difiere
411
+ * el flush al próximo ack — el runnable queue del host no crece sin
412
+ * límite. Solo aplica si el host demostró soportar acks. */
413
+ const MAX_IN_FLIGHT = 4;
414
+
415
+ /** Ops coalescibles por (op,id): valores continuos — style/props/text.
416
+ * Structural y eventos discretos quedan fuera por diseño. */
417
+ function mergeableKey(op: DisplayOp): string | undefined {
418
+ const id = (op as { id?: number }).id;
419
+ if (id === undefined) return undefined;
420
+ switch (op.op) {
421
+ case "update-text":
422
+ case "update-style":
423
+ case "update-props":
424
+ case "update-platform-view-props":
425
+ return `${op.op}:${id}`;
426
+ case "list-update": {
427
+ // U09: dos patches al mismo item en un frame se fusionan —
428
+ // fields latest-wins por campo, removed ∪ menos reañadidos.
429
+ const key = (op as { key?: string }).key;
430
+ return key === undefined ? undefined : `${op.op}:${id}:${key}`;
431
+ }
432
+ default:
433
+ return undefined;
434
+ }
435
+ }
436
+
437
+ /** Merge in-place de una op continua nueva sobre la ya pendiente (R2.4):
438
+ * text reemplaza; style/props mergean por clave — nada se pierde. */
439
+ function mergeInto(prev: DisplayOp, next: DisplayOp): void {
440
+ if (next.op === "update-text") {
441
+ (prev as { value?: unknown }).value = (next as { value?: unknown }).value;
442
+ } else if (next.op === "update-style") {
443
+ const p = prev as { style?: Record<string, unknown> };
444
+ p.style = Object.assign(p.style ?? {}, (next as { style?: object }).style);
445
+ } else if (next.op === "list-update") {
446
+ // Semántica de patch secuencial: fields del nuevo ganan por
447
+ // campo; un campo re-añadido por el patch nuevo sale de removed.
448
+ const p = prev as { fields?: Record<string, unknown>; removed?: string[] };
449
+ const n = next as { fields?: Record<string, unknown>; removed?: string[] };
450
+ p.fields = Object.assign(p.fields ?? {}, n.fields);
451
+ if (n.removed?.length || p.removed?.length) {
452
+ const rem = new Set(p.removed ?? []);
453
+ for (const r of n.removed ?? []) rem.add(r);
454
+ for (const f of Object.keys(n.fields ?? {})) rem.delete(f);
455
+ p.removed = [...rem];
456
+ }
457
+ } else {
458
+ const p = prev as { changedProps?: Record<string, unknown> };
459
+ p.changedProps = Object.assign(
460
+ p.changedProps ?? {}, (next as { changedProps?: object }).changedProps,
461
+ );
462
+ }
463
+ }
464
+
465
+ export { createTextInputProtocol } from "../textInputProtocol";
466
+
467
+ /**
468
+ * Crea el host embebido: batching por frame + dispatch de handlers.
469
+ * `handlers` es el registro de la app (nombre → función JS).
470
+ * `opts.engine` declara el motor cuando el host object no lo expone
471
+ * (tests, bridge legacy) — tiene prioridad sobre `bridge.engine`.
472
+ */
473
+ export function createEmbeddedHost(
474
+ handlers: Record<string, (e?: unknown) => void>,
475
+ opts?: {
476
+ engine?: string;
477
+ /** ADR-0182 — el bundle incluye la capa SDUI con esta versión
478
+ * del dialecto; se publica en `versions().sdui` para el
479
+ * handshake del gateway. Ausente = cliente IR plano. */
480
+ sdui?: number;
481
+ /**
482
+ * R4.1 — fuente de contadores del mundo vivo (reconciler de la
483
+ * pantalla/instancia): se invoca en cada snapshot y se publica
484
+ * bajo `metrics().screen`. mountEmbeddedApp la cablea; ausente
485
+ * = {} (un host sin app encima no inventa ceros).
486
+ */
487
+ gauges?: () => Record<string, number>;
488
+ },
489
+ ): EmbeddedHost {
490
+ // ADR-0172: superficie declarada por el host ≠ la del bundle →
491
+ // fail-loud antes de registrar nada. Ausente = host previo a la
492
+ // declaración (se acepta; el TCK de sesión la exige).
493
+ const declaredAbi = typeof ElurBridge !== "undefined"
494
+ ? ElurBridge.bridgeAbi : undefined;
495
+ if (typeof declaredAbi === "number" && declaredAbi !== BRIDGE_ABI_VERSION) {
496
+ throw new Error(
497
+ `[elur] ElurBridge.bridgeAbi=${declaredAbi} ≠ BRIDGE_ABI_VERSION ` +
498
+ `${BRIDGE_ABI_VERSION} del bundle — host y bundle de superficies distintas`);
499
+ }
500
+ let pending: DisplayOp[] = [];
501
+ let frame = 0;
502
+ let flushScheduled = false;
503
+ // Callbacks de frame pendientes (worklet runner) — el nativo despacha
504
+ // "__elur_frame" una vez por requestFrame; se re-suscriben por frame.
505
+ let frameCbs: Array<(now: number) => void> = [];
506
+ // ADR-0087: runner UI instalado si el host declara la cap — el
507
+ // handler "__elur_uiwk" entrega sus resultados; close() lo dispone.
508
+ let uiRunner: ReturnType<typeof createUiThreadRunner> | undefined;
509
+
510
+ // ADR-0134 — timers sobre el host: setTimeout/setInterval globales
511
+ // armados con ElurBridge.setTimer. En `suspended` los disparos se
512
+ // aparcan y salen una vez en resume(); close() los cancela todos.
513
+ const timers = new Map<number, { fn: () => void; every: number }>();
514
+ const parkedTimers: number[] = [];
515
+ let timerSeq = 1;
516
+ const nativeTimers = typeof ElurBridge !== "undefined" && !!ElurBridge.setTimer;
517
+ const fireTimer = (id: number) => {
518
+ const t = timers.get(id);
519
+ if (!t) return;
520
+ if (t.every >= 0) ElurBridge.setTimer!(id, t.every);
521
+ else timers.delete(id);
522
+ try { t.fn(); } catch (e) { console.error("[elur] timer:", e); }
523
+ };
524
+ if (nativeTimers) {
525
+ const g = globalThis as Record<string, unknown>;
526
+ const add = (fn: unknown, ms: unknown, every: boolean, args: unknown[]) => {
527
+ const id = timerSeq++;
528
+ const delay = Math.max(every ? 1 : 0, Number(ms) | 0);
529
+ timers.set(id, {
530
+ fn: () => { if (typeof fn === "function") fn(...args); },
531
+ every: every ? delay : -1,
532
+ });
533
+ ElurBridge.setTimer!(id, delay);
534
+ return id;
535
+ };
536
+ const clear = (id: unknown) => {
537
+ if (timers.delete(Number(id))) ElurBridge.clearTimer?.(Number(id));
538
+ };
539
+ g.setTimeout = (fn: unknown, ms?: unknown, ...args: unknown[]) => add(fn, ms, false, args);
540
+ g.setInterval = (fn: unknown, ms?: unknown, ...args: unknown[]) => add(fn, ms, true, args);
541
+ g.clearTimeout = clear;
542
+ g.clearInterval = clear;
543
+ }
544
+ installWinterTCGlobals();
545
+
546
+ // ADR-0132: esquema inicial del SO — los cambios llegan por el
547
+ // evento "__elur_scheme" (MainActivity.onConfigurationChanged, uiMode).
548
+ try {
549
+ const cs = typeof ElurBridge !== "undefined" && ElurBridge.colorScheme?.();
550
+ if (cs === "dark" || cs === "light") setSystemColorScheme(cs);
551
+ } catch { /* bridge sin la cap — queda el default */ }
552
+
553
+ // R2.4/R2.5 — estado del lane outbound
554
+ const pendingKeys = new Map<string, number>(); // mergeableKey → índice
555
+ // V04 — barrera de coalescing: una op continua solo puede fusionarse
556
+ // con otra pendiente si NO hay ops no-coalescibles entre medias (un
557
+ // attach-event entre dos update-props del mismo nodo separa las
558
+ // fusiones — mergear a través reordenaría props antes del attach).
559
+ let barrier = 0;
560
+ let lastAcked = 0; // commitId confirmado por el host
561
+ let ackSeen = false; // el host soporta acks (R2.3)
562
+ let coalescedOps = 0;
563
+ let droppedContinuous = 0;
564
+ let emittedOps = 0;
565
+ let maxDepth = 0;
566
+ let deferredByAck = 0; // frames diferidos por stall
567
+ let droppedAfterClose = 0; // trabajo tardío tras close
568
+ let overflowFailed = 0; // desbordes HARD_PENDING → closing
569
+ let hostProtocolErrors = 0; // JSON inválido en canal reservado
570
+ let sessionState: SessionState = "init";
571
+
572
+ /** Payload JSON de un canal reservado. Inválido = bug del host: no
573
+ * hay a quién entregarlo, pero nunca se descarta en silencio. */
574
+ const parseHostJson = (name: string, payload: unknown): unknown => {
575
+ try {
576
+ return JSON.parse(String(payload));
577
+ } catch {
578
+ hostProtocolErrors++;
579
+ console.error(
580
+ `[elur] ${name}: payload JSON inválido del host — descartado`);
581
+ return undefined;
582
+ }
583
+ };
584
+
585
+ // R4.1 — instrumentación: contadores de tiempo/trabajo + ring de
586
+ // eventos de sesión. Nada por frame a logcat: el snapshot sale cada
587
+ // METRICS_EVERY commits y al close() vía console.log (canal que el
588
+ // host ya mapea a logcat — sin JNI nuevo).
589
+ let jsActiveMs = 0; // cbs de frame + flush
590
+ let queueWaitMs = 0; // primer emit → flush
591
+ let encodeMs = 0; // encodeDisplayList/JSON
592
+ let opsSent = 0; // ops post-coalesce enviadas
593
+ let bytesSent = 0; // bytes serializados en JS
594
+ let ackLatencyMs = 0; // suma send→ack
595
+ let ackSamples = 0;
596
+ let handlersInvoked = 0; // handlers de app (no __elur_*)
597
+ let firstEmitAt = 0; // ts del primer emit del commit
598
+ const sentAt = new Map<number, number>(); // frame→ts de envío (ack latency)
599
+ const events: Array<{ t: number; ev: string }> = [];
600
+ const EVENTS_RING = 64;
601
+ const METRICS_EVERY = 1024; // commits entre líneas [metrics-js]
602
+
603
+ const pushEvent = (ev: string) => {
604
+ events.push({ t: Date.now(), ev });
605
+ if (events.length > EVENTS_RING) events.shift();
606
+ };
607
+ const reportMetrics = () => {
608
+ if (typeof console === "undefined" || !console.log) return;
609
+ console.log("[metrics-js] " + JSON.stringify(host.metrics()));
610
+ };
611
+
612
+ const bridge = (): NativeBridge | undefined =>
613
+ (globalThis as { ElurBridge?: NativeBridge }).ElurBridge;
614
+
615
+ // ADR-0191 — reporte al host: best-effort (un bridge que lance no
616
+ // puede romper la sesión; el error ya quedó en console.error).
617
+ const reportErr = (kind: string, detail: Record<string, unknown>) => {
618
+ try {
619
+ bridge()?.reportError?.(kind, JSON.stringify(detail));
620
+ } catch { /* reporting nunca propaga */ }
621
+ };
622
+
623
+ // Frame source: con requestFrame nativo postea un callback de
624
+ // Choreographer (__elur_frame); sin él (bridge legacy o test) cae
625
+ // al microtask. Un solo frame en vuelo — flushScheduled lo garantiza.
626
+ const scheduleFrame = () => {
627
+ if (flushScheduled) return;
628
+ flushScheduled = true;
629
+ const b = bridge();
630
+ if (b?.requestFrame) {
631
+ b.requestFrame();
632
+ } else {
633
+ Promise.resolve().then(() => {
634
+ flushScheduled = false;
635
+ host.flush();
636
+ });
637
+ }
638
+ };
639
+
640
+ // ADR-0043/0051/0076: SDK de módulos — el bridge es opcional; sin
641
+ // callCommand las invocaciones rechazan `unavailable` canónico en
642
+ // vez de morir silenciosas.
643
+ const modules = createModuleRuntime({
644
+ callCommand(callId, module, command, argsJson) {
645
+ const b = bridge();
646
+ if (!b?.callCommand) {
647
+ throw moduleError(
648
+ "unavailable",
649
+ "[native] host sin callCommand — módulo " + module + " no invocable",
650
+ );
651
+ }
652
+ b.callCommand(callId, module, command, argsJson);
653
+ },
654
+ cancelCommand(callId) {
655
+ bridge()?.cancelCommand?.(callId);
656
+ },
657
+ });
658
+ const hasModuleBridge = typeof bridge()?.callCommand === "function";
659
+ const builtinHttpHandle = hasModuleBridge ? modules.register(httpModuleDef) : null;
660
+ if (builtinHttpHandle) setHostHttpEntry(builtinHttpHandle);
661
+ const builtinUiHandle = hasModuleBridge ? modules.register(uiModuleDef) : null;
662
+ const nativeMeasureResolver: NodeMeasureResolver | null = builtinUiHandle
663
+ ? async (numericId: number) => {
664
+ if (sessionState === "closing" || sessionState === "closed") {
665
+ return { x: 0, y: 0, width: 0, height: 0 };
666
+ }
667
+ if (pending.length > 0) host.flush();
668
+ try {
669
+ const r = (await builtinUiHandle.invoke("measureInWindow", { id: numericId })) as {
670
+ x?: unknown; y?: unknown; width?: unknown; height?: unknown;
671
+ } | null;
672
+ const num = (v: unknown) => (typeof v === "number" && Number.isFinite(v) ? v : 0);
673
+ return {
674
+ x: num(r?.x),
675
+ y: num(r?.y),
676
+ width: num(r?.width),
677
+ height: num(r?.height),
678
+ };
679
+ } catch {
680
+ return { x: 0, y: 0, width: 0, height: 0 };
681
+ }
682
+ }
683
+ : null;
684
+ if (nativeMeasureResolver) setNodeMeasureResolver(nativeMeasureResolver);
685
+
686
+ const host: EmbeddedHost = {
687
+ emit(op) {
688
+ // V13: trabajo tardío tras el cierre — se cuenta, nunca
689
+ // toca el bridge ni re-enciende el scheduling.
690
+ if (sessionState === "closing" || sessionState === "closed") {
691
+ droppedAfterClose++;
692
+ return;
693
+ }
694
+ // Latest-wins por (op,id) en continuas (R2.4): merge in-place
695
+ // — orden conservado, la op pendiente absorbe el valor nuevo.
696
+ const key = mergeableKey(op);
697
+ if (key !== undefined) {
698
+ const at = pendingKeys.get(key);
699
+ if (at !== undefined && at >= barrier) {
700
+ mergeInto(pending[at], op);
701
+ coalescedOps++;
702
+ } else {
703
+ // Tras una barrera la misma clave es una op NUEVA —
704
+ // apunta el mapa a la copia posterior.
705
+ pendingKeys.set(key, pending.length);
706
+ pending.push(op);
707
+ }
708
+ } else {
709
+ pending.push(op);
710
+ barrier = pending.length; // esta op es barrera de merge
711
+ }
712
+ // R4.1: el primer emit del batch marca el inicio de la
713
+ // espera en cola JS (emit → frontera de frame).
714
+ if (pending.length === 1) firstEmitAt = Date.now();
715
+ emittedOps++;
716
+ if (pending.length > maxDepth) maxDepth = pending.length;
717
+ // U09: emit nunca publica por cuenta — el commit anticipado
718
+ // por overflow partía lotes estructurales a mitad y eludía
719
+ // MAX_IN_FLIGHT (consumidor detenido seguía recibiendo
720
+ // commits). La cota dura falla explícito: sesión closing.
721
+ if (pending.length >= HARD_PENDING) {
722
+ overflowFailed++;
723
+ pushEvent("overflow");
724
+ pending = [];
725
+ pendingKeys.clear();
726
+ barrier = 0;
727
+ flushScheduled = false;
728
+ sessionState = "closing";
729
+ console.error(
730
+ "[elur] outbound lane overflow — sesión cerrada " +
731
+ "(productor excedió la cota con consumidor detenido)",
732
+ );
733
+ // ADR-0191: la transición a closing es evento de
734
+ // producción — el host la necesita aunque el operador
735
+ // no esté mirando logcat.
736
+ reportErr("session-overflow", {
737
+ commits: frame, opsSent, acked: lastAcked,
738
+ });
739
+ return;
740
+ }
741
+ // CONTRATO F02: el commit ocurre en la frontera de frame —
742
+ // requestFrame postea un callback de Choreographer (__elur_frame)
743
+ // y todas las ops acumuladas viajan en UN flush por frame.
744
+ // Suspended: acumula sin programar — resume() rearma el frame
745
+ // (U11: la sesión en background no consume vsyncs).
746
+ if (sessionState !== "suspended") scheduleFrame();
747
+ },
748
+ flush() {
749
+ if (pending.length === 0) return;
750
+ // U09: único punto de admisión — frame cb, pull nativo,
751
+ // resume y ack convergen aquí. Con MAX_IN_FLIGHT commits sin
752
+ // confirmar se difiere al próximo ack (créditos desde ready);
753
+ // el consumer detenido deja de recibir commits y la cola se
754
+ // acota por HARD_PENDING en emit().
755
+ if (ackSeen && frame - lastAcked >= MAX_IN_FLIGHT) {
756
+ deferredByAck++;
757
+ return;
758
+ }
759
+ frame++;
760
+ const ops = pending;
761
+ pending = [];
762
+ pendingKeys.clear();
763
+ barrier = 0;
764
+ const b = bridge();
765
+ // R4.1: t0 marca el fin de la espera en cola (emit→flush) y
766
+ // el inicio del tiempo JS activo de este commit.
767
+ const t0 = Date.now();
768
+ queueWaitMs += firstEmitAt > 0 ? t0 - firstEmitAt : 0;
769
+ firstEmitAt = 0;
770
+ opsSent += ops.length;
771
+ // Binario ABI v2 default (ADR-0008/0015). P1-ENC: si el bridge
772
+ // expone flushOps, encode+apply en C++ sin ArrayBuffer intermedio.
773
+ if (b?.flushOps) {
774
+ b.flushOps(frame, ops);
775
+ } else if (b?.flushBinary) {
776
+ const e0 = Date.now();
777
+ const buf = encodeDisplayList({ frame, ops });
778
+ encodeMs += Date.now() - e0;
779
+ bytesSent += buf.byteLength;
780
+ b.flushBinary(buf);
781
+ } else {
782
+ const e0 = Date.now();
783
+ const json = JSON.stringify({ frame, ops });
784
+ encodeMs += Date.now() - e0;
785
+ bytesSent += json.length;
786
+ b?.flush(json);
787
+ }
788
+ jsActiveMs += Date.now() - t0;
789
+ sentAt.set(frame, t0);
790
+ // sentAt acotado: un host sin acks dejaría el mapa crecer —
791
+ // se purga el más viejo (los acks llegan en orden, así que
792
+ // una entrada sin ack > MAX_IN_FLIGHT es perdida real).
793
+ if (sentAt.size > 64) {
794
+ const first = sentAt.keys().next().value;
795
+ if (first !== undefined) sentAt.delete(first);
796
+ }
797
+ // R4.1: push cadenciado — 1 línea cada METRICS_EVERY commits
798
+ // (~17s a 60fps), no por frame.
799
+ if (frame % METRICS_EVERY === 0) reportMetrics();
800
+ },
801
+ dispatchEvent(handlerName, payload) {
802
+ // V13: controles de sesión reservados — el host los invoca
803
+ // desde el ciclo de vida nativo (onPause/onResume/onDestroy).
804
+ if (handlerName === "__elur_suspend") { host.suspend(); return; }
805
+ if (handlerName === "__elur_resume") { host.resume(); return; }
806
+ if (handlerName === "__elur_close") { host.close(); return; }
807
+ if (sessionState === "closing" || sessionState === "closed") {
808
+ droppedAfterClose++;
809
+ return;
810
+ }
811
+ // ADR-0043/0051: respuestas y eventos de módulos nativos —
812
+ // nombres reservados, nunca alcanzan `handlers` de la app.
813
+ if (handlerName === "__elur_module_result") {
814
+ const r = parseHostJson(handlerName, payload) as {
815
+ callId?: number; ok?: boolean; data?: unknown; error?: unknown;
816
+ } | undefined;
817
+ if (r && typeof r.callId === "number") {
818
+ modules.dispatchResult(
819
+ r.callId,
820
+ r.ok === true,
821
+ r.ok === true ? r.data : r.error,
822
+ );
823
+ }
824
+ return;
825
+ }
826
+ if (handlerName === "__elur_module_event") {
827
+ // Solo el parse se contiene — una violación de
828
+ // marcador/epoch dentro de dispatchEvent lanza fail-loud
829
+ // (ADR-0076 §11.3).
830
+ const e = parseHostJson(handlerName, payload) as {
831
+ module?: string; event?: string;
832
+ sessionId?: number; data?: unknown;
833
+ } | undefined;
834
+ if (!e) return;
835
+ if (typeof e.module === "string" && typeof e.event === "string") {
836
+ modules.dispatchEvent({
837
+ module: e.module,
838
+ event: e.event,
839
+ sessionId: e.sessionId,
840
+ data: e.data,
841
+ });
842
+ }
843
+ return;
844
+ }
845
+ // R2.3: ack de commit aplicado por el host (main thread).
846
+ if (handlerName === "__elur_commit_ack") {
847
+ const n = parseInt(String(payload), 10);
848
+ if (n > lastAcked) { lastAcked = n; ackSeen = true; }
849
+ // R4.1: send→ack — mide el tramo post-flush (cola main +
850
+ // apply host) separado del tiempo JS. Purga ≤n: los acks
851
+ // son acumulativos (un ack de frame N confirma ≤N).
852
+ const sent = sentAt.get(n);
853
+ if (sent !== undefined) {
854
+ ackLatencyMs += Date.now() - sent;
855
+ ackSamples++;
856
+ }
857
+ for (const k of sentAt.keys()) {
858
+ if (k <= n) sentAt.delete(k); else break;
859
+ }
860
+ // Stall resuelto: si había ops diferidas por backpressure,
861
+ // el ack libera el siguiente commit (V04).
862
+ if (pending.length > 0) host.flush();
863
+ return;
864
+ }
865
+ // ADR-0087: resultados del contexto UI (done/cancelled con
866
+ // finals) — el guard de slot descarta ids de otras sesiones.
867
+ if (handlerName === "__elur_uiwk") {
868
+ const r = parseHostJson(handlerName, payload);
869
+ if (r !== undefined) {
870
+ uiRunner?.onResult(r as Parameters<
871
+ NonNullable<typeof uiRunner>["onResult"]
872
+ >[0]);
873
+ }
874
+ return;
875
+ }
876
+ if (handlerName === "__elur_scheme") {
877
+ // ADR-0132: cambio de uiMode — la app reacciona vía
878
+ // systemColorScheme/createTheme, sin recrear la sesión.
879
+ if (payload === "dark" || payload === "light") setSystemColorScheme(payload);
880
+ return;
881
+ }
882
+ if (handlerName === "__elur_timer") {
883
+ const id = Number(payload);
884
+ if (sessionState === "suspended") { parkedTimers.push(id); return; }
885
+ fireTimer(id);
886
+ if (pending.length > 0) host.flush();
887
+ return;
888
+ }
889
+ if (handlerName === "__elur_frame") {
890
+ flushScheduled = false;
891
+ // U11 — suspend real: el frame se consume pero no ejecuta
892
+ // cbs ni flush — frameCbs y pending quedan para resume()
893
+ // y el frame source se detiene (nada re-pide vsyncs).
894
+ if (sessionState === "suspended") return;
895
+ // Los cbs (worklet ticks) emiten sus ops ANTES del commit:
896
+ // viajan en el mismo flush — una llamada nativa por frame.
897
+ flushScheduled = true;
898
+ const cbs = frameCbs;
899
+ frameCbs = [];
900
+ const now = Date.now();
901
+ for (const cb of cbs) cb(now);
902
+ flushScheduled = false;
903
+ // R4.1: el trabajo de los cbs (worklets/animaciones) es
904
+ // JS activo del frame — se suma aparte del flush.
905
+ jsActiveMs += Date.now() - now;
906
+ // V04/U09: la admisión vive en flush() — el stall de
907
+ // acks difiere aquí; un host sin acks nunca difiere.
908
+ host.flush();
909
+ return;
910
+ }
911
+ const fn = handlers[handlerName];
912
+ if (fn) {
913
+ // ADR-0047: los eventos de app llegan como envelope JSON
914
+ // {v,event,origin,ts,data} — el handler recibe el envelope
915
+ // tipado, igual que en web. Payloads sin sobre (handlers
916
+ // __elur_* de plataforma, bridge legacy) pasan en crudo.
917
+ const env = payload !== undefined ? parseEnvelope(payload) : null;
918
+ // ADR-0055: data {"$cesm":name,"keys":[...]} = canal
919
+ // continuo por región — se resuelve a su objeto de datos.
920
+ if (env && typeof env === "object" && "data" in env) {
921
+ (env as { data: unknown }).data =
922
+ resolveSharedMarker((env as { data: unknown }).data);
923
+ }
924
+ handlersInvoked++;
925
+ fn(env ?? payload);
926
+ }
927
+ },
928
+ state: () => sessionState,
929
+ openUrl: (url: string) => {
930
+ if (typeof ElurBridge !== "undefined") ElurBridge.openUrl?.(url);
931
+ },
932
+ setBackIntercept: (active: boolean) => {
933
+ if (!builtinUiHandle || sessionState === "closing" || sessionState === "closed") return;
934
+ void builtinUiHandle.invoke("setBackIntercept", { active: Boolean(active) }).catch(() => { });
935
+ },
936
+ suspend() {
937
+ if (sessionState === "active") {
938
+ sessionState = "suspended";
939
+ setAppState("background");
940
+ pushEvent("suspend");
941
+ }
942
+ },
943
+ resume() {
944
+ if (sessionState !== "suspended") return;
945
+ sessionState = "active";
946
+ setAppState("active");
947
+ pushEvent("resume");
948
+ for (const id of parkedTimers.splice(0)) fireTimer(id);
949
+ // U11: re-arma el frame source — los cbs aparcados y las ops
950
+ // acumuladas en suspensión salen por la frontera de frame
951
+ // normal (misma admisión, no un bypass).
952
+ if (pending.length > 0 || frameCbs.length > 0) scheduleFrame();
953
+ },
954
+ close() {
955
+ if (sessionState === "closing" || sessionState === "closed") return;
956
+ sessionState = "closing";
957
+ pushEvent("close");
958
+ // ADR-0191: un close con contadores sucios (overflow,
959
+ // trabajo tardío, JSON host inválido) se reporta — el close
960
+ // limpio normal no genera registro de error.
961
+ if (overflowFailed > 0 || droppedAfterClose > 0 ||
962
+ hostProtocolErrors > 0) {
963
+ reportErr("session-close", {
964
+ commits: frame, overflowFailed, droppedAfterClose,
965
+ hostProtocolErrors,
966
+ });
967
+ }
968
+ // R4.1: exportación al terminar — snapshot final a logcat
969
+ // antes de desarmar la sesión.
970
+ reportMetrics();
971
+ pending = [];
972
+ pendingKeys.clear();
973
+ barrier = 0;
974
+ flushScheduled = false;
975
+ frameCbs = [];
976
+ for (const id of timers.keys()) ElurBridge.clearTimer?.(id);
977
+ timers.clear();
978
+ parkedTimers.length = 0;
979
+ // ADR-0087: el contexto UI de worklets es de ESTA sesión —
980
+ // reset nativo + rechazo de pending (ninguna promesa queda
981
+ // colgada; un "done" tardío se descarta por el guard).
982
+ uiRunner?.dispose();
983
+ uiRunner = undefined;
984
+ // El runner y los globals son de ESTA sesión — sin limpiarlos
985
+ // una segunda sesión (mismo globalThis) heredaría handlers y
986
+ // callbacks del muerto.
987
+ setWorkletRunner(undefined);
988
+ // ADR-0055: las proyecciones CESM mueren con la sesión —
989
+ // suelta los shared_ptr del lado JS.
990
+ disposeSharedRegions();
991
+ // Las invocaciones pendientes rechazan session_reset —
992
+ // ninguna promesa de módulo queda colgada tras el cierre
993
+ // (V13); los listeners se desuscriben best-effort (ADR-0076).
994
+ if (builtinHttpHandle) clearHostHttpEntry(builtinHttpHandle);
995
+ if (nativeMeasureResolver) clearNodeMeasureResolver(nativeMeasureResolver);
996
+ modules.reset();
997
+ const g = globalThis as Record<string, unknown>;
998
+ delete g.__elurCallHandler;
999
+ delete g.__elurCallHandlerWithString;
1000
+ delete g.__elurFlush;
1001
+ sessionState = "closed";
1002
+ },
1003
+ // R2.5/R4.1 — snapshot puro; el push lo hace flush()/close().
1004
+ metrics: () => ({
1005
+ depth: pending.length,
1006
+ maxDepth,
1007
+ commits: frame,
1008
+ acked: lastAcked,
1009
+ pendingAcks: frame - lastAcked,
1010
+ coalescedOps,
1011
+ droppedContinuous,
1012
+ emittedOps,
1013
+ deferredByAck,
1014
+ droppedAfterClose,
1015
+ overflowFailed,
1016
+ hostProtocolErrors,
1017
+ opsSent,
1018
+ bytesSent,
1019
+ jsActiveMs,
1020
+ queueWaitMs,
1021
+ encodeMs,
1022
+ ackLatencyAvgMs: ackSamples > 0
1023
+ ? Math.round((ackLatencyMs / ackSamples) * 1000) / 1000
1024
+ : 0,
1025
+ ackSamples,
1026
+ // Cola del ring — la historia completa queda en el proceso,
1027
+ // el snapshot exporta el tramo reciente.
1028
+ events: events.slice(-16),
1029
+ handlersInvoked,
1030
+ screen: opts?.gauges ? opts.gauges() : {},
1031
+ }),
1032
+ versions: () => {
1033
+ const b = bridge();
1034
+ return {
1035
+ ir: IR_VERSION,
1036
+ dlAbi: DL_ABI_VERSION,
1037
+ nav: NAV_STATE_VERSION,
1038
+ // ADR-0044: identidad declarada, nunca inferida —
1039
+ // "unknown" es una respuesta honesta cuando el host
1040
+ // no declara (heurística ausente ≠ quickjs).
1041
+ engine: opts?.engine ?? b?.engine ?? "unknown",
1042
+ platform: Platform.OS,
1043
+ ...(opts?.sdui !== undefined ? { sdui: opts.sdui } : {}),
1044
+ bridgeAbi: BRIDGE_ABI_VERSION,
1045
+ hostBridgeAbi: typeof b?.bridgeAbi === "number" ? b.bridgeAbi : null,
1046
+ // ADR-0187 — topología de hilos declarada por el
1047
+ // host; "unknown" honesto si no la declara.
1048
+ threadModel: typeof b?.threadModel === "string"
1049
+ ? b.threadModel : "unknown",
1050
+ // ADR-0194 — descriptor del backend Skia-árbol; ""
1051
+ // del host se normaliza a ausente.
1052
+ skiaBackend: typeof b?.skiaBackend === "function"
1053
+ ? b.skiaBackend() || undefined : undefined,
1054
+ caps: {
1055
+ flushJson: typeof b?.flush === "function",
1056
+ flushBinary: typeof b?.flushBinary === "function",
1057
+ flushOps: typeof b?.flushOps === "function",
1058
+ requestFrame: typeof b?.requestFrame === "function",
1059
+ nativeList: typeof b?.supportsNativeList === "function" &&
1060
+ b.supportsNativeList() === true,
1061
+ uiWorklet: typeof b?.uiWorkletStart === "function",
1062
+ skia: typeof b?.supportsSkia === "function" &&
1063
+ b.supportsSkia() === true,
1064
+ skiaTree: typeof b?.supportsSkiaTree === "function" &&
1065
+ b.supportsSkiaTree() === true,
1066
+ workletQuota: typeof b?.workletArm === "function" &&
1067
+ typeof b?.workletDisarm === "function",
1068
+ reportError: typeof b?.reportError === "function",
1069
+ },
1070
+ };
1071
+ },
1072
+ modules,
1073
+ };
1074
+
1075
+ // R7.3: publicación en diagnóstico — una línea al boot, visible en
1076
+ // logcat junto a las versiones que el host declara de su lado.
1077
+ if (typeof console !== "undefined" && console.log) {
1078
+ const v = host.versions();
1079
+ const caps = Object.keys(v.caps)
1080
+ .filter((k) => v.caps[k as keyof HostCapabilities])
1081
+ .join(",");
1082
+ console.log(
1083
+ `[elur] runtime: ir=${v.ir} dlAbi=${v.dlAbi} nav=${v.nav} ` +
1084
+ `bridgeAbi=${v.bridgeAbi} engine=${v.engine} ` +
1085
+ `platform=${v.platform} sdui=${v.sdui ?? "none"} ` +
1086
+ `caps=${caps || "none"} hostBridgeAbi=${v.hostBridgeAbi ?? "none"}`,
1087
+ );
1088
+ }
1089
+
1090
+ // MainThreadRunner con frame source nativa: ElurBridge.requestFrame()
1091
+ // → Choreographer one-shot → __elur_frame. Suspendida, el cb se aparca
1092
+ // sin pedir vsync — resume() rearma la cadena (U11). Si el bridge no
1093
+ // lo expone (runtime viejo), el runner queda sin instalar y
1094
+ // animate() no-opea.
1095
+ const b0 = bridge();
1096
+ if (b0?.requestFrame) {
1097
+ // ADR-0188: cuota CPU por llamada a wk.fn si el host la declara
1098
+ // (interrupt handler — Linux); hosts sin la cap corren sin tope.
1099
+ const quota = typeof b0.workletArm === "function" &&
1100
+ typeof b0.workletDisarm === "function"
1101
+ ? { arm: () => b0.workletArm!(), disarm: () => b0.workletDisarm!() }
1102
+ : undefined;
1103
+ const main = createMainThreadRunner((cb) => {
1104
+ frameCbs.push(cb);
1105
+ if (sessionState !== "suspended") b0.requestFrame!();
1106
+ }, quota);
1107
+ // ADR-0087: cap "ui-worklet" — el host (QuickJS-ng) declara el
1108
+ // segundo contexto del hilo UI; el runner decide por worklet la
1109
+ // elegibilidad (signal capturada + bind compositor) y delega el
1110
+ // resto al MainThreadRunner — fallback declarado, nunca silencio.
1111
+ if (typeof b0.uiWorkletStart === "function") {
1112
+ uiRunner = createUiThreadRunner(b0 as UiWorkletBridge, main);
1113
+ setWorkletRunner(uiRunner);
1114
+ } else {
1115
+ setWorkletRunner(main);
1116
+ }
1117
+ }
1118
+
1119
+ // Puntos de entrada que el nativo invoca
1120
+ (globalThis as Record<string, unknown>).__elurCallHandler = (name: string) =>
1121
+ host.dispatchEvent(name);
1122
+ (globalThis as Record<string, unknown>).__elurCallHandlerWithString = (
1123
+ name: string, value: string,
1124
+ ) => host.dispatchEvent(name, value);
1125
+ (globalThis as Record<string, unknown>).__elurFlush = () => host.flush();
1126
+
1127
+ // init → active: globals registrados y runner instalado — la sesión
1128
+ // ya puede recibir emit/dispatchEvent.
1129
+ sessionState = "active";
1130
+
1131
+ return host;
1132
+ }