@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
package/src/sdui/a2ui.ts
ADDED
|
@@ -0,0 +1,1480 @@
|
|
|
1
|
+
// src/sdui/a2ui.ts — adaptador renderer A2UI (v0.9/v1.0) → dialecto SDUI.
|
|
2
|
+
// ADR-0182 §P3b+ — elur como renderer de un stream A2UI: el adaptador
|
|
3
|
+
// mantiene el estado por superficie (components + data model) y
|
|
4
|
+
// materializa un `SduiEnvelope` que entra por `mountEnvelope` — todo el
|
|
5
|
+
// contrato existente aplica (signals, exprs, intents, fail-closed).
|
|
6
|
+
//
|
|
7
|
+
// Mapa normativo:
|
|
8
|
+
// - Data model → signals planas por path: "/contact/firstName" →
|
|
9
|
+
// "contact.firstName" (RFC 6901 con ~0/~1); cada prefijo intermedio
|
|
10
|
+
// también materializa como signal (objeto/array atómico). Un `set`
|
|
11
|
+
// sobre una hoja NO reescribe el snapshot del padre — los contextos
|
|
12
|
+
// de acción deben referenciar paths hoja (patrón del spec).
|
|
13
|
+
// - Dynamic* (literal | {path} | {call}) → literal | {ref} | Expr.
|
|
14
|
+
// and/or/not → ops homónimos; formatString → concat con ${…}
|
|
15
|
+
// interpolado; el resto (required/regex/length/numeric/email/
|
|
16
|
+
// formatNumber/formatCurrency/formatDate/pluralize/openUrl en
|
|
17
|
+
// posición de valor) → sdui.a2ui.func + args.value crudo.
|
|
18
|
+
// - ChildList template {path, componentId} → list{items,fields,
|
|
19
|
+
// renderItem} — fields = paths relativos usados dentro del template.
|
|
20
|
+
// - action.event → intent {emit:"a2ui.action"} con {name, surface,
|
|
21
|
+
// …contexto resuelto}; action.functionCall → {emit:"a2ui.function"} —
|
|
22
|
+
// el host registra ambas en IntentContext.actions (a2uiActions()).
|
|
23
|
+
// - Two-way: TextField/CheckBox/Slider/DateTimeInput escriben la signal
|
|
24
|
+
// ligada vía events input/change → {set: path}.
|
|
25
|
+
// - Catálogo básico materializado (ADR-0206): Tabs (tablist/tab/panels
|
|
26
|
+
// con estado local), Modal (trigger + dialog en flujo), ChoicePicker
|
|
27
|
+
// (radiogroup/checkbox con binding al data model, multi-selección vía
|
|
28
|
+
// `includes`/`concat`) e Icon (glifos Unicode / switch dinámico).
|
|
29
|
+
// Video y AudioPlayer siguen sin materialización honesta → fallback
|
|
30
|
+
// visible con diagnóstico, nunca silencio.
|
|
31
|
+
|
|
32
|
+
import { diagnostic, type Diagnostic } from "./diagnostics";
|
|
33
|
+
import type { Expr } from "./expr";
|
|
34
|
+
import type { SduiEnvelope } from "./envelope";
|
|
35
|
+
import type { Intent } from "./intents";
|
|
36
|
+
import type { IRNode } from "../ir/schema";
|
|
37
|
+
import type { RichNode } from "./lower";
|
|
38
|
+
|
|
39
|
+
/** Mensaje del stream agente→renderer (v0.9 y v1.0 comparten nombres). */
|
|
40
|
+
export type A2uiMessage = {
|
|
41
|
+
version?: string;
|
|
42
|
+
createSurface?: {
|
|
43
|
+
surfaceId: string;
|
|
44
|
+
catalogId: string;
|
|
45
|
+
sendDataModel?: boolean;
|
|
46
|
+
theme?: { primaryColor?: string; iconUrl?: string; agentDisplayName?: string };
|
|
47
|
+
};
|
|
48
|
+
updateComponents?: {
|
|
49
|
+
surfaceId: string;
|
|
50
|
+
components: Array<{ id: string; component: string } & Record<string, unknown>>;
|
|
51
|
+
};
|
|
52
|
+
updateDataModel?: {
|
|
53
|
+
surfaceId: string;
|
|
54
|
+
path?: string;
|
|
55
|
+
value?: unknown;
|
|
56
|
+
};
|
|
57
|
+
deleteSurface?: { surfaceId: string };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type A2uiComponent =
|
|
61
|
+
{ id: string; component: string } & Record<string, unknown>;
|
|
62
|
+
|
|
63
|
+
type A2uiSurface = {
|
|
64
|
+
surfaceId: string;
|
|
65
|
+
catalogId: string;
|
|
66
|
+
sendDataModel: boolean;
|
|
67
|
+
components: Record<string, A2uiComponent>;
|
|
68
|
+
model: Record<string, unknown>;
|
|
69
|
+
/** ADR-0207 — signal plana → JSON Pointer de los bindings two-way. */
|
|
70
|
+
boundPaths: Record<string, string>;
|
|
71
|
+
diags: Diagnostic[];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type A2uiRenderer = {
|
|
75
|
+
/** Aplica un mensaje del stream; devuelve los diagnósticos nuevos. */
|
|
76
|
+
apply(msg: unknown): Diagnostic[];
|
|
77
|
+
/** Envelope SDUI materializado del estado vigente (null sin root). */
|
|
78
|
+
envelope(surfaceId: string): SduiEnvelope | null;
|
|
79
|
+
/** Snapshot del data model de la superficie (sendDataModel). */
|
|
80
|
+
model(surfaceId: string): Record<string, unknown> | null;
|
|
81
|
+
/** ADR-0207 — signals planas del model, sin re-traducir componentes.
|
|
82
|
+
* Es la fuente para el parcheo O(1) de `updateDataModel`. */
|
|
83
|
+
dataSignals(surfaceId: string): Record<string, unknown> | null;
|
|
84
|
+
/** ADR-0207 — bindings two-way: signal plana → JSON Pointer. */
|
|
85
|
+
boundPaths(surfaceId: string): Record<string, string>;
|
|
86
|
+
/** `createSurface.sendDataModel` (contrato de vuelta al agente). */
|
|
87
|
+
sendDataModel(surfaceId: string): boolean;
|
|
88
|
+
/** ADR-0207 — escribe en el model los valores ligados; devuelve el
|
|
89
|
+
* snapshot resultante (lo usa `mountA2uiSurface` en acciones). */
|
|
90
|
+
syncModel(
|
|
91
|
+
surfaceId: string,
|
|
92
|
+
read: (signal: string) => unknown,
|
|
93
|
+
): Record<string, unknown> | null;
|
|
94
|
+
/** Diagnósticos de la última traducción de la superficie (componentes
|
|
95
|
+
* sin materialización, refs rotas, etc.) — no se descartan. */
|
|
96
|
+
envelopeDiagnostics(surfaceId: string): Diagnostic[];
|
|
97
|
+
surfaces(): string[];
|
|
98
|
+
dispose(surfaceId: string): void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const A2UI_VERSIONS = ["v0.9", "v0.9.1", "v1.0"] as const;
|
|
102
|
+
export const A2UI_BASIC_CATALOG =
|
|
103
|
+
"https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json";
|
|
104
|
+
export const A2UI_COMPONENTS = [
|
|
105
|
+
"Text", "Row", "Column", "Card", "Button", "Image", "Divider",
|
|
106
|
+
"List", "CheckBox", "TextField", "Slider", "DateTimeInput",
|
|
107
|
+
"Tabs", "Modal", "ChoicePicker", "Icon",
|
|
108
|
+
] as const;
|
|
109
|
+
|
|
110
|
+
const SUPPORTED_VERSIONS = new Set<string>(A2UI_VERSIONS);
|
|
111
|
+
const BASIC_CATALOG = A2UI_BASIC_CATALOG;
|
|
112
|
+
|
|
113
|
+
/** Acciones que el host debe registrar en `IntentContext.actions` —
|
|
114
|
+
* `a2ui.action` recibe `{name, surface, ...contexto resuelto}`;
|
|
115
|
+
* `a2ui.function` recibe `{call, args}` con args crudos (la
|
|
116
|
+
* interpolación ${/path} de formatString se resuelve a concat/ref,
|
|
117
|
+
* pero args arbitrarios de functionCall viajan sin resolver). */
|
|
118
|
+
export function a2uiActions(handlers: {
|
|
119
|
+
onAction?: (a: Record<string, unknown>) => void;
|
|
120
|
+
onFunction?: (a: Record<string, unknown>) => void;
|
|
121
|
+
}): Record<string, (args: Record<string, unknown>) => void> {
|
|
122
|
+
const out: Record<string, (a: Record<string, unknown>) => void> = {};
|
|
123
|
+
if (handlers.onAction) {
|
|
124
|
+
out["a2ui.action"] = handlers.onAction;
|
|
125
|
+
}
|
|
126
|
+
if (handlers.onFunction) {
|
|
127
|
+
out["a2ui.function"] = handlers.onFunction;
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function unescapeSeg(seg: string): string {
|
|
133
|
+
return seg.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** "/a/b" → "a.b" — nombre de signal para un JSON Pointer absoluto. */
|
|
137
|
+
export function a2uiSignalName(path: string): string {
|
|
138
|
+
const segs = path.split("/").slice(1).map(unescapeSeg)
|
|
139
|
+
.filter((s) => s.length > 0);
|
|
140
|
+
return segs.join(".");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Escribe (o borra con value===undefined) en el model por JSON Pointer;
|
|
144
|
+
* path "/"|"" sustituye el modelo entero. */
|
|
145
|
+
function modelPatch(
|
|
146
|
+
model: Record<string, unknown>, path: string | undefined,
|
|
147
|
+
value: unknown,
|
|
148
|
+
): void {
|
|
149
|
+
if (path === undefined || path === "/" || path === "") {
|
|
150
|
+
for (const k of Object.keys(model)) delete model[k];
|
|
151
|
+
if (value !== null && typeof value === "object") {
|
|
152
|
+
Object.assign(model, value);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const segs = path.split("/").slice(1).map(unescapeSeg);
|
|
157
|
+
let cur: Record<string, unknown> = model;
|
|
158
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
159
|
+
const next = cur[segs[i]];
|
|
160
|
+
if (next === null || typeof next !== "object") {
|
|
161
|
+
cur[segs[i]] = {};
|
|
162
|
+
}
|
|
163
|
+
cur = cur[segs[i]] as Record<string, unknown>;
|
|
164
|
+
}
|
|
165
|
+
const last = segs[segs.length - 1];
|
|
166
|
+
if (value === undefined) delete cur[last];
|
|
167
|
+
else cur[last] = value;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Aplana el model a signals: cada path materializa — hojas con su
|
|
171
|
+
* valor, objetos/arrays como valor atómico bajo su nombre. */
|
|
172
|
+
function flattenModel(
|
|
173
|
+
model: Record<string, unknown>,
|
|
174
|
+
): Record<string, unknown> {
|
|
175
|
+
const out: Record<string, unknown> = {};
|
|
176
|
+
const walk = (v: unknown, name: string): void => {
|
|
177
|
+
if (name.length > 0) out[name] = v;
|
|
178
|
+
if (Array.isArray(v)) {
|
|
179
|
+
v.forEach((x, i) => walk(x, name + "." + i));
|
|
180
|
+
} else if (v !== null && typeof v === "object") {
|
|
181
|
+
for (const [k, x] of Object.entries(v)) {
|
|
182
|
+
walk(x, name.length > 0 ? name + "." + k : k);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
walk(model, "");
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const VARIANT_STYLE: Record<string, Record<string, unknown>> = {
|
|
191
|
+
h1: { fontSize: 30, fontWeight: "bold" },
|
|
192
|
+
h2: { fontSize: 24, fontWeight: "bold" },
|
|
193
|
+
h3: { fontSize: 20, fontWeight: "bold" },
|
|
194
|
+
h4: { fontSize: 17, fontWeight: "bold" },
|
|
195
|
+
h5: { fontSize: 14, fontWeight: "bold" },
|
|
196
|
+
caption: { fontSize: 12, color: "#666666" },
|
|
197
|
+
body: {},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const JUSTIFY: Record<string, string> = {
|
|
201
|
+
start: "flex-start", end: "flex-end", center: "center",
|
|
202
|
+
spaceBetween: "space-between", spaceAround: "space-around",
|
|
203
|
+
spaceEvenly: "space-evenly", stretch: "stretch",
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const ALIGN: Record<string, string> = {
|
|
207
|
+
start: "flex-start", end: "flex-end", center: "center",
|
|
208
|
+
stretch: "stretch",
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/** scope "row" dentro de un template de lista — los paths relativos
|
|
212
|
+
* resuelven contra fields del item (misma regla que el lowering de
|
|
213
|
+
* listas del dialecto). */
|
|
214
|
+
type TranslateCtx = {
|
|
215
|
+
surface: A2uiSurface;
|
|
216
|
+
diags: Diagnostic[];
|
|
217
|
+
rowFields: Set<string> | null;
|
|
218
|
+
depth: number;
|
|
219
|
+
/** ADR-0206 — signals locales del renderer (tabs/modales/query).
|
|
220
|
+
* `envelope()` las declara solo si el data model no las aporta. */
|
|
221
|
+
locals: Record<string, unknown>;
|
|
222
|
+
/** ADR-0207 — bindings two-way descubiertos en esta traducción. */
|
|
223
|
+
boundPaths: Map<string, string>;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
function interpFormatString(
|
|
227
|
+
raw: string, ctx: TranslateCtx,
|
|
228
|
+
): Expr {
|
|
229
|
+
// ${/abs/path} o ${relativo} → concat de literales y refs.
|
|
230
|
+
const parts: Expr[] = [];
|
|
231
|
+
let cur = "";
|
|
232
|
+
let i = 0;
|
|
233
|
+
while (i < raw.length) {
|
|
234
|
+
if (raw[i] === "\\" && raw.startsWith("${", i + 1)) {
|
|
235
|
+
cur += "${";
|
|
236
|
+
i += 3;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (raw.startsWith("${", i)) {
|
|
240
|
+
const end = raw.indexOf("}", i);
|
|
241
|
+
if (end < 0) break;
|
|
242
|
+
if (cur.length > 0) {
|
|
243
|
+
parts.push({ lit: cur });
|
|
244
|
+
cur = "";
|
|
245
|
+
}
|
|
246
|
+
const p = raw.slice(i + 2, end).trim();
|
|
247
|
+
parts.push(dynToExpr({ path: p }, ctx, "formatString") ??
|
|
248
|
+
{ lit: "" });
|
|
249
|
+
i = end + 1;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
cur += raw[i];
|
|
253
|
+
i += 1;
|
|
254
|
+
}
|
|
255
|
+
if (cur.length > 0) parts.push({ lit: cur });
|
|
256
|
+
if (parts.length === 0) return { lit: "" };
|
|
257
|
+
if (parts.length === 1) return parts[0];
|
|
258
|
+
return { concat: parts };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Dynamic* → Expr | literal. `null` = sin valor. */
|
|
262
|
+
function dynToExpr(
|
|
263
|
+
v: unknown, ctx: TranslateCtx, where: string,
|
|
264
|
+
): Expr | string | number | boolean | null {
|
|
265
|
+
if (v === null || v === undefined) return null;
|
|
266
|
+
if (typeof v === "string" || typeof v === "number" ||
|
|
267
|
+
typeof v === "boolean") {
|
|
268
|
+
return v;
|
|
269
|
+
}
|
|
270
|
+
if (typeof v !== "object") return null;
|
|
271
|
+
const o = v as Record<string, unknown>;
|
|
272
|
+
if (typeof o.path === "string") {
|
|
273
|
+
const p = o.path;
|
|
274
|
+
if (p.startsWith("/")) return { ref: a2uiSignalName(p) };
|
|
275
|
+
// Relativo — dentro de template de lista es campo de fila.
|
|
276
|
+
const leaf = p.split("/").map(unescapeSeg).pop() ?? p;
|
|
277
|
+
if (ctx.rowFields) {
|
|
278
|
+
ctx.rowFields.add(leaf);
|
|
279
|
+
return { ref: leaf };
|
|
280
|
+
}
|
|
281
|
+
return { ref: leaf };
|
|
282
|
+
}
|
|
283
|
+
if (typeof o.call === "string") {
|
|
284
|
+
const args = (o.args ?? {}) as Record<string, unknown>;
|
|
285
|
+
switch (o.call) {
|
|
286
|
+
case "and":
|
|
287
|
+
return {
|
|
288
|
+
and: (args.values as unknown[] ?? []).map(
|
|
289
|
+
(x) => dynToExpr(x, ctx, where) as Expr),
|
|
290
|
+
};
|
|
291
|
+
case "or":
|
|
292
|
+
return {
|
|
293
|
+
or: (args.values as unknown[] ?? []).map(
|
|
294
|
+
(x) => dynToExpr(x, ctx, where) as Expr),
|
|
295
|
+
};
|
|
296
|
+
case "not":
|
|
297
|
+
return { not: dynToExpr(args.value, ctx, where) as Expr };
|
|
298
|
+
case "required":
|
|
299
|
+
return {
|
|
300
|
+
required: dynToExpr(args.value, ctx, where) as Expr,
|
|
301
|
+
};
|
|
302
|
+
case "numeric":
|
|
303
|
+
return {
|
|
304
|
+
numeric: dynToExpr(args.value, ctx, where) as Expr,
|
|
305
|
+
};
|
|
306
|
+
case "email":
|
|
307
|
+
return {
|
|
308
|
+
email: dynToExpr(args.value, ctx, where) as Expr,
|
|
309
|
+
};
|
|
310
|
+
case "regex": {
|
|
311
|
+
if (typeof args.pattern !== "string") {
|
|
312
|
+
ctx.diags.push(diagnostic("sdui.a2ui.func",
|
|
313
|
+
"schema", "warn",
|
|
314
|
+
`regex sin patrón string (${where})`));
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
regex: [
|
|
318
|
+
dynToExpr(args.value, ctx, where) as Expr,
|
|
319
|
+
typeof args.pattern === "string" ? args.pattern : "",
|
|
320
|
+
],
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
case "length": {
|
|
324
|
+
const out: {
|
|
325
|
+
value: Expr; min?: number; max?: number;
|
|
326
|
+
} = {
|
|
327
|
+
value: dynToExpr(args.value, ctx, where) as Expr,
|
|
328
|
+
};
|
|
329
|
+
if (typeof args.min === "number") out.min = args.min;
|
|
330
|
+
if (typeof args.max === "number") out.max = args.max;
|
|
331
|
+
return { length: out };
|
|
332
|
+
}
|
|
333
|
+
case "formatNumber": {
|
|
334
|
+
const out: {
|
|
335
|
+
value: Expr; decimals?: number; grouping?: boolean;
|
|
336
|
+
} = {
|
|
337
|
+
value: dynToExpr(args.value, ctx, where) as Expr,
|
|
338
|
+
};
|
|
339
|
+
if (typeof args.decimals === "number") {
|
|
340
|
+
out.decimals = args.decimals;
|
|
341
|
+
} else if (args.decimals !== undefined) {
|
|
342
|
+
ctx.diags.push(diagnostic("sdui.a2ui.func",
|
|
343
|
+
"capability", "warn",
|
|
344
|
+
`formatNumber.decimals dinámico no soportado ` +
|
|
345
|
+
`(${where}) — se ignora`));
|
|
346
|
+
}
|
|
347
|
+
if (typeof args.grouping === "boolean") {
|
|
348
|
+
out.grouping = args.grouping;
|
|
349
|
+
}
|
|
350
|
+
return { formatNumber: out };
|
|
351
|
+
}
|
|
352
|
+
case "formatCurrency": {
|
|
353
|
+
const currency = typeof args.currency === "string"
|
|
354
|
+
? args.currency : "";
|
|
355
|
+
if (typeof args.currency !== "string") {
|
|
356
|
+
ctx.diags.push(diagnostic("sdui.a2ui.func",
|
|
357
|
+
"capability", "warn",
|
|
358
|
+
`formatCurrency.currency dinámico no soportado ` +
|
|
359
|
+
`(${where}) — se usa string vacío`));
|
|
360
|
+
}
|
|
361
|
+
const out: {
|
|
362
|
+
value: Expr; currency: string;
|
|
363
|
+
decimals?: number; grouping?: boolean;
|
|
364
|
+
} = {
|
|
365
|
+
value: dynToExpr(args.value, ctx, where) as Expr,
|
|
366
|
+
currency,
|
|
367
|
+
};
|
|
368
|
+
if (typeof args.decimals === "number") {
|
|
369
|
+
out.decimals = args.decimals;
|
|
370
|
+
}
|
|
371
|
+
if (typeof args.grouping === "boolean") {
|
|
372
|
+
out.grouping = args.grouping;
|
|
373
|
+
}
|
|
374
|
+
return { formatCurrency: out };
|
|
375
|
+
}
|
|
376
|
+
case "formatDate": {
|
|
377
|
+
const format = typeof args.format === "string"
|
|
378
|
+
? args.format : "yyyy-MM-dd";
|
|
379
|
+
if (typeof args.format !== "string" &&
|
|
380
|
+
args.format !== undefined) {
|
|
381
|
+
ctx.diags.push(diagnostic("sdui.a2ui.func",
|
|
382
|
+
"capability", "warn",
|
|
383
|
+
`formatDate.format dinámico no soportado ` +
|
|
384
|
+
`(${where}) — se usa yyyy-MM-dd`));
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
formatDate: {
|
|
388
|
+
value: dynToExpr(args.value, ctx, where) as Expr,
|
|
389
|
+
format,
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
case "pluralize": {
|
|
394
|
+
const forms: Record<string, Expr> = {};
|
|
395
|
+
for (const key of [
|
|
396
|
+
"zero", "one", "two", "few", "many", "other",
|
|
397
|
+
]) {
|
|
398
|
+
if (args[key] !== undefined) {
|
|
399
|
+
forms[key] = (dynToExpr(
|
|
400
|
+
args[key], ctx, `${where}.${key}`,
|
|
401
|
+
) ?? "") as Expr;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
pluralize: {
|
|
406
|
+
value: dynToExpr(args.value, ctx, where) as Expr,
|
|
407
|
+
forms,
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
case "formatString":
|
|
412
|
+
return interpFormatString(String(args.value ?? ""), ctx);
|
|
413
|
+
default:
|
|
414
|
+
ctx.diags.push(diagnostic("sdui.a2ui.func", "schema",
|
|
415
|
+
"warn", `función A2UI no soportada en valor: ` +
|
|
416
|
+
`${o.call} (${where}) — se sirve args.value crudo`));
|
|
417
|
+
return dynToExpr(args.value, ctx, where);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Traduce un objeto `context` de acción: top-level {path} → ref,
|
|
424
|
+
* literales → lit. Objetos anidados viajan crudos (lit) — los paths
|
|
425
|
+
* dentro de ellos no se resuelven (límite declarado). */
|
|
426
|
+
function actionArgs(
|
|
427
|
+
name: string, context: unknown, surfaceId: string,
|
|
428
|
+
ctx: TranslateCtx,
|
|
429
|
+
): Record<string, Expr> {
|
|
430
|
+
const args: Record<string, Expr> = {
|
|
431
|
+
name: { lit: name },
|
|
432
|
+
surface: { lit: surfaceId },
|
|
433
|
+
};
|
|
434
|
+
if (context !== null && typeof context === "object") {
|
|
435
|
+
for (const [k, v] of Object.entries(context as object)) {
|
|
436
|
+
if (v !== null && typeof v === "object" &&
|
|
437
|
+
typeof (v as { path?: unknown }).path === "string") {
|
|
438
|
+
const e = dynToExpr(v, ctx, `action.${name}.${k}`);
|
|
439
|
+
if (e !== null && typeof e === "object") args[k] = e;
|
|
440
|
+
else args[k] = { lit: e };
|
|
441
|
+
} else {
|
|
442
|
+
args[k] = { lit: v };
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return args;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function actionToDo(
|
|
450
|
+
action: unknown, surfaceId: string, ctx: TranslateCtx,
|
|
451
|
+
): Intent[] | undefined {
|
|
452
|
+
if (action === null || typeof action !== "object") return undefined;
|
|
453
|
+
const a = action as Record<string, unknown>;
|
|
454
|
+
if (a.event !== null && typeof a.event === "object") {
|
|
455
|
+
const ev = a.event as { name?: unknown; context?: unknown };
|
|
456
|
+
if (typeof ev.name !== "string") {
|
|
457
|
+
ctx.diags.push(diagnostic("sdui.a2ui.action", "schema",
|
|
458
|
+
"warn", "action.event sin name — ignorado"));
|
|
459
|
+
return undefined;
|
|
460
|
+
}
|
|
461
|
+
return [{
|
|
462
|
+
emit: "a2ui.action",
|
|
463
|
+
args: actionArgs(ev.name, ev.context, surfaceId, ctx),
|
|
464
|
+
}];
|
|
465
|
+
}
|
|
466
|
+
if (a.functionCall !== null && typeof a.functionCall === "object") {
|
|
467
|
+
const fc = a.functionCall as { call?: unknown; args?: unknown };
|
|
468
|
+
if (typeof fc.call !== "string") {
|
|
469
|
+
ctx.diags.push(diagnostic("sdui.a2ui.action", "schema",
|
|
470
|
+
"warn", "action.functionCall sin call — ignorado"));
|
|
471
|
+
return undefined;
|
|
472
|
+
}
|
|
473
|
+
return [{
|
|
474
|
+
emit: "a2ui.function",
|
|
475
|
+
args: { call: { lit: fc.call }, args: { lit: fc.args ?? null } },
|
|
476
|
+
}];
|
|
477
|
+
}
|
|
478
|
+
return undefined;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** Un valor Dynamic* resuelto a Expr viaja como {expr} en el dialecto;
|
|
482
|
+
* los literales pasan directos. */
|
|
483
|
+
function dynProp(
|
|
484
|
+
v: Expr | string | number | boolean | null,
|
|
485
|
+
): unknown {
|
|
486
|
+
if (v !== null && typeof v === "object") return { expr: v };
|
|
487
|
+
return v ?? "";
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** Two-way binding A2UI → props ligadas + evento que escribe la signal.
|
|
491
|
+
* input (TextField/Slider) lleva `text`/`progress`; change (CheckBox)
|
|
492
|
+
* lleva `checked` — vocabulario src/events.ts. `{ref:"event"}` resuelve
|
|
493
|
+
* al EventEnvelope completo: el payload va bajo `data`. */
|
|
494
|
+
function bindValue(
|
|
495
|
+
node: RichNode, valuePath: string | undefined,
|
|
496
|
+
evName: "input" | "change", evField: "text" | "checked" | "progress",
|
|
497
|
+
ctx: TranslateCtx,
|
|
498
|
+
): void {
|
|
499
|
+
if (valuePath === undefined || !valuePath.startsWith("/")) return;
|
|
500
|
+
const sig = a2uiSignalName(valuePath);
|
|
501
|
+
ctx.boundPaths.set(sig, valuePath);
|
|
502
|
+
node.props = { ...node.props, value: { expr: { ref: sig } } };
|
|
503
|
+
node.events = {
|
|
504
|
+
...node.events,
|
|
505
|
+
[evName]: {
|
|
506
|
+
do: [{
|
|
507
|
+
set: sig,
|
|
508
|
+
value: {
|
|
509
|
+
get: [{ get: [{ ref: "event" }, "data"] }, evField],
|
|
510
|
+
},
|
|
511
|
+
}],
|
|
512
|
+
},
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* ADR-0208 — `checks` A2UI → `invalid` semántico + mensaje del primer
|
|
518
|
+
* fallo. `invalid` ya se materializa como aria-invalid / isContentInvalid
|
|
519
|
+
* / GTK invalid en los tres hosts. El wrapper mueve el `flex` del campo
|
|
520
|
+
* para que el peso de layout no se duplique.
|
|
521
|
+
*/
|
|
522
|
+
function withChecks(
|
|
523
|
+
root: RichNode,
|
|
524
|
+
invalidTarget: RichNode,
|
|
525
|
+
checks: unknown,
|
|
526
|
+
ctx: TranslateCtx,
|
|
527
|
+
where: string,
|
|
528
|
+
): RichNode {
|
|
529
|
+
if (!Array.isArray(checks) || checks.length === 0) return root;
|
|
530
|
+
const exprs: Array<Expr | null> = [];
|
|
531
|
+
const messages: string[] = [];
|
|
532
|
+
for (const raw of checks) {
|
|
533
|
+
if (raw === null || typeof raw !== "object") {
|
|
534
|
+
exprs.push(null);
|
|
535
|
+
messages.push("");
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const c = raw as {
|
|
539
|
+
call?: unknown; args?: unknown; message?: unknown;
|
|
540
|
+
};
|
|
541
|
+
let expr: Expr | null = null;
|
|
542
|
+
if (typeof c.call === "string") {
|
|
543
|
+
const e = dynToExpr(
|
|
544
|
+
{ call: c.call, args: c.args }, ctx,
|
|
545
|
+
`${where}.${c.call}`,
|
|
546
|
+
);
|
|
547
|
+
if (e !== null && typeof e === "object") expr = e as Expr;
|
|
548
|
+
}
|
|
549
|
+
if (expr === null) {
|
|
550
|
+
ctx.diags.push(diagnostic("sdui.a2ui.check", "schema",
|
|
551
|
+
"warn", `check no soportado en ${where}: ` +
|
|
552
|
+
`${String(c.call)} — ignorado`));
|
|
553
|
+
exprs.push(null);
|
|
554
|
+
messages.push("");
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
exprs.push(expr);
|
|
558
|
+
messages.push(typeof c.message === "string"
|
|
559
|
+
? c.message : "Valor inválido");
|
|
560
|
+
}
|
|
561
|
+
const valid = exprs.filter((e): e is Expr => e !== null);
|
|
562
|
+
if (valid.length === 0) return root;
|
|
563
|
+
const invalid: Expr = valid.length === 1
|
|
564
|
+
? { not: valid[0] }
|
|
565
|
+
: { or: valid.map((e) => ({ not: e })) };
|
|
566
|
+
invalidTarget.props = {
|
|
567
|
+
...(invalidTarget.props ?? {}),
|
|
568
|
+
invalid: { expr: invalid },
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
let message: RichNode = { type: "text", text: "" };
|
|
572
|
+
for (let i = exprs.length - 1; i >= 0; i--) {
|
|
573
|
+
const expr = exprs[i];
|
|
574
|
+
if (expr === null) continue;
|
|
575
|
+
message = {
|
|
576
|
+
when: { not: expr },
|
|
577
|
+
then: {
|
|
578
|
+
type: "text",
|
|
579
|
+
text: messages[i],
|
|
580
|
+
props: { live: "polite" } as never,
|
|
581
|
+
style: { color: "#b00020", fontSize: 12 },
|
|
582
|
+
},
|
|
583
|
+
else: message,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const style = { ...(root.style ?? {}) };
|
|
588
|
+
const flex = style.flex;
|
|
589
|
+
if (typeof flex === "number") delete style.flex;
|
|
590
|
+
root.style = style;
|
|
591
|
+
return {
|
|
592
|
+
type: "column",
|
|
593
|
+
style: {
|
|
594
|
+
gap: 4,
|
|
595
|
+
...(typeof flex === "number" ? { flex } : {}),
|
|
596
|
+
},
|
|
597
|
+
children: [root, message],
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function unsupported(
|
|
602
|
+
ctx: TranslateCtx, kind: string, id: string,
|
|
603
|
+
): RichNode {
|
|
604
|
+
ctx.diags.push(diagnostic("sdui.a2ui.component", "capability",
|
|
605
|
+
"warn", `componente A2UI sin materialización: ${kind} ` +
|
|
606
|
+
`(${id}) — fallback a text`));
|
|
607
|
+
return { type: "text", text: `[${kind}: no soportado]`, id };
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** ADR-0206 — nombre de signal seguro para estado local del renderer. */
|
|
611
|
+
function safeSignalId(id: string): string {
|
|
612
|
+
return id.replace(/[^A-Za-z0-9_]/g, "_");
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** Declara un estado local por superficie; el data model tiene prioridad
|
|
616
|
+
* si ya trae la misma clave (dos-way binding). */
|
|
617
|
+
function localSignal(
|
|
618
|
+
ctx: TranslateCtx, name: string, initial: unknown,
|
|
619
|
+
): string {
|
|
620
|
+
if (!(name in ctx.locals)) ctx.locals[name] = initial;
|
|
621
|
+
return name;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** Antepone un intent al handler `press` de un nodo interactivo.
|
|
625
|
+
* Un wrapper `when`/`switch` no es interactivo por sí mismo: se deja
|
|
626
|
+
* intacto y el llamador decide el fallback. */
|
|
627
|
+
function addIntent(
|
|
628
|
+
node: RichNode, event: string, intent: Intent,
|
|
629
|
+
): boolean {
|
|
630
|
+
if (node.type === undefined) return false;
|
|
631
|
+
const cur = node.events?.[event];
|
|
632
|
+
if (cur !== undefined && !("do" in cur)) return false;
|
|
633
|
+
const doBlock = cur !== undefined && "do" in cur ? cur.do : [];
|
|
634
|
+
node.events = {
|
|
635
|
+
...(node.events ?? {}),
|
|
636
|
+
[event]: { do: [intent, ...doBlock] },
|
|
637
|
+
};
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** Glifos del catálogo básico A2UI. Sin fuente de iconos embebida:
|
|
642
|
+
* Unicode del sistema, con `role=img` + label para lectores. */
|
|
643
|
+
const ICON_GLYPHS: Record<string, string> = {
|
|
644
|
+
accountCircle: "👤", add: "+", arrowBack: "←", arrowForward: "→",
|
|
645
|
+
attachFile: "📎", calendarToday: "📅", call: "📞", camera: "📷",
|
|
646
|
+
check: "✓", close: "✕", delete: "🗑", download: "↓", edit: "✏",
|
|
647
|
+
event: "📅", error: "⚠", fastForward: "⏩", favorite: "♥",
|
|
648
|
+
favoriteOff: "♡", folder: "📁", help: "?", home: "⌂", info: "ℹ",
|
|
649
|
+
locationOn: "📍", lock: "🔒", lockOpen: "🔓", mail: "✉",
|
|
650
|
+
menu: "☰", moreVert: "⋮", moreHoriz: "…", notificationsOff: "🔕",
|
|
651
|
+
notifications: "🔔", pause: "⏸", payment: "💳", person: "👤",
|
|
652
|
+
phone: "☎", photo: "🖼", play: "▶", print: "🖨", refresh: "↻",
|
|
653
|
+
rewind: "⏪", search: "🔍", send: "➤", settings: "⚙", share: "↗",
|
|
654
|
+
shoppingCart: "🛒", skipNext: "⏭", skipPrevious: "⏮",
|
|
655
|
+
star: "★", starHalf: "◐", starOff: "☆", stop: "⏹", upload: "↑",
|
|
656
|
+
visibility: "👁", visibilityOff: "🚫", volumeDown: "🔉",
|
|
657
|
+
volumeMute: "🔇", volumeOff: "🔇", volumeUp: "🔊", warning: "⚠",
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
/** Recoge los paths relativos que un template de lista usa como campos
|
|
661
|
+
* de fila (primera pasada — el translate real los re-registra). */
|
|
662
|
+
function collectRowFields(
|
|
663
|
+
rootId: string, ctx: TranslateCtx, out: Set<string>,
|
|
664
|
+
): void {
|
|
665
|
+
const c = ctx.surface.components[rootId];
|
|
666
|
+
if (!c) return;
|
|
667
|
+
const stack: unknown[] = [c];
|
|
668
|
+
while (stack.length > 0) {
|
|
669
|
+
const n = stack.pop();
|
|
670
|
+
if (n === null || typeof n !== "object") continue;
|
|
671
|
+
if (Array.isArray(n)) {
|
|
672
|
+
for (const x of n) stack.push(x);
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
const o = n as Record<string, unknown>;
|
|
676
|
+
if (typeof o.path === "string" && !o.path.startsWith("/")) {
|
|
677
|
+
const leaf = o.path.split("/").map(unescapeSeg).pop();
|
|
678
|
+
if (leaf) out.add(leaf);
|
|
679
|
+
}
|
|
680
|
+
for (const v of Object.values(o)) stack.push(v);
|
|
681
|
+
if (o.args !== null && typeof o.args === "object") {
|
|
682
|
+
stack.push(o.args);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function childrenOf(
|
|
688
|
+
c: A2uiComponent, ctx: TranslateCtx, depth: number,
|
|
689
|
+
): { children?: RichNode[]; list?: RichNode["list"] } {
|
|
690
|
+
const cl = c.children ?? (c.child !== undefined ? [c.child] : undefined);
|
|
691
|
+
if (cl === undefined) return {};
|
|
692
|
+
if (Array.isArray(cl)) {
|
|
693
|
+
const out: RichNode[] = [];
|
|
694
|
+
for (const cid of cl) {
|
|
695
|
+
const node = nodeFor(String(cid), ctx, depth + 1);
|
|
696
|
+
if (node) out.push(node);
|
|
697
|
+
}
|
|
698
|
+
return { children: out };
|
|
699
|
+
}
|
|
700
|
+
// Template: {path:"/items", componentId:"tpl"}
|
|
701
|
+
if (typeof cl === "object" && cl !== null) {
|
|
702
|
+
const t = cl as { path?: unknown; componentId?: unknown };
|
|
703
|
+
if (typeof t.path !== "string" || !t.path.startsWith("/") ||
|
|
704
|
+
typeof t.componentId !== "string") {
|
|
705
|
+
ctx.diags.push(diagnostic("sdui.a2ui.template", "schema",
|
|
706
|
+
"warn", `childList template mal formado en ${c.id}`));
|
|
707
|
+
return {};
|
|
708
|
+
}
|
|
709
|
+
const fields = new Set<string>();
|
|
710
|
+
collectRowFields(t.componentId, ctx, fields);
|
|
711
|
+
const sub: TranslateCtx = {
|
|
712
|
+
...ctx, rowFields: fields, depth: depth + 1,
|
|
713
|
+
};
|
|
714
|
+
const tpl = nodeFor(t.componentId, sub, 0);
|
|
715
|
+
if (!tpl) {
|
|
716
|
+
ctx.diags.push(diagnostic("sdui.a2ui.ref", "schema", "warn",
|
|
717
|
+
`template inexistente: ${t.componentId} (${c.id})`));
|
|
718
|
+
return {};
|
|
719
|
+
}
|
|
720
|
+
return {
|
|
721
|
+
list: {
|
|
722
|
+
items: { expr: { ref: a2uiSignalName(t.path) } },
|
|
723
|
+
fields: [...fields],
|
|
724
|
+
renderItem: tpl as unknown as IRNode,
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
if (typeof cl === "string") {
|
|
729
|
+
const node = nodeFor(cl, ctx, depth + 1);
|
|
730
|
+
return node ? { children: [node] } : {};
|
|
731
|
+
}
|
|
732
|
+
return {};
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function nodeFor(
|
|
736
|
+
id: string, ctx: TranslateCtx, depth: number,
|
|
737
|
+
): RichNode | null {
|
|
738
|
+
if (depth > 32) {
|
|
739
|
+
ctx.diags.push(diagnostic("sdui.a2ui.depth", "schema", "warn",
|
|
740
|
+
`árbol de componentes supera cota 32 en ${id}`));
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
const c = ctx.surface.components[id];
|
|
744
|
+
if (!c) {
|
|
745
|
+
ctx.diags.push(diagnostic("sdui.a2ui.ref", "schema", "warn",
|
|
746
|
+
`componente referenciado inexistente: ${id}`));
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
const kind = c.component;
|
|
750
|
+
const node: RichNode = { id, type: "column" };
|
|
751
|
+
|
|
752
|
+
// Propiedades comunes de layout de fila/columna.
|
|
753
|
+
const layoutStyle = (): Record<string, unknown> => {
|
|
754
|
+
const st: Record<string, unknown> = {};
|
|
755
|
+
const j = JUSTIFY[String(c.justify ?? "")];
|
|
756
|
+
const a = ALIGN[String(c.align ?? "")];
|
|
757
|
+
if (j) st.justifyContent = j;
|
|
758
|
+
if (a) st.alignItems = a;
|
|
759
|
+
return st;
|
|
760
|
+
};
|
|
761
|
+
const weight = typeof c.weight === "number" ? { flex: c.weight } : {};
|
|
762
|
+
|
|
763
|
+
switch (kind) {
|
|
764
|
+
case "Text": {
|
|
765
|
+
node.type = "text";
|
|
766
|
+
node.text = dynProp(
|
|
767
|
+
dynToExpr(c.text, ctx, `${id}.text`)) as never;
|
|
768
|
+
node.style = {
|
|
769
|
+
...VARIANT_STYLE[String(c.variant ?? "body")] ?? {},
|
|
770
|
+
...weight,
|
|
771
|
+
};
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
case "Row":
|
|
775
|
+
case "Column": {
|
|
776
|
+
node.type = kind === "Row" ? "row" : "column";
|
|
777
|
+
const ch = childrenOf(c, ctx, depth);
|
|
778
|
+
Object.assign(node, ch);
|
|
779
|
+
node.style = { ...layoutStyle(), ...weight };
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
case "Card": {
|
|
783
|
+
node.type = "column";
|
|
784
|
+
const child = c.child !== undefined
|
|
785
|
+
? nodeFor(String(c.child), ctx, depth + 1) : null;
|
|
786
|
+
node.children = child ? [child] : [];
|
|
787
|
+
node.style = {
|
|
788
|
+
padding: 16, borderRadius: 12,
|
|
789
|
+
backgroundColor: "#FFFFFF", ...weight,
|
|
790
|
+
};
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
case "Button": {
|
|
794
|
+
node.type = "button";
|
|
795
|
+
const child = c.child !== undefined
|
|
796
|
+
? nodeFor(String(c.child), ctx, depth + 1) : null;
|
|
797
|
+
node.children = child ? [child] : [];
|
|
798
|
+
const intents = actionToDo(c.action, ctx.surface.surfaceId, ctx);
|
|
799
|
+
if (intents) node.events = { press: { do: intents } };
|
|
800
|
+
node.style = { padding: 12, ...weight };
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
case "Image": {
|
|
804
|
+
node.type = "image";
|
|
805
|
+
const u = dynToExpr(c.url, ctx, `${id}.url`);
|
|
806
|
+
// La prop portable de <image> es `src` (PROPS_CAPABILITY);
|
|
807
|
+
// `url` solo aplica a WebView en Android y no pinta en web/Linux.
|
|
808
|
+
node.props = { src: dynProp(u) as never };
|
|
809
|
+
const fit = String(c.fit ?? "");
|
|
810
|
+
node.style = {
|
|
811
|
+
objectFit: fit === "scaleDown" ? "scale-down" : fit,
|
|
812
|
+
...weight,
|
|
813
|
+
};
|
|
814
|
+
const desc = dynToExpr(c.description, ctx, `${id}.description`);
|
|
815
|
+
if (desc !== null) {
|
|
816
|
+
// `label` es una clave semántica dentro de props (el
|
|
817
|
+
// reconciler la separa y emite update-semantics).
|
|
818
|
+
(node.props as Record<string, unknown>).label =
|
|
819
|
+
dynProp(desc);
|
|
820
|
+
}
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
case "Divider": {
|
|
824
|
+
const axis = String(c.axis ?? "horizontal");
|
|
825
|
+
node.style = axis === "vertical"
|
|
826
|
+
? { width: 1, alignSelf: "stretch", backgroundColor: "#808080" }
|
|
827
|
+
: { height: 1, alignSelf: "stretch", backgroundColor: "#808080" };
|
|
828
|
+
Object.assign(node.style, weight);
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
case "List": {
|
|
832
|
+
const ch = childrenOf(c, ctx, depth);
|
|
833
|
+
if (ch.list) {
|
|
834
|
+
node.type = "list";
|
|
835
|
+
node.list = ch.list;
|
|
836
|
+
} else {
|
|
837
|
+
// List estática = contenedor scrollable.
|
|
838
|
+
node.type = "scroll-view";
|
|
839
|
+
node.children = ch.children ?? [];
|
|
840
|
+
}
|
|
841
|
+
node.style = weight;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
case "CheckBox": {
|
|
845
|
+
node.type = "row";
|
|
846
|
+
// `variant` convierte el switch en casilla nativa (web,
|
|
847
|
+
// Android y Linux la materializan desde ADR-0195/P1).
|
|
848
|
+
const sw: RichNode = {
|
|
849
|
+
type: "switch", style: weight,
|
|
850
|
+
props: { variant: "checkbox" },
|
|
851
|
+
};
|
|
852
|
+
const vp = typeof c.value === "object" && c.value !== null
|
|
853
|
+
? (c.value as { path?: unknown }).path : undefined;
|
|
854
|
+
if (typeof vp === "string") {
|
|
855
|
+
const sig = a2uiSignalName(vp);
|
|
856
|
+
ctx.boundPaths.set(sig, vp);
|
|
857
|
+
sw.props = {
|
|
858
|
+
...sw.props,
|
|
859
|
+
checked: { expr: { ref: sig } },
|
|
860
|
+
};
|
|
861
|
+
sw.events = {
|
|
862
|
+
change: {
|
|
863
|
+
do: [{
|
|
864
|
+
set: sig,
|
|
865
|
+
value: {
|
|
866
|
+
get: [{ get: [{ ref: "event" }, "data"] },
|
|
867
|
+
"checked"],
|
|
868
|
+
},
|
|
869
|
+
}],
|
|
870
|
+
},
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
const lbl: RichNode = {
|
|
874
|
+
type: "text",
|
|
875
|
+
text: dynProp(dynToExpr(c.label, ctx, `${id}.label`)),
|
|
876
|
+
};
|
|
877
|
+
node.children = [sw, lbl];
|
|
878
|
+
node.style = { alignItems: "center", gap: 8, ...weight };
|
|
879
|
+
return withChecks(node, sw, c.checks, ctx, id);
|
|
880
|
+
}
|
|
881
|
+
case "TextField": {
|
|
882
|
+
node.type = "text-input";
|
|
883
|
+
node.props = {
|
|
884
|
+
placeholder: dynProp(
|
|
885
|
+
dynToExpr(c.label, ctx, `${id}.label`)) as never,
|
|
886
|
+
};
|
|
887
|
+
const v = String(c.variant ?? "shortText");
|
|
888
|
+
if (v === "number") node.props.keyboard = "number";
|
|
889
|
+
if (v === "obscured") node.props.keyboard = "password";
|
|
890
|
+
if (v === "longText") {
|
|
891
|
+
node.props.multiline = true;
|
|
892
|
+
if (typeof c.rows === "number" && c.rows > 0) {
|
|
893
|
+
node.props.rows = c.rows;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const vp = typeof c.value === "object" && c.value !== null
|
|
897
|
+
? (c.value as { path?: unknown }).path : undefined;
|
|
898
|
+
bindValue(node,
|
|
899
|
+
typeof vp === "string" ? vp : undefined,
|
|
900
|
+
"input", "text", ctx);
|
|
901
|
+
node.style = weight;
|
|
902
|
+
return withChecks(node, node, c.checks, ctx, id);
|
|
903
|
+
}
|
|
904
|
+
case "Slider": {
|
|
905
|
+
node.type = "slider";
|
|
906
|
+
const mn = dynToExpr(c.minValue, ctx, `${id}.min`);
|
|
907
|
+
const mx = dynToExpr(c.maxValue, ctx, `${id}.max`);
|
|
908
|
+
node.props = {
|
|
909
|
+
min: (mn === null ? 0 : dynProp(mn)) as never,
|
|
910
|
+
max: (mx === null ? 100 : dynProp(mx)) as never,
|
|
911
|
+
};
|
|
912
|
+
const vp = typeof c.value === "object" && c.value !== null
|
|
913
|
+
? (c.value as { path?: unknown }).path : undefined;
|
|
914
|
+
bindValue(node,
|
|
915
|
+
typeof vp === "string" ? vp : undefined,
|
|
916
|
+
"input", "progress", ctx);
|
|
917
|
+
node.style = weight;
|
|
918
|
+
return withChecks(node, node, c.checks, ctx, id);
|
|
919
|
+
}
|
|
920
|
+
case "DateTimeInput": {
|
|
921
|
+
// `keyboard: date|time|datetime` es el contrato portable del
|
|
922
|
+
// text-input; web lo materializa como <input type=...>, los
|
|
923
|
+
// hosts nativos abren su picker (P1). Sin warning de
|
|
924
|
+
// "no soportado": la intención viaja y el backend decide.
|
|
925
|
+
const rawKind = String(c.type ?? c.mode ?? "date").toLowerCase();
|
|
926
|
+
const keyboard = rawKind.includes("datetime") ||
|
|
927
|
+
rawKind.includes("date_time")
|
|
928
|
+
? "datetime"
|
|
929
|
+
: rawKind.includes("time") ? "time" : "date";
|
|
930
|
+
node.type = "text-input";
|
|
931
|
+
node.props = {
|
|
932
|
+
placeholder: dynProp(
|
|
933
|
+
dynToExpr(c.label, ctx, `${id}.label`)) as never,
|
|
934
|
+
keyboard,
|
|
935
|
+
};
|
|
936
|
+
const vp = typeof c.value === "object" && c.value !== null
|
|
937
|
+
? (c.value as { path?: unknown }).path : undefined;
|
|
938
|
+
bindValue(node,
|
|
939
|
+
typeof vp === "string" ? vp : undefined,
|
|
940
|
+
"input", "text", ctx);
|
|
941
|
+
node.style = weight;
|
|
942
|
+
return withChecks(node, node, c.checks, ctx, id);
|
|
943
|
+
}
|
|
944
|
+
case "Tabs": {
|
|
945
|
+
const tabs = Array.isArray(c.tabs)
|
|
946
|
+
? c.tabs as Array<Record<string, unknown>> : [];
|
|
947
|
+
if (tabs.length === 0) {
|
|
948
|
+
ctx.diags.push(diagnostic("sdui.a2ui.tabs", "schema",
|
|
949
|
+
"warn", `Tabs ${id} sin pestañas — vacío`));
|
|
950
|
+
}
|
|
951
|
+
const state = localSignal(
|
|
952
|
+
ctx, `__a2ui_tab_${safeSignalId(id)}`, 0,
|
|
953
|
+
);
|
|
954
|
+
const headers: RichNode[] = [];
|
|
955
|
+
const panels: RichNode[] = [];
|
|
956
|
+
tabs.forEach((t, i) => {
|
|
957
|
+
const titleExpr = dynToExpr(
|
|
958
|
+
t.title, ctx, `${id}.tabs.${i}.title`);
|
|
959
|
+
const title = dynProp(titleExpr);
|
|
960
|
+
headers.push({
|
|
961
|
+
type: "button",
|
|
962
|
+
id: `${id}:tab:${i}`,
|
|
963
|
+
props: {
|
|
964
|
+
role: "tab",
|
|
965
|
+
label: title,
|
|
966
|
+
selected: { expr: { eq: [{ ref: state }, i] } },
|
|
967
|
+
},
|
|
968
|
+
events: {
|
|
969
|
+
press: { do: [{ set: state, value: { lit: i } }] },
|
|
970
|
+
},
|
|
971
|
+
children: [{ type: "text", text: title }],
|
|
972
|
+
style: { padding: 8 },
|
|
973
|
+
});
|
|
974
|
+
const cid = typeof t.child === "string" ? t.child : "";
|
|
975
|
+
const child = cid ? nodeFor(cid, ctx, depth + 1) : null;
|
|
976
|
+
if (!child) {
|
|
977
|
+
if (cid) {
|
|
978
|
+
ctx.diags.push(diagnostic("sdui.a2ui.tabs",
|
|
979
|
+
"schema", "warn",
|
|
980
|
+
`Tabs ${id}: hijo ${cid} inexistente`));
|
|
981
|
+
}
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
panels.push({
|
|
985
|
+
when: { eq: [{ ref: state }, i] },
|
|
986
|
+
then: {
|
|
987
|
+
type: "column",
|
|
988
|
+
props: { role: "tabpanel", label: title },
|
|
989
|
+
children: [child],
|
|
990
|
+
style: { gap: 6 },
|
|
991
|
+
},
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
node.type = "column";
|
|
995
|
+
node.style = { gap: 8, ...weight };
|
|
996
|
+
node.children = [
|
|
997
|
+
{
|
|
998
|
+
type: "row",
|
|
999
|
+
props: { role: "tablist" },
|
|
1000
|
+
style: { gap: 4 },
|
|
1001
|
+
children: headers,
|
|
1002
|
+
},
|
|
1003
|
+
...panels,
|
|
1004
|
+
];
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
case "Modal": {
|
|
1008
|
+
const state = localSignal(
|
|
1009
|
+
ctx, `__a2ui_modal_${safeSignalId(id)}`, 0,
|
|
1010
|
+
);
|
|
1011
|
+
const triggerId =
|
|
1012
|
+
typeof c.trigger === "string" ? c.trigger : "";
|
|
1013
|
+
const contentId =
|
|
1014
|
+
typeof c.content === "string" ? c.content : "";
|
|
1015
|
+
const trigger = triggerId
|
|
1016
|
+
? nodeFor(triggerId, ctx, depth + 1) : null;
|
|
1017
|
+
const content = contentId
|
|
1018
|
+
? nodeFor(contentId, ctx, depth + 1) : null;
|
|
1019
|
+
if (!trigger || !content) {
|
|
1020
|
+
ctx.diags.push(diagnostic("sdui.a2ui.modal", "schema",
|
|
1021
|
+
"warn", `Modal ${id}: trigger/content inválido`));
|
|
1022
|
+
node.type = "text";
|
|
1023
|
+
node.text = "[Modal: trigger/content inválido]";
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
if (!addIntent(trigger, "press",
|
|
1027
|
+
{ set: state, value: { lit: 1 } })) {
|
|
1028
|
+
ctx.diags.push(diagnostic("sdui.a2ui.modal", "capability",
|
|
1029
|
+
"warn", `Modal ${id}: trigger ${triggerId} no ` +
|
|
1030
|
+
"interactivo (wrapper) — el diálogo no se abre"));
|
|
1031
|
+
}
|
|
1032
|
+
const close: RichNode = {
|
|
1033
|
+
type: "button",
|
|
1034
|
+
props: { role: "button", label: "Cerrar" },
|
|
1035
|
+
events: {
|
|
1036
|
+
press: { do: [{ set: state, value: { lit: 0 } }] },
|
|
1037
|
+
},
|
|
1038
|
+
children: [{ type: "text", text: "×" }],
|
|
1039
|
+
style: { padding: 8 },
|
|
1040
|
+
};
|
|
1041
|
+
node.type = "column";
|
|
1042
|
+
node.style = weight;
|
|
1043
|
+
node.children = [
|
|
1044
|
+
trigger,
|
|
1045
|
+
{
|
|
1046
|
+
when: { eq: [{ ref: state }, { lit: 1 }] },
|
|
1047
|
+
then: {
|
|
1048
|
+
type: "column",
|
|
1049
|
+
props: { role: "dialog", label: "Modal" },
|
|
1050
|
+
style: {
|
|
1051
|
+
padding: 16,
|
|
1052
|
+
gap: 8,
|
|
1053
|
+
backgroundColor: "#ffffff",
|
|
1054
|
+
borderColor: "#999999",
|
|
1055
|
+
borderWidth: 1,
|
|
1056
|
+
borderRadius: 8,
|
|
1057
|
+
},
|
|
1058
|
+
children: [
|
|
1059
|
+
{
|
|
1060
|
+
type: "row",
|
|
1061
|
+
style: { justifyContent: "flex-end" },
|
|
1062
|
+
children: [close],
|
|
1063
|
+
},
|
|
1064
|
+
content,
|
|
1065
|
+
],
|
|
1066
|
+
},
|
|
1067
|
+
},
|
|
1068
|
+
];
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1071
|
+
case "ChoicePicker": {
|
|
1072
|
+
const opts = Array.isArray(c.options)
|
|
1073
|
+
? c.options as Array<Record<string, unknown>> : [];
|
|
1074
|
+
const multiple = String(c.variant ?? "mutuallyExclusive") ===
|
|
1075
|
+
"multipleSelection";
|
|
1076
|
+
const valueObj = c.value !== null &&
|
|
1077
|
+
typeof c.value === "object"
|
|
1078
|
+
? c.value as { path?: unknown } : null;
|
|
1079
|
+
const vp = typeof valueObj?.path === "string"
|
|
1080
|
+
? valueObj.path : undefined;
|
|
1081
|
+
let state: string;
|
|
1082
|
+
if (vp !== undefined && vp.startsWith("/")) {
|
|
1083
|
+
state = a2uiSignalName(vp);
|
|
1084
|
+
localSignal(ctx, state, []);
|
|
1085
|
+
ctx.boundPaths.set(state, vp);
|
|
1086
|
+
} else {
|
|
1087
|
+
const init = Array.isArray(c.value) ? c.value : [];
|
|
1088
|
+
state = localSignal(
|
|
1089
|
+
ctx, `__a2ui_choice_${safeSignalId(id)}`, init);
|
|
1090
|
+
}
|
|
1091
|
+
const groupLabel = dynProp(dynToExpr(
|
|
1092
|
+
c.label, ctx, `${id}.label`));
|
|
1093
|
+
const checkedExpr = (value: string): Expr => multiple
|
|
1094
|
+
? { includes: [{ ref: state }, { lit: value }] }
|
|
1095
|
+
: {
|
|
1096
|
+
or: [
|
|
1097
|
+
{
|
|
1098
|
+
eq: [
|
|
1099
|
+
{ get: [{ ref: state }, 0] },
|
|
1100
|
+
{ lit: value },
|
|
1101
|
+
],
|
|
1102
|
+
},
|
|
1103
|
+
{ eq: [{ ref: state }, { lit: value }] },
|
|
1104
|
+
],
|
|
1105
|
+
};
|
|
1106
|
+
const nextValue = (pressed: string): Expr => {
|
|
1107
|
+
if (!multiple) return { lit: [pressed] };
|
|
1108
|
+
const keep: Expr[] = opts
|
|
1109
|
+
.filter((o) => String(o.value ?? "") !== pressed)
|
|
1110
|
+
.map((o) => {
|
|
1111
|
+
const v = String(o.value ?? "");
|
|
1112
|
+
return {
|
|
1113
|
+
if: [
|
|
1114
|
+
{
|
|
1115
|
+
includes: [
|
|
1116
|
+
{ ref: state }, { lit: v },
|
|
1117
|
+
],
|
|
1118
|
+
},
|
|
1119
|
+
{ lit: [v] },
|
|
1120
|
+
{ lit: [] },
|
|
1121
|
+
],
|
|
1122
|
+
};
|
|
1123
|
+
});
|
|
1124
|
+
const toggle: Expr = {
|
|
1125
|
+
if: [
|
|
1126
|
+
{ includes: [{ ref: state }, { lit: pressed }] },
|
|
1127
|
+
{ lit: [] },
|
|
1128
|
+
{ lit: [pressed] },
|
|
1129
|
+
],
|
|
1130
|
+
};
|
|
1131
|
+
return { arrayConcat: [...keep, toggle] };
|
|
1132
|
+
};
|
|
1133
|
+
const rawLabels: Expr[] = [];
|
|
1134
|
+
const optionNodes: RichNode[] = opts.map((o, i) => {
|
|
1135
|
+
const value = String(o.value ?? "");
|
|
1136
|
+
const raw = dynToExpr(
|
|
1137
|
+
o.label, ctx, `${id}.options.${i}.label`);
|
|
1138
|
+
rawLabels.push(raw === null ? "" : raw);
|
|
1139
|
+
const label = dynProp(raw);
|
|
1140
|
+
return {
|
|
1141
|
+
type: "button",
|
|
1142
|
+
id: `${id}:opt:${i}`,
|
|
1143
|
+
props: {
|
|
1144
|
+
role: multiple ? "checkbox" : "radio",
|
|
1145
|
+
label,
|
|
1146
|
+
checked: { expr: checkedExpr(value) },
|
|
1147
|
+
},
|
|
1148
|
+
events: {
|
|
1149
|
+
press: {
|
|
1150
|
+
do: [{
|
|
1151
|
+
set: state,
|
|
1152
|
+
value: nextValue(value),
|
|
1153
|
+
}],
|
|
1154
|
+
},
|
|
1155
|
+
},
|
|
1156
|
+
children: [{ type: "text", text: label }],
|
|
1157
|
+
style: { padding: 8 },
|
|
1158
|
+
};
|
|
1159
|
+
});
|
|
1160
|
+
const chips = String(c.displayStyle ?? "checkbox") === "chips";
|
|
1161
|
+
let list: RichNode = chips
|
|
1162
|
+
? {
|
|
1163
|
+
type: "row",
|
|
1164
|
+
style: { flexWrap: "wrap", gap: 6 },
|
|
1165
|
+
children: optionNodes,
|
|
1166
|
+
}
|
|
1167
|
+
: {
|
|
1168
|
+
type: "column",
|
|
1169
|
+
style: { gap: 4 },
|
|
1170
|
+
children: optionNodes,
|
|
1171
|
+
};
|
|
1172
|
+
const groupChildren: RichNode[] = [];
|
|
1173
|
+
if (c.filterable === true) {
|
|
1174
|
+
const query = localSignal(
|
|
1175
|
+
ctx, `__a2ui_query_${safeSignalId(id)}`, "");
|
|
1176
|
+
groupChildren.push({
|
|
1177
|
+
type: "text-input",
|
|
1178
|
+
props: {
|
|
1179
|
+
placeholder: "Buscar",
|
|
1180
|
+
value: { expr: { ref: query } },
|
|
1181
|
+
},
|
|
1182
|
+
events: {
|
|
1183
|
+
input: {
|
|
1184
|
+
do: [{
|
|
1185
|
+
set: query,
|
|
1186
|
+
value: {
|
|
1187
|
+
get: [{ get: [{ ref: "event" }, "data"] },
|
|
1188
|
+
"text"],
|
|
1189
|
+
},
|
|
1190
|
+
}],
|
|
1191
|
+
},
|
|
1192
|
+
},
|
|
1193
|
+
style: { height: 36 },
|
|
1194
|
+
});
|
|
1195
|
+
// Filtro declarativo (substring, sin lower): cada opción
|
|
1196
|
+
// se oculta si la query no aparece en su label.
|
|
1197
|
+
const wrapped: RichNode[] = optionNodes.map((n, i) => ({
|
|
1198
|
+
when: {
|
|
1199
|
+
or: [
|
|
1200
|
+
{ eq: [{ ref: query }, { lit: "" }] },
|
|
1201
|
+
{ includes: [{ ref: query }, rawLabels[i]] },
|
|
1202
|
+
],
|
|
1203
|
+
},
|
|
1204
|
+
then: n,
|
|
1205
|
+
}));
|
|
1206
|
+
list = chips
|
|
1207
|
+
? {
|
|
1208
|
+
type: "row",
|
|
1209
|
+
style: { flexWrap: "wrap", gap: 6 },
|
|
1210
|
+
children: wrapped,
|
|
1211
|
+
}
|
|
1212
|
+
: {
|
|
1213
|
+
type: "column",
|
|
1214
|
+
style: { gap: 4 },
|
|
1215
|
+
children: wrapped,
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
groupChildren.push(list);
|
|
1219
|
+
node.type = "column";
|
|
1220
|
+
node.props = {
|
|
1221
|
+
role: multiple ? "group" : "radiogroup",
|
|
1222
|
+
label: groupLabel,
|
|
1223
|
+
};
|
|
1224
|
+
node.style = { gap: 6, ...weight };
|
|
1225
|
+
node.children = groupChildren;
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
case "Icon": {
|
|
1229
|
+
const rawName = c.name;
|
|
1230
|
+
const iconNode = (
|
|
1231
|
+
text: unknown, label: unknown, idSuffix?: string,
|
|
1232
|
+
): RichNode => ({
|
|
1233
|
+
type: "text",
|
|
1234
|
+
id: idSuffix ? `${id}:${idSuffix}` : `${id}:icon`,
|
|
1235
|
+
text: text as never,
|
|
1236
|
+
props: { role: "img", label } as never,
|
|
1237
|
+
style: { fontSize: 20, ...weight },
|
|
1238
|
+
});
|
|
1239
|
+
if (typeof rawName === "string") {
|
|
1240
|
+
node.type = "text";
|
|
1241
|
+
node.text = (ICON_GLYPHS[rawName] ?? "■") as never;
|
|
1242
|
+
node.props = { role: "img", label: rawName } as never;
|
|
1243
|
+
node.style = { fontSize: 20, ...weight };
|
|
1244
|
+
if (!(rawName in ICON_GLYPHS)) {
|
|
1245
|
+
ctx.diags.push(diagnostic("sdui.a2ui.icon",
|
|
1246
|
+
"capability", "warn",
|
|
1247
|
+
`Icon ${id}: nombre "${rawName}" fuera del ` +
|
|
1248
|
+
"catálogo — glifo genérico"));
|
|
1249
|
+
}
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
if (rawName !== null && typeof rawName === "object" &&
|
|
1253
|
+
"svgPath" in (rawName as object)) {
|
|
1254
|
+
ctx.diags.push(diagnostic("sdui.a2ui.icon",
|
|
1255
|
+
"capability", "warn",
|
|
1256
|
+
`Icon ${id}: svgPath no portable aún — glifo genérico`));
|
|
1257
|
+
node.type = "text";
|
|
1258
|
+
node.text = "◆";
|
|
1259
|
+
node.props = { role: "img", label: "icon" } as never;
|
|
1260
|
+
node.style = { fontSize: 20, ...weight };
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
const ex = dynToExpr(rawName, ctx, `${id}.name`);
|
|
1264
|
+
if (ex === null || typeof ex !== "object") {
|
|
1265
|
+
return iconNode("■", "icon");
|
|
1266
|
+
}
|
|
1267
|
+
const cases: Record<string, RichNode> = {};
|
|
1268
|
+
for (const [name, glyph] of Object.entries(ICON_GLYPHS)) {
|
|
1269
|
+
cases[name] = iconNode(glyph, name, name);
|
|
1270
|
+
}
|
|
1271
|
+
return {
|
|
1272
|
+
id,
|
|
1273
|
+
switch: ex as Expr,
|
|
1274
|
+
cases,
|
|
1275
|
+
default: iconNode({ expr: ex } as never, "icon", "name"),
|
|
1276
|
+
} as RichNode;
|
|
1277
|
+
}
|
|
1278
|
+
default:
|
|
1279
|
+
return unsupported(ctx, String(kind), id);
|
|
1280
|
+
}
|
|
1281
|
+
return node;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/** Crea el renderer — un estado por surfaceId, mensajes aplicados en
|
|
1285
|
+
* orden de stream (el transporte garantiza el orden). */
|
|
1286
|
+
export function createA2uiRenderer(): A2uiRenderer {
|
|
1287
|
+
const surfaces: Record<string, A2uiSurface> = {};
|
|
1288
|
+
|
|
1289
|
+
const apply = (msg: unknown): Diagnostic[] => {
|
|
1290
|
+
const diags: Diagnostic[] = [];
|
|
1291
|
+
if (msg === null || typeof msg !== "object") {
|
|
1292
|
+
diags.push(diagnostic("sdui.a2ui.shape", "schema", "warn",
|
|
1293
|
+
"mensaje A2UI no es objeto — ignorado"));
|
|
1294
|
+
return diags;
|
|
1295
|
+
}
|
|
1296
|
+
const m = msg as A2uiMessage;
|
|
1297
|
+
if (m.version !== undefined &&
|
|
1298
|
+
!SUPPORTED_VERSIONS.has(m.version)) {
|
|
1299
|
+
diags.push(diagnostic("sdui.a2ui.version", "schema", "warn",
|
|
1300
|
+
`versión A2UI no reconocida: ${m.version} — se procesa`));
|
|
1301
|
+
}
|
|
1302
|
+
if (m.createSurface) {
|
|
1303
|
+
const cs = m.createSurface;
|
|
1304
|
+
if (surfaces[cs.surfaceId]) {
|
|
1305
|
+
diags.push(diagnostic("sdui.a2ui.surface", "schema",
|
|
1306
|
+
"warn", `surfaceId duplicado sin deleteSurface: ` +
|
|
1307
|
+
cs.surfaceId));
|
|
1308
|
+
return diags;
|
|
1309
|
+
}
|
|
1310
|
+
if (cs.catalogId !== BASIC_CATALOG) {
|
|
1311
|
+
diags.push(diagnostic("sdui.a2ui.catalog", "capability",
|
|
1312
|
+
"warn", `catalogId no declarado como básico: ` +
|
|
1313
|
+
`${cs.catalogId} — componentes desconocidos caen a ` +
|
|
1314
|
+
"fallback"));
|
|
1315
|
+
}
|
|
1316
|
+
surfaces[cs.surfaceId] = {
|
|
1317
|
+
surfaceId: cs.surfaceId,
|
|
1318
|
+
catalogId: cs.catalogId ?? "",
|
|
1319
|
+
sendDataModel: cs.sendDataModel === true,
|
|
1320
|
+
components: {},
|
|
1321
|
+
model: {},
|
|
1322
|
+
boundPaths: {},
|
|
1323
|
+
diags: [],
|
|
1324
|
+
};
|
|
1325
|
+
return diags;
|
|
1326
|
+
}
|
|
1327
|
+
if (m.updateComponents) {
|
|
1328
|
+
const uc = m.updateComponents;
|
|
1329
|
+
const s = surfaces[uc.surfaceId];
|
|
1330
|
+
if (!s) {
|
|
1331
|
+
diags.push(diagnostic("sdui.a2ui.surface", "schema",
|
|
1332
|
+
"warn", `updateComponents a superficie inexistente: ` +
|
|
1333
|
+
uc.surfaceId));
|
|
1334
|
+
return diags;
|
|
1335
|
+
}
|
|
1336
|
+
for (const c of uc.components ?? []) {
|
|
1337
|
+
if (typeof c?.id === "string" &&
|
|
1338
|
+
typeof c?.component === "string") {
|
|
1339
|
+
s.components[c.id] = c;
|
|
1340
|
+
} else {
|
|
1341
|
+
diags.push(diagnostic("sdui.a2ui.component", "schema",
|
|
1342
|
+
"warn", "componente sin id/component — omitido"));
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
return diags;
|
|
1346
|
+
}
|
|
1347
|
+
if (m.updateDataModel) {
|
|
1348
|
+
const ud = m.updateDataModel;
|
|
1349
|
+
const s = surfaces[ud.surfaceId];
|
|
1350
|
+
if (!s) {
|
|
1351
|
+
diags.push(diagnostic("sdui.a2ui.surface", "schema",
|
|
1352
|
+
"warn", `updateDataModel a superficie inexistente: ` +
|
|
1353
|
+
ud.surfaceId));
|
|
1354
|
+
return diags;
|
|
1355
|
+
}
|
|
1356
|
+
modelPatch(s.model, ud.path, ud.value);
|
|
1357
|
+
return diags;
|
|
1358
|
+
}
|
|
1359
|
+
if (m.deleteSurface) {
|
|
1360
|
+
delete surfaces[m.deleteSurface.surfaceId];
|
|
1361
|
+
return diags;
|
|
1362
|
+
}
|
|
1363
|
+
diags.push(diagnostic("sdui.a2ui.shape", "schema", "warn",
|
|
1364
|
+
"mensaje A2UI sin tipo conocido — ignorado"));
|
|
1365
|
+
return diags;
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
const envelope = (surfaceId: string): SduiEnvelope | null => {
|
|
1369
|
+
const s = surfaces[surfaceId];
|
|
1370
|
+
if (!s) return null;
|
|
1371
|
+
const diags: Diagnostic[] = [];
|
|
1372
|
+
const locals: Record<string, unknown> = {};
|
|
1373
|
+
const boundPaths = new Map<string, string>();
|
|
1374
|
+
const ctx: TranslateCtx = {
|
|
1375
|
+
surface: s, diags, rowFields: null, depth: 0, locals,
|
|
1376
|
+
boundPaths,
|
|
1377
|
+
};
|
|
1378
|
+
const root = s.components.root !== undefined
|
|
1379
|
+
? nodeFor("root", ctx, 0) : null;
|
|
1380
|
+
// La traducción puede emitir avisos (refs rotas, componentes sin
|
|
1381
|
+
// materialización) — quedan consultables, nunca se descartan.
|
|
1382
|
+
s.diags = diags;
|
|
1383
|
+
if (!root) {
|
|
1384
|
+
return null;
|
|
1385
|
+
}
|
|
1386
|
+
const signals = flattenModel(s.model);
|
|
1387
|
+
// ADR-0206 — estado local del renderer (tab/modal/query/choice)
|
|
1388
|
+
// solo si el data model no aporta la misma clave.
|
|
1389
|
+
for (const [k, v] of Object.entries(locals)) {
|
|
1390
|
+
if (!(k in signals)) signals[k] = v;
|
|
1391
|
+
}
|
|
1392
|
+
// Refs ligadas sin dato aún → declaradas a null (spec: el
|
|
1393
|
+
// renderer trata undefined con gracia durante el streaming).
|
|
1394
|
+
const declared = new Set(Object.keys(signals));
|
|
1395
|
+
const scan = (n: RichNode): void => {
|
|
1396
|
+
const scanExpr = (e: unknown): void => {
|
|
1397
|
+
if (e === null || typeof e !== "object") return;
|
|
1398
|
+
for (const r of collectRefsOf(e as Expr)) {
|
|
1399
|
+
if (!declared.has(r)) {
|
|
1400
|
+
signals[r] = null;
|
|
1401
|
+
declared.add(r);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
const text = n.text;
|
|
1406
|
+
if (text !== null && typeof text === "object" &&
|
|
1407
|
+
"expr" in text) {
|
|
1408
|
+
scanExpr((text as { expr: Expr }).expr);
|
|
1409
|
+
}
|
|
1410
|
+
for (const map of [n.props, n.style]) {
|
|
1411
|
+
for (const v of Object.values(map ?? {})) {
|
|
1412
|
+
if (v !== null && typeof v === "object" &&
|
|
1413
|
+
"expr" in (v as object)) {
|
|
1414
|
+
scanExpr((v as { expr: Expr }).expr);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
// ADR-0206 — condiciones de Tabs/ChoicePicker y switch de
|
|
1419
|
+
// Icon también pueden referenciar paths del data model.
|
|
1420
|
+
scanExpr(n.when);
|
|
1421
|
+
scanExpr(n.switch);
|
|
1422
|
+
(n.children ?? []).forEach(scan);
|
|
1423
|
+
if (n.then !== undefined) scan(n.then);
|
|
1424
|
+
if (n.else !== undefined) scan(n.else);
|
|
1425
|
+
if (n.default !== undefined) scan(n.default);
|
|
1426
|
+
for (const c of Object.values(n.cases ?? {})) scan(c);
|
|
1427
|
+
};
|
|
1428
|
+
scan(root);
|
|
1429
|
+
s.boundPaths = Object.fromEntries(boundPaths);
|
|
1430
|
+
return {
|
|
1431
|
+
sdui: 1,
|
|
1432
|
+
signals,
|
|
1433
|
+
doc: { root },
|
|
1434
|
+
profile: "a2ui",
|
|
1435
|
+
};
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
return {
|
|
1439
|
+
apply,
|
|
1440
|
+
envelope,
|
|
1441
|
+
model: (id) => surfaces[id]?.model ?? null,
|
|
1442
|
+
dataSignals: (id) => {
|
|
1443
|
+
const s = surfaces[id];
|
|
1444
|
+
return s ? flattenModel(s.model) : null;
|
|
1445
|
+
},
|
|
1446
|
+
boundPaths: (id) => ({
|
|
1447
|
+
...(surfaces[id]?.boundPaths ?? {}),
|
|
1448
|
+
}),
|
|
1449
|
+
sendDataModel: (id) => surfaces[id]?.sendDataModel === true,
|
|
1450
|
+
syncModel: (id, read) => {
|
|
1451
|
+
const s = surfaces[id];
|
|
1452
|
+
if (!s) return null;
|
|
1453
|
+
for (const [sig, pointer] of Object.entries(s.boundPaths)) {
|
|
1454
|
+
modelPatch(s.model, pointer, read(sig));
|
|
1455
|
+
}
|
|
1456
|
+
return s.model;
|
|
1457
|
+
},
|
|
1458
|
+
envelopeDiagnostics: (id) => [...(surfaces[id]?.diags ?? [])],
|
|
1459
|
+
surfaces: () => Object.keys(surfaces),
|
|
1460
|
+
dispose: (id) => { delete surfaces[id]; },
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function collectRefsOf(e: Expr): string[] {
|
|
1465
|
+
const out: string[] = [];
|
|
1466
|
+
const walk = (x: unknown): void => {
|
|
1467
|
+
if (x === null || typeof x !== "object") return;
|
|
1468
|
+
if (Array.isArray(x)) {
|
|
1469
|
+
for (const v of x) walk(v);
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
const o = x as Record<string, unknown>;
|
|
1473
|
+
if (typeof o.ref === "string") out.push(o.ref);
|
|
1474
|
+
for (const v of Object.values(o)) {
|
|
1475
|
+
if (v !== null && typeof v === "object") walk(v);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
walk(e);
|
|
1479
|
+
return out;
|
|
1480
|
+
}
|