@elurjs/universal 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/README.md +228 -0
- package/docs/deuda/i18n-libreria-separada.md +50 -0
- package/docs/doc-data.json +2784 -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 +111 -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 +1470 -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 +216 -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 +373 -0
- package/src/sdui/profile.ts +72 -0
- package/src/sdui/seqStore.ts +89 -0
- package/src/sdui/sign.ts +155 -0
- package/src/sdui/worklets.ts +164 -0
- package/src/ssr/html-applicator.ts +515 -0
- package/src/ssr/render-page.ts +264 -0
- package/src/store/index.ts +28 -0
- package/src/style/textInherit.ts +29 -0
- package/src/style/theme.ts +178 -0
- package/src/testing/index.ts +276 -0
- package/src/transport/.gitkeep +0 -0
- package/src/transport/format.ts +477 -0
- package/src/transport/wireSchema.ts +189 -0
- package/src/web.ts +31 -0
- package/targets/android/app/build.gradle.kts +192 -0
- package/targets/android/app/proguard-rules-elur.pro +12 -0
- package/targets/android/app/proguard-rules.pro +3 -0
- package/targets/android/app/src/main/AndroidManifest.xml +81 -0
- package/targets/android/app/src/main/cpp/CMakeLists.txt +117 -0
- package/targets/android/app/src/main/cpp/dlEncoder.h +117 -0
- package/targets/android/app/src/main/cpp/dlEncoderJsi.cpp +315 -0
- package/targets/android/app/src/main/cpp/dlEncoderQjs.cpp +394 -0
- package/targets/android/app/src/main/cpp/dlOps.inc +145 -0
- package/targets/android/app/src/main/cpp/elurBridge.cpp +1350 -0
- package/targets/android/app/src/main/cpp/elurBridgeHermes.cpp +1294 -0
- package/targets/android/app/src/main/cpp/elurSkia.cpp +287 -0
- package/targets/android/app/src/main/cpp/elurSkiaTree.cpp +448 -0
- package/targets/android/app/src/main/cpp/elurUiWorklet.cpp +1233 -0
- package/targets/android/app/src/main/cpp/elurYoga.cpp +1060 -0
- package/targets/android/app/src/main/cpp/elurYoga.h +82 -0
- package/targets/android/app/src/main/cpp/hermes-libs/LICENSE +21 -0
- package/targets/android/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +276 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +97 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +502 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +107 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +145 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +193 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +211 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +40 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +14 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +27 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +141 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +270 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +64 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +1566 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +37 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +75 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +334 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +328 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +131 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +73 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +89 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +135 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +280 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +137 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +107 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +140 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +71 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +40 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +82 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +72 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +1279 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +313 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +38 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +77 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +127 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +138 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +24 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +20 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +44 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +123 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +29 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +24 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +23 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +30 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +113 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +242 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +52 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +295 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +25 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +642 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +29 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +41 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +12 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +8516 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +137 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +3945 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +119 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +124 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +66 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +456 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +26 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +1157 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +242 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +132 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +434 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +2266 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +59 -0
- package/targets/android/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +79 -0
- package/targets/android/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +1111 -0
- package/targets/android/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
- package/targets/android/app/src/main/java/com/elur/universal/BinaryCodec.kt +121 -0
- package/targets/android/app/src/main/java/com/elur/universal/DlDecoder.kt +260 -0
- package/targets/android/app/src/main/java/com/elur/universal/DlOpsDecode.kt +158 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +161 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBridge.kt +238 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +223 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCanvasView.kt +202 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +206 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +185 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurEditText.kt +17 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +190 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurHttpModule.kt +306 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurImageService.kt +348 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +84 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurListView.kt +954 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurManifest.kt +117 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurMetrics.kt +325 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +14 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +36 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurRenderer.kt +6112 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurRowYoga.kt +130 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurScrollView.kt +240 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurShellView.kt +117 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +162 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +968 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurStateModule.kt +69 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +34 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTckModule.kt +99 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +16 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurTrace.kt +24 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurUiModule.kt +48 -0
- package/targets/android/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +305 -0
- package/targets/android/app/src/main/java/com/elur/universal/JsBridge.kt +67 -0
- package/targets/android/app/src/main/java/com/elur/universal/JsThread.kt +189 -0
- package/targets/android/app/src/main/java/com/elur/universal/MainActivity.kt +844 -0
- package/targets/android/app/src/main/java/com/elur/universal/ModuleRegistry.kt +701 -0
- package/targets/android/app/src/main/java/com/elur/universal/YogaRowScope.kt +97 -0
- package/targets/android/app/src/main/res/values/ids.xml +10 -0
- package/targets/android/app/src/main/res/values/strings.xml +8 -0
- package/targets/android/app/src/main/res/values-es/strings.xml +5 -0
- package/targets/android/app/src/main/res/xml/network_security_config.xml +10 -0
- package/targets/android/build.gradle.kts +5 -0
- package/targets/android/gradle/libs.versions.toml +12 -0
- package/targets/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/targets/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/targets/android/gradle.properties +23 -0
- package/targets/android/gradlew +251 -0
- package/targets/android/gradlew.bat +94 -0
- package/targets/android/settings.gradle.kts +32 -0
- package/targets/web/.gitkeep +0 -0
- package/targets/web/index.html +13 -0
|
@@ -0,0 +1,1293 @@
|
|
|
1
|
+
#include "elur_skia_tree.h"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <cctype>
|
|
5
|
+
#include <cmath>
|
|
6
|
+
#include <cstdio>
|
|
7
|
+
#include <cstdlib>
|
|
8
|
+
|
|
9
|
+
#include "include/core/SkFontMetrics.h"
|
|
10
|
+
#include "include/core/SkPaint.h"
|
|
11
|
+
#include "include/core/SkTypeface.h"
|
|
12
|
+
#if ELUR_SKIA_TEXT
|
|
13
|
+
#include "modules/skparagraph/include/ParagraphBuilder.h"
|
|
14
|
+
#include "modules/skparagraph/include/ParagraphStyle.h"
|
|
15
|
+
#include "modules/skparagraph/include/TextStyle.h"
|
|
16
|
+
#include "modules/skunicode/include/SkUnicode_icu.h"
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace elur::skia {
|
|
20
|
+
#if ELUR_SKIA_TEXT
|
|
21
|
+
namespace tl = ::skia::textlayout;
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
// ── Colores ──────────────────────────────────────────────────────
|
|
25
|
+
// El wire trae cadenas CSS ("#rrggbb[aa]", "rgb()", "rgba()",
|
|
26
|
+
// nombres). El host GTK se las pasa a Pango/CSS; aquí se parsean a
|
|
27
|
+
// SkColor — mismo vocabulario de entrada.
|
|
28
|
+
static bool hexNibble(char c, uint8_t &v) {
|
|
29
|
+
if (c >= '0' && c <= '9') {
|
|
30
|
+
v = c - '0';
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (c >= 'a' && c <= 'f') {
|
|
34
|
+
v = c - 'a' + 10;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (c >= 'A' && c <= 'F') {
|
|
38
|
+
v = c - 'A' + 10;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static bool parseColor(const std::string &s, SkColor &out) {
|
|
45
|
+
if (s.empty())
|
|
46
|
+
return false;
|
|
47
|
+
if (s[0] == '#') {
|
|
48
|
+
std::string h = s.substr(1);
|
|
49
|
+
auto byte = [&](size_t i, uint8_t &b) {
|
|
50
|
+
uint8_t hi, lo;
|
|
51
|
+
if (!hexNibble(h[i], hi) || !hexNibble(h[i + 1], lo))
|
|
52
|
+
return false;
|
|
53
|
+
b = (hi << 4) | lo;
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
uint8_t r, g, b, a = 0xff;
|
|
57
|
+
if (h.size() == 3 || h.size() == 4) {
|
|
58
|
+
uint8_t rr, gg, bb, aa = 0xff;
|
|
59
|
+
if (!hexNibble(h[0], rr) || !hexNibble(h[1], gg) || !hexNibble(h[2], bb))
|
|
60
|
+
return false;
|
|
61
|
+
if (h.size() == 4 && !hexNibble(h[3], aa))
|
|
62
|
+
return false;
|
|
63
|
+
r = rr * 17;
|
|
64
|
+
g = gg * 17;
|
|
65
|
+
b = bb * 17;
|
|
66
|
+
a = aa * 17;
|
|
67
|
+
} else if (h.size() == 6 || h.size() == 8) {
|
|
68
|
+
if (!byte(0, r) || !byte(2, g) || !byte(4, b))
|
|
69
|
+
return false;
|
|
70
|
+
if (h.size() == 8 && !byte(6, a))
|
|
71
|
+
return false;
|
|
72
|
+
} else
|
|
73
|
+
return false;
|
|
74
|
+
out = SkColorSetARGB(a, r, g, b);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (s.rfind("rgb", 0) == 0) {
|
|
78
|
+
// rgb(r,g,b) / rgba(r,g,b,a) — floats separados por coma (el wire
|
|
79
|
+
// emite punto decimal: locale C en todos los hosts).
|
|
80
|
+
auto open = s.find('(');
|
|
81
|
+
if (open == std::string::npos)
|
|
82
|
+
return false;
|
|
83
|
+
std::string body = s.substr(open + 1, s.rfind(')') - open - 1);
|
|
84
|
+
float ch[4] = {0, 0, 0, 1};
|
|
85
|
+
int i = 0;
|
|
86
|
+
char *p = body.data(), *end = nullptr;
|
|
87
|
+
while (i < 4 && *p) {
|
|
88
|
+
ch[i++] = strtof(p, &end);
|
|
89
|
+
if (end == p)
|
|
90
|
+
break;
|
|
91
|
+
p = end;
|
|
92
|
+
while (*p == ' ' || *p == ',')
|
|
93
|
+
p++;
|
|
94
|
+
}
|
|
95
|
+
if (i < 3)
|
|
96
|
+
return false;
|
|
97
|
+
auto clamp255 = [](float v) {
|
|
98
|
+
return (uint8_t)std::lround(std::fmax(0.f, std::fmin(255.f, v)));
|
|
99
|
+
};
|
|
100
|
+
out = SkColorSetARGB(
|
|
101
|
+
(uint8_t)std::lround(std::fmax(0.f, std::fmin(1.f, ch[3])) * 255.f),
|
|
102
|
+
clamp255(ch[0]), clamp255(ch[1]), clamp255(ch[2]));
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// Subset de nombres CSS — la tabla completa la resuelve CSS en el
|
|
106
|
+
// host views; aquí bastan los literales del vocabulario Elur.
|
|
107
|
+
static const std::pair<const char *, SkColor> NAMED[] = {
|
|
108
|
+
{"transparent", SK_ColorTRANSPARENT},
|
|
109
|
+
{"black", SK_ColorBLACK},
|
|
110
|
+
{"white", SK_ColorWHITE},
|
|
111
|
+
{"red", 0xffff0000},
|
|
112
|
+
{"green", 0xff008000},
|
|
113
|
+
{"blue", 0xff0000ff},
|
|
114
|
+
{"yellow", 0xffffff00},
|
|
115
|
+
{"orange", 0xffffa500},
|
|
116
|
+
{"purple", 0xff800080},
|
|
117
|
+
{"pink", 0xffffc0cb},
|
|
118
|
+
{"brown", 0xffa52a2a},
|
|
119
|
+
{"gray", 0xff808080},
|
|
120
|
+
{"grey", 0xff808080},
|
|
121
|
+
{"lightgray", 0xffd3d3d3},
|
|
122
|
+
{"lightgrey", 0xffd3d3d3},
|
|
123
|
+
{"darkgray", 0xffa9a9a9},
|
|
124
|
+
{"darkgrey", 0xffa9a9a9},
|
|
125
|
+
{"cyan", 0xff00ffff},
|
|
126
|
+
{"magenta", 0xffff00ff},
|
|
127
|
+
};
|
|
128
|
+
for (auto &kv : NAMED)
|
|
129
|
+
if (s == kv.first) {
|
|
130
|
+
out = kv.second;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static bool visualNum(const SkiaNode &n, const char *k, double &out) {
|
|
137
|
+
auto it = n.visual.find(k);
|
|
138
|
+
if (it == n.visual.end())
|
|
139
|
+
return false;
|
|
140
|
+
out = strtod(it->second.c_str(), nullptr);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Tree ─────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
void SkiaTree::setFontMgr(sk_sp<SkFontMgr> fm) { fontMgr_ = std::move(fm); }
|
|
147
|
+
|
|
148
|
+
void SkiaTree::createNode(int id, const std::string &type) {
|
|
149
|
+
SkiaNode n;
|
|
150
|
+
n.id = id;
|
|
151
|
+
n.type = type;
|
|
152
|
+
if (type == "scroll" || type == "scroll-view")
|
|
153
|
+
n.overflowClip = true; // el contenido nunca dibuja fuera del viewport
|
|
154
|
+
nodes[id] = std::move(n);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
void SkiaTree::updateText(int id, const std::string &value) {
|
|
158
|
+
auto it = nodes.find(id);
|
|
159
|
+
if (it == nodes.end())
|
|
160
|
+
return;
|
|
161
|
+
SkiaNode &n = it->second;
|
|
162
|
+
if (n.absorbedBy) {
|
|
163
|
+
auto pi = nodes.find(n.absorbedBy);
|
|
164
|
+
if (pi != nodes.end())
|
|
165
|
+
pi->second.absorbedText = value;
|
|
166
|
+
}
|
|
167
|
+
n.text = value;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// erase-if-present: find() devuelve end() cuando el id no está —
|
|
171
|
+
// erase(end()) es UB (corrompe _M_finish en libstdc++ ≥13).
|
|
172
|
+
static void eraseId(std::vector<int> &v, int id) {
|
|
173
|
+
auto it = std::find(v.begin(), v.end(), id);
|
|
174
|
+
if (it != v.end())
|
|
175
|
+
v.erase(it);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static bool isTransformKey(const std::string &k) {
|
|
179
|
+
return k == "translateX" || k == "translateY" || k == "scaleX" ||
|
|
180
|
+
k == "scaleY" || k == "rotate";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bool SkiaTree::setStyle(int id, const std::string &key, bool isNum, double num,
|
|
184
|
+
const std::string &str) {
|
|
185
|
+
auto it = nodes.find(id);
|
|
186
|
+
if (it == nodes.end())
|
|
187
|
+
return true;
|
|
188
|
+
SkiaNode &n = it->second;
|
|
189
|
+
|
|
190
|
+
// Texto absorbido por un button: su tipografía y color pintan en el
|
|
191
|
+
// label del padre (paridad forwardTextStyle del carril views —
|
|
192
|
+
// BUTTON_TEXT_KEYS). El resto de keys quedan en el hijo.
|
|
193
|
+
if (n.absorbedBy) {
|
|
194
|
+
static const char *TEXT_KEYS[] = {
|
|
195
|
+
"color", "fontSize", "fontWeight", "fontFamily",
|
|
196
|
+
"fontStyle", "letterSpacing", "textDecoration", "lineHeight",
|
|
197
|
+
};
|
|
198
|
+
for (const char *k : TEXT_KEYS)
|
|
199
|
+
if (key == k)
|
|
200
|
+
return setStyle(n.absorbedBy, key, isNum, num, str);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (key.rfind("padding", 0) == 0) {
|
|
204
|
+
if (isNum)
|
|
205
|
+
n.padVals[key] = (float)num;
|
|
206
|
+
else
|
|
207
|
+
n.padVals.erase(key);
|
|
208
|
+
auto pv = [&](const char *k) -> float {
|
|
209
|
+
auto i = n.padVals.find(k);
|
|
210
|
+
return i == n.padVals.end() ? NAN : i->second;
|
|
211
|
+
};
|
|
212
|
+
auto orf = [](float a, float b) { return a == a ? a : b; };
|
|
213
|
+
float all = orf(pv("padding"), 0);
|
|
214
|
+
float inl = orf(pv("paddingInline"), all);
|
|
215
|
+
float blk = orf(pv("paddingBlock"), all);
|
|
216
|
+
float start = orf(pv("paddingInlineStart"), inl);
|
|
217
|
+
float end = orf(pv("paddingInlineEnd"), inl);
|
|
218
|
+
n.padL = orf(pv("paddingLeft"), rtl_ ? end : start);
|
|
219
|
+
n.padR = orf(pv("paddingRight"), rtl_ ? start : end);
|
|
220
|
+
n.padT = orf(pv("paddingTop"), orf(pv("paddingBlockStart"), blk));
|
|
221
|
+
n.padB = orf(pv("paddingBottom"), orf(pv("paddingBlockEnd"), blk));
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (isTransformKey(key)) {
|
|
226
|
+
if (isNum)
|
|
227
|
+
n.transform[key] = num;
|
|
228
|
+
else
|
|
229
|
+
n.transform.erase(key);
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (key == "opacity") {
|
|
234
|
+
n.opacity =
|
|
235
|
+
isNum ? num : (str.empty() ? 1.0 : strtod(str.c_str(), nullptr));
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
if (key == "display") {
|
|
239
|
+
n.displayNone = (!isNum && str == "none");
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
if (key == "textAlign") {
|
|
243
|
+
n.textAlign = str;
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (key == "lineHeight" && isNum) {
|
|
247
|
+
n.lineHeight = (float)num;
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
if (key == "fontSize" && isNum) {
|
|
251
|
+
n.fontSizePx = (float)num;
|
|
252
|
+
// cae además a visual — el paintText lo lee de fontSizePx, pero
|
|
253
|
+
// conservarlo en visual mantiene la misma tabla de claves.
|
|
254
|
+
}
|
|
255
|
+
if (key == "overflow") {
|
|
256
|
+
if (str == "hidden" || str == "scroll" || str == "auto")
|
|
257
|
+
n.overflowClip = true;
|
|
258
|
+
else if (str == "visible")
|
|
259
|
+
n.overflowClip = (n.type == "scroll" || n.type == "scroll-view");
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static const char *VISUAL[] = {
|
|
264
|
+
"backgroundColor", "color", "borderRadius", "borderColor",
|
|
265
|
+
"borderStyle", "fontSize", "fontWeight", "fontFamily",
|
|
266
|
+
"fontStyle", "letterSpacing", "textDecoration",
|
|
267
|
+
};
|
|
268
|
+
bool isVisual = false;
|
|
269
|
+
for (const char *k : VISUAL)
|
|
270
|
+
if (key == k)
|
|
271
|
+
isVisual = true;
|
|
272
|
+
if (key.rfind("border", 0) == 0 && key.size() > 6 &&
|
|
273
|
+
(key.compare(key.size() - 5, 5, "Color") == 0 ||
|
|
274
|
+
key.compare(key.size() - 5, 5, "Width") == 0 ||
|
|
275
|
+
key.compare(key.size() - 5, 5, "Style") == 0))
|
|
276
|
+
isVisual = true;
|
|
277
|
+
if (!isVisual)
|
|
278
|
+
return false;
|
|
279
|
+
|
|
280
|
+
if (isNum) {
|
|
281
|
+
char b[40];
|
|
282
|
+
snprintf(b, sizeof(b), "%.10g", num);
|
|
283
|
+
n.visual[key] = b;
|
|
284
|
+
} else if (!str.empty()) {
|
|
285
|
+
n.visual[key] = str;
|
|
286
|
+
} else {
|
|
287
|
+
n.visual.erase(key);
|
|
288
|
+
}
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
void SkiaTree::setProp(int id, const std::string &key,
|
|
293
|
+
const std::string &flat) {
|
|
294
|
+
auto it = nodes.find(id);
|
|
295
|
+
if (it == nodes.end())
|
|
296
|
+
return;
|
|
297
|
+
if (flat.empty())
|
|
298
|
+
it->second.props.erase(key);
|
|
299
|
+
else
|
|
300
|
+
it->second.props[key] = flat;
|
|
301
|
+
// scrollTop/scrollLeft programáticos — paridad adjustment del host
|
|
302
|
+
// views (suppressSignal: el setter no re-emite `scroll`).
|
|
303
|
+
if (key == "scrollTop" && !flat.empty())
|
|
304
|
+
setScroll(id, it->second.scrollX, strtof(flat.c_str(), nullptr));
|
|
305
|
+
else if (key == "scrollLeft" && !flat.empty())
|
|
306
|
+
setScroll(id, strtof(flat.c_str(), nullptr), it->second.scrollY);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
void SkiaTree::insertChild(int parentId, int childId, int index) {
|
|
310
|
+
auto ci = nodes.find(childId);
|
|
311
|
+
if (ci == nodes.end())
|
|
312
|
+
return;
|
|
313
|
+
SkiaNode &child = ci->second;
|
|
314
|
+
auto pi = nodes.find(parentId);
|
|
315
|
+
if (pi == nodes.end()) {
|
|
316
|
+
// Sin padre en el mapa → raíz (surfaceOf del host cae al root).
|
|
317
|
+
child.parent = 0;
|
|
318
|
+
eraseId(roots, childId);
|
|
319
|
+
roots.insert(roots.begin() +
|
|
320
|
+
(index <= (int)roots.size() ? index : (int)roots.size()),
|
|
321
|
+
childId);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
SkiaNode &parent = pi->second;
|
|
325
|
+
child.parent = parentId;
|
|
326
|
+
// paridad yoga mirror: button absorbe todo hijo; un reparent fuera
|
|
327
|
+
// del button debe limpiar la absorción previa.
|
|
328
|
+
child.absorbedBy = parent.type == "button" ? parentId : 0;
|
|
329
|
+
auto &sib = parent.children;
|
|
330
|
+
eraseId(sib, childId);
|
|
331
|
+
sib.insert(sib.begin() + (index <= (int)sib.size() ? index : (int)sib.size()),
|
|
332
|
+
childId);
|
|
333
|
+
if (child.absorbedBy) {
|
|
334
|
+
parent.absorbedText = child.text;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
void SkiaTree::removeChild(int parentId, int childId) {
|
|
339
|
+
auto ci = nodes.find(childId);
|
|
340
|
+
if (ci != nodes.end()) {
|
|
341
|
+
ci->second.parent = 0;
|
|
342
|
+
ci->second.absorbedBy = 0;
|
|
343
|
+
}
|
|
344
|
+
auto pi = nodes.find(parentId);
|
|
345
|
+
if (pi != nodes.end()) {
|
|
346
|
+
auto &sib = pi->second.children;
|
|
347
|
+
eraseId(sib, childId);
|
|
348
|
+
if (pi->second.type == "button")
|
|
349
|
+
pi->second.absorbedText.clear();
|
|
350
|
+
} else {
|
|
351
|
+
eraseId(roots, childId);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
void SkiaTree::moveChild(int parentId, int childId, int index) {
|
|
356
|
+
removeChild(parentId, childId);
|
|
357
|
+
insertChild(parentId, childId, index);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
void SkiaTree::deleteNode(int id) {
|
|
361
|
+
auto it = nodes.find(id);
|
|
362
|
+
if (it == nodes.end())
|
|
363
|
+
return;
|
|
364
|
+
int parent = it->second.parent;
|
|
365
|
+
if (parent) {
|
|
366
|
+
auto pi = nodes.find(parent);
|
|
367
|
+
if (pi != nodes.end()) {
|
|
368
|
+
auto &sib = pi->second.children;
|
|
369
|
+
eraseId(sib, id);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
// Saca el sub-árbol — el host GTK destruye widgets; aquí basta el
|
|
373
|
+
// mapa (sin overlays: exit-anim es fase posterior, declarado).
|
|
374
|
+
std::vector<int> stack(it->second.children.begin(),
|
|
375
|
+
it->second.children.end());
|
|
376
|
+
while (!stack.empty()) {
|
|
377
|
+
int c = stack.back();
|
|
378
|
+
stack.pop_back();
|
|
379
|
+
auto cn = nodes.find(c);
|
|
380
|
+
if (cn != nodes.end()) {
|
|
381
|
+
stack.insert(stack.end(), cn->second.children.begin(),
|
|
382
|
+
cn->second.children.end());
|
|
383
|
+
nodes.erase(cn);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
eraseId(roots, id);
|
|
387
|
+
nodes.erase(it);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
void SkiaTree::attachEvent(int id, const std::string &event,
|
|
391
|
+
const std::string &handler, bool continuous,
|
|
392
|
+
const std::string &payload) {
|
|
393
|
+
auto it = nodes.find(id);
|
|
394
|
+
if (it == nodes.end())
|
|
395
|
+
return;
|
|
396
|
+
it->second.events[event] = SkiaBind{handler, continuous, payload};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
void SkiaTree::detachEvent(int id, const std::string &event) {
|
|
400
|
+
auto it = nodes.find(id);
|
|
401
|
+
if (it != nodes.end())
|
|
402
|
+
it->second.events.erase(event);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
void SkiaTree::resetNode(int id) {
|
|
406
|
+
// ADR-0057: reset de estado efímero al rebind del pool — scroll a
|
|
407
|
+
// origen como hace el host views (gtk_adjustment_set_value 0).
|
|
408
|
+
auto it = nodes.find(id);
|
|
409
|
+
if (it == nodes.end())
|
|
410
|
+
return;
|
|
411
|
+
SkiaNode &n = it->second;
|
|
412
|
+
if (n.type == "scroll" || n.type == "scroll-view") {
|
|
413
|
+
n.scrollX = 0;
|
|
414
|
+
n.scrollY = 0;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
void SkiaTree::setRect(int id, float x, float y, float w, float h) {
|
|
419
|
+
auto it = nodes.find(id);
|
|
420
|
+
if (it == nodes.end())
|
|
421
|
+
return;
|
|
422
|
+
it->second.rx = x;
|
|
423
|
+
it->second.ry = y;
|
|
424
|
+
it->second.rw = w;
|
|
425
|
+
it->second.rh = h;
|
|
426
|
+
it->second.hasRect = true;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ── Fuente ───────────────────────────────────────────────────────
|
|
430
|
+
|
|
431
|
+
SkFont SkiaTree::fontFor(const SkiaNode &n) const {
|
|
432
|
+
float fs = n.fontSizePx > 0 ? n.fontSizePx : 14.f; // base GTK ~14
|
|
433
|
+
fs *= (float)fontScale_;
|
|
434
|
+
int weight = 400;
|
|
435
|
+
if (auto it = n.visual.find("fontWeight"); it != n.visual.end()) {
|
|
436
|
+
const std::string &w = it->second;
|
|
437
|
+
weight = w == "bold" ? 700
|
|
438
|
+
: w == "normal" ? 400
|
|
439
|
+
: (int)strtol(w.c_str(), nullptr, 10);
|
|
440
|
+
if (weight <= 0)
|
|
441
|
+
weight = 400;
|
|
442
|
+
}
|
|
443
|
+
bool italic = false;
|
|
444
|
+
if (auto it = n.visual.find("fontStyle"); it != n.visual.end())
|
|
445
|
+
italic = it->second == "italic";
|
|
446
|
+
SkFontStyle style(weight, SkFontStyle::kNormal_Width,
|
|
447
|
+
italic ? SkFontStyle::kItalic_Slant
|
|
448
|
+
: SkFontStyle::kUpright_Slant);
|
|
449
|
+
sk_sp<SkTypeface> tf;
|
|
450
|
+
if (fontMgr_) {
|
|
451
|
+
std::string fam;
|
|
452
|
+
if (auto it = n.visual.find("fontFamily"); it != n.visual.end()) {
|
|
453
|
+
// Primera familia del stack CSS (la resolución de alias de
|
|
454
|
+
// bundle ya quedó inyectada en fontconfig — ADR-0135).
|
|
455
|
+
fam = it->second.substr(0, it->second.find(','));
|
|
456
|
+
while (!fam.empty() &&
|
|
457
|
+
(fam.front() == ' ' || fam.front() == '\'' || fam.front() == '"'))
|
|
458
|
+
fam.erase(fam.begin());
|
|
459
|
+
while (!fam.empty() &&
|
|
460
|
+
(fam.back() == ' ' || fam.back() == '\'' || fam.back() == '"'))
|
|
461
|
+
fam.pop_back();
|
|
462
|
+
}
|
|
463
|
+
tf = fontMgr_->legacyMakeTypeface(fam.empty() ? nullptr : fam.c_str(),
|
|
464
|
+
style);
|
|
465
|
+
if (!tf)
|
|
466
|
+
tf = fontMgr_->legacyMakeTypeface(nullptr, style);
|
|
467
|
+
}
|
|
468
|
+
// Sin fontMgr inyectado no hay fuente — drawString con typeface
|
|
469
|
+
// nulo no pinta (cap ausente → el glue reporta una vez).
|
|
470
|
+
SkFont f(std::move(tf), fs);
|
|
471
|
+
f.setEdging(SkFont::Edging::kAntiAlias);
|
|
472
|
+
f.setSubpixel(true);
|
|
473
|
+
return f;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
float SkiaTree::lineHeightPx(const SkiaNode &n, const SkFont &f) const {
|
|
477
|
+
if (n.lineHeight > 0 && n.fontSizePx > 0)
|
|
478
|
+
return n.lineHeight * n.fontSizePx * (float)fontScale_;
|
|
479
|
+
SkFontMetrics fm;
|
|
480
|
+
f.getMetrics(&fm);
|
|
481
|
+
return fm.fDescent - fm.fAscent + fm.fLeading;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#if ELUR_SKIA_TEXT
|
|
485
|
+
// Fase 3 — el bloque de texto completo pasa por SkParagraph: shaping
|
|
486
|
+
// harfbuzz (kerning/ligaduras), wrap UAX#14 + bidi reales via
|
|
487
|
+
// SkUnicodes::ICU (el provider Bidi tiene los flags UTF-8 sin
|
|
488
|
+
// implementar → abort en el shaper), align/dirección/maxLines del
|
|
489
|
+
// ParagraphStyle. La font resolution es la misma fontconfig que
|
|
490
|
+
// fontFor — la primera familia del stack CSS.
|
|
491
|
+
std::unique_ptr<tl::Paragraph> SkiaTree::paragraphFor(const SkiaNode &n,
|
|
492
|
+
const std::string &txt,
|
|
493
|
+
float layoutW,
|
|
494
|
+
double alpha) {
|
|
495
|
+
if (!fontCol_) {
|
|
496
|
+
fontCol_ = sk_make_sp<tl::FontCollection>();
|
|
497
|
+
if (fontMgr_)
|
|
498
|
+
fontCol_->setDefaultFontManager(fontMgr_);
|
|
499
|
+
fontCol_->enableFontFallback();
|
|
500
|
+
}
|
|
501
|
+
tl::ParagraphStyle ps;
|
|
502
|
+
auto di = n.props.find("dir");
|
|
503
|
+
ps.setTextDirection(di != n.props.end() && di->second == "rtl"
|
|
504
|
+
? tl::TextDirection::kRtl
|
|
505
|
+
: tl::TextDirection::kLtr);
|
|
506
|
+
// textAlign explícito gana; sin él kStart — el lado lo resuelve dir
|
|
507
|
+
// (paridad views: justify sin textAlign explícito).
|
|
508
|
+
const std::string &al = n.textAlign;
|
|
509
|
+
ps.setTextAlign(al == "center" ? tl::TextAlign::kCenter
|
|
510
|
+
: al == "right" ? tl::TextAlign::kRight
|
|
511
|
+
: al == "end" ? tl::TextAlign::kEnd
|
|
512
|
+
: al == "left" ? tl::TextAlign::kLeft
|
|
513
|
+
: al == "justify" ? tl::TextAlign::kJustify
|
|
514
|
+
: tl::TextAlign::kStart);
|
|
515
|
+
int maxLines = 0;
|
|
516
|
+
if (auto it = n.props.find("numberOfLines"); it != n.props.end())
|
|
517
|
+
maxLines = atoi(it->second.c_str());
|
|
518
|
+
if (maxLines > 0) {
|
|
519
|
+
ps.setMaxLines((size_t)maxLines);
|
|
520
|
+
ps.setEllipsis(SkString("\xe2\x80\xa6")); // U+2026 — paridad "…" de Pango
|
|
521
|
+
}
|
|
522
|
+
tl::TextStyle ts;
|
|
523
|
+
float fs = n.fontSizePx > 0 ? n.fontSizePx : 14.f;
|
|
524
|
+
ts.setFontSize(fs * (float)fontScale_);
|
|
525
|
+
int weight = 400;
|
|
526
|
+
if (auto it = n.visual.find("fontWeight"); it != n.visual.end()) {
|
|
527
|
+
const std::string &w = it->second;
|
|
528
|
+
weight = w == "bold" ? 700
|
|
529
|
+
: w == "normal" ? 400
|
|
530
|
+
: (int)strtol(w.c_str(), nullptr, 10);
|
|
531
|
+
if (weight <= 0)
|
|
532
|
+
weight = 400;
|
|
533
|
+
}
|
|
534
|
+
bool italic = false;
|
|
535
|
+
if (auto it = n.visual.find("fontStyle"); it != n.visual.end())
|
|
536
|
+
italic = it->second == "italic";
|
|
537
|
+
ts.setFontStyle(SkFontStyle(weight, SkFontStyle::kNormal_Width,
|
|
538
|
+
italic ? SkFontStyle::kItalic_Slant
|
|
539
|
+
: SkFontStyle::kUpright_Slant));
|
|
540
|
+
if (auto it = n.visual.find("fontFamily"); it != n.visual.end()) {
|
|
541
|
+
std::string fam = it->second.substr(0, it->second.find(','));
|
|
542
|
+
while (!fam.empty() &&
|
|
543
|
+
(fam.front() == ' ' || fam.front() == '\'' || fam.front() == '"'))
|
|
544
|
+
fam.erase(fam.begin());
|
|
545
|
+
while (!fam.empty() &&
|
|
546
|
+
(fam.back() == ' ' || fam.back() == '\'' || fam.back() == '"'))
|
|
547
|
+
fam.pop_back();
|
|
548
|
+
if (!fam.empty())
|
|
549
|
+
ts.setFontFamilies({SkString(fam.c_str())});
|
|
550
|
+
}
|
|
551
|
+
SkColor col = 0xff111111; // color base del host (#111, BASE_CSS)
|
|
552
|
+
if (auto it = n.visual.find("color"); it != n.visual.end())
|
|
553
|
+
parseColor(it->second, col);
|
|
554
|
+
ts.setColor(SkColorSetA(col, SkColorGetA(col) * alpha));
|
|
555
|
+
int deco = tl::TextDecoration::kNoDecoration;
|
|
556
|
+
if (auto it = n.visual.find("textDecoration"); it != n.visual.end()) {
|
|
557
|
+
if (it->second.find("underline") != std::string::npos)
|
|
558
|
+
deco |= tl::TextDecoration::kUnderline;
|
|
559
|
+
if (it->second.find("line-through") != std::string::npos)
|
|
560
|
+
deco |= tl::TextDecoration::kLineThrough;
|
|
561
|
+
}
|
|
562
|
+
ts.setDecoration((tl::TextDecoration)deco);
|
|
563
|
+
if (n.lineHeight > 0) {
|
|
564
|
+
ts.setHeight(n.lineHeight); // multiplicador unitless ADR-0140
|
|
565
|
+
ts.setHeightOverride(true);
|
|
566
|
+
}
|
|
567
|
+
ps.setTextStyle(ts);
|
|
568
|
+
static sk_sp<SkUnicode> uni = SkUnicodes::ICU::Make();
|
|
569
|
+
auto b = tl::ParagraphBuilder::make(ps, fontCol_, uni);
|
|
570
|
+
b->addText(txt.c_str(), txt.size());
|
|
571
|
+
auto p = b->Build();
|
|
572
|
+
p->layout(layoutW > 0 ? layoutW : SK_ScalarInfinity);
|
|
573
|
+
return p;
|
|
574
|
+
}
|
|
575
|
+
#endif // ELUR_SKIA_TEXT
|
|
576
|
+
|
|
577
|
+
std::vector<std::string>
|
|
578
|
+
SkiaTree::wrapLines(const SkiaNode &n, const std::string &txt, float maxW) {
|
|
579
|
+
// Wrap por palabras (paridad PANGO_WRAP_WORD_CHAR). maxW ≤ 0 = sin
|
|
580
|
+
// wrap (una línea por \n). numberOfLines corta con "…" en la última.
|
|
581
|
+
SkFont f = fontFor(n);
|
|
582
|
+
auto width = [&](const std::string &s) {
|
|
583
|
+
return f.measureText(s.data(), s.size(), SkTextEncoding::kUTF8);
|
|
584
|
+
};
|
|
585
|
+
std::vector<std::string> lines;
|
|
586
|
+
size_t start = 0;
|
|
587
|
+
while (start <= txt.size()) {
|
|
588
|
+
size_t nl = txt.find('\n', start);
|
|
589
|
+
std::string seg =
|
|
590
|
+
txt.substr(start, nl == std::string::npos ? nl : nl - start);
|
|
591
|
+
start = nl == std::string::npos ? txt.size() + 1 : nl + 1;
|
|
592
|
+
if (maxW <= 0 || width(seg) <= maxW) {
|
|
593
|
+
lines.push_back(std::move(seg));
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
// Greedy por espacios; una palabra que no cabe sola se corta por
|
|
597
|
+
// caracteres (word-char, paridad Pango).
|
|
598
|
+
std::string cur;
|
|
599
|
+
size_t i = 0;
|
|
600
|
+
while (i <= seg.size()) {
|
|
601
|
+
size_t sp = seg.find(' ', i);
|
|
602
|
+
std::string word = seg.substr(i, sp == std::string::npos ? sp : sp - i);
|
|
603
|
+
std::string cand = cur.empty() ? word : cur + " " + word;
|
|
604
|
+
if (width(cand) <= maxW) {
|
|
605
|
+
cur = std::move(cand);
|
|
606
|
+
} else {
|
|
607
|
+
if (!cur.empty())
|
|
608
|
+
lines.push_back(cur);
|
|
609
|
+
cur.clear();
|
|
610
|
+
while (!word.empty() && width(word) > maxW) {
|
|
611
|
+
size_t cut = word.size();
|
|
612
|
+
while (cut > 1 && width(word.substr(0, cut)) > maxW)
|
|
613
|
+
cut--;
|
|
614
|
+
lines.push_back(word.substr(0, cut));
|
|
615
|
+
word = word.substr(cut);
|
|
616
|
+
}
|
|
617
|
+
cur = word;
|
|
618
|
+
}
|
|
619
|
+
if (sp == std::string::npos)
|
|
620
|
+
break;
|
|
621
|
+
i = sp + 1;
|
|
622
|
+
}
|
|
623
|
+
if (!cur.empty())
|
|
624
|
+
lines.push_back(cur);
|
|
625
|
+
}
|
|
626
|
+
int maxLines = 0;
|
|
627
|
+
if (auto it = n.props.find("numberOfLines"); it != n.props.end())
|
|
628
|
+
maxLines = atoi(it->second.c_str());
|
|
629
|
+
if (maxLines > 0 && (int)lines.size() > maxLines) {
|
|
630
|
+
lines.resize(maxLines);
|
|
631
|
+
std::string &last = lines.back();
|
|
632
|
+
while (last.size() > 1 && width(last + "…") > maxW)
|
|
633
|
+
last.pop_back();
|
|
634
|
+
last += "…";
|
|
635
|
+
}
|
|
636
|
+
return lines;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// ── Medida (hook del espejo Yoga) ────────────────────────────────
|
|
640
|
+
|
|
641
|
+
bool SkiaTree::isMeasuredLeaf(int id) const {
|
|
642
|
+
auto it = nodes.find(id);
|
|
643
|
+
if (it == nodes.end())
|
|
644
|
+
return false;
|
|
645
|
+
const std::string &t = it->second.type;
|
|
646
|
+
// Mismo isLeafType del espejo Yoga + button absorbente. image/
|
|
647
|
+
// switch/slider miden su caja natural (fase 0: sin intrínseco).
|
|
648
|
+
return t == "text" || t == "text-input" || t == "button" || t == "image" ||
|
|
649
|
+
t == "switch" || t == "slider";
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
void SkiaTree::measure(int id, float w, int wMode, float h, int hMode,
|
|
653
|
+
float &ow, float &oh) {
|
|
654
|
+
ow = oh = 0;
|
|
655
|
+
auto it = nodes.find(id);
|
|
656
|
+
if (it == nodes.end())
|
|
657
|
+
return;
|
|
658
|
+
SkiaNode &n = it->second;
|
|
659
|
+
if (!isMeasuredLeaf(id)) {
|
|
660
|
+
ow = (wMode == 1) ? w : 0;
|
|
661
|
+
oh = (hMode == 1) ? h : 0;
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
// Controles sin texto: intrínsecos del host real (setIntrinsics) +
|
|
665
|
+
// padding — la caja la manda el layout si viene fija.
|
|
666
|
+
if (n.type == "switch") {
|
|
667
|
+
ow = (wMode == 1) ? w : swW_ + n.padL + n.padR;
|
|
668
|
+
oh = (hMode == 1) ? h : swH_ + n.padT + n.padB;
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
if (n.type == "slider") {
|
|
672
|
+
ow = (wMode == 1) ? w : slW_ + n.padL + n.padR;
|
|
673
|
+
oh = (hMode == 1) ? h : slH_ + n.padT + n.padB;
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (n.type == "image") {
|
|
677
|
+
// Natural de la imagen si ya se decodificó (paridad GtkPicture);
|
|
678
|
+
// sin imagen la caja la da el layout/estilo.
|
|
679
|
+
float iw = n.image ? (float)n.image->width() : 0;
|
|
680
|
+
float ih = n.image ? (float)n.image->height() : 0;
|
|
681
|
+
ow = (wMode == 1) ? w : (iw ? iw : 0) + n.padL + n.padR;
|
|
682
|
+
oh = (hMode == 1) ? h : (ih ? ih : 0) + n.padT + n.padB;
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
std::string txt = n.type == "button" ? n.absorbedText : n.text;
|
|
686
|
+
if (n.type == "text-input") {
|
|
687
|
+
if (txt.empty())
|
|
688
|
+
if (auto p = n.props.find("value"); p != n.props.end())
|
|
689
|
+
txt = p->second;
|
|
690
|
+
if (txt.empty()) {
|
|
691
|
+
if (auto p = n.props.find("placeholder"); p != n.props.end())
|
|
692
|
+
txt = p->second;
|
|
693
|
+
}
|
|
694
|
+
if (txt.empty())
|
|
695
|
+
txt = " "; // caja de una línea — paridad GtkEntry
|
|
696
|
+
}
|
|
697
|
+
if (n.type == "text" && txt.empty()) {
|
|
698
|
+
ow = oh = 0; // sin line-box — ADR-0154
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
float availW = (wMode == 0) ? -1.f : w - n.padL - n.padR;
|
|
702
|
+
#if ELUR_SKIA_TEXT
|
|
703
|
+
auto para = paragraphFor(n, txt, availW);
|
|
704
|
+
float fh = para->getHeight() + n.padT + n.padB;
|
|
705
|
+
ow = (wMode == 1) ? w : para->getLongestLine() + n.padL + n.padR;
|
|
706
|
+
#else
|
|
707
|
+
std::vector<std::string> lines = wrapLines(n, txt, availW);
|
|
708
|
+
SkFont f = fontFor(n);
|
|
709
|
+
float lw = 0;
|
|
710
|
+
for (auto &l : lines) {
|
|
711
|
+
float x = f.measureText(l.data(), l.size(), SkTextEncoding::kUTF8);
|
|
712
|
+
if (x > lw)
|
|
713
|
+
lw = x;
|
|
714
|
+
}
|
|
715
|
+
float lh = lineHeightPx(n, f);
|
|
716
|
+
float fh = lines.size() * lh;
|
|
717
|
+
ow = (wMode == 1) ? w : lw + n.padL + n.padR;
|
|
718
|
+
#endif
|
|
719
|
+
if (wMode == 2 && ow > w)
|
|
720
|
+
ow = w;
|
|
721
|
+
#if !ELUR_SKIA_TEXT
|
|
722
|
+
fh += n.padT + n.padB;
|
|
723
|
+
#endif
|
|
724
|
+
oh = (hMode == 1) ? h : (hMode == 2 && fh > h) ? h : fh;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
float SkiaTree::baseline(int id, float w, float h) {
|
|
728
|
+
(void)w;
|
|
729
|
+
auto it = nodes.find(id);
|
|
730
|
+
if (it == nodes.end())
|
|
731
|
+
return h;
|
|
732
|
+
SkiaNode &n = it->second;
|
|
733
|
+
if (!isMeasuredLeaf(id))
|
|
734
|
+
return h;
|
|
735
|
+
#if ELUR_SKIA_TEXT
|
|
736
|
+
auto para = paragraphFor(n, n.text, n.rw - n.padL - n.padR);
|
|
737
|
+
float block = para->getHeight();
|
|
738
|
+
float top = n.padT + (h - n.padT - n.padB - block) / 2;
|
|
739
|
+
return top + para->getAlphabeticBaseline();
|
|
740
|
+
#else
|
|
741
|
+
SkFont f = fontFor(n);
|
|
742
|
+
SkFontMetrics fm;
|
|
743
|
+
f.getMetrics(&fm);
|
|
744
|
+
float lh = lineHeightPx(n, f);
|
|
745
|
+
std::vector<std::string> lines = wrapLines(n, n.text, n.rw - n.padL - n.padR);
|
|
746
|
+
float block = lines.size() * lh;
|
|
747
|
+
float top = n.padT + (h - n.padT - n.padB - block) / 2;
|
|
748
|
+
return top + (lh - (fm.fDescent - fm.fAscent)) / 2 - fm.fAscent;
|
|
749
|
+
#endif
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// ── Paint ────────────────────────────────────────────────────────
|
|
753
|
+
|
|
754
|
+
void SkiaTree::paint(SkCanvas &canvas) {
|
|
755
|
+
for (int id : roots) {
|
|
756
|
+
auto it = nodes.find(id);
|
|
757
|
+
if (it != nodes.end())
|
|
758
|
+
paintNode(canvas, it->second, 0, 0, 1.0);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
void SkiaTree::paintNode(SkCanvas &c, SkiaNode &n, float absX, float absY,
|
|
763
|
+
double parentAlpha) {
|
|
764
|
+
if (n.displayNone || !n.hasRect || n.absorbedBy)
|
|
765
|
+
return;
|
|
766
|
+
float x = absX + n.rx, y = absY + n.ry;
|
|
767
|
+
float w = n.rw, h = n.rh;
|
|
768
|
+
double alpha = parentAlpha * n.opacity;
|
|
769
|
+
if (alpha <= 0.004)
|
|
770
|
+
return;
|
|
771
|
+
|
|
772
|
+
SkAutoCanvasRestore restore(&c, true);
|
|
773
|
+
bool hasTf = !n.transform.empty();
|
|
774
|
+
if (n.opacity < 1.0 || hasTf) {
|
|
775
|
+
// saveLayer para que la alpha aplique al sub-árbol completo —
|
|
776
|
+
// paridad View.setAlpha / CSS opacity (compositing único).
|
|
777
|
+
SkPaint lp;
|
|
778
|
+
if (n.opacity < 1.0)
|
|
779
|
+
lp.setAlphaf((float)n.opacity);
|
|
780
|
+
c.saveLayer(SkRect::MakeXYWH(x, y, w, h), n.opacity < 1.0 ? &lp : nullptr);
|
|
781
|
+
alpha = parentAlpha;
|
|
782
|
+
}
|
|
783
|
+
if (hasTf) {
|
|
784
|
+
double tx = 0, ty = 0, sx = 1, sy = 1, rot = 0;
|
|
785
|
+
for (auto &kv : n.transform) {
|
|
786
|
+
if (kv.first == "translateX")
|
|
787
|
+
tx = kv.second;
|
|
788
|
+
else if (kv.first == "translateY")
|
|
789
|
+
ty = kv.second;
|
|
790
|
+
else if (kv.first == "scaleX")
|
|
791
|
+
sx = kv.second;
|
|
792
|
+
else if (kv.first == "scaleY")
|
|
793
|
+
sy = kv.second;
|
|
794
|
+
else if (kv.first == "rotate")
|
|
795
|
+
rot = kv.second;
|
|
796
|
+
}
|
|
797
|
+
// CSS transform-origin: centro de la caja.
|
|
798
|
+
c.translate(x + w / 2 + tx, y + h / 2 + ty);
|
|
799
|
+
if (rot != 0)
|
|
800
|
+
c.rotate(rot);
|
|
801
|
+
if (sx != 1 || sy != 1)
|
|
802
|
+
c.scale(sx, sy);
|
|
803
|
+
c.translate(-(x + w / 2), -(y + h / 2));
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
double brd = 0;
|
|
807
|
+
visualNum(n, "borderRadius", brd);
|
|
808
|
+
SkRRect rr;
|
|
809
|
+
if (brd > 0)
|
|
810
|
+
rr.setRectXY(SkRect::MakeXYWH(x, y, w, h), (float)brd, (float)brd);
|
|
811
|
+
|
|
812
|
+
paintBox(c, n, x, y, alpha);
|
|
813
|
+
|
|
814
|
+
std::string txt = n.type == "button" ? n.absorbedText : n.text;
|
|
815
|
+
if (n.type == "text-input" && txt.empty()) {
|
|
816
|
+
if (auto p = n.props.find("value"); p != n.props.end())
|
|
817
|
+
txt = p->second;
|
|
818
|
+
if (txt.empty())
|
|
819
|
+
if (auto p = n.props.find("placeholder"); p != n.props.end())
|
|
820
|
+
txt = p->second;
|
|
821
|
+
}
|
|
822
|
+
// keyboard=password → máscara de bullets (paridad
|
|
823
|
+
// gtk_entry_set_visibility(false) del carril views) — solo el
|
|
824
|
+
// value real; el placeholder se muestra en claro.
|
|
825
|
+
if (n.type == "text-input" && !txt.empty()) {
|
|
826
|
+
auto k = n.props.find("keyboard");
|
|
827
|
+
if (k == n.props.end())
|
|
828
|
+
k = n.props.find("keyboardType");
|
|
829
|
+
auto vp = n.props.find("value");
|
|
830
|
+
if (k != n.props.end() && k->second == "password" && vp != n.props.end() &&
|
|
831
|
+
vp->second == txt) {
|
|
832
|
+
std::string mask;
|
|
833
|
+
for (const char *p = txt.c_str(); *p;) {
|
|
834
|
+
mask += "\xe2\x80\xa2"; // U+2022 BULLET por code point
|
|
835
|
+
++p;
|
|
836
|
+
while ((*p & 0xc0) == 0x80)
|
|
837
|
+
++p; // continuación UTF-8
|
|
838
|
+
}
|
|
839
|
+
txt = mask;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (!txt.empty() &&
|
|
843
|
+
(n.type == "text" || n.type == "button" || n.type == "text-input"))
|
|
844
|
+
paintTextBlock(c, n, txt, x, y, w, h, alpha);
|
|
845
|
+
|
|
846
|
+
if (n.type == "switch" || n.type == "slider")
|
|
847
|
+
paintControl(c, n, x, y, alpha);
|
|
848
|
+
if (n.type == "image" && n.image)
|
|
849
|
+
paintImage(c, n, x, y, alpha);
|
|
850
|
+
|
|
851
|
+
// Anillo de foco virtual (fase 2) — GTK4 dibuja un outline
|
|
852
|
+
// accent-alpha a 1.5px del borde; el foco real lo lleva el glue.
|
|
853
|
+
if (n.id == focusedId) {
|
|
854
|
+
SkPaint fp;
|
|
855
|
+
fp.setStyle(SkPaint::kStroke_Style);
|
|
856
|
+
fp.setStrokeWidth(2);
|
|
857
|
+
fp.setColor(0xcc3584e4); // accent Adwaita con alpha
|
|
858
|
+
fp.setAntiAlias(true);
|
|
859
|
+
c.drawRRect(
|
|
860
|
+
SkRRect::MakeRectXY(SkRect::MakeXYWH(x - 1.5f, y - 1.5f, w + 3, h + 3),
|
|
861
|
+
brd > 0 ? (float)brd + 1.5f : 2.0f,
|
|
862
|
+
brd > 0 ? (float)brd + 1.5f : 2.0f),
|
|
863
|
+
fp);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
bool clip = n.overflowClip || n.type == "scroll" || n.type == "scroll-view";
|
|
867
|
+
if (clip) {
|
|
868
|
+
if (brd > 0)
|
|
869
|
+
c.clipRRect(rr, true);
|
|
870
|
+
else
|
|
871
|
+
c.clipRect(SkRect::MakeXYWH(x, y, w, h), true);
|
|
872
|
+
// Solo el translate del canvas: los hijos pintan en su rect de
|
|
873
|
+
// contenido y el desplazamiento lo da la matriz — sumar el scroll
|
|
874
|
+
// además a (x,y) lo cancelaría (bug: scroll visual = 0).
|
|
875
|
+
c.translate(-n.scrollX, -n.scrollY);
|
|
876
|
+
}
|
|
877
|
+
for (int cid : n.children) {
|
|
878
|
+
auto it = nodes.find(cid);
|
|
879
|
+
if (it != nodes.end())
|
|
880
|
+
paintNode(c, it->second, x, y, alpha);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
void SkiaTree::paintBox(SkCanvas &c, SkiaNode &n, float x, float y,
|
|
885
|
+
double alpha) {
|
|
886
|
+
float w = n.rw, h = n.rh;
|
|
887
|
+
SkColor bg;
|
|
888
|
+
double brd = 0;
|
|
889
|
+
visualNum(n, "borderRadius", brd);
|
|
890
|
+
if (auto it = n.visual.find("backgroundColor");
|
|
891
|
+
it != n.visual.end() && parseColor(it->second, bg)) {
|
|
892
|
+
SkPaint p;
|
|
893
|
+
p.setColor(SkColorSetA(bg, SkColorGetA(bg) * alpha));
|
|
894
|
+
p.setAntiAlias(brd > 0);
|
|
895
|
+
if (brd > 0)
|
|
896
|
+
c.drawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, w, h), brd, brd),
|
|
897
|
+
p);
|
|
898
|
+
else
|
|
899
|
+
c.drawRect(SkRect::MakeXYWH(x, y, w, h), p);
|
|
900
|
+
}
|
|
901
|
+
// Borde colapsado a shorthand — mismo criterio que applyVisualCss.
|
|
902
|
+
double bw = 0;
|
|
903
|
+
if (!visualNum(n, "borderWidth", bw)) {
|
|
904
|
+
for (auto &kv : n.visual)
|
|
905
|
+
if (kv.first.rfind("border", 0) == 0 && kv.first.size() > 6 &&
|
|
906
|
+
kv.first.compare(kv.first.size() - 5, 5, "Width") == 0) {
|
|
907
|
+
bw = strtod(kv.second.c_str(), nullptr);
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
if (bw > 0) {
|
|
912
|
+
SkColor bc = SK_ColorBLACK;
|
|
913
|
+
if (auto it = n.visual.find("borderColor"); it != n.visual.end())
|
|
914
|
+
parseColor(it->second, bc);
|
|
915
|
+
SkPaint p;
|
|
916
|
+
p.setColor(SkColorSetA(bc, SkColorGetA(bc) * alpha));
|
|
917
|
+
p.setStyle(SkPaint::kStroke_Style);
|
|
918
|
+
p.setStrokeWidth((float)bw);
|
|
919
|
+
p.setAntiAlias(true);
|
|
920
|
+
float inset = (float)bw / 2;
|
|
921
|
+
if (brd > 0)
|
|
922
|
+
c.drawRRect(SkRRect::MakeRectXY(
|
|
923
|
+
SkRect::MakeXYWH(x + inset, y + inset, w - bw, h - bw),
|
|
924
|
+
std::fmax(0.f, (float)brd - inset),
|
|
925
|
+
std::fmax(0.f, (float)brd - inset)),
|
|
926
|
+
p);
|
|
927
|
+
else
|
|
928
|
+
c.drawRect(SkRect::MakeXYWH(x + inset, y + inset, w - bw, h - bw), p);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
void SkiaTree::paintTextBlock(SkCanvas &c, SkiaNode &n, const std::string &txt,
|
|
933
|
+
float x, float y, float w, float h,
|
|
934
|
+
double alpha) {
|
|
935
|
+
float innerW = w - n.padL - n.padR;
|
|
936
|
+
#if ELUR_SKIA_TEXT
|
|
937
|
+
auto para = paragraphFor(n, txt, innerW, alpha);
|
|
938
|
+
float block = para->getHeight();
|
|
939
|
+
float top = y + n.padT + (h - n.padT - n.padB - block) / 2; // valign center
|
|
940
|
+
para->paint(&c, x + n.padL, top);
|
|
941
|
+
#else
|
|
942
|
+
SkFont f = fontFor(n);
|
|
943
|
+
std::vector<std::string> lines = wrapLines(n, txt, innerW);
|
|
944
|
+
if (lines.empty())
|
|
945
|
+
return;
|
|
946
|
+
float lh = lineHeightPx(n, f);
|
|
947
|
+
SkFontMetrics fm;
|
|
948
|
+
f.getMetrics(&fm);
|
|
949
|
+
float block = lines.size() * lh;
|
|
950
|
+
float top = y + n.padT + (h - n.padT - n.padB - block) / 2; // valign center
|
|
951
|
+
SkColor col = 0xff111111; // color base del host (#111, BASE_CSS)
|
|
952
|
+
if (auto it = n.visual.find("color"); it != n.visual.end())
|
|
953
|
+
parseColor(it->second, col);
|
|
954
|
+
SkPaint p;
|
|
955
|
+
p.setColor(SkColorSetA(col, SkColorGetA(col) * alpha));
|
|
956
|
+
p.setAntiAlias(true);
|
|
957
|
+
bool underline = false, strike = false;
|
|
958
|
+
if (auto it = n.visual.find("textDecoration"); it != n.visual.end()) {
|
|
959
|
+
underline = it->second.find("underline") != std::string::npos;
|
|
960
|
+
strike = it->second.find("line-through") != std::string::npos;
|
|
961
|
+
}
|
|
962
|
+
float baseTop = top + (lh - (fm.fDescent - fm.fAscent)) / 2 - fm.fAscent;
|
|
963
|
+
// CSS dir ≈ text-align:start — el ink se alinea al borde start
|
|
964
|
+
// (justify del carril views; un textAlign explícito gana).
|
|
965
|
+
auto di = n.props.find("dir");
|
|
966
|
+
const bool rtl = di != n.props.end() && di->second == "rtl";
|
|
967
|
+
for (size_t i = 0; i < lines.size(); i++) {
|
|
968
|
+
const std::string &l = lines[i];
|
|
969
|
+
float lw = f.measureText(l.data(), l.size(), SkTextEncoding::kUTF8);
|
|
970
|
+
float lx = x + n.padL;
|
|
971
|
+
if (n.textAlign == "center")
|
|
972
|
+
lx += (innerW - lw) / 2;
|
|
973
|
+
else if (n.textAlign == "right" || n.textAlign == "end" ||
|
|
974
|
+
(n.textAlign.empty() && rtl))
|
|
975
|
+
lx += innerW - lw;
|
|
976
|
+
float baseline = baseTop + i * lh;
|
|
977
|
+
c.drawString(l.c_str(), lx, baseline, f, p);
|
|
978
|
+
if (underline || strike) {
|
|
979
|
+
SkPaint dp;
|
|
980
|
+
dp.setColor(p.getColor());
|
|
981
|
+
float ut = fm.fUnderlineThickness ? fm.fUnderlineThickness : lh * 0.06f;
|
|
982
|
+
dp.setStrokeWidth(ut);
|
|
983
|
+
float upos = fm.fUnderlinePosition ? fm.fUnderlinePosition : lh * 0.08f;
|
|
984
|
+
float ly = underline ? baseline + upos : baseline + fm.fStrikeoutPosition;
|
|
985
|
+
c.drawLine(lx, ly, lx + lw, ly, dp);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
#endif
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// Controles — paridad visual GTK4 simplificada (fase 1): switch =
|
|
992
|
+
// track redondeado + knob; slider = track + fill + knob. El gesto lo
|
|
993
|
+
// resuelve el glue (toggle / setAt), los valores viven en props
|
|
994
|
+
// (checked / progress / min / max) — mismas claves del aplicador
|
|
995
|
+
// views, sin op nueva.
|
|
996
|
+
void SkiaTree::paintControl(SkCanvas &c, SkiaNode &n, float x, float y,
|
|
997
|
+
double alpha) {
|
|
998
|
+
float w = n.rw, h = n.rh;
|
|
999
|
+
SkPaint p;
|
|
1000
|
+
p.setAntiAlias(true);
|
|
1001
|
+
SkColor accent = SkColorSetRGB(0x35, 0x84, 0xe4); // accent GNOME
|
|
1002
|
+
if (n.type == "switch") {
|
|
1003
|
+
bool on = false;
|
|
1004
|
+
if (auto it = n.props.find("checked"); it != n.props.end())
|
|
1005
|
+
on = it->second == "true" || it->second == "1";
|
|
1006
|
+
float r = h / 2;
|
|
1007
|
+
p.setColor(SkColorSetA(on ? accent : SkColorSetRGB(0x77, 0x76, 0x7b),
|
|
1008
|
+
(unsigned)(255 * alpha)));
|
|
1009
|
+
c.drawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, y, w, h), r, r), p);
|
|
1010
|
+
float kr = std::max(1.f, r - 2.f);
|
|
1011
|
+
float kx = on ? x + w - r : x + r;
|
|
1012
|
+
p.setColor(SkColorSetA(SK_ColorWHITE, (unsigned)(255 * alpha)));
|
|
1013
|
+
c.drawCircle(kx, y + r, kr, p);
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
// slider: track 4px centrado; fill [0..t] accent; knob blanco.
|
|
1017
|
+
float lo = 0, hi = 100, v = 0;
|
|
1018
|
+
if (auto it = n.props.find("min"); it != n.props.end())
|
|
1019
|
+
lo = strtof(it->second.c_str(), nullptr);
|
|
1020
|
+
if (auto it = n.props.find("max"); it != n.props.end())
|
|
1021
|
+
hi = strtof(it->second.c_str(), nullptr);
|
|
1022
|
+
if (auto it = n.props.find("progress"); it != n.props.end())
|
|
1023
|
+
v = strtof(it->second.c_str(), nullptr);
|
|
1024
|
+
if (hi <= lo)
|
|
1025
|
+
hi = lo + 1;
|
|
1026
|
+
float t = std::clamp((v - lo) / (hi - lo), 0.f, 1.f);
|
|
1027
|
+
float cy = y + h / 2;
|
|
1028
|
+
float th = std::min(4.f, h / 3);
|
|
1029
|
+
p.setColor(
|
|
1030
|
+
SkColorSetA(SkColorSetRGB(0x9a, 0x99, 0x96), (unsigned)(255 * alpha)));
|
|
1031
|
+
c.drawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, cy - th / 2, w, th),
|
|
1032
|
+
th / 2, th / 2),
|
|
1033
|
+
p);
|
|
1034
|
+
p.setColor(SkColorSetA(accent, (unsigned)(255 * alpha)));
|
|
1035
|
+
c.drawRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(x, cy - th / 2, t * w, th),
|
|
1036
|
+
th / 2, th / 2),
|
|
1037
|
+
p);
|
|
1038
|
+
float kr = std::min(h / 2 - 1, 10.f);
|
|
1039
|
+
p.setColor(SkColorSetA(SK_ColorWHITE, (unsigned)(255 * alpha)));
|
|
1040
|
+
c.drawCircle(x + t * w, cy, std::max(2.f, kr), p);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
void SkiaTree::paintImage(SkCanvas &c, SkiaNode &n, float x, float y,
|
|
1044
|
+
double alpha) {
|
|
1045
|
+
if (!n.image)
|
|
1046
|
+
return;
|
|
1047
|
+
float w = n.rw - n.padL - n.padR, h = n.rh - n.padT - n.padB;
|
|
1048
|
+
if (w <= 0 || h <= 0)
|
|
1049
|
+
return;
|
|
1050
|
+
x += n.padL;
|
|
1051
|
+
y += n.padT;
|
|
1052
|
+
float iw = (float)n.image->width(), ih = (float)n.image->height();
|
|
1053
|
+
std::string fit = "cover"; // content-fit default del host views
|
|
1054
|
+
if (auto it = n.visual.find("objectFit"); it != n.visual.end())
|
|
1055
|
+
fit = it->second;
|
|
1056
|
+
SkRect dst = SkRect::MakeXYWH(x, y, w, h), src = SkRect::MakeIWH(iw, ih);
|
|
1057
|
+
if (fit == "contain" || fit == "cover") {
|
|
1058
|
+
float s =
|
|
1059
|
+
fit == "contain" ? std::min(w / iw, h / ih) : std::max(w / iw, h / ih);
|
|
1060
|
+
float dw = iw * s, dh = ih * s;
|
|
1061
|
+
dst = SkRect::MakeXYWH(x + (w - dw) / 2, y + (h - dh) / 2, dw, dh);
|
|
1062
|
+
if (fit == "cover") {
|
|
1063
|
+
// Recorta el exceso del box — paridad CONTENT_FIT_COVER.
|
|
1064
|
+
c.save();
|
|
1065
|
+
c.clipRect(SkRect::MakeXYWH(x, y, w, h), true);
|
|
1066
|
+
c.drawImageRect(n.image.get(), src, dst, SkSamplingOptions(), nullptr,
|
|
1067
|
+
SkCanvas::kFast_SrcRectConstraint);
|
|
1068
|
+
c.restore();
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
SkPaint p;
|
|
1073
|
+
p.setAlphaf((float)alpha);
|
|
1074
|
+
c.drawImageRect(n.image.get(), src, dst, SkSamplingOptions(), &p,
|
|
1075
|
+
SkCanvas::kFast_SrcRectConstraint);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// ── Hit-test ─────────────────────────────────────────────────────
|
|
1079
|
+
|
|
1080
|
+
// El walk compartido: devuelve la cadena raíz→hoja invertida (path
|
|
1081
|
+
// [hoja…raíz]) del punto, igual que hitTest pero sin filtro de evento.
|
|
1082
|
+
static bool walkHit(std::unordered_map<int, SkiaNode> &nodes,
|
|
1083
|
+
const std::vector<int> &roots, float x, float y,
|
|
1084
|
+
std::vector<int> &path) {
|
|
1085
|
+
std::function<bool(int, float, float)> walk = [&](int id, float ox,
|
|
1086
|
+
float oy) {
|
|
1087
|
+
auto it = nodes.find(id);
|
|
1088
|
+
if (it == nodes.end())
|
|
1089
|
+
return false;
|
|
1090
|
+
SkiaNode &n = it->second;
|
|
1091
|
+
if (n.displayNone || !n.hasRect || n.absorbedBy)
|
|
1092
|
+
return false;
|
|
1093
|
+
float ax = ox + n.rx, ay = oy + n.ry;
|
|
1094
|
+
bool inside = x >= ax && y >= ay && x < ax + n.rw && y < ay + n.rh;
|
|
1095
|
+
if (n.overflowClip && !inside)
|
|
1096
|
+
return false;
|
|
1097
|
+
if (inside) {
|
|
1098
|
+
for (auto ri = n.children.rbegin(); ri != n.children.rend(); ++ri)
|
|
1099
|
+
if (walk(*ri, ax - n.scrollX, ay - n.scrollY)) {
|
|
1100
|
+
path.push_back(id);
|
|
1101
|
+
return true;
|
|
1102
|
+
}
|
|
1103
|
+
path.push_back(id);
|
|
1104
|
+
return true;
|
|
1105
|
+
}
|
|
1106
|
+
for (auto ri = n.children.rbegin(); ri != n.children.rend(); ++ri)
|
|
1107
|
+
if (walk(*ri, ax - n.scrollX, ay - n.scrollY)) {
|
|
1108
|
+
path.push_back(id);
|
|
1109
|
+
return true;
|
|
1110
|
+
}
|
|
1111
|
+
return false;
|
|
1112
|
+
};
|
|
1113
|
+
for (auto ri = roots.rbegin(); ri != roots.rend(); ++ri)
|
|
1114
|
+
if (walk(*ri, 0, 0))
|
|
1115
|
+
return true;
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
int SkiaTree::hitTest(float x, float y, const std::string &event) {
|
|
1120
|
+
// DFS top-down (hijos en z inverso) vía walkHit; `path` = cadena
|
|
1121
|
+
// [hoja…raíz]. El bind lo busca la burbuja desde lo más profundo —
|
|
1122
|
+
// paridad con la propagación BUBBLE de GtkGesture (la gesture del
|
|
1123
|
+
// ancestro captura solo si el hijo no tiene handler).
|
|
1124
|
+
std::vector<int> path;
|
|
1125
|
+
if (!walkHit(nodes, roots, x, y, path))
|
|
1126
|
+
return 0;
|
|
1127
|
+
for (int pi : path) {
|
|
1128
|
+
auto it = nodes.find(pi);
|
|
1129
|
+
if (it != nodes.end() && it->second.events.count(event))
|
|
1130
|
+
return pi;
|
|
1131
|
+
}
|
|
1132
|
+
return 0;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
int SkiaTree::nodeAt(float x, float y) {
|
|
1136
|
+
std::vector<int> path;
|
|
1137
|
+
if (!walkHit(nodes, roots, x, y, path))
|
|
1138
|
+
return 0;
|
|
1139
|
+
return path.front(); // [hoja…raíz]
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
bool SkiaTree::pointInNode(int id, float x, float y, float &lx,
|
|
1143
|
+
float &ly) const {
|
|
1144
|
+
// Posición absoluta del nodo = suma de rects de su cadena menos el
|
|
1145
|
+
// scroll de cada ancestro scrollable.
|
|
1146
|
+
float ax = 0, ay = 0;
|
|
1147
|
+
if (!absPos(id, ax, ay))
|
|
1148
|
+
return false;
|
|
1149
|
+
lx = x - ax;
|
|
1150
|
+
ly = y - ay;
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
int SkiaTree::scrollableAt(float x, float y) {
|
|
1155
|
+
std::vector<int> path;
|
|
1156
|
+
if (!walkHit(nodes, roots, x, y, path))
|
|
1157
|
+
return 0;
|
|
1158
|
+
for (int id : path) {
|
|
1159
|
+
auto it = nodes.find(id);
|
|
1160
|
+
if (it != nodes.end() &&
|
|
1161
|
+
(it->second.type == "scroll" || it->second.type == "scroll-view"))
|
|
1162
|
+
return id;
|
|
1163
|
+
}
|
|
1164
|
+
return 0;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
bool SkiaTree::absPos(int id, float &ax, float &ay) const {
|
|
1168
|
+
// Cadena raíz→id por parent — rects padre-relativos + scroll de cada
|
|
1169
|
+
// ancestro (el scroll propio NO mueve la caja del nodo, sí a hijos).
|
|
1170
|
+
ax = ay = 0;
|
|
1171
|
+
std::vector<int> chain;
|
|
1172
|
+
int cur = id;
|
|
1173
|
+
while (cur) {
|
|
1174
|
+
auto it = nodes.find(cur);
|
|
1175
|
+
if (it == nodes.end())
|
|
1176
|
+
return false;
|
|
1177
|
+
chain.push_back(cur);
|
|
1178
|
+
cur = it->second.parent;
|
|
1179
|
+
}
|
|
1180
|
+
for (auto ri = chain.rbegin(); ri != chain.rend(); ++ri) {
|
|
1181
|
+
const SkiaNode &n = nodes.at(*ri);
|
|
1182
|
+
ax += n.rx;
|
|
1183
|
+
ay += n.ry;
|
|
1184
|
+
if (n.parent) {
|
|
1185
|
+
auto p = nodes.find(n.parent);
|
|
1186
|
+
if (p != nodes.end() &&
|
|
1187
|
+
(p->second.type == "scroll" || p->second.type == "scroll-view")) {
|
|
1188
|
+
ax -= p->second.scrollX;
|
|
1189
|
+
ay -= p->second.scrollY;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
return nodes.at(id).hasRect;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
void SkiaTree::extentWalk(const SkiaNode &n, float ox, float oy, bool vertical,
|
|
1197
|
+
float &ext) const {
|
|
1198
|
+
for (int cid : n.children) {
|
|
1199
|
+
auto ci = nodes.find(cid);
|
|
1200
|
+
if (ci == nodes.end() || ci->second.displayNone || ci->second.absorbedBy)
|
|
1201
|
+
continue;
|
|
1202
|
+
const SkiaNode &c = ci->second;
|
|
1203
|
+
float ax = ox + c.rx, ay = oy + c.ry;
|
|
1204
|
+
ext = std::max(ext, vertical ? ay + c.rh : ax + c.rw);
|
|
1205
|
+
// Scroll anidado aporta su caja, no su contenido (scrollea dentro).
|
|
1206
|
+
if (c.type != "scroll" && c.type != "scroll-view")
|
|
1207
|
+
extentWalk(c, ax, ay, vertical, ext);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
float SkiaTree::contentExtent(int id, bool vertical) const {
|
|
1212
|
+
// Mayor borde de descendientes en el espacio del nodo (offsets
|
|
1213
|
+
// padre-relativos acumulados).
|
|
1214
|
+
auto it = nodes.find(id);
|
|
1215
|
+
if (it == nodes.end())
|
|
1216
|
+
return 0;
|
|
1217
|
+
float ext = 0;
|
|
1218
|
+
extentWalk(it->second, 0, 0, vertical, ext);
|
|
1219
|
+
return ext;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
float SkiaTree::maxScrollY(int id) const {
|
|
1223
|
+
auto it = nodes.find(id);
|
|
1224
|
+
if (it == nodes.end())
|
|
1225
|
+
return 0;
|
|
1226
|
+
return std::max(0.f, contentExtent(id, true) - it->second.rh);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
float SkiaTree::maxScrollX(int id) const {
|
|
1230
|
+
auto it = nodes.find(id);
|
|
1231
|
+
if (it == nodes.end())
|
|
1232
|
+
return 0;
|
|
1233
|
+
return std::max(0.f, contentExtent(id, false) - it->second.rw);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
void SkiaTree::setScroll(int id, float x, float y) {
|
|
1237
|
+
auto it = nodes.find(id);
|
|
1238
|
+
if (it == nodes.end())
|
|
1239
|
+
return;
|
|
1240
|
+
SkiaNode &n = it->second;
|
|
1241
|
+
n.scrollX = std::clamp(x, 0.f, maxScrollX(id));
|
|
1242
|
+
n.scrollY = std::clamp(y, 0.f, maxScrollY(id));
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
bool SkiaTree::scrollBy(int id, float dx, float dy) {
|
|
1246
|
+
auto it = nodes.find(id);
|
|
1247
|
+
if (it == nodes.end())
|
|
1248
|
+
return false;
|
|
1249
|
+
SkiaNode &n = it->second;
|
|
1250
|
+
float nx = std::clamp(n.scrollX + dx, 0.f, maxScrollX(id));
|
|
1251
|
+
float ny = std::clamp(n.scrollY + dy, 0.f, maxScrollY(id));
|
|
1252
|
+
bool moved = nx != n.scrollX || ny != n.scrollY;
|
|
1253
|
+
n.scrollX = nx;
|
|
1254
|
+
n.scrollY = ny;
|
|
1255
|
+
return moved;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
void SkiaTree::setImage(int id, sk_sp<SkImage> img) {
|
|
1259
|
+
auto it = nodes.find(id);
|
|
1260
|
+
if (it != nodes.end())
|
|
1261
|
+
it->second.image = std::move(img);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
bool SkiaTree::switchToggle(int id) {
|
|
1265
|
+
auto it = nodes.find(id);
|
|
1266
|
+
if (it == nodes.end() || it->second.type != "switch")
|
|
1267
|
+
return false;
|
|
1268
|
+
bool on = it->second.props["checked"] == "true";
|
|
1269
|
+
it->second.props["checked"] = on ? "false" : "true";
|
|
1270
|
+
return !on;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
float SkiaTree::sliderSetAt(int id, float localX) {
|
|
1274
|
+
auto it = nodes.find(id);
|
|
1275
|
+
if (it == nodes.end() || it->second.type != "slider")
|
|
1276
|
+
return 0;
|
|
1277
|
+
SkiaNode &n = it->second;
|
|
1278
|
+
float lo = 0, hi = 100;
|
|
1279
|
+
if (auto p = n.props.find("min"); p != n.props.end())
|
|
1280
|
+
lo = strtof(p->second.c_str(), nullptr);
|
|
1281
|
+
if (auto p = n.props.find("max"); p != n.props.end())
|
|
1282
|
+
hi = strtof(p->second.c_str(), nullptr);
|
|
1283
|
+
if (hi <= lo)
|
|
1284
|
+
hi = lo + 1;
|
|
1285
|
+
float t = n.rw > 0 ? std::clamp(localX / n.rw, 0.f, 1.f) : 0.f;
|
|
1286
|
+
float v = lo + t * (hi - lo);
|
|
1287
|
+
char b[40];
|
|
1288
|
+
snprintf(b, sizeof(b), "%.10g", (double)v);
|
|
1289
|
+
n.props["progress"] = b;
|
|
1290
|
+
return v;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
} // namespace elur::skia
|