@elurjs/universal 0.1.15 → 0.2.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 (558) hide show
  1. package/README.md +24 -8
  2. package/cli/add-platform.mjs +121 -0
  3. package/cli/commands.mjs +11 -6
  4. package/cli/create-app.mjs +110 -190
  5. package/cli/dev.mjs +17 -21
  6. package/cli/doctor.mjs +144 -122
  7. package/cli/elur.mjs +112 -34
  8. package/cli/gen-es5.mjs +4 -2
  9. package/cli/gen-hbc.mjs +3 -5
  10. package/cli/gen-host-integration.mjs +26 -11
  11. package/cli/gen-signals.mjs +3 -2
  12. package/cli/gen-worklet-src.mjs +9 -1
  13. package/cli/lib-platforms.d.mts +18 -0
  14. package/cli/lib-platforms.mjs +338 -0
  15. package/cli/package-linux.mjs +8 -4
  16. package/cli/sync-platform-packages.mjs +153 -0
  17. package/docs/INSTALACION-Y-DEV.md +77 -102
  18. package/docs/doc-data.json +34 -14
  19. package/package.json +14 -33
  20. package/docs/AUDITORIA-STATE-OF-THE-ART-2026-11.md +0 -981
  21. package/docs/PENDIENTES.md +0 -1511
  22. package/docs/adr/0013-transiciones-navegacion.md +0 -169
  23. package/docs/adr/0014-list-renderitem-factory.md +0 -41
  24. package/docs/adr/0015-dl-header-versionado.md +0 -57
  25. package/docs/adr/0016-hermes-v1-runtime.md +0 -78
  26. package/docs/adr/0017-encoder-nativo-dl.md +0 -62
  27. package/docs/adr/0018-yoga-tree-nativo.md +0 -78
  28. package/docs/adr/0019-ssr-universal-hidratacion.md +0 -245
  29. package/docs/adr/0020-canvas-draw-list.md +0 -65
  30. package/docs/adr/0021-text-input-props.md +0 -55
  31. package/docs/adr/0022-deep-links.md +0 -49
  32. package/docs/adr/0023-animacion-declarativa.md +0 -130
  33. package/docs/adr/0024-estilos-reactivos-vocabulario.md +0 -100
  34. package/docs/adr/0025-worklets-contrato-runner.md +0 -181
  35. package/docs/adr/0026-threading-js-dedicado.md +0 -94
  36. package/docs/adr/0027-ui-array-children-y-scope-por-fila.md +0 -58
  37. package/docs/adr/0028-commit-por-frame-en-host-embebido.md +0 -93
  38. package/docs/adr/0029-render-commit-latest-wins-screenhost.md +0 -62
  39. package/docs/adr/0030-destruccion-recursiva-ids-monotonicos.md +0 -79
  40. package/docs/adr/0031-scopes-formales-pool-filas.md +0 -76
  41. package/docs/adr/0032-nav-commit-autoritativo.md +0 -64
  42. package/docs/adr/0033-lista-virtual-ventana.md +0 -80
  43. package/docs/adr/0034-attach-event-class-strict-styles.md +0 -89
  44. package/docs/adr/0035-pipeline-imagenes-acotado.md +0 -133
  45. package/docs/adr/0036-data-por-entry-spa.md +0 -91
  46. package/docs/adr/0037-ir-serializable-factories-por-id.md +0 -73
  47. package/docs/adr/0038-transform-keys-compositor.md +0 -79
  48. package/docs/adr/0039-destroy-postorder-scope-ownership.md +0 -86
  49. package/docs/adr/0040-outbound-barriers-overflow-ack.md +0 -60
  50. package/docs/adr/0041-diff-treap-ir-version-strict.md +0 -65
  51. package/docs/adr/0042-data-endpoint-seguridad-hasloader.md +0 -67
  52. package/docs/adr/0043-aplicador-dom-unico.md +0 -70
  53. package/docs/adr/0044-descriptor-runtime-explicito.md +0 -80
  54. package/docs/adr/0045-navstate-versionado-scroll-settle.md +0 -72
  55. package/docs/adr/0046-harness-build-fail-closed.md +0 -99
  56. package/docs/adr/0047-envelope-evento-normalizado.md +0 -110
  57. package/docs/adr/0048-sesion-embebida-estados.md +0 -91
  58. package/docs/adr/0049-strict-styles-valores-portables.md +0 -78
  59. package/docs/adr/0050-update-style-tipado-abi-v5.md +0 -66
  60. package/docs/adr/0051-plugin-sdk-comandos.md +0 -65
  61. package/docs/adr/0052-benchmarks-reproducibles.md +0 -50
  62. package/docs/adr/0053-fling-target-pool-estructural.md +0 -105
  63. package/docs/adr/0054-lista-nativa-render-policy.md +0 -130
  64. package/docs/adr/0055-cesm-core.md +0 -143
  65. package/docs/adr/0056-dos-ejes-superficie-vs-propietario-de-ventana.md +0 -112
  66. package/docs/adr/0057-reset-node-y-firma-de-reciclaje.md +0 -95
  67. package/docs/adr/0058-rollback-de-montaje.md +0 -83
  68. package/docs/adr/0059-traza-on-device-u01-y-scroll-unico-productor.md +0 -89
  69. package/docs/adr/0060-list-update-patch-por-campo.md +0 -73
  70. package/docs/adr/0061-elegibilidad-de-plantilla-nativa.md +0 -70
  71. package/docs/adr/0062-invalidacion-adapter-lista-nativa.md +0 -77
  72. package/docs/adr/0063-autoridad-eventos-y-scroll.md +0 -66
  73. package/docs/adr/0064-admision-unica-de-commits.md +0 -66
  74. package/docs/adr/0065-runtime-de-sesion-u11.md +0 -97
  75. package/docs/adr/0066-perfil-layout-y-safe-area.md +0 -78
  76. package/docs/adr/0067-sesion-robusta-y-procedencia-de-build.md +0 -121
  77. package/docs/adr/0068-metodologia-de-benchmark-y-carril-verificable.md +0 -94
  78. package/docs/adr/0069-schema-de-wire-y-corpus-comun-de-codecs.md +0 -126
  79. package/docs/adr/0070-modelo-publico-de-aplicacion-y-mount.md +0 -91
  80. package/docs/adr/0071-image-service-y-tck-de-plataforma.md +0 -133
  81. package/docs/adr/0072-par-compilador-runtime-hermes.md +0 -62
  82. package/docs/adr/0073-corpus-de-semantica-y-lowering-por-motor.md +0 -67
  83. package/docs/adr/0074-perfil-i18n-formateo-dom-free.md +0 -85
  84. package/docs/adr/0075-back-predictivo-restore-y-layout-adaptativo.md +0 -126
  85. package/docs/adr/0076-contrato-de-modulos-capa-1.md +0 -159
  86. package/docs/adr/0077-manifest-de-plugin-y-plugin-sync.md +0 -109
  87. package/docs/adr/0078-extraccion-de-i18n-a-paquete-propio.md +0 -114
  88. package/docs/adr/0079-handles-de-host-objects-por-epoch.md +0 -96
  89. package/docs/adr/0080-platform-views-por-contrato.md +0 -93
  90. package/docs/adr/0081-codegen-del-dsl-de-modulos.md +0 -118
  91. package/docs/adr/0082-variante-web-de-modulos-nativos.md +0 -126
  92. package/docs/adr/0083-perfiles-dev-release.md +0 -92
  93. package/docs/adr/0084-instrumentacion-acotada-exportable.md +0 -126
  94. package/docs/adr/0085-medicion-agrupada-en-main.md +0 -125
  95. package/docs/adr/0086-matriz-capacidades-props-eventos.md +0 -75
  96. package/docs/adr/0087-uithread-runner-android.md +0 -271
  97. package/docs/adr/0088-worklet-src-estatico.md +0 -82
  98. package/docs/adr/0089-composicion-animaciones-settle-drag.md +0 -122
  99. package/docs/adr/0090-linter-capturas-build.md +0 -94
  100. package/docs/adr/0091-router-core-vs-universal.md +0 -74
  101. package/docs/adr/0092-sharedregion-type-strings.md +0 -59
  102. package/docs/adr/0093-permission-request-estandar.md +0 -52
  103. package/docs/adr/0094-dispatch-worker-timeoutms.md +0 -51
  104. package/docs/adr/0095-tck-modulos.md +0 -65
  105. package/docs/adr/0096-cesm-ring-deferral.md +0 -47
  106. package/docs/adr/0097-tooling-diferido.md +0 -51
  107. package/docs/adr/0098-handshake-moduleabi.md +0 -46
  108. package/docs/adr/0099-modulos-ambient.md +0 -58
  109. package/docs/adr/0100-auto-declaracion-modulos.md +0 -43
  110. package/docs/adr/0101-plataforma-build.md +0 -49
  111. package/docs/adr/0102-permisos-manifest-build.md +0 -38
  112. package/docs/adr/0103-registrant-ownership.md +0 -45
  113. package/docs/adr/0104-toolchain-release.md +0 -125
  114. package/docs/adr/0105-cesm-ring-mode.md +0 -71
  115. package/docs/adr/0106-module-observabilidad.md +0 -100
  116. package/docs/adr/0107-layout-l1-oraculo.md +0 -67
  117. package/docs/adr/0108-semantica-como-ops.md +0 -69
  118. package/docs/adr/0109-text-input-composition.md +0 -64
  119. package/docs/adr/0110-yoga-3-2.md +0 -63
  120. package/docs/adr/0111-hot-reload-con-estado.md +0 -92
  121. package/docs/adr/0112-metricas-nativas-reales.md +0 -65
  122. package/docs/adr/0113-cesm-proyeccion-ampliada.md +0 -80
  123. package/docs/adr/0114-androidx-deps.md +0 -72
  124. package/docs/adr/0115-coil-imagenes.md +0 -57
  125. package/docs/adr/0116-precomputed-text-off-ui.md +0 -49
  126. package/docs/adr/0117-a11y-state-hint-foco.md +0 -54
  127. package/docs/adr/0118-yoga-3-2-vocabulario.md +0 -98
  128. package/docs/adr/0119-codecs-wire-desde-esquema.md +0 -86
  129. package/docs/adr/0120-unidades-logicas-pointscalefactor.md +0 -73
  130. package/docs/adr/0121-yoga-filas-lista.md +0 -100
  131. package/docs/adr/0122-delegado-layout-subarbol.md +0 -140
  132. package/docs/adr/0123-canvas-sobre-skia-raster.md +0 -101
  133. package/docs/adr/0124-evaluacion-taffy-css-grid.md +0 -52
  134. package/docs/adr/0125-paridad-visual-android.md +0 -89
  135. package/docs/adr/0126-documento-web-metadata-enlaces.md +0 -52
  136. package/docs/adr/0127-perfil-l1-shorthand-flex-herencia-texto.md +0 -70
  137. package/docs/adr/0128-pantalla-llena-fragmentos-transparentes.md +0 -56
  138. package/docs/adr/0129-content-visibility-canvas-unidades-logicas.md +0 -37
  139. package/docs/adr/0130-expresiones-reactivas-ui.md +0 -55
  140. package/docs/adr/0131-state-style.md +0 -59
  141. package/docs/adr/0132-create-theme-system-color-scheme.md +0 -58
  142. package/docs/adr/0133-navegacion-rutas-href-chrome.md +0 -59
  143. package/docs/adr/0134-servicios-ambient-modulos-timers.md +0 -63
  144. package/docs/adr/0135-registro-fuentes.md +0 -67
  145. package/docs/adr/0136-i18n-zonas-dst-locale-reactivo.md +0 -70
  146. package/docs/adr/0137-ssg-universal.md +0 -78
  147. package/docs/adr/0138-plantillas-fila-ui-rowref.md +0 -54
  148. package/docs/adr/0139-paridad-geometrica-e-inspector.md +0 -63
  149. package/docs/adr/0140-medida-line-height-css.md +0 -78
  150. package/docs/adr/0141-build-ssr-autocontenido.md +0 -37
  151. package/docs/adr/0142-tema-ssr-cookie-client-hint.md +0 -42
  152. package/docs/adr/0143-paridad-visual-ci.md +0 -51
  153. package/docs/adr/0144-oraculo-layout-chromium.md +0 -45
  154. package/docs/adr/0145-admision-opcodes-wire.md +0 -89
  155. package/docs/adr/0146-presupuesto-divergencias.md +0 -82
  156. package/docs/adr/0147-spans-texto-enriquecido.md +0 -113
  157. package/docs/adr/0148-scroll-restore.md +0 -92
  158. package/docs/adr/0149-gestion-foco.md +0 -94
  159. package/docs/adr/0150-sticky.md +0 -89
  160. package/docs/adr/0151-politica-migracion-snapshots.md +0 -83
  161. package/docs/adr/0152-vocabulario-semantico-v3.md +0 -112
  162. package/docs/adr/0153-puerta-doc-codigo.md +0 -59
  163. package/docs/adr/0154-matriz-paridad.md +0 -79
  164. package/docs/adr/0155-rtl-ambiente.md +0 -73
  165. package/docs/adr/0156-quickjs-ng-0170.md +0 -55
  166. package/docs/adr/0157-qjsc-bytecode-android.md +0 -73
  167. package/docs/adr/0158-abi-host-explicita.md +0 -62
  168. package/docs/adr/0159-entrada-desktop.md +0 -59
  169. package/docs/adr/0160-port-linux-hallazgos-plataforma.md +0 -91
  170. package/docs/adr/0161-paridad-deeplink-alineacion-estructural.md +0 -76
  171. package/docs/adr/0162-fontscale-linux-fuentes.md +0 -63
  172. package/docs/adr/0163-overflow-hidden-linux-clip.md +0 -67
  173. package/docs/adr/0164-nav-transitions-linux.md +0 -126
  174. package/docs/adr/0165-transiciones-declarativas.md +0 -147
  175. package/docs/adr/0166-ime-composition-linux.md +0 -68
  176. package/docs/adr/0167-spans-pango-linux.md +0 -80
  177. package/docs/adr/0168-statestyle-linux.md +0 -65
  178. package/docs/adr/0169-animate-linux.md +0 -114
  179. package/docs/adr/0170-image-service-linux.md +0 -54
  180. package/docs/adr/0171-semantics-atspi-linux.md +0 -80
  181. package/docs/adr/0172-conformidad-de-host-por-terceros.md +0 -159
  182. package/docs/adr/0173-licencias-espec-y-codigo.md +0 -95
  183. package/docs/adr/0174-tabla-estilo-yoga-compartida.md +0 -67
  184. package/docs/adr/0175-easings-normativos-cubic-bezier.md +0 -68
  185. package/docs/adr/0176-harness-plataforma-linux-y-locale-decimal.md +0 -80
  186. package/docs/adr/0177-gaps-linux-dir-as-navstate.md +0 -84
  187. package/docs/adr/0178-matriz-linux-y-tablas-normativas-generadas.md +0 -104
  188. package/docs/adr/0179-eventos-gesto-y-teclado.md +0 -132
  189. package/docs/adr/0180-desktop-nativo-linux-windows-macos-chromeos.md +0 -58
  190. package/docs/adr/0181-linux-platform-views-uiworklet-y-gaps-certificados.md +0 -101
  191. package/docs/adr/0182-sdui-envelope-dialecto-rico-y-lowering.md +0 -452
  192. package/docs/adr/0183-hermes-es6-block-scoping-en-source-eval.md +0 -99
  193. package/docs/adr/0184-sdui-consumidor-de-referencia-y-modulo-http.md +0 -72
  194. package/docs/adr/0185-sdui-modelo-de-seguridad-del-envelope.md +0 -160
  195. package/docs/adr/0186-linux-packaging-deb-rpm-flatpak.md +0 -61
  196. package/docs/adr/0187-modelo-de-hilos-ejecutores-logicos.md +0 -163
  197. package/docs/adr/0188-sdui-seguridad-hardening.md +0 -214
  198. package/docs/adr/0189-worklets-web-worker-y-egreso-pinning.md +0 -235
  199. package/docs/adr/0190-semantics-actions-linux-via-gaction-muxer.md +0 -102
  200. package/docs/adr/0191-reporte-de-errores-en-produccion.md +0 -126
  201. package/docs/adr/0192-source-maps-y-simbolizacion-de-stacks.md +0 -107
  202. package/docs/adr/0193-renderer-skia-opt-in-en-linux.md +0 -143
  203. package/docs/adr/0194-superficie-declarada-y-carril-skia-tree.md +0 -96
  204. package/docs/adr/0195-bundles-embebidos-subpaths-core.md +0 -66
  205. package/docs/adr/0196-matriz-capacidades-verdad.md +0 -84
  206. package/docs/adr/0197-entorno-reactivo-cableado.md +0 -67
  207. package/docs/adr/0198-csprng-host-wintertc.md +0 -57
  208. package/docs/adr/0199-testing-harness-dom-free.md +0 -59
  209. package/docs/adr/0200-overlays-back-foco.md +0 -84
  210. package/docs/adr/0201-paridad-nativa-props-texto-fase1.md +0 -79
  211. package/docs/adr/0202-node-ref-measure-web.md +0 -61
  212. package/docs/adr/0203-primitivas-headless.md +0 -54
  213. package/docs/adr/0204-imagen-load-error-fallback.md +0 -123
  214. package/docs/adr/0205-primitivas-controls-fase2.md +0 -79
  215. package/docs/adr/0206-a2ui-catalogo-tabs-modal-choicepicker-icon.md +0 -110
  216. package/docs/adr/0207-a2ui-superficie-viva.md +0 -104
  217. package/docs/adr/0208-a2ui-checks-validacion.md +0 -94
  218. package/docs/adr/0209-loaddata-nativo-default.md +0 -56
  219. package/docs/adr/0210-primitivas-navegacion-fase3.md +0 -69
  220. package/docs/adr/0211-a2ui-formato-localizado.md +0 -113
  221. package/docs/adr/0212-red-fuera-del-core.md +0 -67
  222. package/docs/adr/0213-dev-fast-y-rutas-automaticas.md +0 -68
  223. package/docs/adr/0214-dev-web-server-reload.md +0 -55
  224. package/docs/adr/0215-ui-host-noderef-back-http-linux.md +0 -77
  225. package/docs/adr/0216-paridad-nativa-switch-scroll-lista.md +0 -53
  226. package/docs/adr/0217-overlays-drag-y-popover-anclado.md +0 -64
  227. package/docs/adr/0218-sdui-gateway-live-mcp-y-scaffold.md +0 -32
  228. package/docs/adr/0219-event-ref-envelope-y-oracle-scroll-aware.md +0 -82
  229. package/docs/adr/0220-target-windows-winui3.md +0 -331
  230. package/docs/adr/0221-shell-tabs-desktop-normativa.md +0 -45
  231. package/docs/adr/0222-a2ui-v1-dialecto-por-superficie.md +0 -109
  232. package/docs/adr/README.md +0 -230
  233. package/docs/deuda/i18n-libreria-separada.md +0 -50
  234. package/docs/propuestas/dx-y-paridad.md +0 -684
  235. package/docs/propuestas/investigacion-apps-completas/PENDIENTES-CORE-APPS-COMPLETAS.md +0 -226
  236. package/docs/propuestas/investigacion-apps-completas/arquitectura-motor-videojuegos-elur.md +0 -254
  237. package/docs/propuestas/investigacion-apps-completas/auditoria-paridad-frameworks-y-sdui.md +0 -295
  238. package/docs/propuestas/investigacion-apps-completas/ciclo-de-vida-dx-y-apps-completas.md +0 -394
  239. package/docs/propuestas/investigacion-apps-completas/crear-proyecto-desde-npm-y-agentes.md +0 -477
  240. package/docs/propuestas/investigacion-apps-completas/especificacion-arquitectura-capacidades-faltantes.md +0 -407
  241. package/docs/propuestas/investigacion-apps-completas/identidad-y-nombre-elur-universal.md +0 -133
  242. package/docs/propuestas/investigacion-apps-completas/migracion-elur-core-4.md +0 -266
  243. package/docs/propuestas/investigacion-apps-completas/sdui-a2ui-aplicaciones-completas.md +0 -255
  244. package/docs/propuestas/investigacion-apps-completas/verificacion-mejoras-y-brechas-nuevas.md +0 -228
  245. package/docs/propuestas/modelo-de-consumo.md +0 -287
  246. package/docs/propuestas/modulos-nativos.md +0 -1062
  247. package/docs/propuestas/palabras-clave-normativas.md +0 -69
  248. package/docs/propuestas/sdui-seguridad-hardening.md +0 -322
  249. package/docs/propuestas/skia-graphite.md +0 -167
  250. package/docs/propuestas/skia-renderer-arbol.md +0 -603
  251. package/docs/propuestas/targets-nativos-nuevos.md +0 -359
  252. package/docs/propuestas/toolchain-y-distribucion.md +0 -311
  253. package/docs/propuestas/ui-worklet-capacidades-exclusivas.md +0 -114
  254. package/examples/a11ylive/elur.app.json +0 -8
  255. package/examples/a11ylive/entry.ts +0 -22
  256. package/examples/a11ysem/elur.app.json +0 -8
  257. package/examples/a11ysem/entry.ts +0 -24
  258. package/examples/anim/elur.app.json +0 -8
  259. package/examples/anim/entry.ts +0 -50
  260. package/examples/app.ts +0 -10
  261. package/examples/cliprad/elur.app.json +0 -8
  262. package/examples/cliprad/entry.ts +0 -16
  263. package/examples/controls/app.ts +0 -32
  264. package/examples/controls/elur.app.json +0 -8
  265. package/examples/counter/app.ts +0 -21
  266. package/examples/counter/elur.app.json +0 -8
  267. package/examples/counter/entry.ts +0 -7
  268. package/examples/entry.ts +0 -11
  269. package/examples/feedstress/app.ts +0 -334
  270. package/examples/feedstress/elur.app.json +0 -8
  271. package/examples/feedstress/entry.ts +0 -7
  272. package/examples/i18n/app.ts +0 -86
  273. package/examples/i18n/elur.app.json +0 -8
  274. package/examples/i18n/entry.ts +0 -22
  275. package/examples/imecomp/elur.app.json +0 -8
  276. package/examples/imecomp/entry.ts +0 -41
  277. package/examples/imgtest/elur.app.json +0 -8
  278. package/examples/imgtest/entry.ts +0 -18
  279. package/examples/mareas/app/ajustes/page.ts +0 -54
  280. package/examples/mareas/app/page.ts +0 -91
  281. package/examples/mareas/app/puerto/[id]/page.ts +0 -106
  282. package/examples/mareas/app.ts +0 -12
  283. package/examples/mareas/elur.app.json +0 -35
  284. package/examples/mareas/entry.ts +0 -11
  285. package/examples/mareas/fonts/DejaVuSansMono-Bold.ttf +0 -0
  286. package/examples/mareas/fonts/DejaVuSansMono.ttf +0 -0
  287. package/examples/mareas/fonts/DejaVuSerif-Bold.ttf +0 -0
  288. package/examples/mareas/fonts/DejaVuSerif-Italic.ttf +0 -0
  289. package/examples/mareas/fonts/DejaVuSerif.ttf +0 -0
  290. package/examples/mareas/fonts/LICENSE-DejaVu.txt +0 -187
  291. package/examples/mareas/fonts.ts +0 -6
  292. package/examples/mareas/head.ts +0 -12
  293. package/examples/mareas/i18n.ts +0 -163
  294. package/examples/mareas/ports.ts +0 -131
  295. package/examples/mareas/routes.gen.ts +0 -44
  296. package/examples/mareas/serve.ts +0 -70
  297. package/examples/mareas/services.ts +0 -5
  298. package/examples/mareas/services.web.ts +0 -6
  299. package/examples/mareas/state.ts +0 -64
  300. package/examples/mareas/theme.ts +0 -56
  301. package/examples/mareas/ui/controls.ts +0 -42
  302. package/examples/mareas/ui/frame.ts +0 -63
  303. package/examples/mareas/ui/marigram.ts +0 -52
  304. package/examples/masonry/app.ts +0 -32
  305. package/examples/masonry/elur.app.json +0 -8
  306. package/examples/masonry/entry.ts +0 -4
  307. package/examples/natprobe/elur.app.json +0 -8
  308. package/examples/natprobe/entry-a11y.ts +0 -52
  309. package/examples/natprobe/entry-tinput.ts +0 -73
  310. package/examples/natprobe/entry-tml.ts +0 -46
  311. package/examples/natprobe/entry.ts +0 -285
  312. package/examples/navdemo/app.ts +0 -109
  313. package/examples/navdemo/elur.app.json +0 -8
  314. package/examples/navdemo/entry.ts +0 -7
  315. package/examples/navtrans/elur.app.json +0 -8
  316. package/examples/navtrans/entry.ts +0 -53
  317. package/examples/platformview/app.ts +0 -26
  318. package/examples/platformview/elur.app.json +0 -8
  319. package/examples/sdui-demo/docs/home.envelope.json +0 -588
  320. package/examples/sdui-demo/docs/home.iife.json +0 -582
  321. package/examples/sdui-demo/elur.app.json +0 -8
  322. package/examples/sdui-demo/entry.ts +0 -346
  323. package/examples/select/elur.app.json +0 -8
  324. package/examples/select/entry.ts +0 -20
  325. package/examples/skiacanvas/app.ts +0 -34
  326. package/examples/skiacanvas/elur.app.json +0 -8
  327. package/examples/skiacanvas/entry.ts +0 -4
  328. package/examples/spans/elur.app.json +0 -8
  329. package/examples/spans/entry.ts +0 -28
  330. package/examples/ssr/app/about/page.ts +0 -18
  331. package/examples/ssr/app/items/[id]/page.ts +0 -16
  332. package/examples/ssr/app/layout.ts +0 -21
  333. package/examples/ssr/app/page.action.ts +0 -10
  334. package/examples/ssr/app/page.data.ts +0 -5
  335. package/examples/ssr/app/page.ts +0 -95
  336. package/examples/ssr/app/slow/loading.ts +0 -10
  337. package/examples/ssr/app/slow/page.data.ts +0 -4
  338. package/examples/ssr/app/slow/page.ts +0 -16
  339. package/examples/ssr/app/store.ts +0 -3
  340. package/examples/ssr/serve.ts +0 -53
  341. package/examples/statestyle/elur.app.json +0 -8
  342. package/examples/statestyle/entry.ts +0 -25
  343. package/examples/swipe/elur.app.json +0 -8
  344. package/examples/swipe/entry.ts +0 -39
  345. package/examples/tasks/app.ts +0 -145
  346. package/examples/tasks/elur.app.json +0 -8
  347. package/examples/uiprops/elur.app.json +0 -8
  348. package/examples/uiprops/entry.ts +0 -65
  349. package/examples/uiwk/app.ts +0 -288
  350. package/examples/uiwk/elur.app.json +0 -8
  351. package/examples/uiwk/entry.ts +0 -7
  352. package/examples/vertical/app.ts +0 -275
  353. package/examples/vertical/elur.app.json +0 -8
  354. package/examples/vertical/entry.ts +0 -31
  355. package/examples/yogafeatures/app.ts +0 -55
  356. package/examples/yogafeatures/elur.app.json +0 -8
  357. package/examples/yogafeatures/entry.ts +0 -4
  358. package/native/cesm/tests/CMakeLists.txt +0 -50
  359. package/native/cesm/tests/README.md +0 -89
  360. package/native/cesm/tests/compile_check_hermes.cpp +0 -23
  361. package/native/cesm/tests/test_core.cpp +0 -101
  362. package/native/cesm/tests/test_main.cpp +0 -13
  363. package/native/cesm/tests/test_quickjs_adapter.cpp +0 -252
  364. package/native/cesm/tests/test_ring.cpp +0 -131
  365. package/native/cesm/tests/test_slots.cpp +0 -81
  366. package/native/cesm/tests/test_sync.cpp +0 -157
  367. package/native/cesm/tests/test_util.h +0 -24
  368. package/targets/android/app/build.gradle.kts +0 -192
  369. package/targets/android/app/proguard-rules-elur.pro +0 -12
  370. package/targets/android/app/proguard-rules.pro +0 -3
  371. package/targets/android/app/src/main/AndroidManifest.xml +0 -81
  372. package/targets/android/app/src/main/cpp/CMakeLists.txt +0 -117
  373. package/targets/android/app/src/main/cpp/dlEncoder.h +0 -117
  374. package/targets/android/app/src/main/cpp/dlEncoderJsi.cpp +0 -315
  375. package/targets/android/app/src/main/cpp/dlEncoderQjs.cpp +0 -394
  376. package/targets/android/app/src/main/cpp/dlOps.inc +0 -145
  377. package/targets/android/app/src/main/cpp/elurBridge.cpp +0 -1350
  378. package/targets/android/app/src/main/cpp/elurBridgeHermes.cpp +0 -1294
  379. package/targets/android/app/src/main/cpp/elurSkia.cpp +0 -287
  380. package/targets/android/app/src/main/cpp/elurSkiaTree.cpp +0 -448
  381. package/targets/android/app/src/main/cpp/elurUiWorklet.cpp +0 -1233
  382. package/targets/android/app/src/main/cpp/elurYoga.cpp +0 -1060
  383. package/targets/android/app/src/main/cpp/elurYoga.h +0 -82
  384. package/targets/android/app/src/main/cpp/hermes-libs/LICENSE +0 -21
  385. package/targets/android/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
  386. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +0 -276
  387. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +0 -97
  388. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +0 -502
  389. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +0 -107
  390. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +0 -145
  391. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +0 -193
  392. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +0 -211
  393. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +0 -40
  394. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +0 -14
  395. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +0 -27
  396. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +0 -141
  397. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +0 -270
  398. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +0 -64
  399. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +0 -1566
  400. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +0 -37
  401. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +0 -75
  402. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +0 -23
  403. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +0 -334
  404. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +0 -328
  405. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +0 -131
  406. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +0 -73
  407. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +0 -89
  408. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +0 -135
  409. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +0 -280
  410. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +0 -137
  411. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +0 -107
  412. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +0 -140
  413. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +0 -71
  414. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +0 -40
  415. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +0 -82
  416. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +0 -72
  417. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +0 -1279
  418. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +0 -313
  419. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +0 -38
  420. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +0 -77
  421. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +0 -127
  422. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +0 -138
  423. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +0 -24
  424. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +0 -20
  425. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +0 -23
  426. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +0 -44
  427. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +0 -123
  428. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +0 -29
  429. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +0 -24
  430. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +0 -23
  431. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +0 -30
  432. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +0 -113
  433. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +0 -242
  434. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +0 -52
  435. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +0 -295
  436. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +0 -25
  437. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +0 -642
  438. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +0 -29
  439. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +0 -41
  440. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +0 -12
  441. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +0 -8516
  442. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +0 -137
  443. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +0 -3945
  444. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +0 -119
  445. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +0 -124
  446. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +0 -66
  447. package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +0 -456
  448. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +0 -26
  449. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +0 -1157
  450. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +0 -242
  451. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +0 -132
  452. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +0 -434
  453. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +0 -2266
  454. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +0 -59
  455. package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +0 -79
  456. package/targets/android/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +0 -1111
  457. package/targets/android/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
  458. package/targets/android/app/src/main/java/com/elur/universal/BinaryCodec.kt +0 -121
  459. package/targets/android/app/src/main/java/com/elur/universal/DlDecoder.kt +0 -260
  460. package/targets/android/app/src/main/java/com/elur/universal/DlOpsDecode.kt +0 -158
  461. package/targets/android/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +0 -161
  462. package/targets/android/app/src/main/java/com/elur/universal/ElurBridge.kt +0 -238
  463. package/targets/android/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +0 -223
  464. package/targets/android/app/src/main/java/com/elur/universal/ElurCanvasView.kt +0 -202
  465. package/targets/android/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +0 -206
  466. package/targets/android/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +0 -185
  467. package/targets/android/app/src/main/java/com/elur/universal/ElurEditText.kt +0 -17
  468. package/targets/android/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +0 -190
  469. package/targets/android/app/src/main/java/com/elur/universal/ElurHttpModule.kt +0 -306
  470. package/targets/android/app/src/main/java/com/elur/universal/ElurImageService.kt +0 -348
  471. package/targets/android/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +0 -84
  472. package/targets/android/app/src/main/java/com/elur/universal/ElurListView.kt +0 -954
  473. package/targets/android/app/src/main/java/com/elur/universal/ElurManifest.kt +0 -117
  474. package/targets/android/app/src/main/java/com/elur/universal/ElurMetrics.kt +0 -325
  475. package/targets/android/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +0 -14
  476. package/targets/android/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +0 -36
  477. package/targets/android/app/src/main/java/com/elur/universal/ElurRenderer.kt +0 -6164
  478. package/targets/android/app/src/main/java/com/elur/universal/ElurRowYoga.kt +0 -130
  479. package/targets/android/app/src/main/java/com/elur/universal/ElurScrollView.kt +0 -240
  480. package/targets/android/app/src/main/java/com/elur/universal/ElurShellView.kt +0 -117
  481. package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +0 -162
  482. package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +0 -968
  483. package/targets/android/app/src/main/java/com/elur/universal/ElurStateModule.kt +0 -69
  484. package/targets/android/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +0 -34
  485. package/targets/android/app/src/main/java/com/elur/universal/ElurTckModule.kt +0 -99
  486. package/targets/android/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +0 -16
  487. package/targets/android/app/src/main/java/com/elur/universal/ElurTrace.kt +0 -24
  488. package/targets/android/app/src/main/java/com/elur/universal/ElurUiModule.kt +0 -48
  489. package/targets/android/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +0 -305
  490. package/targets/android/app/src/main/java/com/elur/universal/JsBridge.kt +0 -67
  491. package/targets/android/app/src/main/java/com/elur/universal/JsThread.kt +0 -189
  492. package/targets/android/app/src/main/java/com/elur/universal/MainActivity.kt +0 -844
  493. package/targets/android/app/src/main/java/com/elur/universal/ModuleRegistry.kt +0 -701
  494. package/targets/android/app/src/main/java/com/elur/universal/YogaRowScope.kt +0 -97
  495. package/targets/android/app/src/main/res/values/ids.xml +0 -10
  496. package/targets/android/app/src/main/res/values/strings.xml +0 -8
  497. package/targets/android/app/src/main/res/values-es/strings.xml +0 -5
  498. package/targets/android/app/src/main/res/xml/network_security_config.xml +0 -10
  499. package/targets/android/build.gradle.kts +0 -5
  500. package/targets/android/gradle/libs.versions.toml +0 -12
  501. package/targets/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  502. package/targets/android/gradle/wrapper/gradle-wrapper.properties +0 -8
  503. package/targets/android/gradle.properties +0 -23
  504. package/targets/android/gradlew +0 -251
  505. package/targets/android/gradlew.bat +0 -94
  506. package/targets/android/settings.gradle.kts +0 -32
  507. package/targets/linux/CMakeLists.txt +0 -196
  508. package/targets/linux/README.md +0 -422
  509. package/targets/linux/ci/tsan.supp +0 -15
  510. package/targets/linux/generated/elur_module_registrar.cpp +0 -18
  511. package/targets/linux/generated/module_sources.cmake +0 -7
  512. package/targets/linux/src/elur_applicator.cpp +0 -5073
  513. package/targets/linux/src/elur_applicator.h +0 -387
  514. package/targets/linux/src/elur_clip.cpp +0 -76
  515. package/targets/linux/src/elur_clip.h +0 -23
  516. package/targets/linux/src/elur_crypto_module.cpp +0 -121
  517. package/targets/linux/src/elur_events.h +0 -57
  518. package/targets/linux/src/elur_fonts.cpp +0 -106
  519. package/targets/linux/src/elur_fonts.h +0 -31
  520. package/targets/linux/src/elur_host.cpp +0 -1041
  521. package/targets/linux/src/elur_host.h +0 -66
  522. package/targets/linux/src/elur_http_module.cpp +0 -437
  523. package/targets/linux/src/elur_js.h +0 -40
  524. package/targets/linux/src/elur_modules.cpp +0 -453
  525. package/targets/linux/src/elur_modules.h +0 -159
  526. package/targets/linux/src/elur_renderer.h +0 -46
  527. package/targets/linux/src/elur_shot.cpp +0 -64
  528. package/targets/linux/src/elur_shot.h +0 -17
  529. package/targets/linux/src/elur_skia_a11y.cpp +0 -987
  530. package/targets/linux/src/elur_skia_a11y.h +0 -146
  531. package/targets/linux/src/elur_skia_app.cpp +0 -1770
  532. package/targets/linux/src/elur_skia_app.h +0 -18
  533. package/targets/linux/src/elur_state_module.cpp +0 -99
  534. package/targets/linux/src/elur_tck_module.cpp +0 -186
  535. package/targets/linux/src/elur_ui_module.cpp +0 -84
  536. package/targets/linux/src/elur_yoga.cpp +0 -452
  537. package/targets/linux/src/elur_yoga.h +0 -95
  538. package/targets/linux/src/main.cpp +0 -294
  539. package/targets/windows/Package.appxmanifest +0 -28
  540. package/targets/windows/README.md +0 -44
  541. package/targets/windows/elur-windows.vcxproj +0 -133
  542. package/targets/windows/packages.config +0 -10
  543. package/targets/windows/src/elur_crypto_module_win.cpp +0 -106
  544. package/targets/windows/src/elur_events.h +0 -58
  545. package/targets/windows/src/elur_host_win.cpp +0 -645
  546. package/targets/windows/src/elur_host_win.h +0 -75
  547. package/targets/windows/src/elur_http_module_win.cpp +0 -331
  548. package/targets/windows/src/elur_js.h +0 -40
  549. package/targets/windows/src/elur_modules.cpp +0 -460
  550. package/targets/windows/src/elur_modules.h +0 -159
  551. package/targets/windows/src/elur_state_module.cpp +0 -99
  552. package/targets/windows/src/elur_ui_module_win.cpp +0 -75
  553. package/targets/windows/src/elur_uia_host.h +0 -129
  554. package/targets/windows/src/elur_win_applicator.cpp +0 -3118
  555. package/targets/windows/src/elur_win_applicator.h +0 -186
  556. package/targets/windows/src/elur_yoga.cpp +0 -452
  557. package/targets/windows/src/elur_yoga.h +0 -95
  558. package/targets/windows/src/main.cpp +0 -321
@@ -1,1233 +0,0 @@
1
- // elurUiWorklet.cpp — segundo contexto QuickJS-ng en el hilo de UI
2
- // (R6.2 / ADR-0087). Todo el estado de este archivo es thread-confined:
3
- // solo se toca desde el hilo de UI vía los posts de ElurUiWorklet.kt —
4
- // no hay locks porque jamás cruza al JsThread (el bridge principal lo
5
- // tiene vedado).
6
- //
7
- // División:
8
- // C++ — runtime/context + natives __uiwkGet/__uiwkSet/__uiwkBind +
9
- // applyProp JNI (write compositor directo al View)
10
- // JS — prelude embebido: parsea specs, re-evalúa wk.src con
11
- // proxies de signal, easing/timing idénticos a runner.ts,
12
- // tick loop, finals/cancel
13
- //
14
- // Signals: mapa plano nombre→valor (compartido entre worklets, igual
15
- // que en el contexto principal donde la Signal es única). El write de
16
- // un worklet propaga a los Views enlazados por `binds` sin pasar por
17
- // Yoga ni por el bridge del JsThread.
18
-
19
- #include "cesm/core/Region.h"
20
- #include "cesm/core/Slots.h"
21
- #include "quickjs.h"
22
- #include <android/log.h>
23
- #include <cstring>
24
- #include <jni.h>
25
- #include <pthread.h>
26
- #include <string>
27
- #include <unordered_map>
28
- #include <vector>
29
-
30
- #define TAG "elur-uiwk"
31
- #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
32
- #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
33
- #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
34
-
35
- static JavaVM *g_jvm = nullptr;
36
- static JSRuntime *g_rt = nullptr;
37
- static JSContext *g_ctx = nullptr;
38
- static pthread_t g_ui_thread;
39
- static jclass g_kls = nullptr;
40
- static jmethodID g_apply_prop = nullptr;
41
- static jmethodID g_apply_prop_on = nullptr;
42
- // itemView siendo bindeada — vigente solo durante nativeBindRow (todo
43
- // en el hilo UI; los writes del proxy `row` del prelude caen aquí).
44
- static jobject g_bind_row = nullptr;
45
-
46
- // ADR-0087 §cesm — nombre → Region* de las regiones workletSafe
47
- // adjuntas vía nativeCesmBind. El puntero es estable: el shared_ptr
48
- // que lo mantiene vivo reside en el bridge del motor (otro mapa,
49
- // posiblemente otra .so bajo Hermes) hasta cesmDetachUi. La lectura
50
- // usa slots:: (header-only, seqlock) — sin shared_ptr cross-.so.
51
- static std::unordered_map<std::string, const elur::cesm::Region *> g_cesm_ui;
52
-
53
- // name → valor actual de signal (espejo UI del contexto principal)
54
- static std::unordered_map<std::string, double> g_values;
55
- // name → [(viewId, propKey)] — solo props compositor (whitelist JS)
56
- static std::unordered_map<std::string,
57
- std::vector<std::pair<int32_t, std::string>>>
58
- g_binds;
59
-
60
- static JNIEnv *env() {
61
- JNIEnv *e = nullptr;
62
- g_jvm->GetEnv(reinterpret_cast<void **>(&e), JNI_VERSION_1_6);
63
- return e;
64
- }
65
-
66
- // ── Natives expuestos al prelude ────────────────────────────────────
67
-
68
- // ADR-0185 §cuotas — el contexto UI evalúa `src` firmado del wire:
69
- // presupuesto de interrupciones por llamada (bucle infinito → excepción,
70
- // no congela UI), techo de heap y de pila del runtime. La unidad es el
71
- // POLL del intérprete: quickjs-ng llama al handler cada
72
- // JS_INTERRUPT_COUNTER_INIT (10000) saltos hacia atrás — un bucle
73
- // `while(1)` consume un poll cada ~10k iteraciones. El contador lo
74
- // rearma __uiwkBudgetReset antes de cada llamada a fn de worklet —
75
- // cuota por worklet, no por frame: un worklet colgado muere él solo
76
- // vía excepción, no envenena el frame. Valor desarmado = UINT64_MAX:
77
- // el handler cuenta hacia atrás y nunca llega a 0 en código del host
78
- // (prelude eval, dispatch, glue) — solo el armado por worklet cuenta.
79
- static volatile uint64_t g_ops_budget = UINT64_MAX;
80
- // ~50M saltos para eval/glue de llamada JNI — compilar 8KB de src está
81
- // en miles, una IIFE maliciosa con bucle muere en ~0.3-0.5s.
82
- #define UIWK_POLLS_PER_CALL 5000u
83
- // ~3M saltos por fn de worklet de usuario — un worklet legítimo es
84
- // O(vistas); 200 polls ≈ ~20-50ms cortan un bucle infinito en tick.
85
- #define UIWK_POLLS_PER_FN 200u
86
-
87
- static int wk_interrupt_handler(JSContext *, void *) {
88
- return --g_ops_budget == 0 ? 1 : 0;
89
- }
90
-
91
- static JSValue js_uiwk_budget_reset(JSContext *, JSValueConst, int,
92
- JSValueConst *) {
93
- g_ops_budget = UIWK_POLLS_PER_FN;
94
- return JS_UNDEFINED;
95
- }
96
-
97
- static JSValue js_uiwk_get(JSContext *ctx, JSValueConst, int argc,
98
- JSValueConst *argv) {
99
- if (argc < 1)
100
- return JS_NewFloat64(ctx, 0);
101
- const char *name = JS_ToCString(ctx, argv[0]);
102
- double v = 0;
103
- if (name) {
104
- auto it = g_values.find(name);
105
- if (it != g_values.end())
106
- v = it->second;
107
- }
108
- JS_FreeCString(ctx, name);
109
- return JS_NewFloat64(ctx, v);
110
- }
111
-
112
- // Telemetría R6.2: una línea cada 120 writes del worklet — con el hilo
113
- // JS bloqueado, estas líneas demuestran en logcat que el contexto UI
114
- // siguió produciendo (los timestamps se intercalan con el busy-wait).
115
- static int g_set_count = 0;
116
-
117
- static JSValue js_uiwk_set(JSContext *ctx, JSValueConst, int argc,
118
- JSValueConst *argv) {
119
- if (argc < 2)
120
- return JS_UNDEFINED;
121
- const char *name = JS_ToCString(ctx, argv[0]);
122
- double v = 0;
123
- JS_ToFloat64(ctx, &v, argv[1]);
124
- if (!name)
125
- return JS_UNDEFINED;
126
- if (++g_set_count % 120 == 1) {
127
- LOGI("worklet write #%d %s=%.2f", g_set_count, name, v);
128
- }
129
- g_values[name] = v;
130
- auto it = g_binds.find(name);
131
- if (it != g_binds.end() && g_apply_prop) {
132
- JNIEnv *e = env();
133
- for (auto &b : it->second) {
134
- jstring k = e->NewStringUTF(b.second.c_str());
135
- e->CallStaticVoidMethod(g_kls, g_apply_prop, (jint)b.first, k,
136
- (jdouble)v);
137
- e->DeleteLocalRef(k);
138
- }
139
- }
140
- JS_FreeCString(ctx, name);
141
- return JS_UNDEFINED;
142
- }
143
-
144
- static JSValue js_uiwk_bind(JSContext *ctx, JSValueConst, int argc,
145
- JSValueConst *argv) {
146
- if (argc < 3)
147
- return JS_UNDEFINED;
148
- const char *name = JS_ToCString(ctx, argv[0]);
149
- int32_t viewId = 0;
150
- JS_ToInt32(ctx, &viewId, argv[1]);
151
- const char *key = JS_ToCString(ctx, argv[2]);
152
- if (name && key)
153
- g_binds[name].push_back({viewId, key});
154
- JS_FreeCString(ctx, name);
155
- JS_FreeCString(ctx, key);
156
- return JS_UNDEFINED;
157
- }
158
-
159
- // __uiwkCesmRead(name, i) — slot f64 con seqlock; 0 si la región no
160
- // está adjunta (attach denegado → lectura neutra, no excepción: el
161
- // worklet corre igual que con una signal en su valor inicial).
162
- static JSValue js_uiwk_cesm_read(JSContext *ctx, JSValueConst, int argc,
163
- JSValueConst *argv) {
164
- if (argc < 2)
165
- return JS_NewFloat64(ctx, 0);
166
- const char *name = JS_ToCString(ctx, argv[0]);
167
- int32_t i = 0;
168
- JS_ToInt32(ctx, &i, argv[1]);
169
- double v = 0;
170
- if (name) {
171
- auto it = g_cesm_ui.find(name);
172
- if (it != g_cesm_ui.end() && it->second)
173
- elur::cesm::slots::read(*it->second, (size_t)i, v);
174
- }
175
- JS_FreeCString(ctx, name);
176
- return JS_NewFloat64(ctx, v);
177
- }
178
-
179
- // __uiwkCesmReadAll(name) → Array de todos los slots en una sola
180
- // transacción seqlock (buffers: paths, morphs, datos por fila).
181
- static JSValue js_uiwk_cesm_read_all(JSContext *ctx, JSValueConst, int argc,
182
- JSValueConst *argv) {
183
- JSValue arr = JS_NewArray(ctx);
184
- if (argc < 1)
185
- return arr;
186
- const char *name = JS_ToCString(ctx, argv[0]);
187
- if (name) {
188
- auto it = g_cesm_ui.find(name);
189
- if (it != g_cesm_ui.end() && it->second) {
190
- const elur::cesm::Region *r = it->second;
191
- size_t n = elur::cesm::slots::slotCount(*r);
192
- std::vector<double> buf(n);
193
- elur::cesm::slots::readAll(*r, buf.data(), n);
194
- for (size_t i = 0; i < n; i++)
195
- JS_SetPropertyUint32(ctx, arr, (uint32_t)i, JS_NewFloat64(ctx, buf[i]));
196
- }
197
- }
198
- JS_FreeCString(ctx, name);
199
- return arr;
200
- }
201
-
202
- // __uiwkCesmVersion(name) → contador seqlock (el worklet detecta
203
- // cambio sin re-leer el buffer entero).
204
- static JSValue js_uiwk_cesm_version(JSContext *ctx, JSValueConst, int argc,
205
- JSValueConst *argv) {
206
- if (argc < 1)
207
- return JS_NewFloat64(ctx, 0);
208
- const char *name = JS_ToCString(ctx, argv[0]);
209
- double v = 0;
210
- if (name) {
211
- auto it = g_cesm_ui.find(name);
212
- if (it != g_cesm_ui.end() && it->second)
213
- v = (double)elur::cesm::slots::version(*it->second);
214
- }
215
- JS_FreeCString(ctx, name);
216
- return JS_NewFloat64(ctx, v);
217
- }
218
-
219
- // __uiwkRowSet(key, v) — write del proxy `row` de un kind:"bind" sobre
220
- // el itemView en curso (g_bind_row durante __uiwkBindEval).
221
- static JSValue js_uiwk_row_set(JSContext *ctx, JSValueConst, int argc,
222
- JSValueConst *argv) {
223
- if (argc < 2 || !g_bind_row || !g_apply_prop_on)
224
- return JS_UNDEFINED;
225
- const char *key = JS_ToCString(ctx, argv[0]);
226
- double v = 0;
227
- JS_ToFloat64(ctx, &v, argv[1]);
228
- if (key) {
229
- JNIEnv *e = env();
230
- jstring k = e->NewStringUTF(key);
231
- e->CallStaticVoidMethod(g_kls, g_apply_prop_on, g_bind_row, k, (jdouble)v);
232
- e->DeleteLocalRef(k);
233
- }
234
- JS_FreeCString(ctx, key);
235
- return JS_UNDEFINED;
236
- }
237
-
238
- // ── Prelude: eval, timing, easing — espejo de runner.ts ─────────────
239
-
240
- // Timing/easing: espejo exacto de MainThreadRunner (runner.ts) — misma
241
- // tabla de easing, iterations -1 = infinito, direction por nombre,
242
- // delay reaplicado por iteración. La paridad visual exige que el mismo
243
- // spec produzca el mismo eased-t en ambos runners.
244
- static const char *PRELUDE = R"JS(
245
- // ADR-0188 §lockdown — el prelude corre dentro de una IIFE: sus `var`
246
- // quedan locales e inalcanzables para el `src` del wire; los puntos de
247
- // entrada salen por el objeto de retorno (el host los retiene como
248
- // JSValue — ninguno se instala en el global). `this` del eval global
249
- // es el objeto global, capturado como `G` para el lockdown final.
250
- (function(G) {
251
- "use strict";
252
- // Natives → locales: el lockdown los borra del global, pero el prelude
253
- // los sigue usando por su nombre de siempre.
254
- var __uiwkGet = G.__uiwkGet;
255
- var __uiwkSet = G.__uiwkSet;
256
- var __uiwkSetSeed = G.__uiwkSetSeed;
257
- var __uiwkBind = G.__uiwkBind;
258
- var __uiwkBindsClear = G.__uiwkBindsClear;
259
- var __uiwkRowSet = G.__uiwkRowSet;
260
- var __uiwkCesmRead = G.__uiwkCesmRead;
261
- var __uiwkCesmReadAll = G.__uiwkCesmReadAll;
262
- var __uiwkCesmVersion = G.__uiwkCesmVersion;
263
- var __uiwkBudgetReset = G.__uiwkBudgetReset;
264
- var __uiwkCompile = G.__uiwkCompile;
265
- var __uiwkActive = {};
266
- var __uiwkOrder = [];
267
- var __uiwkEASE = {
268
- linear: function(t) { return t; },
269
- ease: function(t) { return t * t * (3 - 2 * t); },
270
- "ease-in": function(t) { return t * t; },
271
- "ease-out": function(t) { return 1 - (1 - t) * (1 - t); },
272
- "ease-in-out": function(t) {
273
- return t < 0.5 ? 2 * t * t : 1 - 2 * (1 - t) * (1 - t);
274
- }
275
- };
276
- var __uiwkProxy = function(name) {
277
- var o = {};
278
- Object.defineProperty(o, "value", {
279
- enumerable: true,
280
- get: function() { return __uiwkGet(name); },
281
- set: function(v) { __uiwkSet(name, v); }
282
- });
283
- return o;
284
- };
285
- // ADR-0087 §cesm — proxy de una región workletSafe con el shape del
286
- // facade SharedRegion (subset lectura): get(i) seqlock por slot,
287
- // readAll() en una transacción, version() = contador seqlock.
288
- // Región no adjunta → 0 / [] (misma regla que signal sin seed).
289
- var __uiwkCesmProxy = function(name) {
290
- return {
291
- get: function(i) { return __uiwkCesmRead(name, i); },
292
- readAll: function() { return __uiwkCesmReadAll(name); },
293
- version: function() { return __uiwkCesmVersion(name); }
294
- };
295
- };
296
- var __uiwkFinals = function(e) {
297
- var f = {};
298
- for (var i = 0; i < e.caps.length; i++) f[e.caps[i].name] = __uiwkGet(e.caps[i].name);
299
- return { id: e.id, finals: f };
300
- };
301
- // signal externa → nº de worklets conducidos por ella (scroll, drag,
302
- // bind). El feed nativo solo agenda frame si hay subs — una signal sin
303
- // worklet es un map-set barato, no un wake del loop.
304
- var __uiwkExtSubs = {};
305
- var __uiwkExtSub = function(e) {
306
- for (var i = 0; i < e.exts.length; i++)
307
- __uiwkExtSubs[e.exts[i]] = (__uiwkExtSubs[e.exts[i]] || 0) + 1;
308
- };
309
- var __uiwkExtUnsub = function(e) {
310
- for (var i = 0; i < e.exts.length; i++) {
311
- var n = (__uiwkExtSubs[e.exts[i]] || 1) - 1;
312
- if (n <= 0) delete __uiwkExtSubs[e.exts[i]];
313
- else __uiwkExtSubs[e.exts[i]] = n;
314
- }
315
- };
316
- var __uiwkRemove = function(idx) {
317
- var id = __uiwkOrder[idx];
318
- var e = __uiwkActive[id];
319
- if (e) {
320
- if (e.exts) __uiwkExtUnsub(e);
321
- delete __uiwkActive[id];
322
- }
323
- __uiwkOrder.splice(idx, 1);
324
- return e;
325
- };
326
-
327
- // Drivers de tramo compartidos (ADR-0089): los usan las entradas
328
- // top-level (animate/spring), los steps de kind:"seq" y el settle
329
- // post-release de kind:"drag". Devuelven true cuando el tramo agotó
330
- // su trabajo; una excepción del fn la maneja el caller como cancel.
331
- var __uiwkStepTiming = function(st, now, regions) {
332
- if (st.t0 < 0) st.t0 = now;
333
- var el = now - st.t0 - st.delay;
334
- if (el < 0) return false;
335
- var raw = Math.min(1, el / st.duration);
336
- var flip = st.direction === "reverse" ||
337
- ((st.direction === "alternate" || st.direction === "alternate-reverse") && st.iter % 2 === 1);
338
- var p = st.direction === "alternate-reverse" ? 1 - raw : raw;
339
- __uiwkBudgetReset();
340
- // call(void 0): un member-call `st.fn()` le regalaría `this` = st —
341
- // el src del wire vería el step interno (caps, iter, regions).
342
- st.fn.call(void 0, st.ease(flip ? 1 - p : p), regions);
343
- if (!(raw < 1)) {
344
- if (st.iterations === -1 || st.iter + 1 < st.iterations) {
345
- st.iter++;
346
- st.t0 = now;
347
- } else {
348
- return true;
349
- }
350
- }
351
- return false;
352
- };
353
- var __uiwkStepSpring = function(st, now) {
354
- // Seeding perezoso: x/v arrancan del valor real al primer tick del
355
- // tramo — en seq el spring parte donde lo dejó el tramo anterior y
356
- // en settle post-release parte del translate al soltar.
357
- if (st.lastT < 0) { st.lastT = now; st.x = __uiwkGet(st.name); st.v = st.v0 || 0; return false; }
358
- var dtms = now - st.lastT;
359
- st.lastT = now;
360
- if (dtms <= 0) return false;
361
- var dt = Math.min(dtms / 1000, 0.064);
362
- var f = -st.k * (st.x - st.to) - st.c * st.v;
363
- st.v += (f / st.m) * dt;
364
- st.x += st.v * dt;
365
- var settled = Math.abs(st.x - st.to) < st.eps && Math.abs(st.v) < st.eps;
366
- __uiwkSet(st.name, settled ? st.to : st.x);
367
- return settled;
368
- };
369
- // ADR-0188 §lockdown — compila el `src` del wire SIN eval/Function JS:
370
- // __uiwkCompile (nativo, JS_Eval) evalúa el wrapper; los params-sombra
371
- // vedan globals e internals por nombre y los proxies de captura entran
372
- // como argumentos — `__uiwkProxy` es interno y el src ya no lo nombra.
373
- // En params duplicados sloppy el ÚLTIMO gana: las capturas van tras
374
- // las sombras, igual que el orden de worklets.ts (SHADOWED_GLOBALS
375
- // primero, locals después).
376
- var __uiwkSHADOW = [
377
- "eval", "Function", "globalThis", "__uiwkCompile",
378
- "__uiwkGet", "__uiwkSet", "__uiwkSetSeed", "__uiwkBind",
379
- "__uiwkBindsClear", "__uiwkRowSet", "__uiwkCesmRead",
380
- "__uiwkCesmReadAll", "__uiwkCesmVersion", "__uiwkBudgetReset",
381
- "__uiwkRegister", "__uiwkTick", "__uiwkCancel", "__uiwkReset",
382
- "__uiwkHasActive", "__uiwkSetExternal", "__uiwkBindEval",
383
- "print", "std", "os", "console", "Worker", "WebSocket",
384
- "XMLHttpRequest", "fetch", "setTimeout", "setInterval",
385
- "setImmediate", "queueMicrotask", "Promise", "require", "process",
386
- "module", "exports", "SharedArrayBuffer", "Atomics",
387
- "importScripts", "postMessage", "ElurBridge", "Proxy", "Reflect",
388
- "ElurSharedMemory", "__elurCallHandler", "__elurCallHandlerWithString",
389
- "__elurFlush", "__elurWorkletArm", "__elurWorkletDisarm",
390
- "__elurInterruptRecovery",
391
- // ADR-0189 — espejo de SHADOWED_GLOBALS (workletForm.ts): en este
392
- // contexto los nombres no existen, pero el vedado es por contrato,
393
- // no por casualidad (un día el contexto gana un global nuevo y el
394
- // src no debe heredarlo).
395
- "EventSource", "WebAssembly", "navigator", "WebTransport",
396
- "BroadcastChannel", "MessageChannel", "indexedDB", "localStorage",
397
- "sessionStorage", "caches", "FileSystemSyncAccessHandle",
398
- "createSyncAccessHandle", "document", "location", "history", "top",
399
- "parent", "frames", "opener", "open", "Image", "Audio",
400
- "Notification", "customElements", "addEventListener",
401
- "removeEventListener", "dispatchEvent", "requestAnimationFrame",
402
- "requestIdleCallback", "MutationObserver", "ResizeObserver",
403
- "IntersectionObserver", "PerformanceObserver", "window", "self",
404
- "global", "close"
405
- ];
406
- var __uiwkSHADOW_ARGS = [];
407
- for (var __si = 0; __si < __uiwkSHADOW.length; __si++)
408
- __uiwkSHADOW_ARGS.push(undefined);
409
-
410
- // Form-check del src antes de compilar (ADR-0188 §2.2 — espejo de
411
- // isWorkletSrcLiteral en worklets.ts): el prelude es la última línea
412
- // antes de evaluar — aunque el cliente valida upstream, el contexto
413
- // no confía en la ruta que lo alimentó. Solo forma literal:
414
- // function(…){…} / ident|params => cuerpo sin `,`/`;` top-level.
415
- var __uiwkIDCHAR = /^[$\w]$/;
416
- function __uiwkSkipWs(s, i) {
417
- while (i < s.length && /\s/.test(s[i])) i++;
418
- return i;
419
- }
420
- function __uiwkScanParams(s, i) {
421
- if (s[i] !== "(") return -1;
422
- var close = s.indexOf(")", i + 1);
423
- if (close < 0 || !/^[^(){};=]*$/.test(s.slice(i + 1, close)))
424
- return -1;
425
- return close + 1;
426
- }
427
- function __uiwkScanBlock(s, i) {
428
- if (s[i] !== "{") return -1;
429
- var depth = 0;
430
- for (var j = i; j < s.length; j++) {
431
- if (s[j] === "{") depth++;
432
- else if (s[j] === "}") {
433
- depth--;
434
- if (depth === 0) return j + 1;
435
- }
436
- }
437
- return -1;
438
- }
439
- function __uiwkSkipString(s, i, q) {
440
- for (var j = i + 1; j < s.length; j++) {
441
- if (s[j] === "\\") { j++; continue; }
442
- if (s[j] === q) return j;
443
- if (q !== "`" && (s[j] === "\n" || s[j] === "\r")) return -1;
444
- }
445
- return -1;
446
- }
447
- function __uiwkScanArrowBody(s, i) {
448
- var depth = 0, saw = false;
449
- for (var j = i; j < s.length; j++) {
450
- var c = s[j];
451
- if (c === "/" && s[j + 1] === "/") return false; // // traga hasta EOL
452
- if (c === "/" && s[j + 1] === "*") {
453
- var e2 = s.indexOf("*/", j + 2);
454
- if (e2 < 0) return false;
455
- j = e2 + 1;
456
- continue;
457
- }
458
- if (c === "'" || c === '"' || c === "`") {
459
- j = __uiwkSkipString(s, j, c);
460
- if (j < 0) return false;
461
- saw = true;
462
- continue;
463
- }
464
- if (/\s/.test(c)) continue;
465
- saw = true;
466
- if (c === "(" || c === "[" || c === "{") depth++;
467
- else if (c === ")" || c === "]" || c === "}") {
468
- if (--depth < 0) return false;
469
- } else if ((c === "," || c === ";") && depth === 0) {
470
- return false;
471
- }
472
- }
473
- return depth === 0 && saw;
474
- }
475
- var __uiwkRESERVED = {
476
- "arguments":1,"await":1,"break":1,"case":1,"catch":1,"class":1,
477
- "const":1,"continue":1,"debugger":1,"default":1,"delete":1,"do":1,
478
- "else":1,"enum":1,"eval":1,"export":1,"extends":1,"false":1,
479
- "finally":1,"for":1,"function":1,"if":1,"implements":1,"import":1,
480
- "in":1,"instanceof":1,"interface":1,"let":1,"new":1,"null":1,
481
- "package":1,"private":1,"protected":1,"public":1,"return":1,
482
- "static":1,"super":1,"switch":1,"this":1,"throw":1,"true":1,"try":1,
483
- "typeof":1,"var":1,"void":1,"while":1,"with":1,"yield":1
484
- };
485
- function __uiwkSrcIsLiteral(src) {
486
- var s = src, i = __uiwkSkipWs(s, 0);
487
- if (s.startsWith("async", i) && !__uiwkIDCHAR.test(s[i + 5] || ""))
488
- i = __uiwkSkipWs(s, i + 5);
489
- if (s.startsWith("function", i) && !__uiwkIDCHAR.test(s[i + 8] || "")) {
490
- i = __uiwkSkipWs(s, i + 8);
491
- var nm = /^[$\w]+/.exec(s.slice(i));
492
- if (nm) i = __uiwkSkipWs(s, i + nm[0].length);
493
- var pe = __uiwkScanParams(s, i);
494
- if (pe < 0) return false;
495
- i = __uiwkSkipWs(s, pe);
496
- var be = __uiwkScanBlock(s, i);
497
- return be >= 0 && __uiwkSkipWs(s, be) === s.length;
498
- }
499
- if (s[i] === "(") {
500
- var pe2 = __uiwkScanParams(s, i);
501
- if (pe2 < 0) return false;
502
- i = __uiwkSkipWs(s, pe2);
503
- } else {
504
- var nm2 = /^[$A-Z_a-z][$\w]*/.exec(s.slice(i));
505
- if (!nm2 || __uiwkRESERVED[nm2[0]]) return false;
506
- i = __uiwkSkipWs(s, i + nm2[0].length);
507
- }
508
- if (!s.startsWith("=>", i)) return false;
509
- i = __uiwkSkipWs(s, i + 2);
510
- // `=> {` es cuerpo bloque: tras `}` solo whitespace — un operador
511
- // continuaba la expresión del wrapper (`(x => {} + f())` corre f()).
512
- if (s[i] === "{") {
513
- var be2 = __uiwkScanBlock(s, i);
514
- return be2 >= 0 && __uiwkSkipWs(s, be2) === s.length;
515
- }
516
- return __uiwkScanArrowBody(s, i);
517
- }
518
-
519
- var __uiwkIdent = /^[$A-Z_a-z][$\w]*$/;
520
- var __uiwkCompileFn = function(src, capture) {
521
- var names = [], proxies = [];
522
- for (var local in capture) {
523
- // Los locales viajan al param-list del wrapper compilado — un
524
- // nombre no-identificador inyectaría sintaxis en la eval.
525
- if (!__uiwkIdent.test(local)) return null;
526
- names.push(local);
527
- proxies.push(__uiwkProxy(capture[local]));
528
- }
529
- // Re-chequeo de forma en la frontera de eval: un src con cola
530
- // (coma/`;` top-level tras `=>`) ejecutaría la cola AL COMPILAR.
531
- if (!__uiwkSrcIsLiteral(src)) return null;
532
- // El wrapper externo queda sloppy (params duplicados: la captura
533
- // gana a la sombra — orden SHADOW→capture, mismo que worklets.ts),
534
- // pero el `src` se compila bajo "use strict" en la IIFE interna:
535
- // así `this` dentro de la fn del wire es undefined — sloppy le
536
- // regalaba el objeto global del contexto (this.JSON, this.Math…).
537
- var outer;
538
- try {
539
- outer = __uiwkCompile(
540
- "(function(" + __uiwkSHADOW.concat(names).join(",") +
541
- "){return (function(){\"use strict\";return (" + src +
542
- ");})();})");
543
- } catch (e) { return null; }
544
- if (typeof outer !== "function") return null;
545
- return outer.apply(null, __uiwkSHADOW_ARGS.concat(proxies));
546
- };
547
-
548
- var __uiwkRegister = function(specJson) {
549
- var s;
550
- try { s = JSON.parse(specJson); } catch (e) { return JSON.stringify({ok:false}); }
551
- var caps = [];
552
- for (var local in s.capture) {
553
- caps.push({ local: local, name: s.capture[local] });
554
- }
555
- // Aliases CESM → proxies en un bag que viaja como ÚLTIMO arg del fn
556
- // (mismo shape que el contexto principal, donde es una proyección
557
- // SharedRegion real — el src corre idéntico en ambos runners).
558
- var regions = null;
559
- for (var alias in (s.cesm || {})) {
560
- (regions = regions || {})[alias] = __uiwkCesmProxy(s.cesm[alias]);
561
- }
562
- var i, j, nm, bs;
563
- for (i = 0; i < caps.length; i++) {
564
- nm = caps[i].name;
565
- if (s.values && s.values[nm] !== undefined) __uiwkSetSeed(nm, s.values[nm]);
566
- bs = s.binds ? s.binds[nm] : null;
567
- if (bs) for (j = 0; j < bs.length; j++) __uiwkBind(nm, bs[j][0], bs[j][1]);
568
- }
569
- // kind:"spring" — driver paramétrico sin src: la física la ejecuta
570
- // __uiwkTick (semi-implicit Euler idéntico a runner.ts). caps[0] es
571
- // la signal única del resorte.
572
- if (s.kind === "spring" && caps.length > 0) {
573
- var sp = s.spring || {};
574
- nm = caps[0].name;
575
- __uiwkActive[s.id] = {
576
- id: s.id, kind: "spring", caps: caps, name: nm,
577
- v0: sp.velocity || 0,
578
- to: sp.to === undefined ? 0 : sp.to,
579
- k: sp.stiffness === undefined ? 170 : sp.stiffness,
580
- c: sp.damping === undefined ? 20 : sp.damping,
581
- m: sp.mass === undefined ? 1 : sp.mass,
582
- eps: sp.epsilon === undefined ? 0.01 : sp.epsilon,
583
- lastT: -1, x: 0, v: 0
584
- };
585
- __uiwkOrder.push(s.id);
586
- return JSON.stringify({ok:true});
587
- }
588
- // kind:"seq" (ADR-0089 §sequence) — composición serial en contexto:
589
- // cada tramo animate compila su src con SU capture (los locales son
590
- // por worklet — el mismo local puede apuntar a signals distintas en
591
- // tramos distintos); cada tramo spring referencia la signal por su
592
- // nombre global. Al agotar la lista `iterations` reinicia al paso 0.
593
- if (s.kind === "seq" && s.steps && s.steps.length > 0) {
594
- var steps = [];
595
- var bad = false;
596
- for (i = 0; i < s.steps.length; i++) {
597
- var sst = s.steps[i];
598
- if (sst.kind === "spring") {
599
- var sp2 = sst.spring || {};
600
- steps.push({
601
- kind: "spring", name: sst.name,
602
- v0: sp2.velocity || 0,
603
- to: sp2.to === undefined ? 0 : sp2.to,
604
- k: sp2.stiffness === undefined ? 170 : sp2.stiffness,
605
- c: sp2.damping === undefined ? 20 : sp2.damping,
606
- m: sp2.mass === undefined ? 1 : sp2.mass,
607
- eps: sp2.epsilon === undefined ? 0.01 : sp2.epsilon,
608
- lastT: -1, x: 0, v: 0
609
- });
610
- } else {
611
- var fn2;
612
- try { fn2 = __uiwkCompileFn(sst.src, sst.capture || {}); }
613
- catch (e2) { bad = true; break; }
614
- if (typeof fn2 !== "function") { bad = true; break; }
615
- var tm2 = sst.timing || {};
616
- steps.push({
617
- kind: "animate", fn: fn2, t0: -1, iter: 0,
618
- duration: tm2.duration === undefined ? 300 : tm2.duration,
619
- delay: tm2.delay || 0,
620
- iterations: tm2.iterations === undefined ? 1 : tm2.iterations,
621
- direction: tm2.direction || "normal",
622
- ease: __uiwkEASE[tm2.easing || "ease-out"] || __uiwkEASE["ease-out"]
623
- });
624
- }
625
- }
626
- if (bad) return JSON.stringify({ok:false});
627
- __uiwkActive[s.id] = {
628
- id: s.id, kind: "seq", caps: caps, regions: regions,
629
- steps: steps, cur: 0, iter: 0,
630
- iterations: s.iterations === undefined ? 1 : s.iterations
631
- };
632
- __uiwkOrder.push(s.id);
633
- return JSON.stringify({ok:true});
634
- }
635
- var fn;
636
- try { fn = __uiwkCompileFn(s.src, s.capture || {}); }
637
- catch (e2) { return JSON.stringify({ok:false}); }
638
- if (typeof fn !== "function") return JSON.stringify({ok:false});
639
- // kind:"scroll" — driver continuo: el RecyclerView alimenta la signal
640
- // `s.scroll` ("__scroll_<listId>") directo desde onScrolled sin pasar
641
- // por el JsThread. El fn se re-evalúa con el offset en el tick donde
642
- // el signal cambió (dirty); nunca reporta done — vive hasta que el
643
- // nodo lista muere (cancel/reset).
644
- if (s.kind === "scroll" && s.scroll) {
645
- var se = {
646
- id: s.id, kind: "scroll", fn: fn, caps: caps, regions: regions,
647
- scroll: s.scroll, exts: [s.scroll], dirty: true
648
- };
649
- __uiwkActive[s.id] = se;
650
- __uiwkOrder.push(s.id);
651
- __uiwkExtSub(se);
652
- return JSON.stringify({ok:true});
653
- }
654
- // kind:"drag" — driver por gesto: el OnTouchListener nativo del view
655
- // `s.drag` alimenta "__drag_<id>_dx|_dy|_p|_vx|_vy" (delta lógico
656
- // desde el down, fase 1=down/2=move/0=up y velocidad en lógicas/s al
657
- // soltar). La fn recibe (dx, dy, phase, vx, vy). `release` (ADR-0089
658
- // §gestures) arma el settle: un spring in-context sobre la signal
659
- // `drive` hacia el valor que el worklet dejó en `target` al evaluar
660
- // la fase 0 — `commit` ≠0 → done (finals al modelo), 0 → rearma.
661
- if (s.kind === "drag" && s.drag !== undefined) {
662
- var dn = "__drag_" + s.drag;
663
- var de = {
664
- id: s.id, kind: "drag", fn: fn, caps: caps, regions: regions,
665
- dx: dn + "_dx", dy: dn + "_dy", dp: dn + "_p",
666
- vx: dn + "_vx", vy: dn + "_vy",
667
- exts: [dn + "_dx", dn + "_dy", dn + "_p", dn + "_vx", dn + "_vy"],
668
- dirty: false, settle: null, relCommit: false
669
- };
670
- var rl = s.release;
671
- if (rl) {
672
- var rsp = rl.spring || {};
673
- var relDrive = s.capture[rl.drive];
674
- var relTarget = s.capture[rl.target];
675
- if (relDrive && relTarget) {
676
- de.rel = {
677
- target: relTarget,
678
- commit: rl.commit ? s.capture[rl.commit] : null,
679
- spring: {
680
- name: relDrive, v0: 0, to: 0, lastT: -1, x: 0, v: 0,
681
- k: rsp.stiffness === undefined ? 170 : rsp.stiffness,
682
- c: rsp.damping === undefined ? 20 : rsp.damping,
683
- m: rsp.mass === undefined ? 1 : rsp.mass,
684
- eps: rsp.epsilon === undefined ? 0.01 : rsp.epsilon
685
- }
686
- };
687
- }
688
- }
689
- __uiwkActive[s.id] = de;
690
- __uiwkOrder.push(s.id);
691
- __uiwkExtSub(de);
692
- return JSON.stringify({ok:true});
693
- }
694
- // kind:"bind" — evaluado síncrono desde el onBindViewHolder nativo
695
- // (__uiwkBindEval), NO por tick: la fila nace ya transformada. `list`
696
- // es el nodeId de la lista; la fn recibe (position, row) — `row` es
697
- // el proxy que aplica props compositor al itemView siendo bindeado.
698
- if (s.kind === "bind" && s.list !== undefined) {
699
- __uiwkActive[s.id] = { id: s.id, kind: "bind", fn: fn, caps: caps,
700
- regions: regions, list: s.list };
701
- __uiwkOrder.push(s.id);
702
- return JSON.stringify({ok:true});
703
- }
704
- var tm = s.timing || {};
705
- __uiwkActive[s.id] = {
706
- id: s.id, fn: fn, caps: caps, regions: regions,
707
- t0: -1, iter: 0,
708
- duration: tm.duration === undefined ? 300 : tm.duration,
709
- delay: tm.delay || 0,
710
- iterations: tm.iterations === undefined ? 1 : tm.iterations,
711
- direction: tm.direction || "normal",
712
- ease: __uiwkEASE[tm.easing || "ease-out"] || __uiwkEASE["ease-out"]
713
- };
714
- __uiwkOrder.push(s.id);
715
- return JSON.stringify({ok:true});
716
- };
717
-
718
- var __uiwkTick = function(now) {
719
- var fin = [], can = [];
720
- for (var i = __uiwkOrder.length - 1; i >= 0; i--) {
721
- var id = __uiwkOrder[i];
722
- var e = __uiwkActive[id];
723
- if (!e) { __uiwkOrder.splice(i, 1); continue; }
724
- // kind:"bind" no es frame-driven: se evalúa síncrono por
725
- // __uiwkBindEval. Sin este guard caería al path de animate — con
726
- // t0 undefined produce raw=NaN y la removemos como finished en el
727
- // primer frame (muerte silenciosa del row-worklet).
728
- if (e.kind === "bind") continue;
729
- // Drivers conducidos por signals externas (scroll/drag): re-evalúan
730
- // solo cuando alguna cambió (dirty). Una excepción lo retira como
731
- // cancelled — igual que los animate (el contexto es compartido; un
732
- // worklet no congela a los demás).
733
- if (e.kind === "scroll") {
734
- if (!e.dirty) continue;
735
- e.dirty = false;
736
- __uiwkBudgetReset();
737
- try { e.fn.call(void 0, __uiwkGet(e.scroll) || 0, e.regions); }
738
- catch (es) { can.push(__uiwkFinals(__uiwkRemove(i))); }
739
- continue;
740
- }
741
- if (e.kind === "drag") {
742
- if (e.dirty) {
743
- e.dirty = false;
744
- var dp = __uiwkGet(e.dp) || 0;
745
- try {
746
- __uiwkBudgetReset();
747
- e.fn.call(void 0, __uiwkGet(e.dx) || 0, __uiwkGet(e.dy) || 0, dp,
748
- __uiwkGet(e.vx) || 0, __uiwkGet(e.vy) || 0, e.regions);
749
- }
750
- catch (es) { can.push(__uiwkFinals(__uiwkRemove(i))); continue; }
751
- // ADR-0089 §gestures — release-settle: al soltar, un spec con
752
- // `release` arma un spring sobre `drive` hacia el destino que
753
- // el worklet escribió en `target`. Un gesto nuevo (dirty con
754
- // p≠0) interrumpe el settle y devuelve el control al feed.
755
- if (dp === 0 && e.rel) {
756
- e.rel.spring.to = __uiwkGet(e.rel.target);
757
- e.rel.spring.lastT = -1;
758
- e.settle = e.rel.spring;
759
- e.relCommit = e.rel.commit ? __uiwkGet(e.rel.commit) !== 0 : false;
760
- } else {
761
- e.settle = null;
762
- }
763
- } else if (e.settle) {
764
- var sdone;
765
- try { sdone = __uiwkStepSpring(e.settle, now); }
766
- catch (es2) { can.push(__uiwkFinals(__uiwkRemove(i))); continue; }
767
- if (sdone) {
768
- var com = e.relCommit;
769
- e.settle = null;
770
- // commit → done: los finals llevan la decisión al modelo
771
- // (onDismiss). Snap-back → el worklet rearma para el próximo
772
- // gesto, sin emitir done.
773
- if (com) fin.push(__uiwkFinals(__uiwkRemove(i)));
774
- }
775
- }
776
- continue;
777
- }
778
- // Física del resorte — espejo de runner.ts spring(): dt del frame
779
- // real con clamp 64ms, semi-implicit Euler, reposo clava `to`.
780
- if (e.kind === "spring") {
781
- var ssp;
782
- try { ssp = __uiwkStepSpring(e, now); }
783
- catch (es3) { can.push(__uiwkFinals(__uiwkRemove(i))); continue; }
784
- if (ssp) fin.push(__uiwkFinals(__uiwkRemove(i)));
785
- continue;
786
- }
787
- // kind:"seq" — tramo vigente hasta que termina; reset del estado del
788
- // tramo al avanzar para que una iteración lo re-corra limpio.
789
- if (e.kind === "seq") {
790
- var st = e.steps[e.cur];
791
- var stDone;
792
- try {
793
- stDone = st.kind === "spring" ? __uiwkStepSpring(st, now)
794
- : __uiwkStepTiming(st, now, e.regions);
795
- }
796
- catch (es4) { can.push(__uiwkFinals(__uiwkRemove(i))); continue; }
797
- if (stDone) {
798
- st.t0 = -1; st.iter = 0; st.lastT = -1;
799
- e.cur++;
800
- if (e.cur >= e.steps.length) {
801
- e.cur = 0;
802
- e.iter++;
803
- if (e.iterations !== -1 && e.iter >= e.iterations) {
804
- fin.push(__uiwkFinals(__uiwkRemove(i)));
805
- }
806
- }
807
- }
808
- continue;
809
- }
810
- try {
811
- if (__uiwkStepTiming(e, now, e.regions)) fin.push(__uiwkFinals(__uiwkRemove(i)));
812
- }
813
- catch (err) { can.push(__uiwkFinals(__uiwkRemove(i))); }
814
- }
815
- return JSON.stringify({ finished: fin, cancelled: can });
816
- };
817
-
818
- var __uiwkCancel = function(id) {
819
- var idx = __uiwkOrder.indexOf(id);
820
- if (idx < 0) return "{}";
821
- var e = __uiwkRemove(idx);
822
- // Los finals del punto de corte viajan al modelo — la vista quedó
823
- // donde el último write la dejó y el signal debe reflejarlo.
824
- return JSON.stringify(__uiwkFinals(e));
825
- };
826
- var __uiwkReset = function() {
827
- var ids = [];
828
- for (var i = 0; i < __uiwkOrder.length; i++) ids.push(__uiwkOrder[i]);
829
- __uiwkActive = {};
830
- __uiwkOrder = [];
831
- __uiwkExtSubs = {};
832
- __uiwkBindsClear();
833
- return JSON.stringify(ids);
834
- };
835
- // "Hay trabajo" ≠ "hay entradas": los worklets conducidos por signals
836
- // externas idle no cuentan — sin este gating el Choreographer
837
- // repostearía por siempre (dreno de batería sin scroll/drag). El feed
838
- // nativo despierta el loop vía __uiwkSetExternal al marcar dirty.
839
- var __uiwkHasActive = function() {
840
- for (var i = 0; i < __uiwkOrder.length; i++) {
841
- var e = __uiwkActive[__uiwkOrder[i]];
842
- if (!e) continue;
843
- if (e.kind === "bind") continue; // síncrono por bind — no frame-driven
844
- // settle post-release (ADR-0089): el drag no depende ya del feed —
845
- // el spring corre por frame hasta asentar.
846
- if (!e.exts || e.dirty || e.settle) return true;
847
- }
848
- return false;
849
- };
850
- // Eval síncrono de row-worklets desde onBindViewHolder: fn(pos, row).
851
- // Errores retiran la entrada como cancelled — un row-worklet roto no
852
- // rompe el bind de las filas siguientes.
853
- var __uiwkBindEval = function(listId, pos) {
854
- var can = [];
855
- for (var i = __uiwkOrder.length - 1; i >= 0; i--) {
856
- var e = __uiwkActive[__uiwkOrder[i]];
857
- if (e && e.kind === "bind" && e.list === listId) {
858
- __uiwkBudgetReset();
859
- try { e.fn.call(void 0, pos, __uiwkRow, e.regions); }
860
- catch (err) { can.push(__uiwkFinals(__uiwkRemove(i))); }
861
- }
862
- }
863
- return JSON.stringify({ finished: [], cancelled: can });
864
- };
865
- // Proxy de la fila siendo bindeada: escribir una clave compositor
866
- // aplica directo al itemView nativo (vía __uiwkRowSet → g_bindRow).
867
- var __uiwkRow = {};
868
- var __uiwkRowKeys = ["opacity","translateX","translateY","scaleX","scaleY","rotate"];
869
- for (var __ri = 0; __ri < __uiwkRowKeys.length; __ri++) {
870
- (function(k) {
871
- Object.defineProperty(__uiwkRow, k, {
872
- set: function(v) { __uiwkRowSet(k, v); }
873
- });
874
- })(__uiwkRowKeys[__ri]);
875
- }
876
- // Sync externo (main→UI por watch, o el feed nativo scroll/drag). Marca
877
- // dirty a los worklets suscritos a esa signal y devuelve si hay dirty
878
- // pendiente — Kotlin postea el frame solo cuando es true.
879
- var __uiwkSetExternal = function(name, v) {
880
- __uiwkSetSeed(name, v);
881
- var dirty = false;
882
- if (__uiwkExtSubs[name]) {
883
- for (var i = 0; i < __uiwkOrder.length; i++) {
884
- var e = __uiwkActive[__uiwkOrder[i]];
885
- if (e && e.exts && e.exts.indexOf(name) >= 0) {
886
- e.dirty = true; dirty = true;
887
- }
888
- }
889
- }
890
- return dirty;
891
- };
892
-
893
- // ── Lockdown (ADR-0188 §lockdown) — corre UNA vez, antes del primer
894
- // registro. El src del wire corre siempre en este contexto compartido:
895
- // se vedan eval/Function/globalThis, los internals __uiwk* salen del
896
- // global, los constructores dinámicos alcanzables por cadena
897
- // `.constructor` quedan envenenados y los intrínsecos se congelan —
898
- // la contaminación de prototipos es sabotaje entre worklets. No es un
899
- // realm: la frontera es de superficie (los residuales — bugs del
900
- // motor, gadgets exóticos — quedan declarados en el ADR).
901
- var __uiwkPoison = function() {
902
- throw new TypeError("uiwk: construcción dinámica bloqueada");
903
- };
904
- try { Function.prototype.constructor = __uiwkPoison; } catch (e0) {}
905
- try {
906
- // AsyncFunction/GeneratorFunction/AsyncGeneratorFunction — solo
907
- // alcanzables por cadena de prototipos (nunca por global: los
908
- // nombres ni existen). El slot `constructor` de cada proto es
909
- // read-only en QuickJS pero configurable → defineProperty, no
910
- // asignación (en V8 la asignación bastaría; defineProperty cubre
911
- // ambos).
912
- var __uiwkCtorProtos = [
913
- Object.getPrototypeOf(function*(){}),
914
- Object.getPrototypeOf(async function(){}),
915
- Object.getPrototypeOf(async function*(){})
916
- ];
917
- for (var __ci = 0; __ci < __uiwkCtorProtos.length; __ci++) {
918
- try {
919
- Object.defineProperty(__uiwkCtorProtos[__ci], "constructor", {
920
- value: __uiwkPoison, writable: false,
921
- enumerable: false, configurable: false
922
- });
923
- } catch (e1x) {}
924
- }
925
- } catch (e1) {}
926
- delete G.eval;
927
- delete G.Function;
928
- delete G.globalThis;
929
- for (var __di = 0; __di < __uiwkSHADOW.length; __di++) {
930
- try { delete G[__uiwkSHADOW[__di]]; } catch (e2) {}
931
- }
932
- var __uiwkGlobals = Object.getOwnPropertyNames(G);
933
- for (var __gi = 0; __gi < __uiwkGlobals.length; __gi++) {
934
- try {
935
- var __gv = G[__uiwkGlobals[__gi]];
936
- if (__gv && (typeof __gv === "object" || typeof __gv === "function")) {
937
- if (__gv.prototype) Object.freeze(__gv.prototype);
938
- Object.freeze(__gv);
939
- }
940
- } catch (e3) {}
941
- }
942
- try { Object.freeze(G); } catch (e4) {}
943
-
944
- // Los puntos de entrada vuelven al host como valor — jamás en global.
945
- return {
946
- __uiwkRegister: __uiwkRegister,
947
- __uiwkTick: __uiwkTick,
948
- __uiwkCancel: __uiwkCancel,
949
- __uiwkReset: __uiwkReset,
950
- __uiwkHasActive: __uiwkHasActive,
951
- __uiwkSetExternal: __uiwkSetExternal,
952
- __uiwkBindEval: __uiwkBindEval
953
- };
954
- })(this);
955
- )JS";
956
-
957
- // __uiwkSetSeed — set sin propaga a views (sync desde el contexto
958
- // principal: el bridge ya aplicó el valor por su camino normal).
959
- static JSValue js_uiwk_set_seed(JSContext *ctx, JSValueConst, int argc,
960
- JSValueConst *argv) {
961
- if (argc < 2)
962
- return JS_UNDEFINED;
963
- const char *name = JS_ToCString(ctx, argv[0]);
964
- double v = 0;
965
- JS_ToFloat64(ctx, &v, argv[1]);
966
- if (name)
967
- g_values[name] = v;
968
- JS_FreeCString(ctx, name);
969
- return JS_UNDEFINED;
970
- }
971
-
972
- static JSValue js_uiwk_binds_clear(JSContext *ctx, JSValueConst, int,
973
- JSValueConst *) {
974
- g_binds.clear();
975
- return JS_UNDEFINED;
976
- }
977
-
978
- // __uiwkCompile(decl) — ADR-0188 §lockdown: el prelude compila los
979
- // wrappers de `src` por JS_Eval nativo, no por `eval` de JS — así el
980
- // global `eval` puede morir en el lockdown. El nativo sale del global
981
- // tras el prelude (solo el prelude lo captura como local).
982
- static JSValue js_uiwk_compile(JSContext *ctx, JSValueConst, int argc,
983
- JSValueConst *argv) {
984
- if (argc < 1)
985
- return JS_UNDEFINED;
986
- size_t len = 0;
987
- const char *src = JS_ToCStringLen(ctx, &len, argv[0]);
988
- if (!src)
989
- return JS_ThrowTypeError(ctx, "uiwk compile sin decl");
990
- JSValue r = JS_Eval(ctx, src, len, "<uiwk-compile>", JS_EVAL_TYPE_GLOBAL);
991
- JS_FreeCString(ctx, src);
992
- return r;
993
- }
994
-
995
- // Puntos de entrada del prelude (ADR-0188 §lockdown): el prelude los
996
- // devuelve como objeto; nunca se instalan en el global — el src del
997
- // wire no los puede nombrar ni alcanzar por `this`.
998
- static std::unordered_map<std::string, JSValue> g_fns;
999
-
1000
- static void ensure_ctx(JNIEnv *e) {
1001
- if (g_ctx)
1002
- return;
1003
- g_ui_thread = pthread_self();
1004
- g_rt = JS_NewRuntime();
1005
- JS_SetMemoryLimit(g_rt, 8 * 1024 * 1024);
1006
- JS_SetMaxStackSize(g_rt, 256 * 1024);
1007
- JS_SetInterruptHandler(g_rt, wk_interrupt_handler, nullptr);
1008
- g_ctx = JS_NewContext(g_rt);
1009
- JS_SetContextOpaque(g_ctx, nullptr);
1010
- JSValue global = JS_GetGlobalObject(g_ctx);
1011
- JS_SetPropertyStr(g_ctx, global, "__uiwkGet",
1012
- JS_NewCFunction(g_ctx, js_uiwk_get, "__uiwkGet", 1));
1013
- JS_SetPropertyStr(g_ctx, global, "__uiwkSet",
1014
- JS_NewCFunction(g_ctx, js_uiwk_set, "__uiwkSet", 2));
1015
- JS_SetPropertyStr(
1016
- g_ctx, global, "__uiwkSetSeed",
1017
- JS_NewCFunction(g_ctx, js_uiwk_set_seed, "__uiwkSetSeed", 2));
1018
- JS_SetPropertyStr(g_ctx, global, "__uiwkBind",
1019
- JS_NewCFunction(g_ctx, js_uiwk_bind, "__uiwkBind", 3));
1020
- JS_SetPropertyStr(
1021
- g_ctx, global, "__uiwkBindsClear",
1022
- JS_NewCFunction(g_ctx, js_uiwk_binds_clear, "__uiwkBindsClear", 0));
1023
- JS_SetPropertyStr(g_ctx, global, "__uiwkRowSet",
1024
- JS_NewCFunction(g_ctx, js_uiwk_row_set, "__uiwkRowSet", 2));
1025
- JS_SetPropertyStr(
1026
- g_ctx, global, "__uiwkCesmRead",
1027
- JS_NewCFunction(g_ctx, js_uiwk_cesm_read, "__uiwkCesmRead", 2));
1028
- JS_SetPropertyStr(
1029
- g_ctx, global, "__uiwkCesmReadAll",
1030
- JS_NewCFunction(g_ctx, js_uiwk_cesm_read_all, "__uiwkCesmReadAll", 1));
1031
- JS_SetPropertyStr(
1032
- g_ctx, global, "__uiwkCesmVersion",
1033
- JS_NewCFunction(g_ctx, js_uiwk_cesm_version, "__uiwkCesmVersion", 1));
1034
- JS_SetPropertyStr(
1035
- g_ctx, global, "__uiwkBudgetReset",
1036
- JS_NewCFunction(g_ctx, js_uiwk_budget_reset, "__uiwkBudgetReset", 0));
1037
- JS_SetPropertyStr(
1038
- g_ctx, global, "__uiwkCompile",
1039
- JS_NewCFunction(g_ctx, js_uiwk_compile, "__uiwkCompile", 1));
1040
- JS_FreeValue(g_ctx, global);
1041
-
1042
- jclass local = e->FindClass("com/elur/universal/ElurUiWorklet");
1043
- g_kls = (jclass)e->NewGlobalRef(local);
1044
- e->DeleteLocalRef(local);
1045
- g_apply_prop =
1046
- e->GetStaticMethodID(g_kls, "applyProp", "(ILjava/lang/String;D)V");
1047
- g_apply_prop_on = e->GetStaticMethodID(
1048
- g_kls, "applyPropOn", "(Landroid/view/View;Ljava/lang/String;D)V");
1049
-
1050
- JSValue r =
1051
- JS_Eval(g_ctx, PRELUDE, strlen(PRELUDE), "<uiwk>", JS_EVAL_TYPE_GLOBAL);
1052
- if (JS_IsException(r)) {
1053
- JSValue exc = JS_GetException(g_ctx);
1054
- const char *err = JS_ToCString(g_ctx, exc);
1055
- LOGE("prelude: %s", err ? err : "?");
1056
- JS_FreeCString(g_ctx, err);
1057
- JS_FreeValue(g_ctx, exc);
1058
- } else if (JS_IsObject(r)) {
1059
- // El prelude devuelve sus entry points ya bajo lockdown — el host
1060
- // los retiene como JSValue, ninguno queda en el global.
1061
- static const char *const kEntries[] = {
1062
- "__uiwkRegister", "__uiwkTick", "__uiwkCancel", "__uiwkReset",
1063
- "__uiwkHasActive", "__uiwkSetExternal", "__uiwkBindEval",
1064
- };
1065
- for (const char *k : kEntries) {
1066
- JSValue f = JS_GetPropertyStr(g_ctx, r, k);
1067
- if (JS_IsFunction(g_ctx, f)) {
1068
- g_fns[k] = f;
1069
- } else {
1070
- LOGE("prelude sin entry point %s", k);
1071
- JS_FreeValue(g_ctx, f);
1072
- }
1073
- }
1074
- }
1075
- JS_FreeValue(g_ctx, r);
1076
- }
1077
-
1078
- static bool on_ui_thread() {
1079
- return pthread_equal(pthread_self(), g_ui_thread);
1080
- }
1081
-
1082
- static JSValue call_prelude(const char *fn, int argc, JSValueConst *argv) {
1083
- g_ops_budget = UIWK_POLLS_PER_CALL; // cuota CPU por llamada (ADR-0185)
1084
- auto it = g_fns.find(fn);
1085
- JSValue f = it != g_fns.end() ? JS_DupValue(g_ctx, it->second) : JS_UNDEFINED;
1086
- JSValue global = JS_GetGlobalObject(g_ctx);
1087
- JSValue r = JS_IsFunction(g_ctx, f) ? JS_Call(g_ctx, f, global, argc, argv)
1088
- : JS_EXCEPTION;
1089
- JS_FreeValue(g_ctx, f);
1090
- JS_FreeValue(g_ctx, global);
1091
- if (JS_IsException(r)) {
1092
- JSValue exc = JS_GetException(g_ctx);
1093
- const char *err = JS_ToCString(g_ctx, exc);
1094
- LOGE("%s: %s", fn, err ? err : "?");
1095
- JS_FreeCString(g_ctx, err);
1096
- JS_FreeValue(g_ctx, exc);
1097
- }
1098
- return r;
1099
- }
1100
-
1101
- static jstring call_json(JNIEnv *e, const char *fn, int argc,
1102
- JSValueConst *argv, const char *fallback) {
1103
- JSValue r = call_prelude(fn, argc, argv);
1104
- const char *s = JS_ToCString(g_ctx, r);
1105
- jstring out = e->NewStringUTF(s ? s : fallback);
1106
- JS_FreeCString(g_ctx, s);
1107
- JS_FreeValue(g_ctx, r);
1108
- return out;
1109
- }
1110
-
1111
- // ── JNI — siempre llamados desde el hilo de UI (posts Kotlin) ───────
1112
-
1113
- extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
1114
- g_jvm = vm;
1115
- return JNI_VERSION_1_6;
1116
- }
1117
-
1118
- extern "C" JNIEXPORT jstring JNICALL
1119
- Java_com_elur_universal_ElurUiWorklet_nativeRegister(JNIEnv *e, jclass,
1120
- jstring specJson) {
1121
- ensure_ctx(e);
1122
- if (!on_ui_thread())
1123
- LOGW("register fuera del hilo UI");
1124
- const char *s = e->GetStringUTFChars(specJson, nullptr);
1125
- JSValueConst arg = JS_NewString(g_ctx, s);
1126
- e->ReleaseStringUTFChars(specJson, s);
1127
- jstring out = call_json(e, "__uiwkRegister", 1, &arg, "{\"ok\":false}");
1128
- JS_FreeValue(g_ctx, arg);
1129
- return out;
1130
- }
1131
-
1132
- extern "C" JNIEXPORT jstring JNICALL
1133
- Java_com_elur_universal_ElurUiWorklet_nativeCancel(JNIEnv *e, jclass,
1134
- jstring jid) {
1135
- if (!g_ctx)
1136
- return e->NewStringUTF("{}");
1137
- const char *s = e->GetStringUTFChars(jid, nullptr);
1138
- JSValueConst arg = JS_NewString(g_ctx, s);
1139
- e->ReleaseStringUTFChars(jid, s);
1140
- jstring out = call_json(e, "__uiwkCancel", 1, &arg, "{}");
1141
- JS_FreeValue(g_ctx, arg);
1142
- return out;
1143
- }
1144
-
1145
- extern "C" JNIEXPORT jboolean JNICALL
1146
- Java_com_elur_universal_ElurUiWorklet_nativeSetSignal(JNIEnv *e, jclass,
1147
- jstring jname,
1148
- jdouble v) {
1149
- if (!g_ctx)
1150
- return JNI_FALSE;
1151
- const char *s = e->GetStringUTFChars(jname, nullptr);
1152
- JSValueConst argv[2] = {JS_NewString(g_ctx, s), JS_NewFloat64(g_ctx, v)};
1153
- e->ReleaseStringUTFChars(jname, s);
1154
- JSValue r = call_prelude("__uiwkSetExternal", 2, argv);
1155
- int dirty = JS_ToBool(g_ctx, r);
1156
- JS_FreeValue(g_ctx, r);
1157
- JS_FreeValue(g_ctx, argv[0]);
1158
- JS_FreeValue(g_ctx, argv[1]);
1159
- return dirty ? JNI_TRUE : JNI_FALSE;
1160
- }
1161
-
1162
- extern "C" JNIEXPORT void JNICALL
1163
- Java_com_elur_universal_ElurUiWorklet_nativeReset(JNIEnv *e, jclass) {
1164
- if (!g_ctx)
1165
- return;
1166
- // Los Region* mueren con la sesión UI — Kotlin libera las
1167
- // retenciones del bridge (cesmDetachUi) en el mismo reset.
1168
- g_cesm_ui.clear();
1169
- JSValue r = call_prelude("__uiwkReset", 0, nullptr);
1170
- const char *ids = JS_ToCString(g_ctx, r);
1171
- LOGI("reset: %s", ids ? ids : "[]");
1172
- JS_FreeCString(g_ctx, ids);
1173
- JS_FreeValue(g_ctx, r);
1174
- }
1175
-
1176
- extern "C" JNIEXPORT jstring JNICALL
1177
- Java_com_elur_universal_ElurUiWorklet_nativeTick(JNIEnv *e, jclass,
1178
- jdouble nowMs) {
1179
- if (!g_ctx)
1180
- return e->NewStringUTF("{\"finished\":[],\"cancelled\":[]}");
1181
- JSValueConst arg = JS_NewFloat64(g_ctx, nowMs);
1182
- jstring out =
1183
- call_json(e, "__uiwkTick", 1, &arg, "{\"finished\":[],\"cancelled\":[]}");
1184
- JS_FreeValue(g_ctx, arg);
1185
- return out;
1186
- }
1187
-
1188
- extern "C" JNIEXPORT jboolean JNICALL
1189
- Java_com_elur_universal_ElurUiWorklet_nativeHasActive(JNIEnv *, jclass) {
1190
- if (!g_ctx)
1191
- return JNI_FALSE;
1192
- JSValue r = call_prelude("__uiwkHasActive", 0, nullptr);
1193
- int v = JS_ToBool(g_ctx, r);
1194
- JS_FreeValue(g_ctx, r);
1195
- return v ? JNI_TRUE : JNI_FALSE;
1196
- }
1197
-
1198
- // nativeBindRow — onBindViewHolder nativo: los kind:"bind" de la lista
1199
- // se evalúan síncrono con g_bind_row apuntando al itemView (los writes
1200
- // del proxy `row` aplican antes del primer dibujo de la fila).
1201
- // nativeCesmBind — el resolver Kotlin ya verificó workletSafe y el
1202
- // bridge retiene la región; aquí solo se mapea nombre → Region*.
1203
- // addr=0 (attach denegado) deja el nombre sin entrada: las lecturas
1204
- // del worklet devuelven 0, misma regla que una signal sin seed.
1205
- extern "C" JNIEXPORT void JNICALL
1206
- Java_com_elur_universal_ElurUiWorklet_nativeCesmBind(JNIEnv *e, jclass,
1207
- jstring jname,
1208
- jlong addr) {
1209
- const char *name = e->GetStringUTFChars(jname, nullptr);
1210
- if (addr)
1211
- g_cesm_ui[name] = reinterpret_cast<const elur::cesm::Region *>(addr);
1212
- else
1213
- g_cesm_ui.erase(name);
1214
- e->ReleaseStringUTFChars(jname, name);
1215
- }
1216
-
1217
- extern "C" JNIEXPORT jstring JNICALL
1218
- Java_com_elur_universal_ElurUiWorklet_nativeBindRow(JNIEnv *e, jclass,
1219
- jint listId,
1220
- jobject rowView,
1221
- jdouble pos) {
1222
- if (!g_ctx)
1223
- return e->NewStringUTF("{\"finished\":[],\"cancelled\":[]}");
1224
- g_bind_row = rowView;
1225
- JSValueConst argv[2] = {JS_NewFloat64(g_ctx, listId),
1226
- JS_NewFloat64(g_ctx, pos)};
1227
- jstring out = call_json(e, "__uiwkBindEval", 2, argv,
1228
- "{\"finished\":[],\"cancelled\":[]}");
1229
- JS_FreeValue(g_ctx, argv[0]);
1230
- JS_FreeValue(g_ctx, argv[1]);
1231
- g_bind_row = nullptr;
1232
- return out;
1233
- }