@elurjs/universal 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +24 -0
- package/README.md +102 -2
- package/THIRD_PARTY_NOTICES.md +153 -0
- package/cli/.gitkeep +0 -0
- package/cli/build-spec.mjs +46 -0
- package/cli/build-ssg.mjs +145 -0
- package/cli/build-ssr.mjs +276 -0
- package/cli/check-divergences.mjs +135 -0
- package/cli/check-doc-sync.mjs +282 -0
- package/cli/commands.d.mts +8 -0
- package/cli/commands.mjs +124 -0
- package/cli/commit-present.py +157 -0
- package/cli/create-app.mjs +768 -0
- package/cli/debug.mjs +45 -0
- package/cli/dev.mjs +488 -0
- package/cli/doctor.mjs +197 -0
- package/cli/elur.mjs +394 -0
- package/cli/font-license.mjs +24 -0
- package/cli/gen-bundle.mjs +195 -0
- package/cli/gen-doc-data.mjs +274 -0
- package/cli/gen-es5.mjs +60 -0
- package/cli/gen-hbc.mjs +87 -0
- package/cli/gen-host-integration.mjs +386 -0
- package/cli/gen-i18n-corpus.mjs +47 -0
- package/cli/gen-manifest.mjs +95 -0
- package/cli/gen-qjsc.mjs +77 -0
- package/cli/gen-route-types.mjs +65 -0
- package/cli/gen-routes.mjs +129 -0
- package/cli/gen-signals.mjs +151 -0
- package/cli/gen-ssr-client.mjs +119 -0
- package/cli/gen-wire-codec.mjs +214 -0
- package/cli/gen-wire-corpus.mjs +318 -0
- package/cli/gen-worklet-src.mjs +200 -0
- package/cli/gen-zones.mjs +197 -0
- package/cli/hermes-pair.mjs +61 -0
- package/cli/inspect.mjs +55 -0
- package/cli/layout-oracle-web.mjs +213 -0
- package/cli/layout-oracle.mjs +80 -0
- package/cli/lib-vlq.mjs +84 -0
- package/cli/measure-engines.mjs +206 -0
- package/cli/measure-shared.mjs +143 -0
- package/cli/package-linux.mjs +440 -0
- package/cli/parity-align.mjs +66 -0
- package/cli/platform-plugin.ts +97 -0
- package/cli/plugin-manifest.mjs +573 -0
- package/cli/run-bench.mjs +291 -0
- package/cli/run-commit-present.sh +91 -0
- package/cli/run-device-ab-surface.sh +94 -0
- package/cli/run-device-ab.sh +107 -0
- package/cli/run-energy.sh +44 -0
- package/cli/run-parity.mjs +164 -0
- package/cli/run-semantics.mjs +111 -0
- package/cli/run-tck.mjs +243 -0
- package/cli/sdui.mjs +1211 -0
- package/cli/symbolicate.mjs +90 -0
- package/cli/tck-android.sh +21 -0
- package/cli/tck-events-android.mjs +101 -0
- package/cli/tck-linux-atspi.py +389 -0
- package/cli/tck-platform-linux.mjs +638 -0
- package/cli/tck-platform.mjs +510 -0
- package/cli/visual-parity.mjs +691 -0
- package/docs/AUDITORIA-STATE-OF-THE-ART-2026-11.md +981 -0
- package/docs/ESTADO.md +679 -0
- package/docs/IMPLEMENTACION-NATIVA-v5.md +507 -0
- package/docs/PENDIENTES.md +1306 -0
- package/docs/adr/0013-transiciones-navegacion.md +169 -0
- package/docs/adr/0014-list-renderitem-factory.md +41 -0
- package/docs/adr/0015-dl-header-versionado.md +57 -0
- package/docs/adr/0016-hermes-v1-runtime.md +78 -0
- package/docs/adr/0017-encoder-nativo-dl.md +62 -0
- package/docs/adr/0018-yoga-tree-nativo.md +78 -0
- package/docs/adr/0019-ssr-universal-hidratacion.md +245 -0
- package/docs/adr/0020-canvas-draw-list.md +65 -0
- package/docs/adr/0021-text-input-props.md +55 -0
- package/docs/adr/0022-deep-links.md +49 -0
- package/docs/adr/0023-animacion-declarativa.md +130 -0
- package/docs/adr/0024-estilos-reactivos-vocabulario.md +100 -0
- package/docs/adr/0025-worklets-contrato-runner.md +181 -0
- package/docs/adr/0026-threading-js-dedicado.md +94 -0
- package/docs/adr/0027-ui-array-children-y-scope-por-fila.md +58 -0
- package/docs/adr/0028-commit-por-frame-en-host-embebido.md +93 -0
- package/docs/adr/0029-render-commit-latest-wins-screenhost.md +62 -0
- package/docs/adr/0030-destruccion-recursiva-ids-monotonicos.md +79 -0
- package/docs/adr/0031-scopes-formales-pool-filas.md +76 -0
- package/docs/adr/0032-nav-commit-autoritativo.md +64 -0
- package/docs/adr/0033-lista-virtual-ventana.md +80 -0
- package/docs/adr/0034-attach-event-class-strict-styles.md +89 -0
- package/docs/adr/0035-pipeline-imagenes-acotado.md +133 -0
- package/docs/adr/0036-data-por-entry-spa.md +91 -0
- package/docs/adr/0037-ir-serializable-factories-por-id.md +73 -0
- package/docs/adr/0038-transform-keys-compositor.md +79 -0
- package/docs/adr/0039-destroy-postorder-scope-ownership.md +86 -0
- package/docs/adr/0040-outbound-barriers-overflow-ack.md +60 -0
- package/docs/adr/0041-diff-treap-ir-version-strict.md +65 -0
- package/docs/adr/0042-data-endpoint-seguridad-hasloader.md +67 -0
- package/docs/adr/0043-aplicador-dom-unico.md +70 -0
- package/docs/adr/0044-descriptor-runtime-explicito.md +80 -0
- package/docs/adr/0045-navstate-versionado-scroll-settle.md +72 -0
- package/docs/adr/0046-harness-build-fail-closed.md +99 -0
- package/docs/adr/0047-envelope-evento-normalizado.md +110 -0
- package/docs/adr/0048-sesion-embebida-estados.md +91 -0
- package/docs/adr/0049-strict-styles-valores-portables.md +78 -0
- package/docs/adr/0050-update-style-tipado-abi-v5.md +66 -0
- package/docs/adr/0051-plugin-sdk-comandos.md +65 -0
- package/docs/adr/0052-benchmarks-reproducibles.md +50 -0
- package/docs/adr/0053-fling-target-pool-estructural.md +105 -0
- package/docs/adr/0054-lista-nativa-render-policy.md +130 -0
- package/docs/adr/0055-cesm-core.md +143 -0
- package/docs/adr/0056-dos-ejes-superficie-vs-propietario-de-ventana.md +112 -0
- package/docs/adr/0057-reset-node-y-firma-de-reciclaje.md +95 -0
- package/docs/adr/0058-rollback-de-montaje.md +83 -0
- package/docs/adr/0059-traza-on-device-u01-y-scroll-unico-productor.md +89 -0
- package/docs/adr/0060-list-update-patch-por-campo.md +73 -0
- package/docs/adr/0061-elegibilidad-de-plantilla-nativa.md +70 -0
- package/docs/adr/0062-invalidacion-adapter-lista-nativa.md +77 -0
- package/docs/adr/0063-autoridad-eventos-y-scroll.md +66 -0
- package/docs/adr/0064-admision-unica-de-commits.md +66 -0
- package/docs/adr/0065-runtime-de-sesion-u11.md +97 -0
- package/docs/adr/0066-perfil-layout-y-safe-area.md +78 -0
- package/docs/adr/0067-sesion-robusta-y-procedencia-de-build.md +121 -0
- package/docs/adr/0068-metodologia-de-benchmark-y-carril-verificable.md +94 -0
- package/docs/adr/0069-schema-de-wire-y-corpus-comun-de-codecs.md +126 -0
- package/docs/adr/0070-modelo-publico-de-aplicacion-y-mount.md +91 -0
- package/docs/adr/0071-image-service-y-tck-de-plataforma.md +133 -0
- package/docs/adr/0072-par-compilador-runtime-hermes.md +62 -0
- package/docs/adr/0073-corpus-de-semantica-y-lowering-por-motor.md +67 -0
- package/docs/adr/0074-perfil-i18n-formateo-dom-free.md +85 -0
- package/docs/adr/0075-back-predictivo-restore-y-layout-adaptativo.md +126 -0
- package/docs/adr/0076-contrato-de-modulos-capa-1.md +159 -0
- package/docs/adr/0077-manifest-de-plugin-y-plugin-sync.md +109 -0
- package/docs/adr/0078-extraccion-de-i18n-a-paquete-propio.md +114 -0
- package/docs/adr/0079-handles-de-host-objects-por-epoch.md +96 -0
- package/docs/adr/0080-platform-views-por-contrato.md +93 -0
- package/docs/adr/0081-codegen-del-dsl-de-modulos.md +118 -0
- package/docs/adr/0082-variante-web-de-modulos-nativos.md +126 -0
- package/docs/adr/0083-perfiles-dev-release.md +92 -0
- package/docs/adr/0084-instrumentacion-acotada-exportable.md +126 -0
- package/docs/adr/0085-medicion-agrupada-en-main.md +125 -0
- package/docs/adr/0086-matriz-capacidades-props-eventos.md +75 -0
- package/docs/adr/0087-uithread-runner-android.md +271 -0
- package/docs/adr/0088-worklet-src-estatico.md +82 -0
- package/docs/adr/0089-composicion-animaciones-settle-drag.md +122 -0
- package/docs/adr/0090-linter-capturas-build.md +94 -0
- package/docs/adr/0091-router-core-vs-universal.md +74 -0
- package/docs/adr/0092-sharedregion-type-strings.md +59 -0
- package/docs/adr/0093-permission-request-estandar.md +52 -0
- package/docs/adr/0094-dispatch-worker-timeoutms.md +51 -0
- package/docs/adr/0095-tck-modulos.md +65 -0
- package/docs/adr/0096-cesm-ring-deferral.md +47 -0
- package/docs/adr/0097-tooling-diferido.md +51 -0
- package/docs/adr/0098-handshake-moduleabi.md +46 -0
- package/docs/adr/0099-modulos-ambient.md +58 -0
- package/docs/adr/0100-auto-declaracion-modulos.md +43 -0
- package/docs/adr/0101-plataforma-build.md +49 -0
- package/docs/adr/0102-permisos-manifest-build.md +38 -0
- package/docs/adr/0103-registrant-ownership.md +45 -0
- package/docs/adr/0104-toolchain-release.md +125 -0
- package/docs/adr/0105-cesm-ring-mode.md +71 -0
- package/docs/adr/0106-module-observabilidad.md +100 -0
- package/docs/adr/0107-layout-l1-oraculo.md +67 -0
- package/docs/adr/0108-semantica-como-ops.md +69 -0
- package/docs/adr/0109-text-input-composition.md +64 -0
- package/docs/adr/0110-yoga-3-2.md +63 -0
- package/docs/adr/0111-hot-reload-con-estado.md +92 -0
- package/docs/adr/0112-metricas-nativas-reales.md +65 -0
- package/docs/adr/0113-cesm-proyeccion-ampliada.md +80 -0
- package/docs/adr/0114-androidx-deps.md +72 -0
- package/docs/adr/0115-coil-imagenes.md +57 -0
- package/docs/adr/0116-precomputed-text-off-ui.md +49 -0
- package/docs/adr/0117-a11y-state-hint-foco.md +54 -0
- package/docs/adr/0118-yoga-3-2-vocabulario.md +98 -0
- package/docs/adr/0119-codecs-wire-desde-esquema.md +86 -0
- package/docs/adr/0120-unidades-logicas-pointscalefactor.md +73 -0
- package/docs/adr/0121-yoga-filas-lista.md +100 -0
- package/docs/adr/0122-delegado-layout-subarbol.md +140 -0
- package/docs/adr/0123-canvas-sobre-skia-raster.md +101 -0
- package/docs/adr/0124-evaluacion-taffy-css-grid.md +52 -0
- package/docs/adr/0125-paridad-visual-android.md +89 -0
- package/docs/adr/0126-documento-web-metadata-enlaces.md +52 -0
- package/docs/adr/0127-perfil-l1-shorthand-flex-herencia-texto.md +70 -0
- package/docs/adr/0128-pantalla-llena-fragmentos-transparentes.md +56 -0
- package/docs/adr/0129-content-visibility-canvas-unidades-logicas.md +37 -0
- package/docs/adr/0130-expresiones-reactivas-ui.md +55 -0
- package/docs/adr/0131-state-style.md +59 -0
- package/docs/adr/0132-create-theme-system-color-scheme.md +58 -0
- package/docs/adr/0133-navegacion-rutas-href-chrome.md +59 -0
- package/docs/adr/0134-servicios-ambient-modulos-timers.md +63 -0
- package/docs/adr/0135-registro-fuentes.md +67 -0
- package/docs/adr/0136-i18n-zonas-dst-locale-reactivo.md +70 -0
- package/docs/adr/0137-ssg-universal.md +78 -0
- package/docs/adr/0138-plantillas-fila-ui-rowref.md +54 -0
- package/docs/adr/0139-paridad-geometrica-e-inspector.md +63 -0
- package/docs/adr/0140-medida-line-height-css.md +78 -0
- package/docs/adr/0141-build-ssr-autocontenido.md +37 -0
- package/docs/adr/0142-tema-ssr-cookie-client-hint.md +42 -0
- package/docs/adr/0143-paridad-visual-ci.md +51 -0
- package/docs/adr/0144-oraculo-layout-chromium.md +45 -0
- package/docs/adr/0145-admision-opcodes-wire.md +89 -0
- package/docs/adr/0146-presupuesto-divergencias.md +82 -0
- package/docs/adr/0147-spans-texto-enriquecido.md +113 -0
- package/docs/adr/0148-scroll-restore.md +92 -0
- package/docs/adr/0149-gestion-foco.md +94 -0
- package/docs/adr/0150-sticky.md +89 -0
- package/docs/adr/0151-politica-migracion-snapshots.md +83 -0
- package/docs/adr/0152-vocabulario-semantico-v3.md +112 -0
- package/docs/adr/0153-puerta-doc-codigo.md +59 -0
- package/docs/adr/0154-matriz-paridad.md +79 -0
- package/docs/adr/0155-rtl-ambiente.md +73 -0
- package/docs/adr/0156-quickjs-ng-0170.md +55 -0
- package/docs/adr/0157-qjsc-bytecode-android.md +73 -0
- package/docs/adr/0158-abi-host-explicita.md +62 -0
- package/docs/adr/0159-entrada-desktop.md +59 -0
- package/docs/adr/0160-port-linux-hallazgos-plataforma.md +91 -0
- package/docs/adr/0161-paridad-deeplink-alineacion-estructural.md +76 -0
- package/docs/adr/0162-fontscale-linux-fuentes.md +63 -0
- package/docs/adr/0163-overflow-hidden-linux-clip.md +67 -0
- package/docs/adr/0164-nav-transitions-linux.md +126 -0
- package/docs/adr/0165-transiciones-declarativas.md +147 -0
- package/docs/adr/0166-ime-composition-linux.md +68 -0
- package/docs/adr/0167-spans-pango-linux.md +80 -0
- package/docs/adr/0168-statestyle-linux.md +65 -0
- package/docs/adr/0169-animate-linux.md +114 -0
- package/docs/adr/0170-image-service-linux.md +54 -0
- package/docs/adr/0171-semantics-atspi-linux.md +80 -0
- package/docs/adr/0172-conformidad-de-host-por-terceros.md +159 -0
- package/docs/adr/0173-licencias-espec-y-codigo.md +95 -0
- package/docs/adr/0174-tabla-estilo-yoga-compartida.md +67 -0
- package/docs/adr/0175-easings-normativos-cubic-bezier.md +68 -0
- package/docs/adr/0176-harness-plataforma-linux-y-locale-decimal.md +80 -0
- package/docs/adr/0177-gaps-linux-dir-as-navstate.md +84 -0
- package/docs/adr/0178-matriz-linux-y-tablas-normativas-generadas.md +104 -0
- package/docs/adr/0179-eventos-gesto-y-teclado.md +132 -0
- package/docs/adr/0180-desktop-nativo-linux-windows-macos-chromeos.md +58 -0
- package/docs/adr/0181-linux-platform-views-uiworklet-y-gaps-certificados.md +101 -0
- package/docs/adr/0182-sdui-envelope-dialecto-rico-y-lowering.md +452 -0
- package/docs/adr/0183-hermes-es6-block-scoping-en-source-eval.md +99 -0
- package/docs/adr/0184-sdui-consumidor-de-referencia-y-modulo-http.md +72 -0
- package/docs/adr/0185-sdui-modelo-de-seguridad-del-envelope.md +160 -0
- package/docs/adr/0186-linux-packaging-deb-rpm-flatpak.md +61 -0
- package/docs/adr/0187-modelo-de-hilos-ejecutores-logicos.md +163 -0
- package/docs/adr/0188-sdui-seguridad-hardening.md +214 -0
- package/docs/adr/0189-worklets-web-worker-y-egreso-pinning.md +235 -0
- package/docs/adr/0190-semantics-actions-linux-via-gaction-muxer.md +102 -0
- package/docs/adr/0191-reporte-de-errores-en-produccion.md +126 -0
- package/docs/adr/0192-source-maps-y-simbolizacion-de-stacks.md +107 -0
- package/docs/adr/0193-renderer-skia-opt-in-en-linux.md +143 -0
- package/docs/adr/0194-superficie-declarada-y-carril-skia-tree.md +96 -0
- package/docs/adr/0195-bundles-embebidos-subpaths-core.md +66 -0
- package/docs/adr/0196-matriz-capacidades-verdad.md +84 -0
- package/docs/adr/0197-entorno-reactivo-cableado.md +67 -0
- package/docs/adr/0198-csprng-host-wintertc.md +57 -0
- package/docs/adr/0199-testing-harness-dom-free.md +59 -0
- package/docs/adr/0200-overlays-back-foco.md +84 -0
- package/docs/adr/0201-paridad-nativa-props-texto-fase1.md +79 -0
- package/docs/adr/0202-node-ref-measure-web.md +61 -0
- package/docs/adr/0203-primitivas-headless.md +54 -0
- package/docs/adr/0204-imagen-load-error-fallback.md +123 -0
- package/docs/adr/0205-primitivas-controls-fase2.md +79 -0
- package/docs/adr/0206-a2ui-catalogo-tabs-modal-choicepicker-icon.md +110 -0
- package/docs/adr/0207-a2ui-superficie-viva.md +104 -0
- package/docs/adr/0208-a2ui-checks-validacion.md +94 -0
- package/docs/adr/0209-loaddata-nativo-default.md +56 -0
- package/docs/adr/0210-primitivas-navegacion-fase3.md +69 -0
- package/docs/adr/0211-a2ui-formato-localizado.md +113 -0
- package/docs/adr/0212-red-fuera-del-core.md +67 -0
- package/docs/adr/0213-dev-fast-y-rutas-automaticas.md +68 -0
- package/docs/adr/0214-dev-web-server-reload.md +55 -0
- package/docs/adr/0215-ui-host-noderef-back-http-linux.md +77 -0
- package/docs/adr/0216-paridad-nativa-switch-scroll-lista.md +53 -0
- package/docs/adr/0217-overlays-drag-y-popover-anclado.md +64 -0
- package/docs/adr/0218-sdui-gateway-live-mcp-y-scaffold.md +31 -0
- package/docs/adr/0219-event-ref-envelope-y-oracle-scroll-aware.md +82 -0
- package/docs/adr/README.md +229 -0
- package/docs/deuda/i18n-libreria-separada.md +50 -0
- package/docs/doc-data.json +2788 -0
- package/docs/propuestas/demo-google-devfest-a2ui-sdui.md +374 -0
- package/docs/propuestas/dx-y-paridad.md +684 -0
- package/docs/propuestas/investigacion-apps-completas/PENDIENTES-CORE-APPS-COMPLETAS.md +226 -0
- package/docs/propuestas/investigacion-apps-completas/arquitectura-motor-videojuegos-elur.md +254 -0
- package/docs/propuestas/investigacion-apps-completas/auditoria-paridad-frameworks-y-sdui.md +295 -0
- package/docs/propuestas/investigacion-apps-completas/ciclo-de-vida-dx-y-apps-completas.md +394 -0
- package/docs/propuestas/investigacion-apps-completas/crear-proyecto-desde-npm-y-agentes.md +477 -0
- package/docs/propuestas/investigacion-apps-completas/especificacion-arquitectura-capacidades-faltantes.md +407 -0
- package/docs/propuestas/investigacion-apps-completas/identidad-y-nombre-elur-universal.md +133 -0
- package/docs/propuestas/investigacion-apps-completas/migracion-elur-core-4.md +266 -0
- package/docs/propuestas/investigacion-apps-completas/sdui-a2ui-aplicaciones-completas.md +255 -0
- package/docs/propuestas/investigacion-apps-completas/verificacion-mejoras-y-brechas-nuevas.md +228 -0
- package/docs/propuestas/modelo-de-consumo.md +287 -0
- package/docs/propuestas/modulos-nativos.md +1062 -0
- package/docs/propuestas/palabras-clave-normativas.md +69 -0
- package/docs/propuestas/sdui-seguridad-hardening.md +322 -0
- package/docs/propuestas/skia-graphite.md +167 -0
- package/docs/propuestas/skia-renderer-arbol.md +603 -0
- package/docs/propuestas/targets-nativos-nuevos.md +359 -0
- package/docs/propuestas/toolchain-y-distribucion.md +311 -0
- package/docs/propuestas/ui-worklet-capacidades-exclusivas.md +114 -0
- package/examples/a11ylive/elur.app.json +8 -0
- package/examples/a11ylive/entry.ts +22 -0
- package/examples/a11ysem/elur.app.json +8 -0
- package/examples/a11ysem/entry.ts +24 -0
- package/examples/anim/elur.app.json +8 -0
- package/examples/anim/entry.ts +50 -0
- package/examples/app.ts +10 -0
- package/examples/cliprad/elur.app.json +8 -0
- package/examples/cliprad/entry.ts +16 -0
- package/examples/controls/app.ts +32 -0
- package/examples/controls/elur.app.json +8 -0
- package/examples/counter/app.ts +21 -0
- package/examples/counter/elur.app.json +8 -0
- package/examples/counter/entry.ts +7 -0
- package/examples/entry.ts +11 -0
- package/examples/feedstress/app.ts +334 -0
- package/examples/feedstress/elur.app.json +8 -0
- package/examples/feedstress/entry.ts +7 -0
- package/examples/i18n/app.ts +86 -0
- package/examples/i18n/elur.app.json +8 -0
- package/examples/i18n/entry.ts +22 -0
- package/examples/imecomp/elur.app.json +8 -0
- package/examples/imecomp/entry.ts +41 -0
- package/examples/imgtest/elur.app.json +8 -0
- package/examples/imgtest/entry.ts +18 -0
- package/examples/mareas/app/ajustes/page.ts +54 -0
- package/examples/mareas/app/page.ts +91 -0
- package/examples/mareas/app/puerto/[id]/page.ts +106 -0
- package/examples/mareas/app.ts +12 -0
- package/examples/mareas/elur.app.json +35 -0
- package/examples/mareas/entry.ts +11 -0
- package/examples/mareas/fonts/DejaVuSansMono-Bold.ttf +0 -0
- package/examples/mareas/fonts/DejaVuSansMono.ttf +0 -0
- package/examples/mareas/fonts/DejaVuSerif-Bold.ttf +0 -0
- package/examples/mareas/fonts/DejaVuSerif-Italic.ttf +0 -0
- package/examples/mareas/fonts/DejaVuSerif.ttf +0 -0
- package/examples/mareas/fonts/LICENSE-DejaVu.txt +187 -0
- package/examples/mareas/fonts.ts +6 -0
- package/examples/mareas/head.ts +12 -0
- package/examples/mareas/i18n.ts +163 -0
- package/examples/mareas/ports.ts +131 -0
- package/examples/mareas/routes.gen.ts +44 -0
- package/examples/mareas/serve.ts +70 -0
- package/examples/mareas/services.ts +5 -0
- package/examples/mareas/services.web.ts +6 -0
- package/examples/mareas/state.ts +64 -0
- package/examples/mareas/theme.ts +56 -0
- package/examples/mareas/ui/controls.ts +42 -0
- package/examples/mareas/ui/frame.ts +63 -0
- package/examples/mareas/ui/marigram.ts +52 -0
- package/examples/masonry/app.ts +32 -0
- package/examples/masonry/elur.app.json +8 -0
- package/examples/masonry/entry.ts +4 -0
- package/examples/natprobe/elur.app.json +8 -0
- package/examples/natprobe/entry.ts +196 -0
- package/examples/navdemo/app.ts +109 -0
- package/examples/navdemo/elur.app.json +8 -0
- package/examples/navdemo/entry.ts +7 -0
- package/examples/navtrans/elur.app.json +8 -0
- package/examples/navtrans/entry.ts +53 -0
- package/examples/platformview/app.ts +26 -0
- package/examples/platformview/elur.app.json +8 -0
- package/examples/sdui-demo/docs/home.envelope.json +588 -0
- package/examples/sdui-demo/docs/home.iife.json +582 -0
- package/examples/sdui-demo/elur.app.json +8 -0
- package/examples/sdui-demo/entry.ts +346 -0
- package/examples/select/elur.app.json +8 -0
- package/examples/select/entry.ts +20 -0
- package/examples/skiacanvas/app.ts +34 -0
- package/examples/skiacanvas/elur.app.json +8 -0
- package/examples/skiacanvas/entry.ts +4 -0
- package/examples/spans/elur.app.json +8 -0
- package/examples/spans/entry.ts +28 -0
- package/examples/ssr/app/about/page.ts +18 -0
- package/examples/ssr/app/items/[id]/page.ts +16 -0
- package/examples/ssr/app/layout.ts +21 -0
- package/examples/ssr/app/page.action.ts +10 -0
- package/examples/ssr/app/page.data.ts +5 -0
- package/examples/ssr/app/page.ts +95 -0
- package/examples/ssr/app/slow/loading.ts +10 -0
- package/examples/ssr/app/slow/page.data.ts +4 -0
- package/examples/ssr/app/slow/page.ts +16 -0
- package/examples/ssr/app/store.ts +3 -0
- package/examples/ssr/serve.ts +53 -0
- package/examples/statestyle/elur.app.json +8 -0
- package/examples/statestyle/entry.ts +25 -0
- package/examples/swipe/elur.app.json +8 -0
- package/examples/swipe/entry.ts +39 -0
- package/examples/tasks/app.ts +145 -0
- package/examples/tasks/elur.app.json +8 -0
- package/examples/uiwk/app.ts +288 -0
- package/examples/uiwk/elur.app.json +8 -0
- package/examples/uiwk/entry.ts +7 -0
- package/examples/vertical/app.ts +275 -0
- package/examples/vertical/elur.app.json +8 -0
- package/examples/vertical/entry.ts +31 -0
- package/examples/yogafeatures/app.ts +55 -0
- package/examples/yogafeatures/elur.app.json +8 -0
- package/examples/yogafeatures/entry.ts +4 -0
- package/native/cesm/README.md +94 -0
- package/native/cesm/adapters/hermes/HermesAdapter.h +432 -0
- package/native/cesm/adapters/quickjs/QuickJsAdapter.h +562 -0
- package/native/cesm/core/Bytes.h +236 -0
- package/native/cesm/core/Core.h +157 -0
- package/native/cesm/core/EngineAdapter.h +20 -0
- package/native/cesm/core/Region.h +77 -0
- package/native/cesm/core/Ring.h +99 -0
- package/native/cesm/core/Slots.h +132 -0
- package/native/cesm/core/Types.h +67 -0
- package/native/cesm/tests/CMakeLists.txt +50 -0
- package/native/cesm/tests/README.md +89 -0
- package/native/cesm/tests/compile_check_hermes.cpp +23 -0
- package/native/cesm/tests/test_core.cpp +101 -0
- package/native/cesm/tests/test_main.cpp +13 -0
- package/native/cesm/tests/test_quickjs_adapter.cpp +252 -0
- package/native/cesm/tests/test_ring.cpp +131 -0
- package/native/cesm/tests/test_slots.cpp +81 -0
- package/native/cesm/tests/test_sync.cpp +157 -0
- package/native/cesm/tests/test_util.h +24 -0
- package/native/layout/elur_layout_style.cpp +297 -0
- package/native/layout/elur_layout_style.h +36 -0
- package/native/layout-oracle/CMakeLists.txt +22 -0
- package/native/layout-oracle/oracle.cpp +140 -0
- package/native/rand/elur_random.h +43 -0
- package/native/skia-tree/elur_skia_tree.cpp +1293 -0
- package/native/skia-tree/elur_skia_tree.h +231 -0
- package/native/yoga/LICENSE +21 -0
- package/native/yoga/YGConfig.cpp +92 -0
- package/native/yoga/YGConfig.h +158 -0
- package/native/yoga/YGEnums.cpp +262 -0
- package/native/yoga/YGEnums.h +142 -0
- package/native/yoga/YGMacros.h +99 -0
- package/native/yoga/YGNode.cpp +366 -0
- package/native/yoga/YGNode.h +304 -0
- package/native/yoga/YGNodeLayout.cpp +92 -0
- package/native/yoga/YGNodeLayout.h +35 -0
- package/native/yoga/YGNodeStyle.cpp +405 -0
- package/native/yoga/YGNodeStyle.h +130 -0
- package/native/yoga/YGPixelGrid.cpp +22 -0
- package/native/yoga/YGPixelGrid.h +29 -0
- package/native/yoga/YGValue.cpp +20 -0
- package/native/yoga/YGValue.h +84 -0
- package/native/yoga/Yoga.h +21 -0
- package/native/yoga/algorithm/AbsoluteLayout.cpp +563 -0
- package/native/yoga/algorithm/AbsoluteLayout.h +41 -0
- package/native/yoga/algorithm/Align.h +72 -0
- package/native/yoga/algorithm/Baseline.cpp +78 -0
- package/native/yoga/algorithm/Baseline.h +21 -0
- package/native/yoga/algorithm/BoundAxis.h +79 -0
- package/native/yoga/algorithm/Cache.cpp +121 -0
- package/native/yoga/algorithm/Cache.h +30 -0
- package/native/yoga/algorithm/CalculateLayout.cpp +2428 -0
- package/native/yoga/algorithm/CalculateLayout.h +38 -0
- package/native/yoga/algorithm/FlexDirection.h +120 -0
- package/native/yoga/algorithm/FlexLine.cpp +124 -0
- package/native/yoga/algorithm/FlexLine.h +75 -0
- package/native/yoga/algorithm/PixelGrid.cpp +132 -0
- package/native/yoga/algorithm/PixelGrid.h +29 -0
- package/native/yoga/algorithm/SizingMode.h +73 -0
- package/native/yoga/algorithm/TrailingPosition.h +44 -0
- package/native/yoga/config/Config.cpp +135 -0
- package/native/yoga/config/Config.h +92 -0
- package/native/yoga/debug/AssertFatal.cpp +53 -0
- package/native/yoga/debug/AssertFatal.h +29 -0
- package/native/yoga/debug/Log.cpp +107 -0
- package/native/yoga/debug/Log.h +34 -0
- package/native/yoga/enums/Align.h +47 -0
- package/native/yoga/enums/BoxSizing.h +40 -0
- package/native/yoga/enums/Dimension.h +40 -0
- package/native/yoga/enums/Direction.h +41 -0
- package/native/yoga/enums/Display.h +41 -0
- package/native/yoga/enums/Edge.h +47 -0
- package/native/yoga/enums/Errata.h +41 -0
- package/native/yoga/enums/ExperimentalFeature.h +39 -0
- package/native/yoga/enums/FlexDirection.h +42 -0
- package/native/yoga/enums/Gutter.h +41 -0
- package/native/yoga/enums/Justify.h +44 -0
- package/native/yoga/enums/LogLevel.h +44 -0
- package/native/yoga/enums/MeasureMode.h +41 -0
- package/native/yoga/enums/NodeType.h +40 -0
- package/native/yoga/enums/Overflow.h +41 -0
- package/native/yoga/enums/PhysicalEdge.h +21 -0
- package/native/yoga/enums/PositionType.h +41 -0
- package/native/yoga/enums/Unit.h +42 -0
- package/native/yoga/enums/Wrap.h +41 -0
- package/native/yoga/enums/YogaEnums.h +85 -0
- package/native/yoga/event/event.cpp +87 -0
- package/native/yoga/event/event.h +130 -0
- package/native/yoga/node/CachedMeasurement.h +53 -0
- package/native/yoga/node/LayoutResults.cpp +48 -0
- package/native/yoga/node/LayoutResults.h +122 -0
- package/native/yoga/node/LayoutableChildren.h +148 -0
- package/native/yoga/node/Node.cpp +443 -0
- package/native/yoga/node/Node.h +337 -0
- package/native/yoga/numeric/Comparison.h +81 -0
- package/native/yoga/numeric/FloatOptional.h +93 -0
- package/native/yoga/style/SmallValueBuffer.h +133 -0
- package/native/yoga/style/Style.h +757 -0
- package/native/yoga/style/StyleLength.h +107 -0
- package/native/yoga/style/StyleValueHandle.h +98 -0
- package/native/yoga/style/StyleValuePool.h +127 -0
- package/package.json +112 -3
- package/src/adapters/kit-bridge.ts +72 -0
- package/src/adapters/kit-ssg.ts +219 -0
- package/src/adapters/kit-ssr.ts +577 -0
- package/src/adapters/kit-types.ts +28 -0
- package/src/adapters/request-adapter.ts +41 -0
- package/src/adapters/ssr-resolver.ts +177 -0
- package/src/adapters/web-history.ts +218 -0
- package/src/adapters/web-nav-executor.ts +72 -0
- package/src/animations/.gitkeep +0 -0
- package/src/animations/bindWorklets.ts +49 -0
- package/src/animations/captureCheck.ts +75 -0
- package/src/animations/compose.ts +127 -0
- package/src/animations/easing.ts +75 -0
- package/src/animations/gestureWorklets.ts +129 -0
- package/src/animations/index.ts +23 -0
- package/src/animations/runner.ts +404 -0
- package/src/animations/scrollWorklets.ts +48 -0
- package/src/animations/uiBindings.ts +83 -0
- package/src/animations/uiRunner.ts +449 -0
- package/src/animations/worklet.ts +157 -0
- package/src/animations/workletForm.ts +197 -0
- package/src/app/clock.ts +69 -0
- package/src/app/embedded.ts +232 -0
- package/src/app/index.ts +24 -0
- package/src/app/load-data.ts +36 -0
- package/src/app/mount.native.ts +18 -0
- package/src/app/mount.ts +26 -0
- package/src/app/mount.web.ts +21 -0
- package/src/app/state.ts +256 -0
- package/src/app/types.ts +146 -0
- package/src/app/web.ts +291 -0
- package/src/backends/native/hostAbi.ts +304 -0
- package/src/backends/native/index.ts +1132 -0
- package/src/backends/textInputProtocol.ts +111 -0
- package/src/backends/web/.gitkeep +0 -0
- package/src/backends/web/base-css.ts +148 -0
- package/src/backends/web/batcher.ts +162 -0
- package/src/backends/web/hydrate.ts +227 -0
- package/src/backends/web/index.ts +2231 -0
- package/src/backends/web/inspect.ts +80 -0
- package/src/backends/web/workerRunner.ts +513 -0
- package/src/context/index.ts +19 -0
- package/src/events.ts +139 -0
- package/src/forms/index.ts +264 -0
- package/src/hydration/.gitkeep +0 -0
- package/src/index.ts +169 -0
- package/src/ir/.gitkeep +0 -0
- package/src/ir/catalog.ts +166 -0
- package/src/ir/events.ts +54 -0
- package/src/ir/schema.ts +1103 -0
- package/src/ir/semantics.ts +189 -0
- package/src/ir/shortcut.ts +104 -0
- package/src/ir/signal-names.ts +27 -0
- package/src/ir/ui.ts +709 -0
- package/src/layout/.gitkeep +0 -0
- package/src/native/.gitkeep +0 -0
- package/src/native/binaryCodec.ts +230 -0
- package/src/native/codegen.ts +635 -0
- package/src/native/hostArtifacts.ts +386 -0
- package/src/native/http.ts +558 -0
- package/src/native/index.ts +54 -0
- package/src/native/manifest.ts +227 -0
- package/src/native/module.ts +1108 -0
- package/src/native/platformView.ts +107 -0
- package/src/native/pluginManifest.ts +269 -0
- package/src/native/sharedMemory.ts +168 -0
- package/src/native/specType.ts +164 -0
- package/src/native/tck.ts +436 -0
- package/src/native/trace.ts +97 -0
- package/src/native/webModule.ts +281 -0
- package/src/overlays/index.ts +579 -0
- package/src/platform.ts +89 -0
- package/src/primitives/controls.ts +725 -0
- package/src/primitives/index.ts +400 -0
- package/src/primitives/navigation.ts +407 -0
- package/src/reconciler/reconciler.ts +2857 -0
- package/src/router/guards.ts +129 -0
- package/src/router/index.ts +41 -0
- package/src/router/lifecycle.ts +133 -0
- package/src/router/match.ts +184 -0
- package/src/router/router.ts +508 -0
- package/src/router/screen-host.ts +918 -0
- package/src/router/state.ts +76 -0
- package/src/router/table.ts +55 -0
- package/src/router/transitions.ts +87 -0
- package/src/router/types.ts +161 -0
- package/src/runtime/environment.ts +332 -0
- package/src/runtime/wintertc-globals.ts +1067 -0
- package/src/sdui/a2ui.ts +1480 -0
- package/src/sdui/a2uiSurface.ts +214 -0
- package/src/sdui/client.ts +370 -0
- package/src/sdui/cryptoModule.ts +107 -0
- package/src/sdui/diagnostics.ts +39 -0
- package/src/sdui/downlevel.ts +375 -0
- package/src/sdui/envelope.ts +729 -0
- package/src/sdui/expr.ts +658 -0
- package/src/sdui/gateway.ts +223 -0
- package/src/sdui/httpModule.ts +29 -0
- package/src/sdui/index.ts +74 -0
- package/src/sdui/intents.ts +217 -0
- package/src/sdui/lower.ts +576 -0
- package/src/sdui/machines.ts +141 -0
- package/src/sdui/manifest.ts +167 -0
- package/src/sdui/oracle.ts +400 -0
- package/src/sdui/profile.ts +72 -0
- package/src/sdui/seqStore.ts +89 -0
- package/src/sdui/sign.ts +155 -0
- package/src/sdui/worklets.ts +164 -0
- package/src/ssr/html-applicator.ts +515 -0
- package/src/ssr/render-page.ts +264 -0
- package/src/store/index.ts +28 -0
- package/src/style/textInherit.ts +29 -0
- package/src/style/theme.ts +178 -0
- package/src/testing/index.ts +276 -0
- package/src/transport/.gitkeep +0 -0
- package/src/transport/format.ts +477 -0
- package/src/transport/wireSchema.ts +189 -0
- package/src/web.ts +31 -0
- package/targets/android/app/build.gradle.kts +192 -0
- package/targets/android/app/proguard-rules-elur.pro +12 -0
- package/targets/android/app/proguard-rules.pro +3 -0
- package/targets/android/app/src/main/AndroidManifest.xml +81 -0
- package/targets/android/app/src/main/cpp/CMakeLists.txt +117 -0
- package/targets/android/app/src/main/cpp/dlEncoder.h +117 -0
- package/targets/android/app/src/main/cpp/dlEncoderJsi.cpp +315 -0
- package/targets/android/app/src/main/cpp/dlEncoderQjs.cpp +394 -0
- package/targets/android/app/src/main/cpp/dlOps.inc +145 -0
- package/targets/android/app/src/main/cpp/elurBridge.cpp +1350 -0
- package/targets/android/app/src/main/cpp/elurBridgeHermes.cpp +1294 -0
- package/targets/android/app/src/main/cpp/elurSkia.cpp +287 -0
- package/targets/android/app/src/main/cpp/elurSkiaTree.cpp +448 -0
- package/targets/android/app/src/main/cpp/elurUiWorklet.cpp +1233 -0
- package/targets/android/app/src/main/cpp/elurYoga.cpp +1060 -0
- package/targets/android/app/src/main/cpp/elurYoga.h +82 -0
- package/targets/android/app/src/main/cpp/hermes-libs/LICENSE +21 -0
- package/targets/android/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +276 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +97 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +502 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +107 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +145 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +193 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +211 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +40 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +14 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +27 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +141 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +270 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +64 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +1566 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +37 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +75 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +334 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +328 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +131 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +73 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +89 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +135 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +280 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +137 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +107 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +140 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +71 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +40 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +82 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +72 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +1279 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +313 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +38 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +77 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +127 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +138 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +24 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +20 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +44 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +123 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +29 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +24 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +30 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +113 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +242 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +52 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +295 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +25 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +642 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +29 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +41 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +12 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +8516 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +137 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +3945 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +119 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +124 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +66 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +456 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +26 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +1157 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +242 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +132 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +434 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +2266 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +59 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +79 -0
- package/targets/android/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +1111 -0
- package/targets/android/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
- package/targets/android/app/src/main/java/com/elur/universal/BinaryCodec.kt +121 -0
- package/targets/android/app/src/main/java/com/elur/universal/DlDecoder.kt +260 -0
- package/targets/android/app/src/main/java/com/elur/universal/DlOpsDecode.kt +158 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +161 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBridge.kt +238 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +223 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCanvasView.kt +202 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +206 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +185 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurEditText.kt +17 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +190 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurHttpModule.kt +306 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurImageService.kt +348 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +84 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurListView.kt +954 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurManifest.kt +117 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurMetrics.kt +325 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +14 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +36 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurRenderer.kt +6112 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurRowYoga.kt +130 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurScrollView.kt +240 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurShellView.kt +117 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +162 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +968 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurStateModule.kt +69 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +34 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTckModule.kt +99 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +16 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTrace.kt +24 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurUiModule.kt +48 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +305 -0
- package/targets/android/app/src/main/java/com/elur/universal/JsBridge.kt +67 -0
- package/targets/android/app/src/main/java/com/elur/universal/JsThread.kt +189 -0
- package/targets/android/app/src/main/java/com/elur/universal/MainActivity.kt +844 -0
- package/targets/android/app/src/main/java/com/elur/universal/ModuleRegistry.kt +701 -0
- package/targets/android/app/src/main/java/com/elur/universal/YogaRowScope.kt +97 -0
- package/targets/android/app/src/main/res/values/ids.xml +10 -0
- package/targets/android/app/src/main/res/values/strings.xml +8 -0
- package/targets/android/app/src/main/res/values-es/strings.xml +5 -0
- package/targets/android/app/src/main/res/xml/network_security_config.xml +10 -0
- package/targets/android/build.gradle.kts +5 -0
- package/targets/android/gradle/libs.versions.toml +12 -0
- package/targets/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/targets/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/targets/android/gradle.properties +23 -0
- package/targets/android/gradlew +251 -0
- package/targets/android/gradlew.bat +94 -0
- package/targets/android/settings.gradle.kts +32 -0
- package/targets/web/.gitkeep +0 -0
- 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
|
+
}
|